Issues I've seen in the current Dev Library.

Related to the development libraries, released by Curt Binder
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Issues I've seen in the current Dev Library.

Post by Sacohen »

No. The other pump is sitting at 0.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

Sacohen wrote:No. The other pump is sitting at 0.
Great, thanks.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Since the threshold is only done during dcpump, I think the reporting would be OK becasue we set the channel value after the threshold is applied.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

lnevo wrote:Since the threshold is only done during dcpump, I think the reporting would be OK because we set the channel value after the threshold is applied.
Well, I'll give you an example of how the mapping messes up the set vs reported value.

If you set the DCPump mode to 0 which is Constant and are using Daylight and Actinic as DC Pumps.

Now you set the speed to 40 percent, then the threshold function would map your 40 from a scale of 0-100 to a range of 30-100, you end up actually getting a speed of 30+((100-30)*0.40) = 58 percent. That gets sets as the channel value and it faithfully reports 58 on wifi, on the portal, and on the head unit because Wifi just does: ReefAngel.PWM.GetDaylightValue() to get the number. All of this would be happening while the DCPump.Speed still reported 40 percent.

Anyway, I like Roberto's idea of somehow putting the threshold on a per-channel basis for the PWM channels instead of in DCPump. Then maybe we could tweak around the GetDaylightValue and stuff to take the threshold and some mapping into account when calculating the percent to report.

Might have to think for a while about the right way to do it, though, and it might take some user education to get people used to being able to send values like 5 percent to their Tunze, but it's really sending, assuming the threshold is 30, 30+(70*0.05) = 33.5 percent or 3.35V to the DC control channel.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

I'm not mapping any more i'm constraining. If you set to 40 its 40. If you set to 30 its 30.

If you set to 15 its 30. If you set to 1 its 30. If its set to 0 its 0.

The only difference is the arbitrary less than/greater than 15.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

Ah, ok. I thought we were still talking about mapping it, an idea that I still kinda like. It makes sense not to have that large dead-band in there from 0-15. I put it there because it kind of made sense to make to round down or up based on half of the threshold, but it does leave the pump off too much when you're ramping around that area.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

Thinking back, I put it in there so I could get a 0 at all from Nutrient Transport and the other profiles. If I had to set 30 as my minimum speed for those, then I'd never get a 0 for pulses, but if I set a 0 then I'd get all of those non-supported values for the surge portions. So threshold was made to just skip over anything not supported...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Yeah so we're still getting the 0 for pulses and i think the way you suggested addressing it for gyre works fine.

I think actually thats how we address it for LED by setting the start speed and end speed. Something we dont do really in DCPump.

Thinking now on that, I'm not sure how much we need it in the PWM library, but it would still be nice to change the threshold and offset on a per channel, but its a bit of code. At least now it's only in one function (for DCPump)
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Issues I've seen in the current Dev Library.

Post by 89delta »

I just added the Dev library to my folder. Am getting errors now when it comes to the Else coding for the dc pumps. Has this issue been fixed? My code can be found http://forum.reefangel.com/viewtopic.php?f=11&t=4731
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

You have to take the ElseMode function out of your code. Its part of the libraries now.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Anyway, I've made the pull request for the above changes. I also changed the range for Sine mode the same way we did for Gyre. Otherwise pumps would be off for a lot longer than expected...
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

Good idea. So it just stays at the threshold all the way down to 0, and then briefly stops at 0 and right back up to threshold? I haven't pulled your branch to try it. I get periodic errors when using the bluetooth with timeouts or port in use problems and it makes me nervous, so I only load when I really need to.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Issues I've seen in the current Dev Library.

Post by cosmith71 »

AlanM wrote: I get periodic errors when using the bluetooth with timeouts or port in use problems and it makes me nervous, so I only load when I really need to.
Is this new behavior? I've had major problems this weekend with this. Usually I only see an occasional port in use error. The timeouts are new.

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

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

AlanM wrote:Good idea. So it just stays at the threshold all the way down to 0, and then briefly stops at 0 and right back up to threshold?
For which mode?
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

cosmith71 wrote:
AlanM wrote: I get periodic errors when using the bluetooth with timeouts or port in use problems and it makes me nervous, so I only load when I really need to.
Is this new behavior? I've had major problems this weekend with this. Usually I only see an occasional port in use error. The timeouts are new.

