Page 1 of 1

Why my wave str is -1 when assigned?

Posted: Mon Oct 20, 2014 5:02 am
by Smotz
'lo all..

Something stupid - not a huge deal.
Can anyone advise why my wave strength is 1 less than assigned during feeding mode? In the code below I assigned it to 28% yet when in feeding mode it is at 27%

Code: Select all

// Custom Wave Routine 
// set the wpMode based on what time it is
    if ( (hour() >= 2) && (hour() < 5) ) wpMode=1;       // from 2am - 5am  
    if ( (hour() >= 5) && (hour() < 8) )  wpMode=2;     // from 5am - 8am
    if ( (hour() >= 8) && (hour() < 11) ) wpMode=4;      // from 8am - 11am  Nutrient Transport
    if ( (hour() >= 11) && (hour() < 14) ) wpMode=2;     // from 11a - 2pm
    if ( (hour() >= 14) && (hour() < 17) ) wpMode=1;     // from 2pm - 5pm
    if ( (hour() >= 17) && (hour() < 20) ) wpMode=2;     // from 5pm - 8pm
    if ( (hour() >= 20) && (hour() < 23) ) wpMode=3;     // from 8pm - 11p
    if (hour() >= 23) wpMode=2;                          // from 11pm - midnight 
    if (hour() < 2) wpMode=1;                            // from midnight - 2am
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) wpMode=5;  // Feeding Mode
    if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) wpMode=6; //Water Change Mode
      
    switch (wpMode) 
    {
    case 1:  wpWavStr=29; wpWavOff=3; break;
    case 2:  wpWavStr=31; wpWavOff=5; break;
    case 3:  wpWavStr=33; wpWavOff=7; break;
    case 4:  wpWavStr=40; wpWavOff=50; break;
    [b]case 5:  wpWavStr=28; wpWavOff=0; break;  // Feeding mode[/b]
    case 6:  wpWavStr=0; wpWavOff=0; break;   // Waterchange Mode
    default: wpWavStr=34; wpWavOff=2;
    }
//If 8am - 11am, Nutrient Transport   
    if (wpMode==4)
    {
    ReefAngel.PWM.SetDaylight( NutrientTransportMode(wpWavStr,wpWavOff,7000,true) );
    ReefAngel.PWM.SetActinic ( NutrientTransportMode(wpWavStr,wpWavOff,7000,false) );
    }
    else  
    {
  [b]  if (wpMode==5)
    {    
    ReefAngel.PWM.SetDaylight(wpWavStr);
    ReefAngel.PWM.SetActinic(wpWavStr);    //// Right wavemaker under feeder
    }[/b]
    else
    {
//Set the wave     
    ReefAngel.PWM.SetDaylight( ElseMode(wpWavStr,wpWavOff,true) );
    ReefAngel.PWM.SetActinic( ElseMode(wpWavStr,wpWavOff,false) );
    }}
//end Custom Wave Routine   

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 4:08 am
by Smotz
Nothin huh

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 4:36 am
by lnevo
It might be something with the rounding in the 12bit conversion.

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 4:56 am
by Smotz
thats what I was thinking :-)

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 5:36 am
by lnevo
Where are you seeing the 27? On the screen? Or in the portal?

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 7:24 am
by Smotz
On the android app

Re: Why my wave str is -1 when assigned?

Posted: Wed Oct 22, 2014 11:25 am
by lnevo
Hmm, I took a look at the math and it even adds .5 to address any rounding issues. Maybe Alan can take a look with that number to see if it's reproducible.

Are you sure there's no other code affecting it.

Re: Why my wave str is -1 when assigned?

Posted: Thu Oct 23, 2014 5:15 am
by Smotz
Not, I am not positive - Nothing else calls for that variable. It's not crucial, either - don't want to take people away from more important stuff. I was just curious. I can simply make adjustments knowing the discrepancy.

Re: Why my wave str is -1 when assigned?

Posted: Thu Oct 23, 2014 7:15 am
by lnevo
Nonsense, this is the fun stuff.