Author Topic: LED grow light  (Read 20969 times)

0 Members and 1 Guest are viewing this topic.

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: LED grow light
« Reply #25 on: February 09, 2016, 08:01:38 pm »
For years, I've had problems with my houseplants (mostly chiles, but also some citrus) perishing over winter indoors. I had chalked it up to just having a black thumb, but my roommate thought it was insufficient light. So we started just turning on a desk lamp at night to shine on the plants. Lo and behold, that seems to be it! The plants are now beginning to grow new baby leaves to replace all the ones they shed. So I began thinking about building some kind of grow light, probably using LED strips as the light source.
What's the temperature where you're growing the plants?

Perhaps it's too warm. When it's warm, the plants will be expecting there to be enough light to grow so won't go dormant, which could be causing them to die. Reducing the temperature to the minimum acceptable, without causing any damage to the plant tissues, may help by making them dormant, so the extra light isn't needed to keep them alive.

Citrus plants should be fine down to 5oC. I don't know about chillies though. If you can keep the temperature below 18oC, then the growth will stop and the extra light won't be needed.
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #26 on: February 10, 2016, 03:10:08 am »
Unfortunately that's incorrect. It's around 490Hz on 8-bit timers but 980Hz on 16-bit timers.

Ref: https://www.arduino.cc/en/Reference/AnalogWrite
Dude, is it really necessary for you to bicker about irrelevant details (whether it's 490Hz or 980Hz is inconsequential; either is much too low) and ignore the questions that would actually help me complete the project?? I really cannot tell if you're doing this unintentionally, or if you're trolling me.

Your original statement was:
The standard Arduino "analogWrite()" function outputs a 1kHz PWM signal so you're not going to see any flicker.
I said it's incorrect because that WILL cause me to see flicker. I know this cuz I've tested it, and the fact that LED PWM is often done at massively higher PWM frequencies (100s of KHz - 1MHz) is because many people perceive PWM flicker on LEDs at low duty cycles.

And ... you can easily have frequencies much higher than that. It's one line of code: Just subtract a value or two from the clock divider on the corresponding timer (Warning: timer0 generates the millis() interrupt so millis() will run faster if you do this on timer0).
And this remark, repeating what I already said in the post you're responding to, helps further the discussion how?

If you can see flicker the Arduino hardware isn't the problem, the problem is with the code. The Mega328 chip is capable of much more than Arduino's "easy-for-total-newbies-to-use" libraries expose.
The Arduino platform is the combination of the AtMega chips and the libraries and IDE. You are correct that the Mega328 can be manually driven to bit-bang much higher PWM speeds (I knew that before starting this thread), but I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.


I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.
« Last Edit: February 10, 2016, 03:15:43 am by tooki »
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #27 on: February 10, 2016, 03:13:30 am »
What's the temperature where you're growing the plants?

Perhaps it's too warm. When it's warm, the plants will be expecting there to be enough light to grow so won't go dormant, which could be causing them to die. Reducing the temperature to the minimum acceptable, without causing any damage to the plant tissues, may help by making them dormant, so the extra light isn't needed to keep them alive.

Citrus plants should be fine down to 5oC. I don't know about chillies though. If you can keep the temperature below 18oC, then the growth will stop and the extra light won't be needed.
You're certainly right, but since I live in a 1 bedroom apartment, there's no way to reduce the temperature of the plants' environment without also changing my own environment to temperatures decidedly outside my comfort zone! (It's about 21C in here, and that has me hiding under a blanket.)
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: LED grow light
« Reply #28 on: February 10, 2016, 05:26:08 am »
I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.

I already told you:  :)

So one solution is to use a smoothing capacitor in combination with an inductor, right? That way you're basically making an open-loop buck converter; the transistors are OK because the inductor prevents current spikes, you get the efficiency/current boosting effect of a buck converter, and the LEDs are running on a nice constant current.

Incidentally, there are specially designed LED buck converter chips which do all this for you, although you can just PWM it from a MCU too.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16640
  • Country: 00
Re: LED grow light
« Reply #29 on: February 10, 2016, 02:18:49 pm »
The standard Arduino "analogWrite()" function outputs a 1kHz PWM signal so you're not going to see any flicker.
I said it's incorrect because that WILL cause me to see flicker. I know this cuz I've tested it

Then:
a) You tested it wrong, or
b) You have superhuman eyes and should go and see a specialist to be studied for posterity.

