Improved Arduino LED lighting code - Page 9
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 06-13-2012, 12:04 PM   #121
Knut
Newbie
 
PTrader: (0/0%)
Join Date: Jun 2012
Posts: 2
Thumbs up

Hello guys,

great work! I installed the code on my Arduino Uno (with DS1307) and it works perfect!
I build a lamp with two strings (? or circuits?), one with warm white and one with cold white LEDs to simulate the sunrise. The lamp is driven by 2 PT4115 constant current regulators with 24V at ~1,1A. So I have round about 50W LED light power!

The only problem is now, how can I switch the 2 PWM outputs separately? For example: ww begins at 8h for 1h and after 45min the cw starts. Now it starts simultaneously.

It is possible to reduce the time for the moonlight? I think 2h (22-0) is enough.

The feature list says it is possible: "Flexible timing logic. You can do anything you want (with minor modifications) so long as it's on a 24hr cycle."

Regards
Knut

PS: Sorry for my bad english, I hope u understand me.
Knut is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 06-13-2012, 02:16 PM   #122
O2surplus
Planted Tank Enthusiast
 
O2surplus's Avatar
 
PTrader: (4/100%)
Join Date: Jan 2010
Location: "The Land of Fruits & Nuts"
Posts: 623
Default

From what I can tell, by reading the sketch, both channels are governed by the same set of constants. Sink would have to re-write the code to make each channel independent of the other. I'm no expert in code writing but I think it's possible. Sink is the ultimate authority on that Subject though.
O2surplus is offline   Reply With Quote
Old 06-13-2012, 02:20 PM   #123
Knut
Newbie
 
PTrader: (0/0%)
Join Date: Jun 2012
Posts: 2
Default

@Sink: Help me please

Yes, I think you are right. So I wait for a reply from the master Sink!
Knut is offline   Reply With Quote
Old 06-22-2012, 08:36 PM   #124
electriccraft1
Newbie
 
PTrader: (0/0%)
Join Date: Jun 2012
Location: Gainesville, FL
Posts: 1
Default

I have been looking for a solution like this, but was considering rgb. I an new to this, so what ask is required to get a working set up for a 80 gal salt tank ? DIY is not an issue for me as I have done holiday DIY for years now. Please lead me in the right direction as far as parts go. I would like to simulate the correct color temperatures for the full 24 HR cycle. Thank you in advance.
electriccraft1 is offline   Reply With Quote
Old 12-03-2012, 04:24 PM   #125
chuckxx
Newbie
 
PTrader: (0/0%)
Join Date: Dec 2012
Location: Canada
Posts: 2
Default Getting it to work on Ver 1 Arduino

It's not much of a contribution but I'm sure this would save you a lot time rewriting the code.

You mention that this code is pre ver 1.0 Arduino

I have managed to compile it get it working on a Ver 1.01 Arduino UNO Rev3 with changing one Library Time.h

Thanks for the great code hope this helps to the cause.
Attached Files
File Type: zip Time.zip (30.3 KB, 103 views)

Last edited by chuckxx; 12-03-2012 at 04:27 PM.. Reason: typos
chuckxx is offline   Reply With Quote
Old 12-03-2012, 04:49 PM   #126
O2surplus
Planted Tank Enthusiast
 
O2surplus's Avatar
 
PTrader: (4/100%)
Join Date: Jan 2010
Location: "The Land of Fruits & Nuts"
Posts: 623
Default

Quote:
Originally Posted by chuckxx View Post
It's not much of a contribution but I'm sure this would save you a lot time rewriting the code.

You mention that this code is pre ver 1.0 Arduino

I have managed to compile it get it working on a Ver 1.01 Arduino UNO Rev3 with changing one Library Time.h

Thanks for the great code hope this helps to the cause.

Thanks A Lot! That's a big help for people running Arduino 1.0l
__________________
225 Gal, Glass "Reef Ready" w/ twin Iwaki Pumps & 2 Ocean Clear inline filters. Custom 320 watt LED Lighting system utilizing a 6' Maker's Heat Sink, 12 BridgeLux Vero 18's,3 purpose built 5 channel A6211 Led driver/Controllers, and a 20lb CO2 system w/ Milwaukee Ph Controller.
O2surplus is offline   Reply With Quote
Old 12-09-2012, 11:55 PM   #127
chuckxx
Newbie
 
