Improved Arduino LED lighting code - Page 4
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


Reply
 
Thread Tools Display Modes
Old 01-27-2012, 11:09 PM   #46
MoeBetta
Planted Tank Obsessed
 
PTrader: (10/100%)
Join Date: Feb 2011
Location: Dayton, OH
Posts: 357
Default

Shoot me a PM with your e-mail addy and I'll send you the serial monitoring code Sink send me a while back to see if it is what you're looking for.
MoeBetta is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 01-28-2012, 12:21 AM   #47
O2surplus
Planted Tank Enthusiast
 
O2surplus's Avatar
 
PTrader: (4/100%)
Join Date: Jan 2010
Location: yorba linda, ca.
Posts: 591
Default

Quote:
Originally Posted by stephenpence View Post
Well i'm playing catch up on this whole Code thing.. I'm basically worthless at it. BUT i bought an arduino Uno and a chronoDOt RTC and by gosh i'm gonna make this thing work. so a few questions:
If i were to reduce the code to only have one driver running off of it, what would i need to edit?
Also, for the life of me, i can't figure out what the heck Python is. I got it, installed it, and i am still just absolutely clueless.

In my defense, i am not an idiot.. i'm just an engineer. so i've never had a good reason to try and delve into this. Thanks in advance for the help!!
Unless you need that output pin for some other task- I don't see a need to modify the code at all. Since you say that you'll only be running one driver- just edit the start/stop times for one of the PWM channel pins and leave the other pin alone. You may find that you want to add another group of leds in the future and the code left, "as= is" will allow for that.
O2surplus is online now   Reply With Quote
Old 01-28-2012, 12:44 AM   #48
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by stephenpence View Post
Well i'm playing catch up on this whole Code thing.. I'm basically worthless at it. BUT i bought an arduino Uno and a chronoDOt RTC and by gosh i'm gonna make this thing work. so a few questions:
If i were to reduce the code to only have one driver running off of it, what would i need to edit?
Also, for the life of me, i can't figure out what the heck Python is. I got it, installed it, and i am still just absolutely clueless.

In my defense, i am not an idiot.. i'm just an engineer. so i've never had a good reason to try and delve into this. Thanks in advance for the help!!
Hi, thanks for the interest!

You shouldn't have to change anything to get the code running for only one driver/channel. It should just work. The program will still send out a PWM signal on the second channel, but that won't hurt anything.

Python is a scripting language. I used it to write the control code that you run on your PC to set/check the Arduino clock. Since it's an interpreted language, you need to install Python to actually run that script. Make sure you install version 2.7 and not one of the 3.x versions, though you can safely have both installed at the same time. You also need the pyserial library from here: http://pypi.python.org/pypi/pyserial

Then you upload the control code sketch to the Arduino. As indicated above use the 0023 version of Arduino and not the 1.0 ones as a bunch of the libraries I use aren't updated to use the new version yet.
sink is offline   Reply With Quote
Old 01-28-2012, 12:49 AM   #49
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by stephenpence View Post
great thank you! also, is there a program that will show what's going on on the arduino board as it happens? I'm not used to sending a program, and hoping it's doing what i told it to.
When you upload the sketch using the Arduino IDE it's pretty clear whether or not it worked. If it uploads, you're almost set, then you just need to run the Python script to set the time properly. You should only have to do that once; the ChronoDot is scary accurate.

I have another version of the sketch with debugging turned on that can help if you're having an issue (it'll show if the RTC isn't hooked up properly, for example) but try with the normal version first.
sink is offline   Reply With Quote
Old 01-28-2012, 06:39 AM   #50
stephenpence
Planted Member
 
PTrader: (7/100%)
Join Date: Mar 2010
Location: Laramie, WY
Posts: 165
Default

