Setting a timer on a port that is already controlled

Do you have a question on how to do something.
Ask in here.

Posts: 36
Joined: Thu Jan 04, 2018 10:47 pm
PostPosted: Sun Jun 07, 2020 8:28 am
To better balance my daily alkalinity, I'm interested in turning off my Carbondoser (fancy solenoid connected to CO2 tank for my Ca reactor) for a few hours in the middle of the night. The problem is, this relay/port is already set for CO2 control, tied to the pH read by my PH Expansion module
Code: Select all
ReefAngel.CO2Control( Box1_Port1, InternalMemory.CO2ControlOff_read(), InternalMemory.CO2ControlOn_read(), true );


I can set simple time if/then statements, but I figure that if I set the port to time-off at say 1:00 am and then time-on at say 4:00 am, it would create a conflict in that my CO2 control code is telling the port one thing (to turn on/off based on Internal Memory settings), while the if/then statements would be telling it to turn on at 4 am and remain on until 1 am. The way out of this is to set two "off" values creating a range
Code: Select all
if ( hour(now()) >= 1 ) ReefAngel.Relay.Off( Box1_Port1 );
    if ( hour(now()) <= 4 ) ReefAngel.Relay.Off( Box_Port1 );


Is this the best way to accomplish?

Posts: 36
Joined: Thu Jan 04, 2018 10:47 pm
PostPosted: Sun Jun 07, 2020 8:41 am
Oops... I just realized that my if/then statement code won't work without "and". Can you include an "and" in the if/then statement code?

Posts: 12628
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sun Jun 07, 2020 6:40 pm
Yes you can use and and on your if statement.
Just make sure to add that line after your CO2Control function.
Roberto.

Posts: 36
Joined: Thu Jan 04, 2018 10:47 pm
PostPosted: Sun Jun 07, 2020 9:09 pm
rimai wrote:Yes you can use and and on your if statement.
Just make sure to add that line after your CO2Control function.


Great. What is the syntax for using “and” when linking two if/then statements?

Posts: 12628
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Jun 08, 2020 7:17 am
Code: Select all
if ( hour(now()) >= 1 && hour(now()) <= 4 ) ReefAngel.Relay.Off( Box1_Port1 );
Roberto.

Posts: 36
Joined: Thu Jan 04, 2018 10:47 pm
PostPosted: Mon Jun 08, 2020 11:09 am
rimai wrote:
Code: Select all
if ( hour(now()) >= 1 && hour(now()) <= 4 ) ReefAngel.Relay.Off( Box1_Port1 );


Thanks! So the syntax for the logical function "and" is: <space>&&<space>, correct? Also, my pH Expansion has dropped out a couple of times, showing a pH of 0.00. Since 0.00 is lower than my Internal Memory "turn off" value, my Carbondoser shut-off until the value came back (wasn't out for long either time). I have my Carbondoser/regulator set such that my Carbondoser runs continuously, and my internal memory values are just there as a failsafe. My question is, if I add the if/then statement:
Code: Select all
if ( ReefAngel.Params.PHExp <= 100 ) ReefAngel.Relay.On( Box1_Port1 ); //Keeps Carbondoser running in the event pH Expansion value is lost

would that nullify the problem in that my Carbondoser would remain 'on' in the event Expansion pH dropped to 0.00 (<=1.00)?

Posts: 12628
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Tue Jun 09, 2020 5:59 am
Yes
Roberto.

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 4 guests

cron