, and the fact that LED PWM is often done at massively higher PWM frequencies

No it isn't: https://encrypted.google.com/search?q=led+pwm+frequency

The frequency response of human eyes is well studied: https://en.wikipedia.org/wiki/Flicker_fusion_threshold

 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16640
  • Country: 00
Re: LED grow light
« Reply #30 on: February 10, 2016, 02:22:23 pm »
The Arduino platform is the combination of the AtMega chips and the libraries and IDE. You are correct that the Mega328 can be manually driven to bit-bang much higher PWM speeds (I knew that before starting this thread), but I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.

As I said before, it's one line of code (and I'll be happy to tell you what that line is, all I need to know is what pin you're using for PWM).


I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.

All you need is a big inductor and a current sensor connected to your Arduino.

Make a feedback loop, ie. turn MOSFET on if there's too little current, turn if off if there's too much.

Code: [Select]
if ( analogRead(CURRENT_SENSOR) < preset_value ) {
  digitalWrite(MOSFET,1);
}
else {
  digitalWrite(MOSFET,0);
}

That's it.

If that loop is running very fast then the effect is constant-current at the defined value.


I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.

I thought you said you were an engineer who wanted a challenge...

« Last Edit: February 10, 2016, 02:31:23 pm by Fungus »
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #31 on: February 11, 2016, 04:21:14 am »
The standard Arduino "analogWrite()" function outputs a 1kHz PWM signal so you're not going to see any flicker.
I said it's incorrect because that WILL cause me to see flicker. I know this cuz I've tested it

Then:
a) You tested it wrong, or
b) You have superhuman eyes and should go and see a specialist to be studied for posterity.

, and the fact that LED PWM is often done at massively higher PWM frequencies

No it isn't: https://encrypted.google.com/search?q=led+pwm+frequency

The frequency response of human eyes is well studied: https://en.wikipedia.org/wiki/Flicker_fusion_threshold
Sorry, you're wrong. I did not "test it wrong". I had the LED hooked up, and a scope as well, measuring the frequency and duty cycle. The fact is, at 490Hz I can readily detect flicker at low duty cycles, as many people can. (Just Google "led pwm flicker" - you'll find plenty of people who agree.)

The flicker fusion threshold applies to an unmoving light source. The problem is, we don't stare at light bulbs in normal use. They're around us, and we look at things, which we do by moving our heads, and our eyes within them (saccades). The second you move your eyes quickly, a frequency that was fine without motion suddenly breaks into a series of flashes precisely because we have a certain amount of persistence of vision.  You know those displays that go on car tires and display messages and stuff? That's precisely the effect in action. If you took one of those wheel displays and looked at it when not moving, you'd see a bunch of unblinking, unflickering LEDs. But move them quickly and it breaks into discrete dots of light. THAT is the flicker people like me perceive in slow PWM lighting. It's annoying as fuck, it's not imaginary, and it's entirely reproducible. 

http://www.tftcentral.co.uk/articles/pulse_width_modulation.htm has an image that illustrates the problem, precisely as I experience it.

And this discussion on stackexchange goes into it more, and suggests that to successfully eliminate it, PWM frequencies of as high as 15KHz are necessary: http://physics.stackexchange.com/a/19056

I looked at the LED driver chips again, and must confess that I misread one datasheet and confused its buck converter switching frequency with its PWM frequency. The PWM frequency is "only" 20KHz.

The Arduino platform is the combination of the AtMega chips and the libraries and IDE. You are correct that the Mega328 can be manually driven to bit-bang much higher PWM speeds (I knew that before starting this thread), but I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.

As I said before, it's one line of code (and I'll be happy to tell you what that line is, all I need to know is what pin you're using for PWM).


I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.

All you need is a big inductor and a current sensor connected to your Arduino.

Make a feedback loop, ie. turn MOSFET on if there's too little current, turn if off if there's too much.

Code: [Select]
if ( analogRead(CURRENT_SENSOR) < preset_value ) {
  digitalWrite(MOSFET,1);
}
else {
  digitalWrite(MOSFET,0);
}

That's it.

If that loop is running very fast then the effect is constant-current at the defined value.


I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.

I thought you said you were an engineer who wanted a challenge...
I want to learn electronics engineering, not software engineering. (Indeed, one of the reasons for me getting back into electronics is to be doing something more physical, because I have RSI problems that require me to limit computer use.) I'm willing to do the minimum in software that is necessary to complete a project, but it's expressly what I don't want to be doing! :p

