ATO code is not working properly.

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

Re: ATO code is not working properly.

Post by lnevo »

:) I'm sure you'd have done the right thing...

Here's the details to confirm

From my analysis... port 7 comes on first for 20 minutes, then port 6 for 20 minutes.

Port 6 - DeNit_Pump
Port 7 - DeNit_Doser

From the labels though, that would be the Doser coming on before the pump... let's see what happens tonight.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

You are correct my friend.

The labels were reversed in the code.
Everyplace else I have them labeled correctly (IE the Portal, the Android App, the RA Client.

I never noticed that I had them reversed in the code because the actual cycle was coming on in the correct order so I never looked for a problem.

I truly apologize, as I'm sure that this lead to some of the problems we have been running into and why you were so confused as to why it is not working properly.

I will try the code as you have it tonight, but will not correct the labels until we have everything working properly or until you tell me too.


Again , I feel really horrible about this.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Cool. That explains a LOT. It explains why my initial code didn't work... why the fix to that didn't work.. why the last code didn't work :) Don't feel horrible. It's a learning process all around. I like the final code we ended up with and hopefully it will do the trick.

Let's still test it as-is and once we got it working, I'll let you do it as an excercise :)

Then we can work on enhancing your WP-40 routines.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

It has been uploaded and I'll see what happens at 7pm and let you know.

Thanks again.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Fingers crossed!!!
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

I'm sure it is correct and will work fine.
It probably would have worked correctly from the very beginning if I wasn't such a jack a__.

I'll let you know.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

We definitely had some issues in the beginning...so it would have needed some tweaks either way. Can't wait for the results already!! :)
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Wheres the update??? ATO should be kicked back in by now!! :)
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Sorry man. I had 4th grade homework to do.
I was able to watch what happened, but just didn't have time to sit down and write this out, until afterwards.
The wife was like "What is so important that it can't wait."
She hate the tank and anytime I take aware from things that need to be done around the house to deal with the tank.

Anyway. It seems to have worked.
I'll explain.

7pm WL was at 29% during the exchange and ATO did not kick in.
I siphoned out some more water so I know it would be below 31% after the exchange. I took it to 24% during the exchange.

After the exchange it went to 27% and the ATO did not kick in until 7:30pm. (10 min after the exchange) This is fine with me, it doesn't need to be 5 min that was just a # I picked.

1 thing I have noticed the past couple of days is that the red ATO notification has been on during the exchange.
I reset it before the end of the exchange to make sure that this did not keep the ATO from kicking in.

I know I'm rambling a bit. If something doesn't make sense ask.

Thanks this seems to be pretty damn close and it totally acceptable except for the ATO warning going on.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

The ato timeout makes sense in why you always had problems when doing Relay.Off in my earlier code!!!!

I suggest we change the relay.off function to what you ised to have with the 0,1 for the level...

That prevented the ato timeout from happening!! Unless roberto has another trick we could use i think cosmoth71 had the right approach...

Just change the ReefAngel.Relay.Off() calls to the bogus WaterLevelATO call.

Then i think we are golden. I think the 30 minutes vs 25 was just a fluke or the level was still working itself out..
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

So replace this...

Code: Select all

if ( (now()-3600)%21600<1500) ReefAngel.Relay.Off(ATO_Pump); 
with this...

Code: Select all

if (ReefAngel.Relay.Status(DeNit_Pump)) // Check to see if DeNit Pump is on and update time is empty
{ 
ATOUpdate = now(); // If so, set the update time to now
} 

if (now() - ATOUpdate < 300) // If it hasn't been 300 seconds turn off the port
{ 
ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

No replace this

Code: Select all

ReefAngel.Relay.Off(ATO_Pump); 
with this...

Code: Select all

ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);
Everything else is perfect.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Done.

So the new code is like this...

Code: Select all

// Disable ATO
if ( (now()-3600)%21600<1500) ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Yes but use it for all conditions where we turn off the ato...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

OK I was wondering about that.

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

Re: ATO code is not working properly.

Post by Sacohen »

It looks like it is working.
I was here for the 7pm cycle and it started at 31% prior to the exchange.b
Dropped below, but did not kick in until 7:26pm.

I think you got it.

Thanks for everything.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO code is not working properly.