--Colin
Not sure. I have only had one for a couple of weeks. Is it possible that it times out when the wifi is being used already since they kind of preempt each other being on the same wires?
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Issues I've seen in the current Dev Library.

Post by AlanM »

lnevo wrote:
AlanM wrote:Good idea. So it just stays at the threshold all the way down to 0, and then briefly stops at 0 and right back up to threshold?
For which mode?
For the sine one that you said you changed.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

No i think it will just travel between threshold and speed. Otherwise it would spend an inordinate amount of time at the threshold value.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Issues I've seen in the current Dev Library.

Post by Sacohen »

In the last 3 days my random wave mode has choosen Gyre.

I don't think that is a random coincidence?

I can't see what (if any thing) in the threshold dev library that I've been running that would cause that.

And even though I'm the first to point towards my lack of coding knowledge. I don'tvsrr how adding ", Gyre" to my list of optional modes would have done it either.

Not a major thing. I pulled Gyre out of the options for nowz bit I thought I would mention it.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Didn't you just include that mode for testing? Can you post the code you've been using again so i can check it out. Try putting Gyre in a different slot in the array. The thing about random numbers is they don't always seem random... :) plus the arduino doesn't seed the random number so if you keep bouncing the controller it may end up being the same random result each day.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Issues I've seen in the current Dev Library.

Post by Sacohen »

I'll try later today.
Right now I'm tearing apart a swing set.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Issues I've seen in the current Dev Library.

Post by Sacohen »

I was trying it for testing, but then I decided to leave it in and see how I like the mode.

I just uploaded it with Gyre in the middle of the options and it came up in Else mode after the Reboot, so it may be as you were saying about how the Arduino handles random numbers and reboots.

Here is the code I was testing with.
The code I have in there now is changed a little bit to narrow down the issue with the Muti WL sensor dropping.

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>fF
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>f
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>

// Define Relay Ports by Name
#define Actinic_Lights     1
#define Day_Lights         2
#define Kalkwasser         3
#define Pumps              4
#define Sump_Fan           5
#define DeNit_Doser        6
#define DeNit_Pump         7
#define ATO_Pump           8

#define Unused             Box1_Port1
#define Feeder             Box1_Port2
#define Unused             Box1_Port3
#define Unused             Box1_Port4
#define Unused             Box1_Port5
#define Unused             Box1_Port6
#define Unused             Box1_Port7
#define Dummy              Box1_Port8


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

// Does not need to be global.
// unsigned long ATOUpdate=0;

////// Place global variable code above here


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 825 );
//Set Standard Menu
ReefAngel.AddStandardMenu();
//Water Level
ReefAngel.AddMultiChannelWaterLevelExpansion();
//Webserver Authentication
//ReefAngel.Network.WifiAuthentication("Sacohen:xxxxxxxx");
//DDNS Server
ReefAngel.DDNS("xxxxxxxx");

// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.DaylightChannel=Sync; // Now you're pump will be affected by the portal settings.
ReefAngel.DCPump.ActinicChannel=AntiSync; // Now you're pump will be affected by the portal settings.
ReefAngel.DCPump.AntiSyncOffset=85;

// Ports that are always on
ReefAngel.Relay.On( Pumps );
ReefAngel.Relay.On( Dummy );

////// Place additional initialization code below here


////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.StandardLights( Actinic_Lights,12,0,22,0 );
  ReefAngel.StandardLights( Day_Lights,13,0,21,0 );
  ReefAngel.StandardLights( Sump_Fan,13,0,21,0 );
  ReefAngel.WaterLevelATO(0,ATO_Pump,720,28,31);
  if ( hour()>=13 && hour()<21 )
  ReefAngel.PWM.SetChannel( 5, 0 );
  else
  ReefAngel.PWM.SetChannel( 5, PWMSlope(21,0,13,0,0,MoonPhase() ,60,0) );
 
  ////// Place your custom code below here
  
  //Mix Kalkwasser
static unsigned long Kalk_Mixing = 0;

static unsigned long stopTime = 0;
static byte prevWL=0;

if (ReefAngel.WaterLevel.GetLevel(1)==100 && prevWL<100) {   
  stopTime=now()+3600; // Get time one hour from now.
}
prevWL = ReefAngel.WaterLevel.GetLevel(1); // Store the water level