wow guys thanks for the quick replies!! i figured since this thread had been asleep for a month i might have to poke the beehive a few times before anything happened haha...
So here's MY update. I realized my first problem is that i hadn't set the time in my rtc shield. So that made a big difference (obviously). now then, when i woke up the serial code at the end of the tank control pde... it was talking to me in.. i dunno, klingon maybe. But i DID get the times set, and get the arduino to turn on and off the lights at the correct interval. This is for a smaller LED string (for now) and I'm running it on the Meanwell 60-27P driver. I've notices that anything below ~300 for brightness in the program just turns the LED's off. above 300 is pretty bright, and then it just gets brighter. Was i under a false impression thinking that these guys (CREE XP-Gs) would dim quite a bit? or is the dimming function just to pinpoint your PAR readings at the substrate?? I would love to see this thing power a full sunrise simulation but as of now it's less "sunrise" and more "daybreak". let me know if you have any ideas, and again, thanks for the quick responses!!
stephenpence is offline   Reply With Quote
Old 01-28-2012, 03:31 PM   #51
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by stephenpence View Post
wow guys thanks for the quick replies!! i figured since this thread had been asleep for a month i might have to poke the beehive a few times before anything happened haha...
So here's MY update. I realized my first problem is that i hadn't set the time in my rtc shield. So that made a big difference (obviously). now then, when i woke up the serial code at the end of the tank control pde... it was talking to me in.. i dunno, klingon maybe. But i DID get the times set, and get the arduino to turn on and off the lights at the correct interval. This is for a smaller LED string (for now) and I'm running it on the Meanwell 60-27P driver. I've notices that anything below ~300 for brightness in the program just turns the LED's off. above 300 is pretty bright, and then it just gets brighter. Was i under a false impression thinking that these guys (CREE XP-Gs) would dim quite a bit? or is the dimming function just to pinpoint your PAR readings at the substrate?? I would love to see this thing power a full sunrise simulation but as of now it's less "sunrise" and more "daybreak". let me know if you have any ideas, and again, thanks for the quick responses!!
I'm subscribed to this thread, so I get prodded when new posts show up. I assume the rest of these guys just spend all day on the forums...

I'm glad you got everything working. Did you set the clock using the Python script, or the time-set code? I guess the latter should still work, though the former is easier and more accurate (and allows you to reset the clock without having to re-sketch the Arduino. You should also make sure the time stays accurate across a power cycle: Pull the power to the arduino and RTC (leave the battery in though), wait about ten seconds, then turn it back on and make sure it still sets the lights the right way. The RTC should keep time fine during a power outage when configured properly.

The dimming issue is your driver. The XP-Gs (I have 6 each of Neutral White and Cool White over my tank...) allow linear dimming all the way down, and my code can dim to about 0.1% intensity (1/1023). The limitation regarding how much dimming you actually get is in the driver, though.

