Closed johnny2678 closed 3 years ago
I do not know where this calculation came from but I assume it came from a user of njspc with a chem controller as it has been around for several years. It uses a number of lookup table constants and uses the following calculation
HF = Lookup on Calcium Hardness range
< 50 = 1.3
50 - 75 = 1.5
75 - 100 = 1.6
100 - 125 = 1.7
125 - 150 = 1.8
150 - 200 = 1.9
200 - 250 = 2.0
250 - 300 = 2.1
300 - 400 = 2.2
> 400 = 2.5
CA = Corrected Alkalinity = Total Alkalinity - (Cyanuric Acid / 3)
CARB = Lookup on CA
< 25 = 1.4
25 - 50 = 1.7
50 - 75 = 1.9
75 - 100 = 2.0
100 - 125 = 2.1
125 - 150 = 2.2
150 - 200 = 2.3
200 - 250 = 2.4
250 - 300 = 2.5
300 - 400 = 2.6
> 400 = 2.9
TF = Temperature Factor = Lookup on temp in Celsius
< 0 = 0
0 - 2.8 = .1
2.8 - 7.8 = .2
7.8 - 11.7 = .3
11.7 - 15.6 = .4
15.6 - 18.9 = .5
18.9 - 24.4 = .6
24.4 - 28.9 = .7
28.9 - 34.4 = .8
> 34.4 = .9
DSS = Dissolved solids factor = SWG in use ? 12.2 : 12.1
saturationIndex = pH + HF + CARB + TF - DSS
found the source!
https://www.troublefreepool.com/threads/csi-formula.19688/post-166165
wonder if the method you posted is what pentair or some other chem automation platform uses?
oh well, not too important. Maybe in the future you can allow the user to supply their own CSI level or calculate it for them. but not at all important.
interesting, mostly coherent comment from user in that thread that I am in no way qualified to affirm or deny -
"The LSI as used by the pool industry is actually incorrect and uses logarithms for the temperature and TDS portions of the computation when they should have used the formulas I showed above, but then they were trying to simplify things though the temperature formula isn't complicated so I'm not sure why they went with logarithms for that except to "appear" consistent with all factors except for pH (which is already a logarithm)."
Yeah my guess is that all of this is derived from empirical testing. Hence the lookup tables vs algorithms. I think there probably are paths to using alternate algorithms though.
I'm open to any better algorithms. The calcs came directly from the IntelliChem Manual (page 28, but could have changed with different versions).
Looks like I was waiting for the hip hop group tag team to help me plan dessert. Scoop there it is! Thanks @tagyoureit for the reference.
Yea, I don't know enough to say which method is better. Only that I've been managing my pool to the other method for a while and it seems to work reasonably well.
I just finished porting my CSI calc code over from python to NodeRed. It writes a new CSI value every time a new temp, pH, or salt reading comes in. Sends to MQTT and Influx - would just need an endpoint in njspc and I could send it there as well.
Just to be perfectly transparent, I don't bring this up because I'm some kind of CSI formula purist. Probably makes sense to use Pentair as a kind of standard. It's just because I was getting water balance error notifications in dashPanel. Pentair (and njspc) thinks my water is out of balance and TFP thinks my water is perfect. I'm feeling judged and my OCD couldn't take it 😂
I've since figured out how to change the alert range to get rid of the alert but would still be nice to use the alerts with a value I supply - or with an alternate njspc calculation.
Oh now that you have done some work. I think it behooves us to make all of that moot and include multiple csi calc methods. And yes you are being judged. When I get some time I'll add it in.
If you pull njspc next and dashPanel you will now have an option to select either LSI or CSI under the REM Chem config.
If you pull njspc next and dashPanel you will now have an option to select either LSI or CSI under the REM Chem config.
Pulled the latest, is this what you mean by REM Chem config? I'm not seeing it
Under the setpoints tab.
hmm...
Don't see a version for DashPanel but I'm pretty sure git pulled the latest from master
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ git pull
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 14 (delta 11), reused 11 (delta 8), pack-reused 0
Unpacking objects: 100% (14/14), done.
From https://github.com/rstrouse/nodejs-poolController-dashPanel
6dfb7d6..33b58cd master -> origin/master
Updating 6dfb7d6..33b58cd
Fast-forward
package-lock.json | 7 +++----
package.json | 2 +-
scripts/config/chemistry.js | 23 +++++++++++++++++++----
scripts/config/schedules.js | 13 +++++++------
4 files changed, 30 insertions(+), 15 deletions(-)
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ npm i
Also make sure you get njspc. Do a hard refresh of your dashPanel.
I can even see your comment about CSI/LSI being added after a hard reset but same pic as above. Did njspc also.
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ git fetch --all
Fetching origin
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ git reset --hard origin/master
HEAD is now at 33b58cd Added CSI and LSI balance calculations for chemControllers
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ git pull
Already up to date.
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ npm i
audited 181 packages in 6.257s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
pi@tmpPiPool:~/nodejs-poolController-dashPanel $ pm2 start 2
[PM2] Applying action restartProcessId on app [2](ids: [ '2' ])
[PM2] [poolController-dashPanel](2) ✓
[PM2] Process successfully started
The only thing left is to hard refresh dashPanel CTRL+F5.
well geez, you have better things to do than teach computers 101 to me. Thanks! I'm on the run but I'll take a harder look at it later.
Couldn't let all that work you did stand. Let me know if your numbers pan out. However, I noticed in your spreadsheet your carbAlk calculation on the cell didn't match what you had written. Since what you had written matches what is in tfp I went with the formula as it is written.
Couldn't let all that work you did stand.
😂
However, I noticed in your spreadsheet your carbAlk calculation on the cell didn't match what you had written.
The Borates part? 4.63*(ppm Borates)/(1+10^(9.11-pH))
Think i just made that 0 in excel since I don't use borates
edit: calculation lines up perfectly.
My CSI results are slightly different because I use a more accurate ds18b20 temp sensor for the temp reading instead of the pool body temp. Right now my ds18b20 is reading 78.125 and the pool body temp is reading 75. But that's a marginal impact on CSI. Now my balance alerts in dashPanel will mean something.
Thanks for this!
Don't count on ds18b20 being more accurate than the Pentair 10k sensor. 10k sensors that are properly calibrated have greater accuracy over a larger range. The problem with 10k thermistors is that some resistance is added due to the wire length that needs to be calibrated out. This calibration also ties to a curve fitting algorithm that matches the characteristics of the sensor and since the self heating on the sensor is deterministic it becomes part of the curve fit. To be fair I believe Pentair uses a lookup table so the accuracy is only to the rounded degree. I wrote an SPI interface into REM just to see if I could do better with that (I know I am a masochist). The curve fitting is much tighter to the .005 level... but why.
The ds18b20 has a high resolution but the accuracy is dependent on the linear calibration within the chip itself and the 1 wire connection. The issue is that when you get out of the 25C range a lot depends on the code behind it to maintain linear measurement.
To be fair I believe Pentair uses a lookup table so the accuracy is only to the rounded degree.
Yep, in FL decimals matter. My wife can tell the difference between 85.55 and 86. Same as the HVAC thermostat - can be the most accurate sensor in the tstat internals but then they round it off to the nearest whole number. Doesn't cut it for me.
edit: also should add that I used ds18b20 because that's the only temp sensors I could programmatically read. 1-wire was easy enough for my small brain. Not everyone can whip up their own SPI interface 😂
Not everyone can whip up their own SPI interface 😂
Yeah there are other options and the punch line is that I won't use it for anything. Just wanted to take SPI apart to see how many screws were in it.
I think we can close this - CSI calc is working great. thx.
Not a big deal at all, but curious what your source is for calculating CSI in dashPanel?
I've been calculating CSI on my own for a while now - so long that I can't even remember the original source for my calculation. It was somewhere on TFP.
However, i did create a spreadsheet showing how my calculation was performed using the other chem values as inputs and my result does match the result from the TFP Pool Math app on my phone.
Here's the spreadsheet I created: https://docs.google.com/spreadsheets/d/1A-Ft_TsP99Cz_nOYRvTolrPFoDZxyuaikvJhhE3NV60/edit?usp=sharing
Posting a screenshot below showing the differences using the following chem values as inputs. Any ideas where our methods differ?
pH | 7.53 ch | 400 ta | 81 cya | 10 salt | 3750 tempF | 68. *dashPanel is reading 67 in the pic but 1 degree wouldn't account for the result discrepancy