Page 1 of 1

Setting a timer on a port that is already controlled

Posted: Sun Jun 07, 2020 8:28 am
by jcjrogersstar
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?

Re: Setting a timer on a port that is already controlled

Posted: Sun Jun 07, 2020 8:41 am
by jcjrogersstar
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?

Re: Setting a timer on a port that is already controlled

Posted: Sun Jun 07, 2020 6:40 pm
by rimai
Yes you can use and and on your if statement.
Just make sure to add that line after your CO2Control function.

Re: Setting a timer on a port that is already controlled

Posted: Sun Jun 07, 2020 9:09 pm
by jcjrogersstar
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?

Re: Setting a timer on a port that is already controlled

Posted: Mon Jun 08, 2020 7:17 am
by rimai

Code: Select all

if ( hour(now()) >= 1 && hour(now()) <= 4 ) ReefAngel.Relay.Off( Box1_Port1 );

Re: Setting a timer on a port that is already controlled

Posted: Mon Jun 08, 2020 11:09 am
by jcjrogersstar
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)?

Re: Setting a timer on a port that is already controlled

Posted: Tue Jun 09, 2020 5:59 am
by rimai
Yes