Salinity temp compensation?

Expansion modules and attachments
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: Salinity temp compensation?

Post 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?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post 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();
Roberto.
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: Salinity temp compensation?

Post 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
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: Salinity temp compensation?

Post by ahmedess »

I ve done as you said and the value of internalmemory.alpha_read() changes properly to the value I set it to
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post 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);
Roberto.
ahmedess
Posts: 174
Joined: Sun May 22, 2011 2:29 pm

Re: Salinity temp compensation?

Post by ahmedess »

Finally!!

this one is working: ReefAngel.Salinity.SetCompensation((double)InternalMemory.Alpha_read()/100000);

Thanks alot
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Salinity temp compensation?

Post 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?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post 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);
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Salinity temp compensation?

Post 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).
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post 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 :)
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Salinity temp compensation?

Post 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.
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: Salinity temp compensation?

Post 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..
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post by rimai »

setup()
Roberto.
howaboutme
Posts: 245
Joined: Tue Jan 28, 2014 11:10 am
Location: Northern VA

Re: Salinity temp compensation?

Post 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!
Jack
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity temp compensation?

Post by rimai »

That is it.
Roberto.
howaboutme
Posts: 245
Joined: Tue Jan 28, 2014 11:10 am
Location: Northern VA

Re: Salinity temp compensation?

Post by howaboutme »

rimai wrote:That is it.
thanks!
Jack
Post Reply