CO2Control - Relay on and Off all the time

Do you have a question on how to do something.
Ask in here.
Post Reply
rrodriguess
Posts: 133
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

CO2Control - Relay on and Off all the time

Post by rrodriguess »

Hi there

I use the code ReefAngel.CO2Control(Port1,620,650); to control a solenoid valve attached to a CO2 cilinder.

The problem is that the PH reading fluctuat a little bit, so the Port1 relay keep's getting On and Off in matter of seconds. I am afraid it can damage the solenoid valve.

Is there a way to prevent that from happening? I dont know.. maybe after X seconds above 650 just then get relay On.

Best regards
Rafa
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: CO2Control - Relay on and Off all the time

Post by rimai »

You would have to create your own code.
Maybe something like this:

Code: Select all

static unsigned long lastmillis=millis();
static enablesolenoid=false;
if (ReefAngel.Params.PH>650 && !enablesolenoid)
{
  enablesolenoid=true;
  lastmillis=millis();
}
if (ReefAngel.Params.PH<620) enablesolenoid=false;
ReefAngel.Relay.Set(Port1,enablesolenoid);
if (millis()-lastmillis<5000) ReefAngel.Relay.Off(Port1);
Roberto.
rrodriguess
Posts: 133
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

Re: CO2Control - Relay on and Off all the time

Post by rrodriguess »

Obrigado Roberto!

That's what I was thinking.

Best regards
Rafa
Image
Post Reply