Page 1 of 2
Custom Dosing
Posted: Tue Feb 26, 2013 8:05 pm
by chachew
Im needing to Dose Alk, Mag and Cal on three different pumps for various seconds per day.
For Example:
6am - Pump(Box1_Port1) comes on for 12 seconds
7am - Pump(Box1_Port2) comes on for 9 seconds
8am - Pump(Box1_Port3) comes on for 2 seconds
I would ideally like to have this in a custom menu that i can change on the fly from the reef controller menu but if i can hard code it for now that would be the easiest and the fastest. I need a bullet prof way of doing it so i dont over dose the tank and eff it up
I was thinking something like:
Code: Select all
if( (hour() == 6) && (minute() == 00) )
ReefAngel.Relay.On(Box1_Port1);
else
ReefAngel.Relay.Off(Box1_Port1);
What are your suggestions?
Custom Dosing
Posted: Tue Feb 26, 2013 8:52 pm
by lnevo
Do you have wifi? You can set the values in a memory location and change them on fly...
Custom Dosing
Posted: Tue Feb 26, 2013 8:54 pm
by lnevo
Easiest function to use would be this...
void ReefAngelClass::DosingPump ( byte DPRelay,
byte OnHour,
byte OnMinute,
int RunTime
)
So...
DosingPump(Box1_Port1, 6, 0, 12);
Re: Custom Dosing
Posted: Tue Feb 26, 2013 9:00 pm
by chachew
Lnevo, i do have the wifi attachment. How do i know the memory location of specific ports? Also, the above function would go in the setup() or loop() section of the code?
Custom Dosing
Posted: Tue Feb 26, 2013 9:20 pm
by lnevo
loop()
To put it into a memory location you would change the seconds to be a function call
InternalMemory.read(100);
Then in memory location 100 you would put 12...
To do that you'd do the following
http://reefangelwifi:2000/mb100,12
To check the location, just leave off the ,12
Global memory locations start at 200 using locations sorting at 100 should be fine. Each pump would have a separate location.
There are predefined variables for dosing pump 1 and 2 that you could use also and ones for the onhour and onminute.. Take a look at Globals/Globals.h in the libraries file to see all the definitions...
If you set these up you can just define dosing pump 1 and 2 to use memory for everything...
DosingPump1(Box1_Port1); and the rest would come from memory...same for pump 2.
Only pump 3 would need the custom memory locations..
Also, you should be able to set the dosing pump 1 and 2 locations in the InternalMemory locations in the portal...
Re: Custom Dosing
Posted: Wed Feb 27, 2013 3:01 pm
by chachew
So in my loop() section i would add:
Code: Select all
void ReefAngelClass::DosingPump(Box1_Port1, 6, 0, InternalMemory.read(100));
void ReefAngelClass::DosingPump(Box1_Port2, 7, 0, InternalMemory.read(101));
void ReefAngelClass::DosingPump(Box1_Port3, 8, 0, InternalMemory.read(102));
And then Add the seconds to each memory location as follows:
Code: Select all
http://reefangelwifi:2000/mb100,12
http://reefangelwifi:2000/mb101,9
http://reefangelwifi:2000/mb102,2
That way i can easily change the run time of each pump via the portal or my android app correct?
Custom Dosing
Posted: Wed Feb 27, 2013 3:13 pm
by lnevo
You don't need the void ReefAngelClass: part...but yeah, sounds like you got it.
Re: Custom Dosing
Posted: Wed Feb 27, 2013 4:12 pm
by chachew
Awesome, ill try it here shortly. Thanks for the help
Re: Custom Dosing
Posted: Wed Feb 27, 2013 4:40 pm
by chachew
So will this work?
Code: Select all
ReefAngel.DosingPump(Box1_Port1, InternalMemory.read(100), InternalMemory.read(101), InternalMemory.read(102));
ReefAngel.DosingPump(Box1_Port2, InternalMemory.read(103), InternalMemory.read(104), InternalMemory.read(105));
ReefAngel.DosingPump(Box1_Port3, InternalMemory.read(106), InternalMemory.read(107), InternalMemory.read(108));
Seems like it errors unless i use:
Code: Select all
ReefAngel.DosingPumpRepeat(Box1_Port1, InternalMemory.read(100), InternalMemory.read(101), InternalMemory.read(102));
ReefAngel.DosingPumpRepeat(Box1_Port2, InternalMemory.read(103), InternalMemory.read(104), InternalMemory.read(105));
ReefAngel.DosingPumpRepeat(Box1_Port3, InternalMemory.read(106), InternalMemory.read(107), InternalMemory.read(108));
Also are the memory locations suppose to be byte or int?
Custom Dosing
Posted: Wed Feb 27, 2013 4:43 pm
by lnevo
Runtime needs to be an int from what it looks like. You have the concept down. Keep in mind there are already mem locations defined for dosing pump 1 and 2 you can use and modify through the portal interface, but your way will work too.
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:01 am
by chachew
So does this function work? I seem to always get an error when it tries to compile the code when this function is used
Code: Select all
void ReefAngel.DosingPump( byte DPRelay, byte DPTimer, byte OnHour, byte OnMinute, int RunTime )
Re: Custom Dosing
Posted: Thu Feb 28, 2013 8:56 am
by lnevo
What is the error you are getting? Can you paste it...
You should be doing something like this... no "void"
ReefAngel.DosingPump(Relay, Timer, OnHour, OnMinute, Runtime);
where all those are variables or values. If variables they should all be byte except for Runtime.
There is also another function that leaves off the Timer... I think that's the one you should use...
ReefAngel.DosingPump(Relay, OnHour, OnMinute, Runtime);
Easiest way is to use the following as a test
ReefAngel.DosingPump(Port1,6,0,30);
Does that compile for you?
Re: Custom Dosing
Posted: Thu Feb 28, 2013 4:48 pm
by chachew
Code: Select all
NewCodeWithEXP2_26_13.cpp.o: In function `loop':
C:\Users\Matt\AppData\Local\Temp\build9212269777689315176.tmp/NewCodeWithEXP2_26_13.cpp:89: undefined reference to `ReefAngelClass::DosingPump(unsigned char, unsigned char, unsigned char, int)'
I get this error when trying to upload: ReefAngel.DosingPump(Port1,6,0,30);
Custom Dosing
Posted: Thu Feb 28, 2013 5:50 pm
by lnevo
Hmmm... Something is odd for sure. It compiles without it? I guess we need Roberto to confirm the syntax...maybe I'm missing something.
Re: Custom Dosing
Posted: Thu Feb 28, 2013 5:53 pm
by chachew
Yea without it it compiles perfectly.