I use CAT4101 drivers on my board. The specs say they dim linearly to about 1% intensity and this is consistent with what I see in practice (I can dim below that, but it's not very smooth). Other drivers like the Meanwells are slower and only have linear dimming to a much higher cutoff. I recall the manufacturer telling me that the *P models (the ones with PWM) can only dim to about 11-12 % intensity. If yours cuts off at about 300, that's about 29%, which seems high.

If you don't mind experimenting a bit, try two things for me. Set your intensity to, say, 200 (a bit lower than you can achieve right now). Now, in the tank_control.pde sketch there is this on line 176:

Timer1.initialize(6666); // 150Hz PWM

That sets the frequency of your PWM output. I want you to try a few new values instead of that 6666 and see if your driver likes them better. Try 10000 first and experiment with the dimming, and then try 333. Those correspond to 100Hz and 3kHz respectively, the upper and lower frequencies that your Meanwell can handle (obviously you'll have to save and then upload the sketch again to the Arduino after each change). You might be able to eek out a bit better dimming using one of those settings. Don't expect miracles though, the Meanwells won't dim all the way down no matter what you do.

One more thing that may make a difference -- that 11-12% might be expressed as a percentage of *max* output. So if you aren't running the LEDs at full power during daylight anyway, turn the current knob on the Meanwell down all the way and then check. I bet that will give a bigger dimmable range...

Good luck and please let me know how it goes.
sink is offline   Reply With Quote
Old 01-28-2012, 03:37 PM   #52
MoeBetta
Planted Tank Obsessed
 
PTrader: (10/100%)
Join Date: Feb 2011
Location: Dayton, OH
Posts: 357
Default

I thought the meanwell driver was the limiting factor on those, I believe it has a minimum built in.

LED's will run as low as you want them to. This is the reason I've chosen to build a driver from scratch based on o2's design. I'm currently waiting on boards. As I understand it I'll be able to use my XM-L string as moonlights.

I know there is nothing in the code that cuts output below any level. I currently have a 3mm led dimming to a output value of 2. You can barely tell it is on, but it is.

Cheers!

Jason
MoeBetta is offline   Reply With Quote
Old 01-28-2012, 04:16 PM   #53
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by MoeBetta View Post
LED's will run as low as you want them to. This is the reason I've chosen to build a driver from scratch based on o2's design. I'm currently waiting on boards. As I understand it I'll be able to use my XM-L string as moonlights.
May work, but even well less than 1% or so of a very bright LED is still amusingly bright, especially if you have a string of them. If it's too bright, I may be able to knock up something for you. In theory you can get 16bit PWM output on the Arduino but it's fairly complex so I've never tried. That would let the code dim down to 0.0015% intensity (instead of the 0.1% currently). There would still be the limitation of your driver, but might be enough.
sink is offline   Reply With Quote
Old 01-28-2012, 07:07 PM   #54
stephenpence
Planted Member
 
PTrader: (7/100%)
Join Date: Mar 2010
Location: Laramie, WY
Posts: 165
Default

So i spent some time doing some fine tuning, to find my minimum allowable values.
At 10000 - 233. (at this point the LEDs showed some pulsing, and the lights
were pretty dim. just going from 233-235 is a dramatic
difference in light output
At 6666 - 232. Lights were not significantly more dim than the 235 mark at
10000. i was never able to achieve a significant dimming level.
At 333 - 234. Essentially the same as the 6666 level. no significant dimming
level.
I adjusted the SVR2 screw in the driver so that the 10000 test showed quite a bit of dimming. then we set the day night phase to go from 230 to 236 over a one mnute dimming inverval.

At 10000 - the lights showed smooth dimming across the board, went from
lights out to bright.
At 6666 - Less smoooth than 10000. towards the dim end, they started to
flicker before they turned off

At 333 - dimming was really choppy. towards the lowest value in the dimming the lights were flickering more and more rapidly until they shut off.


So i'm not entirely sure how to get a decent sunrise efffect. i'm thinkng starting one below the min value, and having it dim up to 800, which is visually about where i want the tank at.
I have to admit, there's a not so small part of me that's bummed by the lack of dimming capabilities of these meanwell drivers. regretfully, before this build, i had no idea how any of it worked, so i bought the kit from Rapid LED so i could learn by doing. What is important is that i should have the ability, once i have my par meter built, to adjust the max brightness to the level i want at my substrate.
If you have any thoughts on my results, or other ideas how to get this guy to work on the full spectrum, let me know!
stephenpence is offline   Reply With Quote
Old 01-28-2012, 07:57 PM   #55
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by stephenpence View Post
So i spent some time doing some fine tuning, to find my minimum allowable values.
At 10000 - 233. (at this point the LEDs showed some pulsing, and the lights
were pretty dim. just going from 233-235 is a dramatic
difference in light output
At 6666 - 232. Lights were not significantly more dim than the 235 mark at
10000. i was never able to achieve a significant dimming level.
At 333 - 234. Essentially the same as the 6666 level. no significant dimming
level.
I adjusted the SVR2 screw in the driver so that the 10000 test showed quite a bit of dimming. then we set the day night phase to go from 230 to 236 over a one mnute dimming inverval.

At 10000 - the lights showed smooth dimming across the board, went from
lights out to bright.
At 6666 - Less smoooth than 10000. towards the dim end, they started to
flicker before they turned off

At 333 - dimming was really choppy. towards the lowest value in the dimming the lights were flickering more and more rapidly until they shut off.


So i'm not entirely sure how to get a decent sunrise efffect. i'm thinkng starting one below the min value, and having it dim up to 800, which is visually about where i want the tank at.
I have to admit, there's a not so small part of me that's bummed by the lack of dimming capabilities of these meanwell drivers. regretfully, before this build, i had no idea how any of it worked, so i bought the kit from Rapid LED so i could learn by doing. What is important is that i should have the ability, once i have my par meter built, to adjust the max brightness to the level i want at my substrate.
If you have any thoughts on my results, or other ideas how to get this guy to work on the full spectrum, let me know!
Very thorough experimentation. You can safely use whatever of those frequencies works best in your case (probably 10000).

I understand the issue. Howabout this proposal:

Set the current knob on the Meanwell such that max intensity in the code (1023) corresponds to a bit higher than the highest light output you want during daytime over the tank. I know you might not know this value yet without a PAR meter, but you can always tweak it later. Set the nighttime intensity in the code to just less than the value needed to turn on the lights, and your daytime intensity to 1023. Then, set the sunrise/sunset duration (kFadeDuration) to be very long, say a few hours. Set the sunrise time (kTurnOn) to the time you want the lights to start coming on, and then set the sunset time (kTurnOff) to the time you want the lights to be off MINUS the long fade duration--meaning it will probably be a time in the afternoon.

This will give you a long dawn, then a while at high intensity, followed be a long drawn out sunset. Since much of the actual light fading happens at the extreme of each fade (courtesy of the Meanwell limitations) this should give you a decently smooth sunrise/sunset. You can probably tweak the values so that your plants still get enough light (and realistically this is a more natural cycle than a quick sunrise/sunset followed by a long flat noon).

Last edited by sink; 01-29-2012 at 03:01 PM.. Reason: typo
sink is offline   Reply With Quote
Old 01-29-2012, 07:28 AM   #56
stephenpence
Planted Member
 
PTrader: (7/100%)
Join Date: Mar 2010
Location: Laramie, WY
Posts: 165
Default

brilliant. i'm setting it up now! one day i'll be able to justify buying some better drivers, and when i do, i'll be coming back here to ask you where to look. Seriously thank you for helping me make these work for the mean time though!!!
stephenpence is offline   Reply With Quote
Old 01-29-2012, 03:12 PM   #57
sink
Algae Grower
 
PTrader: (2/100%)
Join Date: Jun 2011
Location: Boston, MA
Posts: 148
Default

Quote:
Originally Posted by stephenpence View Post
brilliant. i'm setting it up now! one day i'll be able to justify buying some better drivers, and when i do, i'll be coming back here to ask you where to look. Seriously thank you for helping me make these work for the mean time though!!!
You are very welcome, and please let us know if it works. For driver questions, ask O2Surplus. The board that I'm using on my tank is actually just a vastly inferior homemade copy of one of his designs
sink is offline   Reply With Quote
Old 01-29-2012, 04:16 PM   #58
MoeBetta
Planted Tank Obsessed
 
PTrader: (10/100%)
Join Date: Feb 2011
Location: Dayton, OH
Posts: 357
Default

Stephen, fwiw, ill have some extra of o2's latest boards laying around as long as I dont ruin all 10 trying to solder the lm3409.

We may have to work on setup values depending on you parameters. But I should be able to help you with a turn key solution.
MoeBetta is offline   Reply With Quote
Old 01-29-2012, 04:54 PM   #59
O2surplus
Planted Tank Enthusiast
 
O2surplus's Avatar
 
PTrader: (4/100%)
Join Date: Jan 2010
Location: yorba linda, ca.
Posts: 591
Default

Quote:
Originally Posted by MoeBetta View Post
Stephen, fwiw, ill have some extra of o2's latest boards laying around as long as I dont ruin all 10 trying to solder the lm3409.

We may have to work on setup values depending on you parameters. But I should be able to help you with a turn key solution.
Moe- Did I give you the design w/ analog current adjustment? If I did, The current can be adjusted from a maximum of 3000mA to a minimum of 100mA. That's enough adjustment range to drive practically any high power led on the market today. Stephen could just turn down the current to whatever level he desires and then PWM dim from there. As an experiment- I have the same driver pushing a single Bridgelux BXRA-C4500 to 75 watts (27vdc x 2750mA) right now. It's been up and running 24/7 since last week and there have been no failures yet. I think we have ourselves a winner in the search for a cheap and reliable DIY Led driver .
O2surplus is online now   Reply With Quote
Old 01-30-2012, 02:31 AM   #60
MoeBetta
Planted Tank Obsessed
 
PTrader: (10/100%)
Join Date: Feb 2011
Location: Dayton, OH
Posts: 357
Default

Yeah, I've got the adjustable pot.

Sounds great to me, I can't wait to get these 12 XM-L blinding these poor fish. This 70" heatsink is pretty solid, hoping to not even need active cooling, but if I do I'll just get the arduino a sensor on the HS and have it switch on 4 12v fans in series off the 48v supply via a relay.

Did you get your most recent project up and running yet? I'm anxious to see what you came up with.
MoeBetta is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012