if (now() < stopTime) { ReefAngel.Relay.On(Kalkwasser); } else { ReefAngel.Relay.Off(Kalkwasser); } 
  
  //AutoFeeder
static unsigned long autofeeding = 0;

if ((now()%SECS_PER_DAY==64800)) //if it is 6 pm
{
ReefAngel.FeedingModeStart(); //START FEEDING MODE
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
if ( autofeeding == 0 ) {
autofeeding = now(); //set the time of the start of feeding to variable feeding
}

if ((now()-autofeeding>=60) && (now()-autofeeding<=61)) //if between 60 and 61 seconds has past
{
ReefAngel.Relay.On(Feeder); //TURN FEEDER RELAY ON
}
else 
{
ReefAngel.Relay.Off(Feeder); //TURN FEEDER RELAY OFF
}
} else {
if ( autofeeding > 0 ) {
autofeeding = 0;
}
}
  // 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
   
  // Disable ATO
if ( (now()-3600)%21600<DeNit_ATO_Offtime) ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);

  // Delay WL ATO after water change and DeNit_Dosing
  static time_t wcTimer=0;
  if (ReefAngel.DisplayedMenu == WATERCHANGE_MODE) wcTimer=now();

  // First 10 minutes after WC disable ATO
  if (now()-wcTimer >= 0 && now()-wcTimer < 600)
    ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);

    // Track Salinity low duration
    static unsigned long lastGoodSal;
    static boolean lowSalFlag;
   
    // Salinity is good, update counter
    if (ReefAngel.Params.Salinity>=335) lastGoodSal=now(); 
    
    // Counter hasn't been updating in 300 seconds..
    if (now()-lastGoodSal>300) {
      lowSalFlag=true; // Salinity is definitely below 33.5
    } else {
      lowSalFlag=false; // Salinity back to normal
    }
    
    // Disable ATO if lowSalFlag is true
    if (lowSalFlag) ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);
    
  // Disable ATO if ATO High IsActive()
  if (ReefAngel.HighATO.IsActive()) 
    ReefAngel.WaterLevelATO(0,ATO_Pump,720,0,1);
    

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


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

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.Duration=InternalMemory.DCPumpDuration_read();
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
  // Night mode (go to 30%)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
  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;
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
  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
}

  ////// Place your custom code above here

  // This should always be the last line
  ReefAngel.Portal( "Sacohen","xxxxxxxx" );
  ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,57, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,57, ReefAngel.WaterLevel.GetLevel() );

ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,66,66, "WL 1:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel(1) );

//Salinity  
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  strcat(text,"  ");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,39,75,"Salinity:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,99,75,text);
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
pingSerial();
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 104, TempRelay);

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Its because you've been rebooting every day. If you look in my setup() function you can see how the random function gets "seeded" so that each reboot would give a different random number. I believe I use the current time as the seed.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Issues I've seen in the current Dev Library.

Post by lnevo »

Roberto, does setting Feeding_Start recognize the speed arg on the RF module, or does it follow the speed set by the driver?

In ReefAngel.cpp we set the speed to 0 when going into feeding mode and I was thinking of adding the WaterChange and FeedingMode speed to the RF class like we did with DCPump.

RF.SetMode(Feeding_Start,0,0);
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Ok, I have a patch I will try and if it works, I have a pull request ready :)
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issues I've seen in the current Dev Library.

Post by rimai »

The drivers will dictate the vortech speed on feeding.
You can adjust it directly on the driver itself. Check the vortech manual for more info.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Yeah, I know. I'm thinking though of having FeedingSpeed if set not have the RF go into feeding mode, but in constant whatever speed RF.FeedingSpeed is set to. This way the default is the current behavior, but if someone wanted to override, then it would go into Constant ReefAngel.RF.FeedingSpeed. Changing the drivers is a pain in the ass and then you have to do it on all of them. I'd rather do it in one place and be able to change it on the fly. About to try that now.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

That worked exceedingly well. I tested with the value set and also with it cleared. The default works fine. I'll be making a pull request for this one shortly :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

Roberto, merge that patch :) it's awesome
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issues I've seen in the current Dev Library.

Post by rimai »

Sorry, done :)
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues I've seen in the current Dev Library.

Post by lnevo »

It's my new favorite feature :)
Post Reply