Page 3 of 3
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 12:18 pm
by ahmedess
okay I've tested the code but i have made a minor change to it. I created a memory location for the salinity constant "Alpha" and I have placed this line into my code:
Code: Select all
ReefAngel.Salinity.SetCompensation(InternalMemory.Alpha_read()/100000);
The problem is no matter what value I set Alpha to the compensation remains the same. I have tried many values starting from 240 and changed it from 1 to 1000 and the salinity value stays the same.
However, when i change the "Salinity Temp Compensation" value to a different one the salinity changes. I've been trying to figure out why this is happening but I couldnt find a solution. Could it be this part of the code "InternalMemory.Alpha_read()/100000" the controller is not calculating properly?
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 12:21 pm
by rimai
Could be.
Are you sure that you are reading the correct memory location?
Just print somewhere on the screen what the controller is reading from InternalMemory.Alpha_read();
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 12:30 pm
by ahmedess
I m using ReefAngel Status to change the value in memory. I have Alpha placed in memory location 3 and when i read the value in location 3 it gets the correct value I changed it to. Do you think it might differ if i print on the screen InternalMemory.Alpha_read();
this is part of my custom memory locations in globals.h:
Code: Select all
//custom memory locations (0-199)
#define CustomVarsStart 0
#define Mem_B_DP4Timer CustomVarsStart
#define Mem_I_DP4RepeatInterval CustomVarsStart+1
#define Mem_I_Alpha CustomVarsStart+3
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 12:46 pm
by ahmedess
I ve done as you said and the value of internalmemory.alpha_read() changes properly to the value I set it to
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 1:27 pm
by rimai
I'm thinking you may have a casting issue when you are dividing the value, since it is an int value and the function calls for a double.
Try this:
Code: Select all
ReefAngel.Salinity.SetCompensation((doube)InternalMemory.Alpha_read()/100000);
If this doesn't work, try this:
Code: Select all
double temp=InternalMemory.Alpha_read();
temp/=100000;
ReefAngel.Salinity.SetCompensation(temp);
Re: Salinity temp compensation?
Posted: Mon Apr 29, 2013 1:38 pm
by ahmedess
Finally!!
this one is working: ReefAngel.Salinity.SetCompensation((double)InternalMemory.Alpha_read()/100000);
Thanks alot
Re: Salinity temp compensation?
Posted: Thu Aug 15, 2013 9:22 am
by binder
When using the compensation, do we need to set the compensation temperature as well as enabling it? I would think that we would want to tell it what temperature we plan on using but I'm not 100% positive. Could somebody clarify please?
Re: Salinity temp compensation?
Posted: Thu Aug 15, 2013 9:33 am
by rimai
When you enable the compensation, you should recalibrate.
It will store the temperature in which the calibration happened in the internal memory and use it as reference.
To enable compensation and use the default alpha value, use this:
Code: Select all
ReefAngel.Salinity.SetCompensation(0);
Re: Salinity temp compensation?
Posted: Thu Aug 15, 2013 9:41 am
by binder
Ok cool. I didn't know it stored the temperature used during the calibration.
I already have the SetCompensation(0) line in my code. I just didn't know about the temperature stored.
Does it have to be calibrated to 35ppt or can we change that value? Or does it really matter if it's calibrated to 35ppt? I believe I run my tank salinity slightly lower (around 1.024 or 32ppt).
Re: Salinity temp compensation?
Posted: Thu Aug 15, 2013 9:45 am
by rimai
Yes, needs to be calibrated at 35ppt and you can't change it

If you want to create a FlexibleSalinityCalibration() function

, maybe others could benefit from it too

Re: Salinity temp compensation?
Posted: Thu Aug 15, 2013 9:50 am
by binder
rimai wrote:Yes, needs to be calibrated at 35ppt and you can't change it

If you want to create a FlexibleSalinityCalibration() function

, maybe others could benefit from it too

Maybe. I will see.

It seems like I don't even have enough time to get stuff done that I "need" to get done.
Re: Salinity temp compensation?
Posted: Mon Aug 26, 2013 2:41 am
by dazza1304
rimai wrote:When you enable the compensation, you should recalibrate.
It will store the temperature in which the calibration happened in the internal memory and use it as reference.
To enable compensation and use the default alpha value, use this:
Code: Select all
ReefAngel.Salinity.SetCompensation(0);
Quick question, where to I place this in my code - in the initialisation or loop? Sorry if a silly question!
Cheers..
Re: Salinity temp compensation?
Posted: Mon Aug 26, 2013 8:11 am
by rimai
setup()
Re: Salinity temp compensation?
Posted: Fri Feb 12, 2021 3:07 pm
by howaboutme
hi all,
bumping this thread.
can someone confirm that this code is all that's needed (other than recalibrate) to enable temp compensation for salinity?
Code: Select all
ReefAngel.Salinity.SetCompensation(0);
I'm trying to follow the initial developments in this thread but at the end it does look like the above is it?
Thanks!
Re: Salinity temp compensation?
Posted: Fri Feb 12, 2021 3:11 pm
by rimai
That is it.
Re: Salinity temp compensation?
Posted: Fri Feb 12, 2021 3:22 pm
by howaboutme
rimai wrote:That is it.
thanks!