Post by rimai »

YAY :)
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

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

Re: ATO code is not working properly.

Post by Sacohen »

It seems like everything has bee running fine.

My water levels are not really high or really low. They have been staying between 31 and 34 like I have them set and my salinity is stable so I know there is not an inordinate amount of RO water getting pumped in, but I still feel more comfortable knowing exactly when the ATO is going on and for how long at least until I know things are running correctly.

I know sebyte talked about setting a custom variable (I think that was it), but I really didn't understand that.

Is there a simple way to be notified, by e-mail or something that the ATO is running?

If it is on for a really short time it doesn't always show up in the portal Relay Activity.
IE: I know it ran about 7:30 this morning, but I don't see it on the portal.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Theres a thread that i did with kirkwood to log his dosing pump activity. The same function can be applied to log ato. I think we actually did it as well. If you can dig up that thread we can figure out what you need for your setup.

There is also the LogDosingPump() function in my INO but its a bit more involved since its logging the volume dispensed and calculating the rate of the pumps.

But this is easily fixed. I just added the routine to calculate the amount of water i change during WCs. :) it uses the same function i mentioned...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Is it the Dosing Pump not running on Schedule thread (http://forum.reefangel.com/viewtopic.php?f=12&t=3262)?

I'll read through it tomorrow.

Thanks.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Yeah, that was it.

This is what you'd want to add...

Code: Select all

// Define Ports to log
const byte numPumps=1;
byte pump[numPumps] = { ATO_Pump };
byte portalMinutes[numPumps] = { 0 };
byte portalPrevMinutes[numPumps] = { 1 };

static unsigned long pumpTimer[numPumps];
static boolean pumpStatus[numPumps];

for (int i=0;i< numPumps;i++) {
  if (ReefAngel.Relay.Status(pump[i])) {
    if (!pumpStatus[i]) {
      pumpTimer[i]=now()-pumpTimer[i]; // Pump was off, timer is now a time
      pumpStatus[i]=true;
    }
  } else {
    if (pumpStatus[i]) {
      pumpTimer[i]=now()-pumpTimer[i]; // Pump was on, timer is now a timer
      pumpStatus[i]=false;

      // Normalize and assign to CustomVar for reporting on the portal
      ReefAngel.CustomVar[portalMinutes[i]]=pumpTimer[i]/60; // Number of Minutes
    }
  }
}

static boolean clearTimer;
if (now()%SECS_PER_DAY!=SECS_PER_DAY-1) clearTimer=true;
if ((now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer==true) {
  // Backup timers to portal variable
  for (int i=0;i<numPumps;i++) {
     ReefAngel.CustomVar[portalPrevMinutes[i]] = pumpTimer[i]/60;
     pumpTimer[i]=0; // Clear timer for port
  }
  clearTimer=false;
}
This will log the number of minutes your ATO pump is on through out the day into the Portal Custom Variable C0. At 11:59pm it will back that up to C1. If you want to add more ports to log, you'll need to define them in the first few lines above. You'll need to set the number of pumps, the ports, and the variables to use for the logging and backup..

For instance, to add Port3 and have it save to variables 2 and backup to variable 3..

Code: Select all

const byte numPumps=2;
byte pump[numPumps] = { ATO_Pump, Port3 };
byte portalMinutes[numPumps] = { 0, 2 };
byte portalPrevMinutes[numPumps] = { 1, 3 };
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Thanks Lee.

I can view the results from this code?

http://forum.reefangel.com/status/chart ... &filter=c0

From what I was reading in the other thread (I've just skimmed through t it right now) this code will tell me what time it wen on as well, is that correct?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

No it won't tell you what time it went on, but you will see the time progress in the graph. So you can kind of correlate. Remember the controller only sends data every 5 minutes so that is the resolution you will get. I would not worry about this so much. The key point is that your WL and salinity are stable.

What I would do is set some alarm in the portal if your water level goes below the 30% mark or above the 35% mark and you'll have all the monitoring you need. But since you asked the code above is what could easily be done.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Thanks. There is no way around that 5 min update delay, huh?
Yes things are stable so I may not really need this an alarm like you said may work just as good.

Let me ponder on it a bit.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

Yeah, no way around the 5 minute update. But if the ATO pump is on during the timeframe then it will show up as an increase in the timer regardless of whether it's on/off during the update. The one issue gap may be if it is not on for a full minute or increase the timer to the next minute mark then it won't show either till the next update. Because we're tracking minutes not seconds. The variables can only hold a byte. With kirkwood we were tracking minutes and seconds, but since the seconds would not really be a valuable measure we got rid of it and used it to log the previous day's usage.

That's one reason also why in my code I track by volume, which also suffers the same problem though. But I also have a WaterLevel sensor in my ATO container, so I can constantly see how my reservoir is and know my ATO is operating properly.

Just some things to consider....
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Yeah. Thanks.

BTW. The code it working great.

I heard the ATO kink on at like 6:58 last night and at 7pm it turned off because the water exchange started and the code kicked in.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO code is not working properly.

Post by rimai »

I know Curt added logging of ATO at one point in the past.
I think it saves the last 4 ATO triggers in internal memory.
Nobody ever used it but maybe this is what you guys are looking for.
Because no one ever used it, there isn't a way to trigger the #define, but I can easily add that to the next patch if you want to start using the feature.
Or we can implement your own logging. An idea would be to assign a block of memory for your data.
Then, save in memory the time that the ATO triggers and then how long it stayed on.
So, let's say you assign the block 0x3000-0x3258.
This will give you 600 (0x258) memory locations.
The reason I chose 600 is because you need to save 6 bytes each time and this would give you 100 entries. I think it is enough for you to check things out.
6 bytes per entry would be distributes like this:
4 bytes for time (now() function uses unsigned long size)
2 bytes for duration (this would give you an integer value, which can hold up to 65535 seconds)
Then everytime the ATO triggers, you log that time and everytime the ATO disengages, you log the duration.
To retrieve the memory block, you can use the wifi command that lnevo created to read your memory block and use some sort of spreadsheet software in your computer to plot the data.
What do you think?
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO code is not working properly.

Post by Sacohen »

Thanks Roberto, but I just wanted something simple to use to double check when the ATO is going on and for how long to make sure everything is working OK after that code upgrade. It's not anything I'm going to use long term so we don't need to put that mush effort into it.

I'm pretty confident that everything has been working the way it should.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO code is not working properly.

Post by lnevo »

To add Paul Turner's jaebo random modes, feeding and night mode that is now working properly.. you will need to replace the following code

Code: Select all

  // Modified to use the DCPump class
  if (hour()<12 || hour()>=22) {
    ReefAngel.DCPump.UseMemory=false;                
    ReefAngel.DCPump.Mode=Constant;                  
    ReefAngel.DCPump.Speed=30;
  } else if (InternalMemory.DCPumpMode_read()==Custom) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Mode=Constant;                  // Won't really be constant. See next line.
    ReefAngel.DCPump.Speed=ElseMode(40,20,true );    // ElseMode on sync mode, 40 +/- 20%
  } else  {
    ReefAngel.DCPump.UseMemory=true;                 // Use whatever is in the portal
  }
With this:

Code: Select all


// Add random mode if we set to Mode to Custom in portal
static int rmode;
static boolean changeMode=true;

// Add Else Mode definition..
const int Else=16;

// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { ReefCrest, TidalSwell, ShortPulse, NutrientTransport, Else };

if (now()%SECS_PER_DAY==0 || changeMode==true) { // Change at midnight or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
changeMode=false;
}

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();

if (now()-feeding<3600) { 
  // Continue NTM for the 60 minutes
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<30600 || now()%SECS_PER_DAY>=81000) { // 8:30am / 10:30pm
  // Night mode (go to 30%)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=Constant;
  ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) { 
  // Custom Mode and nothing else going on
  ReefAngel.DCPump.UseMemory=false;
  if (rmode==Else) {
    ReefAngel.DCPump.Mode=Constant;
    ReefAngel.DCPump.Speed=ElseMode(InternalMemory.DCPumpSpeed_read(),20,true );    // ElseMode on sync mode, Portal Speed Setting +/- 20%
  } else {
    ReefAngel.DCPump.Mode=modes[rmode];  // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
  }
} else {
  ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
The only difference between this and what Paul had is the addition of the ElseMode to the random list of modes...
Post Reply