I've said twice already that I know how to tweak Arduino's PWM, and that I know what other consequences that has. What I definitely don't want to do is the other approach, which is to circumvent the Arduino PWM (analogWrite) altogether and bit bang it by writing directly to registers or something, for the aforementioned reason that I lack the skills to debug that. (And I don't want to acquire that skill either, lest I spend even more time at the computer and ruin my hand even more...)


I think I understand what you're saying with the feedback loop. Let me refresh my knowledge on inductors (something I've never used in any project so far, so something I'm very green on) and get back to you.
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #32 on: February 11, 2016, 04:23:16 am »
I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.

I already told you:  :)

So one solution is to use a smoothing capacitor in combination with an inductor, right? That way you're basically making an open-loop buck converter; the transistors are OK because the inductor prevents current spikes, you get the efficiency/current boosting effect of a buck converter, and the LEDs are running on a nice constant current.

Incidentally, there are specially designed LED buck converter chips which do all this for you, although you can just PWM it from a MCU too.
So you did! I somehow managed to overlook that part.  |O I'll do my homework and come back with my inevitable questions, ok? :)
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16640
  • Country: 00
Re: LED grow light
« Reply #33 on: February 11, 2016, 08:24:32 am »
What I definitely don't want to do is the other approach, which is to circumvent the Arduino PWM (analogWrite) and bit bang it by writing directly to registers or something,

Is writing to registers bad? I must inform Atmel. :popcorn:

