Hunter X's Arduino Whole Tank Controller (52K Warning) - Page 15
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 08-22-2014, 12:58 PM   #211
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,283
Default

Nice! That's a sweet little board!
AnotherHobby is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 08-22-2014, 02:20 PM   #212
HunterX
Planted Tank Obsessed
 
HunterX's Avatar
 
PTrader: (22/100%)
Join Date: May 2012
Location: Springfield MO
Posts: 360
Default

Quote:
Originally Posted by AnotherHobby View Post
I just wanted to drop in and say this is an awesome build! Excellent job Hunter! I somehow missed this thread until recently (I think because I was so engrossed in my own project). I finally read through the whole thing, and I'm super impressed.

One thing that might make things cleaner for scheduling is to use the Time.Alarms library. I used it in my project, and it's nice that you don't have to check time in the loop to catch things. It also makes it easy to change the schedule. If you read the docs, you can adjust the library to do up to 255 timers. It has quite a bit of functionality.

Here is an example. This one line below would be executed at startup and creates a schedule that'll run a routine called "lightsOn" every day at 11:00am.

Code:
Alarm.alarmRepeat(11,00,0, lightsOn);
The lightsOn routine could look like this:

Code:
void lightsOn()
{
   digitalWrite(pwrLightPin, HIGH); // this turns the relay on
}
That's it — super easy! It also opens the doors to making it pretty easy to edit the schedule through a menu, and saving that in EEPROM.
Hey Hobby,

That does look like it would make my code more simple but I have a question. Say I wanted to turn something on at and exact second and then turn it off at an exact second. Have you seen any issues where the areduing misses that second and skips that alarm. I have an automatic feeder connected to my Arduino. I drive it through a transister using the 5 volts from the Arduino. It takes 5 seconds for it to complete 1 feed cycle. I turn it on say at (11,05,01) and turn it off at (11,05,04). What do you think?

Bump:
Quote:
Originally Posted by bigd603 View Post
Check out what came in the mail today...





The AquaShield boards!

I think they look great! I tested the pump controls, and they all work flawlessly! Really stoked.
Those look great bigd!

Last edited by HunterX; 08-22-2014 at 02:23 PM.. Reason: Spelling!
HunterX is offline   Reply With Quote
Old 08-22-2014, 02:45 PM   #213
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 13,991
Default

@HunterX
I don't see why TimeAlarms would skip time set in seconds. It has an internal loop where it checks up on time from what I remember when I looked at the library code.
mistergreen is offline   Reply With Quote
Old 08-22-2014, 02:51 PM   #214
HunterX
Planted Tank Obsessed
 
HunterX's Avatar
 
PTrader: (22/100%)
Join Date: May 2012
Location: Springfield MO
Posts: 360
Default

I think I'm going to give it a shot. I'll rewrite my code this weekend and let everyone know how it went. Thanks for the info Hobby.

Quote:
Originally Posted by mistergreen View Post
@HunterX
I don't see why TimeAlarms would skip time set in seconds. It has an internal loop where it checks up on time from what I remember when I looked at the library code.
HunterX is offline   Reply With Quote
Old 08-22-2014, 02:55 PM   #215
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,283
Default

Quote:
Originally Posted by mistergreen View Post
@HunterX
I don't see why TimeAlarms would skip time set in seconds. It has an internal loop where it checks up on time from what I remember when I looked at the library code.
Correct. In your main loop, you have to use "Alarm.delay(5);" at the end of the loop instead of a normal delay. That's how it keeps track. It should not skip any seconds.
AnotherHobby is offline   Reply With Quote
Old 08-22-2014, 02:59 PM   #216
HunterX
Planted Tank Obsessed
 
HunterX's Avatar
 
PTrader: (22/100%)
Join Date: May 2012
Location: Springfield MO
Posts: 360
Default

Quote:
Originally Posted by AnotherHobby View Post
Correct. In your main loop, you have to use "Alarm.delay(5);" at the end of the loop instead of a normal delay. That's how it keeps track. It should not skip any seconds.
Would I really have to use the "Alrarm.delay(5)"? If I just turn it on and then turn it off 5 seconds later wouldn't that do the same thing? Which would be more effecient way of coding?
HunterX is offline   Reply With Quote
Old 08-22-2014, 03:04 PM   #217
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 13,991
Default

Alarm.delay(5) means to check up on all Alarms & timers every 5 milliseconds (the internal loop). You can do Alarm.delay(0) if you don't want any delay for the Alarms class.
mistergreen is offline   Reply With Quote
Old 08-22-2014, 03:27 PM   #218
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (8/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,283
Default

Quote:
Originally Posted by mistergreen View Post
Alarm.delay(5) means to check up on all Alarms & timers every 5 milliseconds (the internal loop). You can do Alarm.delay(0) if you don't want any delay for the Alarms class.
Yes, I just grabbed the line I had in my project.

Quote:
Originally Posted by HunterX View Post
Would I really have to use the "Alrarm.delay(5)"? If I just turn it on and then turn it off 5 seconds later wouldn't that do the same thing? Which would be more effecient way of coding?
You have to use Alarm.delay(n) no matter what in your loop (where n can be any number of millis). It's what calls the TimeAlarms library.

The timer library also has "Alarm.alarmOnce" instead of "Alarm.repeat". You could just kick that off when you start, with the Once timer set to kick off 5 seconds later. Go through the readme, it's pretty easy to use.
AnotherHobby is offline   Reply With Quote
Old 08-22-2014, 03:41 PM   #219
HunterX
Planted Tank Obsessed
 
HunterX's Avatar
 
PTrader: (22/100%)
Join Date: May 2012
Location: Springfield MO
Posts: 360
Default

Quote:
Originally Posted by AnotherHobby View Post
Yes, I just grabbed the line I had in my project.



You have to use Alarm.delay(n) no matter what in your loop (where n can be any number of millis). It's what calls the TimeAlarms library.

The timer library also has "Alarm.alarmOnce" instead of "Alarm.repeat". You could just kick that off when you start, with the Once timer set to kick off 5 seconds later. Go through the readme, it's pretty easy to use.
Yeah I just checked it out. I understand it now. I'm using a differnt RTC time library. Looks like I would have to change that too. Which means changing all the code for displaying the time on the LCD as well. I'll play with it this weekend.
HunterX 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 07:27 AM.


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