Page 2 of 3
Re: Expansion module
Posted: Tue Jan 31, 2012 7:26 pm
by maxxdog21
Ok, I put in a 35ppt solution and let it sit a minute and hit okay. Now it says done.
Re: Expansion module
Posted: Tue Jan 31, 2012 7:31 pm
by maxxdog21
I reloaded my code and unplugged the unit from the computer and now it says:
35.0/35.1
Should I check it with my refractometer? Or do you think it's good to go?
Re: Expansion module
Posted: Tue Jan 31, 2012 7:34 pm
by rimai
There you go.
Should be good now.
Sorry about all the trouble.
Next release of libraries will have that corrected and you won't need to go through this again.
Re: Expansion module
Posted: Tue Jan 31, 2012 7:37 pm
by maxxdog21
My refracto says my tank i dead on 35ppt/1.026
So I would say our mission tonight was successfull!!!
Re: Expansion module
Posted: Tue Jan 31, 2012 7:38 pm
by maxxdog21
Thanks so much Roberto. Once again, you're the best! Soon I will tackle the wifi module... maybe I can do that by myself....
Re: Expansion module
Posted: Tue Jan 31, 2012 7:42 pm
by rimai
Anytime
Glad you got it working
Re: Expansion module
Posted: Tue Jan 31, 2012 7:43 pm
by binder
maxxdog21 wrote:My refracto says my tank i dead on 35ppt/1.026
So I would say our mission tonight was successfull!!!
Sweet. Nice job. Glad you got it working.
Re: Expansion module
Posted: Sun Mar 11, 2012 11:05 am
by ahmedess
I m using libraries version 8.5.19 is the calibration code in these libraries broken? I m actually trying to calibrate but after i finished calibration and while having the probe in the same standard 35ppt solution the salinity reading would be 33ppt.
Re: Expansion module
Posted: Sun Mar 11, 2012 2:22 pm
by rimai
yes. sorry...
It was fixed on 0.9.0
Re: Expansion module
Posted: Mon Mar 12, 2012 1:34 pm
by ahmedess
okay now I m running version 0.9.2 code. I made a standard 35ppt solution and tested it using a calibrated refractometer, then I inserted the probe into the solution and started calibration on the controller. the reading stabilized at 1140 then i pressed okay. I have my tank water adjusted to 37ppm when i place the probe in the tank it reads 45.3ppm. So a 2ppm increase in salinity corresponded to an increase of 10.3ppm in the reading of the controller. Is the calibration code on 0.9.2 correct?
Re: Expansion module
Posted: Mon Mar 12, 2012 2:13 pm
by rimai
It should be correct.
When you finished calibrating with the 35ppt solution, did RA show you 35ppt on the screen?
Did you just dilute the 37ppt down to 35ppt?
The salinity or conductivity is temperature dependent.
If you measure the same solution at different temperatures, you will get different results, but it shouldn't be 10ppt. It would be within 1ppt.
Re: Expansion module
Posted: Mon Mar 12, 2012 2:21 pm
by ahmedess
Yes RA showed 35 ppm on the screen but i m sure the solution i calibrated with is like 5 degrees celcius less than the tanks temprature. Also the solution i m calibrating with is diluted from 37 to 35 from the tank
Re: Expansion module
Posted: Mon Mar 12, 2012 2:28 pm
by ahmedess
I m setting the temprature of the calibration solution to match the tanks then i ll recalibrate and see
Re: Expansion module
Posted: Mon Mar 12, 2012 3:11 pm
by ahmedess
It was all temperature related as you said. The fluctuation in the reading due to temprature change is huge is that normal? When i set the 35 ppt calibration solution to 25deg celcius it calibrates correctly. Where in internal memory is the calibration value stored? Is it possible to do a software temprature compensation for the salinity reading?
Re: Expansion module
Posted: Mon Mar 12, 2012 3:15 pm
by rimai
Yeah
The value is store at memory location 847. It's int size.
You can come up with a software mathematical compensation if you are able to
Re: Expansion module
Posted: Mon Mar 12, 2012 3:48 pm
by ahmedess
What about if we compensate over a small temprature range like from "heater on" temp to "chiller on" temp.
Re: Expansion module
Posted: Mon Mar 12, 2012 4:00 pm
by ahmedess
Check this link out:
http://en.m.wikipedia.org/w/index.php?t ... ormal_site
It says that over a small range of temprature the compensation can be done using a linear equation and the equation is given. I dont think it would be that complicated if we do it over the range i ve mentioned in the previous post and the equation seems simple. What do you think?
Re: Expansion module
Posted: Fri Mar 16, 2012 4:01 pm
by ahmedess
Where can i find the formula already used by Reefangel to convert the value received from the probe to salinity?
Re: Expansion module
Posted: Fri Mar 16, 2012 7:18 pm
by binder
ahmedess wrote:Where can i find the formula already used by Reefangel to convert the value received from the probe to salinity?
In ReefAngel.cpp
Code: Select all
#if defined SALINITYEXPANSION
Params.Salinity=Salinity.Read();
Params.Salinity=map(Params.Salinity, 0, SalMax, 60, 350); // apply the calibration to the sensor reading
LCD.Clear(DefaultBGColor,0,0,1,1);
#endif // defined SALINITYEXPANSION
that's where it's stored. If you want to look further, check out the Salinity.cpp file.
Re: Expansion module
Posted: Sat Mar 17, 2012 8:13 am
by ahmedess
does Salinity.Read() returns conductivity? in what units? and why is the lower limit of salinity 6 ppt?
Re: Expansion module
Posted: Sat Mar 17, 2012 9:07 am
by rimai
Salinity.Read() simply reads the value of a 12bit resolution ADC (Analog to Digital Converter) chip.
Being 12bit resolution, the value goes from 0 to 4095.
The basis of the salinity (or should I say conductivity) circuitry is to generate a sinusoidal wave form to go across the two platinum plates in the probe.
The waveform has to be sinusoidal and cannot be DC or you would have electrolysis on the plates.
This waveform travels through the water as long as there is material to transport electricity from one plate to another.
In our case, this material is salt.
What we want to measure is the peak-to-peak voltage that is passed through these platinum plates. The voltage is then translated into electric conductivity in EC or salinity in ppt through mathematical interpolation.
The higher the content of salt, the more voltage you will get it measured.
The 6ppt limit is on the circuitry designed and probe being used. Anything below 6ppt is just going to output 0 volts and in turn can't be measured.
The circuit and the probe are designed for the higher end of measurement (35ppt)
Below 6ppt, you will need a TDS meter or something designed for low concentration of minerals.
I hope this explains a little what the salinity module is doing behind the scenes.
Re: Expansion module
Posted: Sat Mar 17, 2012 12:50 pm
by ahmedess
I m currently using Celcius temperature on my RA and I want to use the value recorded by probe T1 in Celsius in a formula, will "Params.Temp[T1_PROBE]" have the value in C or F?
Re: Expansion module
Posted: Sat Mar 17, 2012 5:29 pm
by rimai
should be whatever unit you are displaying.
Re: Expansion module
Posted: Mon Mar 19, 2012 11:51 am
by ahmedess
when does this code run?
Code: Select all
#if defined SALINITYEXPANSION
Params.Salinity=Salinity.Read();
Params.Salinity=map(Params.Salinity, 0, SalMax, 60, 350);
The reason I'm asking is because when i change the value stored in SalMax using RAStatus manually it does not affect the above code until i do a restart, which got me thinking that this code only runs during startup or when the calibration menu is opened. If this is true then how does the value of salinity keeps refreshing according to probe after start up and when the calibration menu is closed? There is something that I dont understand.
Re: Expansion module
Posted: Mon Mar 19, 2012 11:54 am
by rimai
That is run all the time in every loop.
SalMax is only read from internal memory on startup.
You can force a refresh on the SalMax variable by using this:
Code: Select all
SalMax = InternalMemory.SalMax_read();
if you have wifi, you can browse your wifi with /cr and it will refresh your calibration too.
Like http://controller_ip:2000/cr
/cr = calibration reload.
Re: Expansion module
Posted: Mon Mar 19, 2012 12:52 pm
by ahmedess
I have recorded several readings for salinity of the same sample of tank water at different temperatures ranging from 20 degrees to 30 degrees Celcius and I have found that salinity vs temperature is linear across this range as it was said in several articles online, So I used the formula below to compensate for the change in temperature to give us a more accurate reading of salinity if the tank's temperature fluctuates within the range above, which is more than enough for our application.
Stcal = St / {1 + a(T-25)}
where: St = Salinity at any temperature T in °C, Stcal = Salinity at calibration temperature 25 in °C, a = temperature coefficient of solution at 25 in °C.
Then To determine "a" I plotted the change in conductivity versus the change in temperature. Then I Divided the slope of the graph by Stcal to get "a", as mentioned on this article "
http://www.eutechinst.com/techtips/tech-tips25.htm"
The value of "a" i got was 0.024 and by substituting the values in the above formula temperature compensation worked pretty well on paper. but when i coded the formula to try to run it on RA it didn't work.
The last line is the code of the formula for temperature compensation but there seems to be something wrong with it
#if defined SALINITYEXPANSION
Params.Salinity=Salinity.Read();
Params.Salinity=map(Params.Salinity, 0, SalMax, 60, 350);
Params.Salinity=Params.Salinity/(1+((24/1000)*(Params.Temp[T1_PROBE]-25)));
Is the above coded formula the same as this one "Stcal = St / {1 + 0.024(T1-25)}"
Re: Expansion module
Posted: Mon Mar 19, 2012 3:10 pm
by rimai
Awesome work!!
I'll take a look at why it failed to apply the compensation.
My thought is that the variable Params.Salinity is integer and can't calculate decimals, but I'll look at it later.
Re: Expansion module
Posted: Thu Mar 22, 2012 10:21 am
by ahmedess
Where is Params.Salinity declared and can i declare it as float instead of int
Re: Expansion module
Posted: Thu Mar 22, 2012 10:32 am
by rimai
RA_NokiaLCD.h, but it needs to get moved out of there.
Let me go look at your code right now.
Re: Expansion module
Posted: Thu Mar 22, 2012 10:57 am
by binder
rimai wrote:RA_NokiaLCD.h, but it needs to get moved out of there.
Let me go look at your code right now.
I just moved the ParamsStruct from RA_NokiaLCD to Globals. It's a more "suitable" fit I think.