PTrader: (0/0%)
Join Date: Dec 2012
Location: Canada
Posts: 2
Default Getting it to work with RGB

Ok I have been at this for a week now, I too was looking at getting my RGB lights running off of this simple but wonderful code.

But looking into it getting it to run on the Uno was the easy part but getting 3 CH timer is an other story entirely and I'm not programer I'm more of a band aid hacker lets say.

Well to explain it shortly the Arduino has 3 Timer, Timer0, Timer1, Timer2,
each one of these timers have 2 CH with a variety feature for each.
It polls an compares the millis() and Freq ch A, B. The timers and says hey you need to Turn on, or off, or Fade, ext.. but each timer has 2 Registers to keep track of the time.

And see this is a great feature and what makes this code great, Is its not taking up all your clock times(CPU) while trying to keep track of the time and do other things.

Like keeping track of Temps, or controlling your 3 speed pump or turing them on and off ect..

I tried to add one of the other timer from pin 11 but I don't have all the programming knowledge to get it to work properly, I mean it was working sort of.

So I'm taking the easy route and using the Arduino Mega 2560 it adds 3 more 16 Bit Timers.

Making it easy to modify the code to work withe RGB lights.
Plus if you really wanted too you could use both Timer1 for your main lights and Timer3 for your complementary RGB Lights.

I am plaining to adding lots more features I just need to mash all this code a have together like setting the time from the LCD Unit it self with 2 Buttons or a rotary encoder, Alarms to tell you its time to do Water changes or clean your filter.

If any one is interested when I get it all done I can post it up.

Cheers! Happy coding..
Oh here's the Timer3 file for the Mega I have it using Pin 5,3,2
And you need to add or change this code.
I'm still trying to debug the Error so if you find one or see something wrong let me know.

Code:
#include <TimerThree.h>
const int kChan0Pin = 5; // Channel 0 Pin
const int kChan1Pin = 2; // Channel 1 Pin
const int kChan2Pin = 3; // Channel 2 Pin
Code:
const int kDayState[] = { 1023, 1023, 1023 }; // daytime LED state
const int kNightState[] = { 0, 0, 0 }; // nighttime LED state
Code:
int state_chan1, state_chan2, state_chan3;
Code:
void fader(long start_time, const int start_state[], const int end_state[], int out[3]) {

  float per_second_delta_0 = (float) (end_state[0]-start_state[0])/kFadeDuration;
  float per_second_delta_1 = (float) (end_state[1]-start_state[1])/kFadeDuration;
  float per_second_delta_2 = (float) (end_state[2]-start_state[2])/kFadeDuration;
  
  long elapsed = ctr-start_time; // Calculate the elapsed Time

  out[0] = start_state[0] + per_second_delta_0 * elapsed;
  out[1] = start_state[1] + per_second_delta_1 * elapsed;
  out[2] = start_state[2] + per_second_delta_2 * elapsed;
}
Code:
void set_state(const int state[]) {
  if (state[0] >= 0 && state[0] <= 1023) {
    Timer3.setPwmDuty(kChan0Pin, state[0]);
    state_chan1 = state[0]; }
  if (state[1] >= 0 && state[1] <= 1023) {
    Timer3.setPwmDuty(kChan1Pin, state[1]);
    state_chan2 = state[1]; }
  if (state[2] >= 0 && state[2] <= 1023) {
    Timer3.setPwmDuty(kChan2Pin, state[2]);
    state_chan3 = state[2]; }
}
Attached Files
File Type: zip Timer3.zip (9.0 KB, 62 views)

Last edited by chuckxx; 12-09-2012 at 11:59 PM.. Reason: Opps forgot the file
chuckxx is offline   Reply With Quote
Old 01-03-2013, 04:26 PM   #128
scapegoat
Planted Tank Guru
 
scapegoat's Avatar
 
PTrader: (15/100%)
Join Date: Jun 2010
Location: philadelphia, pa
Posts: 2,220
Default

so uh... does anyone want to put together a shopping list via amazon.com?

I'd love to get started on this to eventually control the lights and co2 of a 125g. I've heard of the arduino and knew it was being used for fun stuff like this. I'm a web developer by trade, so this hardware stuff is quite confusing to me, but i can definitely dig into the code.
scapegoat is offline   Reply With Quote
Old 01-03-2013, 06:04 PM   #129
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,128
Default

