Simple bit of coding help please!!
Simple bit of coding help please!!
Ok, I want to use the ATO low and high switches to do the following:
ATO High active , turn off the skimmer until the switch reads low, then when switch not active skimmer switched on.
Why - switch is skimmer lid to stop skimmer overflowing
ATO Low active , disable my ATO pump until switch is not active, then when non active, allow the ATO pump to be controlled as normal (currently controlling ATO pump based off salinity.
Why - to stop ATO pump and send email when ATO reservoir empty.
I look forward to your help!!
ATO High active , turn off the skimmer until the switch reads low, then when switch not active skimmer switched on.
Why - switch is skimmer lid to stop skimmer overflowing
ATO Low active , disable my ATO pump until switch is not active, then when non active, allow the ATO pump to be controlled as normal (currently controlling ATO pump based off salinity.
Why - to stop ATO pump and send email when ATO reservoir empty.
I look forward to your help!!
Re: Simple bit of coding help please!!
OK, I am trying to work through this myself, but have a few questions.
Taking it one bit at a time and my first bit is to get the skimmer turning off and on correctly.
Currently I have the skimmer set (port 7), so that when reset or power off, there is a 10 min delay.
I have come up with the code below, but the bit of code "else ReefAngel.Relay.On( Port7 )" seems to override the delay on, which makes sense as I guess as I am turning the port on with that instruction.
So how do I code so that if the delayed time on is invoked, that takes precedence over the "else ReefAngel.Relay.On( Port7 )" instruction??
void loop()
{
ReefAngel.Relay.DelayedOn( Port7,10 );
ReefAngel.StandardHeater( Port6,259,261 );
ReefAngel.StandardFan( Port7,260,263 );
////// Place your custom code below here
if (ReefAngel.Params.Salinity<351) lastLowSal=now();
ReefAngel.Relay.Set(Port1,(now()-lastLowSal>120));
if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port7); else ReefAngel.Relay.On( Port7 );
Taking it one bit at a time and my first bit is to get the skimmer turning off and on correctly.
Currently I have the skimmer set (port 7), so that when reset or power off, there is a 10 min delay.
I have come up with the code below, but the bit of code "else ReefAngel.Relay.On( Port7 )" seems to override the delay on, which makes sense as I guess as I am turning the port on with that instruction.
So how do I code so that if the delayed time on is invoked, that takes precedence over the "else ReefAngel.Relay.On( Port7 )" instruction??
void loop()
{
ReefAngel.Relay.DelayedOn( Port7,10 );
ReefAngel.StandardHeater( Port6,259,261 );
ReefAngel.StandardFan( Port7,260,263 );
////// Place your custom code below here
if (ReefAngel.Params.Salinity<351) lastLowSal=now();
ReefAngel.Relay.Set(Port1,(now()-lastLowSal>120));
if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port7); else ReefAngel.Relay.On( Port7 );
Simple bit of coding help please!!
I use a mask instead of turning on an off if the float switch is triggered. This way you set the mask or clear the mask but you don't turn it on if it should be off.
Code: Select all
if (ReefAngel.LowATO.IsActive()) {
bitClear(ReefAngel.Relay.RelayMaskOff,Return-1);
}
Re: Simple bit of coding help please!!
Hi, thanks for the reply, and I can see how the mask function will do what I want, the only problem, is I dont understand the syntax!!lnevo wrote:I use a mask instead of turning on an off if the float switch is triggered. This way you set the mask or clear the mask but you don't turn it on if it should be off.
Code: Select all
if (ReefAngel.LowATO.IsActive()) { bitClear(ReefAngel.Relay.RelayMaskOff,Return-1); }
What does this bit mean? bitClear(ReefAngel.Relay.RelayMaskOff,Return-1)
And how do I relate that to "masking" Port 7 of the relay box?
Simple bit of coding help please!!
Replace Return-1 with 6 for port 7. The mask bits are set from 0-7 for ports 1-8.
Clearing the OffMask for that port enables that mask. Whereas for the OnMask you'll want to bitSet. You can also override the OffMask with bitSet.
Clearing the OffMask for that port enables that mask. Whereas for the OnMask you'll want to bitSet. You can also override the OffMask with bitSet.
Re: Simple bit of coding help please!!
Well, I have got it working, but it seems to be reversed?
So, I have set port 8 with a 1 minute delay to test.
During this 1 minute delay, everything is as I would expect, port 8 stays off, regardless of the state of the float switch.
After the 1 minute delay, port 8 is still off, but when the float switch is active, the port switches on, and not active the port switches off.
Below is my code, I am sure it is something simples that I have done wrong!!!!
ReefAngel.Relay.DelayedOn( Port8,1 );
////// Place your custom code below here
if (ReefAngel.HighATO.IsActive()) {
bitSet(ReefAngel.Relay.RelayMaskOff,7);
}
else {
bitClear(ReefAngel.Relay.RelayMaskOff,7);
}
So, I have set port 8 with a 1 minute delay to test.
During this 1 minute delay, everything is as I would expect, port 8 stays off, regardless of the state of the float switch.
After the 1 minute delay, port 8 is still off, but when the float switch is active, the port switches on, and not active the port switches off.
Below is my code, I am sure it is something simples that I have done wrong!!!!
ReefAngel.Relay.DelayedOn( Port8,1 );
////// Place your custom code below here
if (ReefAngel.HighATO.IsActive()) {
bitSet(ReefAngel.Relay.RelayMaskOff,7);
}
else {
bitClear(ReefAngel.Relay.RelayMaskOff,7);
}
Re: Simple bit of coding help please!!
Well, I changed the code around to this, and it works, fine, but I am confused as to why!!!
if (ReefAngel.HighATO.IsActive()) {
bitClear(ReefAngel.Relay.RelayMaskOff,7);
}
else {
bitSet(ReefAngel.Relay.RelayMaskOff,7);
}
if (ReefAngel.HighATO.IsActive()) {
bitClear(ReefAngel.Relay.RelayMaskOff,7);
}
else {
bitSet(ReefAngel.Relay.RelayMaskOff,7);
}
Re: Simple bit of coding help please!!
The maskoff variable is an AND bit comparison.
The default state is 255, so clearing a bit means turning off the port.
The default state is 255, so clearing a bit means turning off the port.
Roberto.
Re: Simple bit of coding help please!!
So if I understand you correctly with this code below:rimai wrote:The maskoff variable is an AND bit comparison.
The default state is 255, so clearing a bit means turning off the port.
bitClear(ReefAngel.Relay.RelayMaskOff,7);
}
I am setting a bit mask for bit 7 with a "0" from the bitclear function, making it always a zero output
and then with this code below:
else {
bitSet(ReefAngel.Relay.RelayMaskOff,7);
I am setting a bit mask for bit 7 with a "1"with the bit set function which then allows the output to follow the auto function?
Re: Simple bit of coding help please!!
Correct.
The same concept applies to mask on, except the maskon is a OR bit comparison.
The default value is 0 and setting a bit means turning on that port and clearing the bit means returning to auto.
The only thing you must be careful is to not cause the masks to be out of sync.
You should never have a maskon bit set to 1 while maskoff bit is set to 0. This state would mean you are trying to override on and override off at the same time, which should never exist.
These should be the valid states:
Auto: maskon=0 and maskoff=1
Override On: maskon=1 and maskoff=1
Override Off: maskon=0 and maskoff=0
Invalid: maskon=1 and maskoff=0
The same concept applies to mask on, except the maskon is a OR bit comparison.
The default value is 0 and setting a bit means turning on that port and clearing the bit means returning to auto.
The only thing you must be careful is to not cause the masks to be out of sync.
You should never have a maskon bit set to 1 while maskoff bit is set to 0. This state would mean you are trying to override on and override off at the same time, which should never exist.
These should be the valid states:
Auto: maskon=0 and maskoff=1
Override On: maskon=1 and maskoff=1
Override Off: maskon=0 and maskoff=0
Invalid: maskon=1 and maskoff=0
Roberto.
Re: Simple bit of coding help please!!
Cool- I understand why my code works now!
Thanks Roberto!
No more having to worry about the skimmer overflowing!
Thanks Roberto!
No more having to worry about the skimmer overflowing!
Re: Simple bit of coding help please!!
Yeap
I do the same thing... I drain my skimmate to an external container and have a float switch as safety too.
My tank is in the living room and I have no place to drain, so I have to store it in a container.
The container handled 2 1/2 weeks of my vacation just fine
I just returned yesterday and it was 3/4 full.
I do the same thing... I drain my skimmate to an external container and have a float switch as safety too.
My tank is in the living room and I have no place to drain, so I have to store it in a container.
The container handled 2 1/2 weeks of my vacation just fine
I just returned yesterday and it was 3/4 full.
Roberto.
-
- Posts: 12
- Joined: Wed Nov 07, 2012 10:08 am
Re: Simple bit of coding help please!!
I hate to sound ignorant, but I feel as if I am. What is the difference in setting the mask on the relay verses simply turning the port on and off? Don't they accomplish the same thing?
Simple bit of coding help please!!
By using the on/off commands directly, he was overriding the DelayedOn setting for the port. By using the mask the ato switch applies an override instead of messing with standard behavior.
Re: Simple bit of coding help please!!
The masks are a way to override a port, regardless of what the port is programmed to do.
That's what the Portal or smart phone apps do when you want to override any port.
That's what the Portal or smart phone apps do when you want to override any port.
Roberto.
-
- Posts: 12
- Joined: Wed Nov 07, 2012 10:08 am