Custom code, please help

Do you have a question on how to do something.
Ask in here.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

That is an old internal memory file.
Use this instead:

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#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 <AI.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <Salinity.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

void setup()
{
  InternalMemory.LCDID_write(255);
  InternalMemory.FeedingTimer_write(900);
  InternalMemory.LCDTimer_write(600);
  InternalMemory.HeaterTempOn_write(765);
  InternalMemory.HeaterTempOff_write(770);
  InternalMemory.ChillerTempOn_write(785);
  InternalMemory.ChillerTempOff_write(775);
  InternalMemory.OverheatTemp_write(800);
  InternalMemory.IMCheck_write(0xCF06A31E);
  ReefAngel.Init();
  ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
  ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
  ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
  ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code") ;
}

void loop()
{
  wdt_reset();
}

It will also configure the board for your old screen.
Roberto.
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Thank you Roberto. It works great. I appreciate it
Image
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

For the past weeks i switched from dosing Ca & Alk to dosing Kalk + vinegar solution. Now that the Ph probe is working properly with the new RA plus board i'd like the ato sensor(s) to control the kalk + vinegar dosing pump instead of water if the ph is lower than lets say 8.1

This the current config:
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.DosingPumpRepeat(Port8,1,120,4);

If the ph is smaller than 8.1 then ReefAngel.SingleATO(true,Port8,180,1) else ReefAngel.SingleATO(true,Box1_Port2,180,2);

Is this doable? What are the risks?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

Not sure what you are trying to do... :(
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

He wants to ato the vinegar+kalk when ph is less than 8.1 and ato ro/di otherwise
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

Ahh... I don't think it would work though.
I think the port would never shut off if it was on and ph raised above 8.1
Try like this:

Code: Select all

if (ReefAngel.Params.PH <= 810)
{
  ReefAngel.SingleATO(true,Port8,180,1);
  ReefAngel.Relay.Off(Box1_Port2);
}
else
{
  ReefAngel.SingleATO(true,Box1_Port2,180,2);
  ReefAngel.Relay.Off(Port8);
}
Roberto.
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Right, Inevo. Perfect. Roberto. Thanks. I'll give it a try asap.

Maybe I'm over complicating things. Maybe I should stay with the classic dosing method.
Image
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

It works but it needs more tweaking.

If pH <=818 & ATO ON then the ATO controls the Kalk pump but if during this process ph>818 and the ATO still on, it stops pumping kalk and it doesn' start pumping fresh water without manually resetting the ATO sensor On/OFF

This is the existing code:
if (ReefAngel.Params.PH <= 818)
{
ReefAngel.SingleATO(true,Box1_Port7,70,0);
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,0);
ReefAngel.Relay.Off(Box1_Port7);
}

I think we have to introduce another IF that checks the ATO status.

We have the following variables:
Ph <= 818
Single ATO status = On/Off
ATO pump port = Box1_Port8
Kalk pump port = Box1_Port7

If ph <= 818
then
check ATO Status
{If ATO ON then
ReefAngel.SingleATO(true,Box1_Port7,70,1); # ATO pumps kalk
ReefAngel.Relay.Off(Box1_Port8);
else
ReefAngel.Relay.On(Box1_Port7); #Kalk pump ON
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,1); # ATO pumps fresh water
ReefAngel.Relay.Off(Box1_Port7);
It needs a check ATO Status refresh at this point.
}

What do you think?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

I think it is your restriction on the single ato function.
ReefAngel.SingleATO(true,Box1_Port8,120,1);
The last 1 means it will have to wait another hour to pump again.
Try zero instead.
Roberto.
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Anyway, lets disregard this idea for now. It doesn't make too much sense in practice.

What's the safest way to dose kalk via Box1_Port7 if the ph drops below 818 but I also need a time out and a waiting period similar to the ATO function?

I built this code for now, is it ok? It will dose kalk for 20 seconds every 10 min until pH goes above 818, I hope. For my 8-9 gal of water, a 20 sec dose of kalk + vinegar+water (2g+15ml+1l) will increase the pH by 0.01-0.02

if (ReefAngel.Params.PH <= 818){ReefAngel.DosingPumpRepeat(Box1_Port7,0,10,20);}
if (ReefAngel.Params.PH >= 820){ReefAngel.Relay.Off(Box1_Port7);}
if (ReefAngel.Params.PH < 800){ReefAngel.Relay.Off(Box1_Port7);} #if it runs out of kalk or if the pH probe is damaged
Image
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

For the past 24h the dosing worked great.
Attachments
image.jpg
image.jpg (49.35 KiB) Viewed 3888 times
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

Nice! Just keep your eyes on the probe and double check it once in a while so you don't end up doing something bad :) but way to control that swing!
d0lph1n
Posts: 122
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Look what happend when it ran out of kalk + vinegar.
I left home for a couple of days and i forgot to refill the kalk+v container. When I realized why the pH was dropping I turned on an air pump to push more air into the skimmer. It helped for a while...but it was not enough.
Attachments
image.jpg
image.jpg (50.45 KiB) Viewed 3859 times
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

Thats not too bad...should see what my ph dropped to on thanksgiving with everyone over my house!
Post Reply