Quote:
Originally Posted by scapegoat View Post
so uh... does anyone want to put together a shopping list via amazon.com?

I'd love to get started on this to eventually control the lights and co2 of a 125g. I've heard of the arduino and knew it was being used for fun stuff like this. I'm a web developer by trade, so this hardware stuff is quite confusing to me, but i can definitely dig into the code.
If you're new to arduino, I suggest playing with simple stuff first like making LED blink and such just to get yourself acquainted. Buy a starter kit like here

https://www.sparkfun.com/products/11226

It's too much and confusing if you jump right in.
If you want to get acquainted with the coding check here
http://aquatictechtank.net/viewtopic...bbdb9b12409943
mistergreen is offline   Reply With Quote
Old 01-04-2013, 01:25 PM   #130
scapegoat
Planted Tank Guru
 
scapegoat's Avatar
 
PTrader: (15/100%)
Join Date: Jun 2010
Location: philadelphia, pa
Posts: 2,220
Default

Quote:
Originally Posted by mistergreen View Post
If you're new to arduino, I suggest playing with simple stuff first like making LED blink and such just to get yourself acquainted. Buy a starter kit like here

https://www.sparkfun.com/products/11226

It's too much and confusing if you jump right in.
If you want to get acquainted with the coding check here
http://aquatictechtank.net/viewtopic...bbdb9b12409943
jumping in is half the fun. I'm not concerned about programming the thing as I've got experience with scripting languages. More so concerned about selecting the right items to get it working. I'd love to have one control the timing of everything, ferts, food, lights, co2, etc.
scapegoat is offline   Reply With Quote
Old 02-18-2013, 08:02 PM   #131
Gisimo
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2012
Location: Denmark
Posts: 17
Default

Hi all i was wondering if it is possible to implement auto daylight savings time so it automatic change the time?!
Gisimo is offline   Reply With Quote
Old 02-21-2013, 10:59 AM   #132
Gisimo
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2012
Location: Denmark
Posts: 17
Default

I need help understanding how an n-fet works i have chosen one ( irf520) it can handel alot of power about 10 amp or so, but why is it getting so hot when it is only handling a load of 1.0 amp?
I have mounted it on a large heat sink because i want to make a salt water one day and i may then nead 6amp pr. Channel!!
But how hot vil it be at that load ?

Is it becurse i have a resistor betwin Arduino pin 9 and gaten on the fet so it dosent open totely?? Is it nessasery with a resistor?

Last edited by Gisimo; 02-21-2013 at 02:26 PM.. Reason: spelling
Gisimo is offline   Reply With Quote
Old 02-21-2013, 02:34 PM   #133
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,128
Default

Quote:
Originally Posted by Gisimo View Post
Hi all i was wondering if it is possible to implement auto daylight savings time so it automatic change the time?!
You have to write code for this but the time change date is arbitrary based on the government. It's easier just to change the time manually.


Quote:
Originally Posted by Gisimo View Post
I need help understanding how an n-fet works i have chosen one ( irf520) it can handel alot of power about 10 amp or so, but why is it getting so hot when it is only handling a load of 1.0 amp?
I have mounted it on a large heat sink because i want to make a salt water one day and i may then nead 6amp pr. Channel!!
But how hot vil it be at that load ?
It's natural for components with large amps to get warm/hot but not boiling hot. Check your circuit for shorts if it gets really hot and the circuit is broken.
mistergreen is offline   Reply With Quote
Old 02-21-2013, 03:03 PM   #134
Gisimo
Algae Grower
 
PTrader: (0/0%)
Join Date: Apr 2012
Location: Denmark
Posts: 17
Default

Thank you!! Every thing works fine i just wondered why it gets hot when it is that little current!!! Is the fet getting hotter if the voltage on the gate is lover than 4.8 volts? Is it necessary to have a resistor in front of the gate?? (Between pin 9 and gate)
Gisimo is offline   Reply With Quote
Old 02-21-2013, 03:39 PM   #135
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,128
Default

Quote:
Originally Posted by Gisimo View Post
Is it necessary to have a resistor in front of the gate?? (Between pin 9 and gate)
I usually do put resistor in front of the gate but it depends on the transistor's spec.

The wattage is what makes a component hot or not. Use the correct wattage rated component.

P = V*I

watts = volt * current
mistergreen 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 12:20 PM.


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