Reading internal memory in loop()

Do you have a question on how to do something.
Ask in here.
Post Reply
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Reading internal memory in loop()

Post by sabo »

I have set up my wavemakers so I can set the strength and duration in internal memory. Now im wondering if it would be better to maybe store that in a variable at initialisation and run that through the loop rather than reading the internal memory everytime the loops runs. I imagine it cycles pretty quickly, and may be better read from volatile memory? Or does it not really matter? Heres a snippet of the code I am running. The only downside I can see to reading the memory at initialisation and storing it in a variable is that I would have to reboot the RA for the changes to take place. Any words of wisdom?

Code: Select all

ReefAngel.PWM.SetDaylight( ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );

Ive also set my skimmer to delay coming on but was wondering if my code after that would overide the delay. I have a few lines that will turn the skimmer off if the float switches in the collection drum activate. Also to turn it off if it is sucking water out of the sump quicker than the ATO can replace it. I need to make sure these three functions work in the correct order I guess.

Code: Select all

   ReefAngel.Relay.DelayedOn( Skimmer );

    if (ReefAngel.WaterLevel.GetLevel() < InternalMemory.read(Mem_B_SkimmerWL) ) ReefAngel.Relay.Off(Skimmer);
    
    if (ReefAngel.LowATO.IsActive() && ReefAngel.HighATO.IsActive())
      {
        ReefAngel.Relay.On(Skimmer);
      }
     else
      {
        ReefAngel.Relay.Off(Skimmer);
      }
Thanks
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reading internal memory in loop()

Post by rimai »

You can read as much as you want. You can't write though.
Writing is limited to 100000 cycles.
The delay code would be overwriten. I think your best case is to use the masks to overwrite the port to off/on depending on your WL readings.
Like this
ReefAngel.Relay.Override( Skimmer, 0);
Where 0 is off, 1is On and 2 is auto.

Sent from my Galaxy S5 with Tapatalk
Roberto.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: Reading internal memory in loop()

Post by sabo »

OK, cool. The reading solves that problem. I'll try and find a thread that explains the override/masks and see if I can make sense of it. Thanks.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: Reading internal memory in loop()

Post by sabo »

OK, came up with this using the override. Im away at the moment and trying to get a few different things done so if someone could check over to make sure it looks sane it would be appreciated. Then hopefully I can upload some cool new features when I get home and it will all work OK.

Code: Select all

 ReefAngel.Relay.DelayedOn( Skimmer );
   if (ReefAngel.WaterLevel.GetLevel() < InternalMemory.read(Mem_B_SkimmerWL) ) ReefAngel.Relay.Override(Skimmer, 0);
    
    if (ReefAngel.LowATO.IsActive() && ReefAngel.HighATO.IsActive())
      {
        ReefAngel.Relay.Override(Skimmer,2);
      }
     else
      {
        ReefAngel.Relay.Override(Skimmer,0);
      }
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reading internal memory in loop()

Post by lnevo »

Take out the else part. Once you trigger the override you would want it to be manual to turn back on. Otherwise once you disconnect your skimmate container the skimmer turns back on getting stuff everywhere :) otherwise looks good.
Post Reply