ORP calibration with 220mV fluid

Post Reply
Graham2212
Posts: 21
Joined: Wed Mar 27, 2013 2:58 am
Location: Johannesburg, South Africa

ORP calibration with 220mV fluid

Post by Graham2212 »

Hi All
Can anyone help me with the code that I would need to calibrate my ORP if I have 220mV fluid?
Thanks!
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ORP calibration with 220mV fluid

Post by rimai »

You need to update the libraries, but the problem with updating the libraries is that everytime there is an update, it will overwrite the changes you've made.
But, if you want to give it a shot, you must change the lines:
https://github.com/reefangel/Libraries/ ... l.cpp#L886
https://github.com/reefangel/Libraries/ ... .cpp#L5513
Look for the 470 and change it to 220 or whatever standard that you have.
Roberto.
Graham2212
Posts: 21
Joined: Wed Mar 27, 2013 2:58 am
Location: Johannesburg, South Africa

Re: ORP calibration with 220mV fluid

Post by Graham2212 »

Thanks Roberto
To be honest, I am not a code person at all... I tried to take the relevant lines from your links and put them into my code, but I got the error "'Params' was not declared in the scope" or "'ORP' was not declared in this script. Here is my code at the moment:

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 <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <LCD_Timer.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

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


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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Timer[LCD_TIMER].SetInterval(84600);
    ReefAngel.PHMin=523;
    ReefAngel.PHMax=828;
    ReefAngel.UseFlexiblePhCalibration();
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 290 );


    // Ports that are always on
    ReefAngel.Relay.On( Port7 );
    ReefAngel.Relay.On( Port8 );

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

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

void loop()
{
    ReefAngel.StandardATO( Port1,1000 );
    ReefAngel.WavemakerRandom1( Port5,15,60 );
    ReefAngel.WavemakerRandom2( Port6,15,60 );
    ////// Place your custom code below here
    
#if defined ORPEXPANSION
	unsigned long temporp=0;
    for (int a=0;a<20;a++)
    {
    	temporp+=ORP.Read();
    }
	Params.ORP=temporp/20;
	if (Params.ORP!=0)
	{
		Params.ORP=map(Params.ORP, ORPMin, ORPMax, 0, 470); // apply the calibration to the sensor reading
		Params.ORP=constrain(Params.ORP,0,550);
	}
	RefreshScreen();
#endif  // defined ORPEXPANSION



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

    // This should always be the last line
    ReefAngel.Portal( "Graham2212" );
    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();

    // Salinity
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,66, "SAL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,66, ReefAngel.Params.Salinity );
    pingSerial();
    
     // ORP
    ReefAngel.LCD.DrawText( COLOR_PALEVIOLETRED,DefaultBGColor,75,54, "ORP:" );
    ReefAngel.LCD.DrawText( COLOR_PALEVIOLETRED,DefaultBGColor,99,54, ReefAngel.Params.ORP );
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
    pingSerial();

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

void DrawCustomGraph()
{
}
Is there anyway to say maybe "UseFlexibleORPCalibration()" under the setup section, so that I can define in reef angel, that I am using 220mV?

Thank you
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ORP calibration with 220mV fluid

Post by rimai »

Oh, it won't work if you use in your code.
It needs to be changed in the libraries itself. That's why I said is not a good practice to do that.
Nobody created a "UseFlexibleORPCalibration()" yet.
Maybe if you bug phrusher long enough, he may be able to do that for us :)
He was the one that created the "UseFlexiblePHCalibration()" function.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ORP calibration with 220mV fluid

Post by lnevo »

I can take a look, but I would have no way to test :)
Graham2212
Posts: 21
Joined: Wed Mar 27, 2013 2:58 am
Location: Johannesburg, South Africa

Re: ORP calibration with 220mV fluid

Post by Graham2212 »

I'm very happy to test!! I would really appreciate your help!!
coolbird
Posts: 90
Joined: Thu Apr 18, 2013 2:16 am
Location: Stockport, Cheshire, UK

Re: ORP calibration with 220mV fluid

Post by coolbird »

Hi
I would be really interested in this as well, I have found it impossible to get the 470mv calibration fluid in the uk, some say they can get it but 2 months on nothing.
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ORP calibration with 220mV fluid

Post by lnevo »

Sorry i have not had any time to put something together for this..
coolbird
Posts: 90
Joined: Thu Apr 18, 2013 2:16 am
Location: Stockport, Cheshire, UK

Re: ORP calibration with 220mV fluid

Post by coolbird »

lnevo wrote:Sorry i have not had any time to put something together for this..
Sorry no pressure just wanted to register interest :-)

I raised this a while ago and didn't like the idea of messing with the libraries, especially after reading so many posts that said it wasnt wise.

Thanks for the reply though :-)
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ORP calibration with 220mV fluid

Post by lnevo »

Sorry i have not had any time to put something together for this..
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ORP calibration with 220mV fluid

Post by lnevo »

Ok, I started a branch and added in all the framework to do the flexible orp calibration... now the function just needs to be written.

I have to back out a little bit because it's quite a large function with lots of drawing, etc. Maybe phrusher wants to get involved :) or if anyone else wants to give it a try, you can checkout the flexOrp branch on my repo

https://github.com/lnevo/Libraries/tree/flexOrp
coolbird
Posts: 90
Joined: Thu Apr 18, 2013 2:16 am
Location: Stockport, Cheshire, UK

Re: ORP calibration with 220mV fluid

Post by coolbird »

lnevo wrote:Ok, I started a branch and added in all the framework to do the flexible orp calibration... now the function just needs to be written.

I have to back out a little bit because it's quite a large function with lots of drawing, etc. Maybe phrusher wants to get involved :) or if anyone else wants to give it a try, you can checkout the flexOrp branch on my repo

https://github.com/lnevo/Libraries/tree/flexOrp
Thank you for your assistance :-)
Image
Graham2212
Posts: 21
Joined: Wed Mar 27, 2013 2:58 am
Location: Johannesburg, South Africa

Re: ORP calibration with 220mV fluid

Post by Graham2212 »

Any luck with an update on this?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ORP calibration with 220mV fluid

Post by lnevo »

Not really. I think if roberto can answer its easy enough to manually modify. Its a lot of work i dont have time for to create the screens for flex orp calibration. Sorry :( maybe someone else can pitch in and pick it up but not sure how close the framework is since i did it a few versions ago..
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ORP calibration with 220mV fluid

Post by rimai »

For manual edit, there files that need to be modified is a different one.
In the new libraries, you actually need to update the file ReefAngel_1.5_LCD.h located in \Documents\Arduino\Libraries\ReefAngel
Look for the line 3786 and change this:

Code: Select all

	unsigned int iCal[2] = {0,470};
To this:

Code: Select all

	unsigned int iCal[2] = {0,220};
Then open ReefAngel.cpp located in the same folder and look for line 583 and change this:

Code: Select all

		Params.ORP=map(Params.ORP, ORPMin, ORPMax, 0, 470); // apply the calibration to the sensor reading
To this:

Code: Select all

		Params.ORP=map(Params.ORP, ORPMin, ORPMax, 0, 220); // apply the calibration to the sensor reading
Roberto.
rrodriguess
Posts: 132
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

Re: ORP calibration with 220mV fluid

Post by rrodriguess »

Roberto

Any loss (precision or somethong else) calibrating with a 220mv instead of 470mv? What about 400mv?

Just to understand our options here.

Best regards
Rafa
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ORP calibration with 220mV fluid

Post by rimai »

Yes, you will get twice less resolution.
Roberto.
rrodriguess
Posts: 132
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

Re: ORP calibration with 220mV fluid

Post by rrodriguess »

Simple as that..

tks Roberto
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ORP calibration with 220mV fluid

Post by rimai »

Actually, no. You should be fine as long as you know the readings would be about half of what RA is showing.
Roberto.
Post Reply