Re: Custom Dosing
Posted: Thu Feb 28, 2013 6:36 pm
by lnevo
Ok, I found the issue... the function is declared but never defined which is why it doesn't fail immediately when compiling...
So, this function does not exist...
ReefAngel.DosingPump(Relay, OnHour, OnMinute, Runtime);
You need to use this one as you mentioned...
ReefAngel.DosingPump(Relay, Timer, OnHour, OnMinute, Runtime);
So, the following should compile for you..
ReefAngel.DosingPump(Port1,1,6,0,30);
Where 1 is the timer we are going to use.. I believe the ReefAngel class has 4 defined and 4 is used for Portal. Not sure, but some people (like me..) use 1 for other things...like my Vortech modes. so use what works for you, just don't use 4

Re: Custom Dosing
Posted: Thu Feb 28, 2013 6:40 pm
by lnevo
The ReefAngel class has 6 built in timers 0-5...
They are defined as follows
#define FEEDING_TIMER 0
#define LCD_TIMER 3
#define PORTAL_TIMER 4
#define STORE_PARAMS_TIMER 5
According to the declaration also, they are defined as such
Timers:
0 - Feeding Mode timer
1 - Wavemaker 1 or Dosing Pump 1
2 - Wavemaker 2 or Dosing Pump 2
3 - Backlight timer / Sleep timer
4 - Portal
5 - Store params to eeprom
*/
So really 1 and 2 should be reserved for WaveMaker or DosingPumps... you don't need multiple for your purposes though..
We should probably have users (like myself...) not use the ReefAngel.Timer[] timers... I should change my code and declare my own Timer for future... just seems like a bad habit to get people into..
Lee
Re: Custom Dosing
Posted: Thu Feb 28, 2013 6:44 pm
by lnevo

Actually the way DosingPump() works, the DPTimer should be one of the 0-5 timers that are defined int the ReefAngel class...
Since it's called with the following..
Timer[DPTimer].SetInterval(RunTime);
Timer[DPTimer].Start();
where DPTimer is the timer number you pass in the function... so stick with 1 or 2 and like I said...
We may need Roberto to comment further since you need 3.. if the same one can be used each time (your declaring the runtime each time anyway...)
Re: Custom Dosing
Posted: Thu Feb 28, 2013 6:47 pm
by chachew
So since not more than 1 dosing pump will ever be running at the same time, then i can use the same timer for all three dosers correct?
Custom Dosing
Posted: Thu Feb 28, 2013 6:55 pm
by lnevo
Potentially...but i'd like to hear from roberto on the topic...
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:07 pm
by rimai
Yes, you can use same timer for all 3 as long as they are not simultaneously turning on.
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:18 pm
by chachew
Well i just tried it and it looks like it fails. The first doser fires as it should but the other two do not
EDIT: Actually i had something set wrong...it appears to be working but not exactly. The first relay to use the timer works flawlessly, the second and third relay turn on but NEVER turn off
Custom Dosing
Posted: Thu Feb 28, 2013 7:23 pm
by lnevo
Custom Dosing
Posted: Thu Feb 28, 2013 7:24 pm
by lnevo
Try using 1 and 2.. See if youd get 2/3 working..
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:31 pm
by rimai
Yeah... It won't work...

Sorry
Try this:
Code: Select all
ReefAngel.Relay.Set(Port1,hour()=6 && minute()=0 && second()<30);
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:35 pm
by chachew
I edited my above post for my findings. Is there no other way to have 3 dosing timers?

Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:36 pm
by chachew
Ill try your code above Rimai, is that as reliable as the other function?
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:43 pm
by rimai
Basically the same code, except the code above will only let you run the doser for a max of 60s as opposed to the other that would let you run for more than 60s.
Custom Dosing
Posted: Thu Feb 28, 2013 7:53 pm
by lnevo
If you did need more than 60s you could just do the same command with minute==1 and continue where you left off...
Re: Custom Dosing
Posted: Thu Feb 28, 2013 7:58 pm
by chachew
rimai wrote:Yeah... It won't work...

Sorry
Try this:
Code: Select all
ReefAngel.Relay.Set(Port1,hour()=6 && minute()=0 && second()<30);
Code: Select all
NewCodeWithEXP2_26_13.cpp: In function 'void loop()':
NewCodeWithEXP2_26_13:77: error: lvalue required as left operand of assignment
I get this error on compile