... for the aforementioned reason that I lack the skills to debug that. (And I don't want to acquire that skill either, lest I spend even more time at the computer and ruin my hand even more...)

The entire code for increasing the PWM frequency of pins 9+10 on an Arduino Uno would be this (do it once in your setup() function):

Code: [Select]
--TCCR1B;

Pins 3+11...?

Code: [Select]
--TCCR2B;

You can do very precise frequency control if you know what you're doing, but ... if you just want it to go a lot faster then that will do the trick. You want even more? Do it twice.

I think I understand what you're saying with the feedback loop. Let me refresh my knowledge on inductors (something I've never used in any project so far, so something I'm very green on) and get back to you.
They just try to keep constant current using their magnetic field as a buffer.

You can do the same feedback-loop thing with a comparator if you want but a microcontroller makes everything a bit easier to fiddle with all the levels. And you wanted remote control. Microcontrollers are good at that.
« Last Edit: February 11, 2016, 08:55:11 am by Fungus »
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #34 on: February 11, 2016, 12:19:38 pm »
What I definitely don't want to do is the other approach, which is to circumvent the Arduino PWM (analogWrite) and bit bang it by writing directly to registers or something,

Is writing to registers bad? I must inform Atmel. :popcorn:
Oh my god, dude, what is your damage? I never said it's bad. I said I don't wanna do it because it exceeds my coding and debugging skills and aspirations. Stop putting words in my mouth and then twisting them into nonsense.

... for the aforementioned reason that I lack the skills to debug that. (And I don't want to acquire that skill either, lest I spend even more time at the computer and ruin my hand even more...)

The entire code for increasing the PWM frequency of pins 9+10 on an Arduino Uno would be this (do it once in your setup() function):

Code: [Select]
--TCCR1B;

Pins 3+11...?

Code: [Select]
--TCCR2B;

You can do very precise frequency control if you know what you're doing, but ... if you just want it to go a lot faster then that will do the trick. You want even more? Do it twice.
Yeah yeah I get it, you wanna show off your l33t h4x0r coding skills. Whooptie-shit. I've said repeatedly that I have the info already. (And this isn't the bit banging to which I was referring. That's a different approach altogether.)



You can do the same feedback-loop thing with a comparator if you want but a microcontroller makes everything a bit easier to fiddle with all the levels. And you wanted remote control. Microcontrollers are good at that.
I didn't say I wanted remote control. I only said I was considering trying an off-the-shelf controller, and those are practically all IR or RF remote control. I also said that the alternatives were a bank of switches or an arduino.

They just try to keep constant current using their magnetic field as a buffer.
Thanks. But is there a reason why in each reply, you provide one little nugget of helpful info, and 10 nuggets of trolling and distraction? Seriously, if you don't wanna help without being a dick, just don't help.
« Last Edit: February 11, 2016, 02:09:01 pm by tooki »
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #35 on: February 11, 2016, 02:07:58 pm »
Quote
$20-30 for a 5m strip of 660/445nm grow light LEDs (totaling 72W) doesn't seem that expensive to me.

You also need 620nm.
That's probably overkill for my purposes. I just need for the plants to not die every winter, I'm not running an indoor plantation. :p



Then you need to look at specific emitters - I have some Chinese 10W "620" which are in fact white with red filter in front of the phosphor.
Eww, lame.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16640
  • Country: 00
Re: LED grow light
« Reply #36 on: February 11, 2016, 05:30:24 pm »
What I definitely don't want to do is the other approach, which is to circumvent the Arduino PWM (analogWrite) and bit bang it by writing directly to registers or something,
Is writing to registers bad? I must inform Atmel. :popcorn:
Oh my god, dude, what is your damage? I never said it's bad. I said I don't wanna do it because it exceeds my coding and debugging skills and aspirations. Stop putting words in my mouth and then twisting them into nonsense.

In that case it's a strange choice of word: "Circumvent" is usually associated with doing something dishonest, or something against the rules.


Yeah yeah I get it, you wanna show off your l33t h4x0r coding skills. Whooptie-shit.

Nope. I'm just showing you that it really is very simple and that you won't need to spend hours debugging anything or hurting your hands.

The best way to do that? By providing the complete, working code needed to do what I was suggesting. That way you can make a fully informed decision about the complexity (or simplicity) of the software side.

(Here's me thinking I'm helping ...   :-// )


is there a reason why in each reply, you provide one little nugget of helpful info, and 10 nuggets of trolling and distraction?

Nope. That's just your interpretation of it.

Seriously, if you don't wanna help without being a dick, just don't help.

Good advice. I'll be following it to the letter.  :-+
 

Offline tookiTopic starter

  • Super Contributor
  • ***
  • Posts: 11473
  • Country: ch
Re: LED grow light
« Reply #37 on: February 12, 2016, 01:53:44 pm »
Nope. I'm just showing you that it really is very simple and that you won't need to spend hours debugging anything or hurting your hands.

The best way to do that? By providing the complete, working code needed to do what I was suggesting. That way you can make a fully informed decision about the complexity (or simplicity) of the software side.

(Here's me thinking I'm helping ...   :-// )
First of all, my apologies for being so reactive. It's just been frustrating getting the same info over and over, while questions that are more pressing to me remain unanswered. Nonetheless, I actually do appreciate your taking the time to reply.

I think there's a misunderstanding about what I said. Your code is for changing Arduino's timers to allow faster PWM. But that's not what I was talking about.

There are two distinct, unrelated ways to get faster PWM on an Arduino, as far as I can find:
1. Speed up the Atmel's timers to speed up the existing PWM function.
2. Circumvent the Arduino libraries (i.e. analogWrite, digitalWrite) entirely and bit-bang directly to the port registers with your own code.

I said early on that I know how to do #1, which is the approach you illustrated. But I clearly said it was #2 that exceeded my coding and debugging skills and aspirations. (I can't find the discussion about this approach, as it was months ago that I read it, but it went sorta in this direction: https://www.peterbeard.co/blog/post/why-is-arduino-digitalwrite-so-slow/ ) It's been so long, it might even have been assembler or something. I think people were doing that to achieve far higher PWM frequencies, at the expense of resolution. (E.g. 500KHz at just 16 PWM levels.)

Sorry about PMSing there for a moment!  :-[
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: LED grow light
« Reply #38 on: February 12, 2016, 02:27:21 pm »
One option, in between your options 1 and 2, is to use the TIMER registers directly. You can set your frequency to a precise, calculated value, you can make use of the full 16 bits -- it's just better. That way, you're not second-guessing what analogWrite is doing, nor are you using up the CPU resources of bit-banging.

It's not really programming per se, it's just reading the right section of the MCU datasheet, and figuring out the magic numbers to plug into those registers. I enjoy doing this, although I gather I'm unusual in that respect...


 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16640
  • Country: 00
Re: LED grow light
« Reply #39 on: February 12, 2016, 02:49:14 pm »
It's not really programming per se, it's just reading the right section of the MCU datasheet, and figuring out the magic numbers to plug into those registers. I enjoy doing this, although I gather I'm unusual in that respect...

I do it too. It's not rocket science but there's an awful lot of timer modes and pin output modes to wade through in the datasheet. It isn't for the faint-hearted.

If all you want is "faster" then changing the clock divider works.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf