Setting a timer on a port that is already controlled

Do you have a question on how to do something.
Ask in here.
Post Reply
jcjrogersstar
Posts: 43
Joined: Thu Jan 04, 2018 10:47 pm

Setting a timer on a port that is already controlled

Post 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?
jcjrogersstar
Posts: 43
Joined: Thu Jan 04, 2018 10:47 pm

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

Post 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?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

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

Post by rimai »

Yes you can use and and on your if statement.
Just make sure to add that line after your CO2Control function.
Roberto.
jcjrogersstar
Posts: 43
Joined: Thu Jan 04, 2018 10:47 pm

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

Post 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?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

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

Post by rimai »

Code: Select all

if ( hour(now()) >= 1 && hour(now()) <= 4 ) ReefAngel.Relay.Off( Box1_Port1 );
Roberto.
jcjrogersstar
Posts: 43
Joined: Thu Jan 04, 2018 10:47 pm

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

Post 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)?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

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

Post by rimai »

Yes
Roberto.
Post Reply