Multiple on/off times

Do you have a question on how to do something.
Ask in here.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Awesome. Post up your full code now. Lets see what you ended up with.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

This is the code that wound up working.

Code: Select all

////// Place global variable code below here

unsigned long ATOUpdate=0;
////// Place global variable code above here

Code: Select all

void loop()
{
ReefAngel.StandardLights( Port1,12,0,22,0 );
ReefAngel.StandardLights( Port2,13,0,21,0 );
ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port1 ) );
ReefAngel.StandardLights( Port7,13,0,21,0 );
ReefAngel.Relay.Set(Port5,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
ReefAngel.Relay.Set(Port8,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
ReefAngel.WaterLevelATO(Port6,720,29,31); // Enable ATO the ATO
if (ReefAngel.Relay.Status(Port5)) // Check to see if port 5 is on and update time is empty
{ 
ATOUpdate = now(); // If so, set the update time to now
} 

if (now() - ATOUpdate < 120) // If it hasnt been 120 seconds turn off the port
{ 
ReefAngel.WaterLevelATO(Port6,720,0,1);
}
ReefAngel.PWM.SetActinic(MyCustomWave(50));
if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(0);
if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);
if (hour()<12 || hour()>=22) ReefAngel.PWM.SetActinic(30);
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

See, I told you we'd get it!

--Colin
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

I knew we would get it, but I didn't want to take any more of your and Lee's time.
Glad we wrapped it up this quick.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Can you set at partial # in the water level sensor.
like 29.5% or does it need to be full #'s?

If so would it be 295 or 29.5?
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Sacohen wrote:Can you set at partial # in the water level sensor.
like 29.5% or does it need to be full #'s?

If so would it be 295 or 29.5?
Nope. Has to be a whole number. They're defined as byte type.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Im still waiting to hear what happened with the priest and rabbi..
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Thanks Colin. Lee I'll get back to you on that.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

A rabbi, a priest, and a Lutheran minister walk into a bar. The bartender looks up and says, "Is this some kind of joke?"

or

the Priest asks the Rabbi "Have you ever tried a bacon sandwich or even fancied one? The Rabbi answers "Well i have speculated about it but my faith forbids me from trying, but father, have you ever fancied a nice night of sex with a good woman, i mean a really good woman?" The Priest thinks hard and answers " Well Rabbi, i have sometimes wondered but my vow of celibacy prevents it from ever occurring" The Rabbi answers "Sure as hell beats a bacon sandwich, don't it?"
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Lol! Ty :)
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Lee;

I've forgot how my code for the denitrification chamber is set up.

I want to change the amount of time that the pump is on from 20 min to 10 min.

This is the original code...

Code: Select all

// DeNitrate Routine
  int DeNit_Offset=3600; 
  int DeNit_Repeat=21600;
  int DeNit_Doser_Offset=1200;
  int DeNit_Doser_Runtime=1200;
  int DeNit_Pump_Runtime=1200;
  int DeNit_ATO_Offtime=1500;

  // Pump comes on first
  ReefAngel.Relay.Set(DeNit_Pump,(now()-3600)%21600<1200);       // Runs for 1200s every 21600 seconds  
  // Doser comes on second
  ReefAngel.Relay.Set(DeNit_Doser,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
  
Do I change it at the DeNit_Doser Runtime or in this line...

Code: Select all

// Doser comes on second
  ReefAngel.Relay.Set(DeNit_Doser,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
To this....

Code: Select all

// Doser comes on second
  ReefAngel.Relay.Set(DeNit_Doser,((now()-3600)-1200)%21600<600); // Runs for 600s every 21600 seconds with 1200s offset
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

First off why don't we confirm that we're talking about the carbon source dosing pump and not the chamber fill/flush pump. Is yours like DrThompson? Are you dosing methanol?

Finally I believe you got it perfect it. What you should do now is change it ALSO in the Denit_Doser_Runtime and then at some point replace the numbers defined with the variable names so next time or for someone else who comes along you/them just need to change the variables.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

I'm talking about changing the time on the dosing pump.
Yes it is like DrThompsons. I have an actual denitrification chamber and pump from NatuReef and am switching from the Nitragone that they sell to a 50% Methanol/RODI mix, like he runs.

So it would be like this...

Code: Select all

// DeNitrate Routine
  int DeNit_Offset=3600; 
  int DeNit_Repeat=21600;
  int DeNit_Doser_Offset=1200;
  int DeNit_Doser_Runtime=600;
  int DeNit_Pump_Runtime=1200;
  int DeNit_ATO_Offtime=1500;

  // Pump comes on first
  ReefAngel.Relay.Set(DeNit_Pump,(now()-3600)%21600<1200);       // Runs for 1200s every 21600 seconds  
  // Doser comes on second
  ReefAngel.Relay.Set(DeNit_Doser,((now()-3600)-1200)%21600<600); // Runs for 600s every 21600 seconds with 1200s offset
 
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Yes, but let's use this finally...

Code: Select all

// DeNitrate Routine
int DeNit_Offset=3600; 
int DeNit_Repeat=21600;
int DeNit_Doser_Offset=1200;
int DeNit_Doser_Runtime=600;
int DeNit_Pump_Runtime=1200;
int DeNit_ATO_Offtime=1500;

// Pump comes on first
ReefAngel.Relay.Set(DeNit_Pump,(now()-DeNit_Offset)%DeNit_Repeat<DeNit_Pump_Runtime);  // Runs denitrator pump
// Doser comes on second
ReefAngel.Relay.Set(DeNit_Doser,((now()-DeNit_Offset)-DeNit_Doser_Offset)%DeNit_Repeat<DeNit_Doser_Runtime); // Runs denitrator doser
And replace the DeNit_ATO_Offtime wherever you have that as well so you can just use the variables moving forward. You'll be less confused and you'll see what each number means.
Post Reply