Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:53 19 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : TDS/EC Conductivity Meter

Author Message
MikeO
Senior Member

Joined: 11/09/2011
Location: Australia
Posts: 275
Posted: 09:43pm 18 Apr 2017
Copy link to clipboard 
Print this post

The following conductivity meter is based on an original project for Arduino here
The original used an American 2 pin power plug as a conductivity sensor, my version is a little different using the ubiquitous "RCA" phono plug, seen here complete with 3D printed holder. Link to STL file

You also need a waterproof Temperature sensor (18b20). The Cell is powered through a resistor (470 ohms) from two outputs on the mite via pins ECpower and ECground. Power is applied to the resistor + cell network briefly whilst the junction voltage is measured then turned off, the voltage is then reversed for a brief period to help with water polarisation. The code is fairly well commented and should be self explanatory. Operation is simple and should work straight off but calibration is recommended. I didn't have any commercial standards but was able to make some simple NaCl solutions which seemed to work reasonably well with the aid of this calculator. I made two TDS standards, a 1.5 (1000ppm) and a 3.0 (2000ppm) with 0.29 and 0.58 grams in 250ml of filtered water respectively.

Run the software and follow the prompts, if you are going to calibrate the new cell constant may be saved by pressing the S key, you may need to wait out the 10 seconds cycle time before its is saved. The following is a typical Calibrate and Measurement run.
New Callibration has been saved
Restart in Measure

EC/TDS Monitor (Console Mode) Ver 0.6b
Defaults - Calibration @: 1.5EC - Temp Coefficient: 0.019 - TDS/ppm Conversion factor: 0.7
Cell Constant: 3.52427 Resistance R1/Ra: 470 / 36ohms - Cell Voltage: 3.28 Vdc
Temperature is in Degrees Celcius

Waiting for Keypress (C or M)

Measure

Volt drop:1.031 Temps: 23.25 / 23.25 Resistance: 195.847 Ohms EC:1.50 S Concentration: 1049 ppm/TDS '1.5EC standard
Volt drop:1.030 Temps: 23.25 / 23.25 Resistance: 195.671 Ohms EC:1.50 S Concentration: 1050 ppm/TDS 'as used for
Volt drop:1.031 Temps: 23.25 / 23.25 Resistance: 195.847 Ohms EC:1.50 S Concentration: 1049 ppm/TDS 'calibration
'
Volt drop:2.012 Temps: 23 / 23.25 Resistance: 766.718 Ohms EC:0.38 S Concentration: 269 ppm/TDS 'Filtered
Volt drop:2.034 Temps: 23 / 23.25 Resistance: 789.868 Ohms EC:0.37 S Concentration: 261 ppm/TDS 'tap water
Volt drop:2.060 Temps: 23 / 23.25 Resistance: 818.633 Ohms EC:0.36 S Concentration: 252 ppm/TDS
'
Volt drop:0.741 Temps: 23.25 / 23.25 Resistance: 111.777 Ohms EC:2.63 S Concentration: 1838 ppm/TDS '3.00EC standard
Volt drop:0.738 Temps: 23.25 / 23.25 Resistance: 110.809 Ohms EC:2.65 S Concentration: 1854 ppm/TDS
Volt drop:0.737 Temps: 23.25 / 23.25 Resistance: 110.533 Ohms EC:2.66 S Concentration: 1859 ppm/TDS
Volt drop:0.734 Temps: 23.25 / 23.25 Resistance: 109.982 Ohms EC:2.67 S Concentration: 1868 ppm/TDS
>


Code for Console version:

'EC Measurment for Micromite
'M Ogden April 2017
'http://www.codenquilts.com.au
'Based on Arduino code by Michael Ratcliffe

'Versions
'v0.5b Console ver Cal, Measure

'Options
option explicit
option default Integer

'Contants
const Sver$="Ver 0.6b"
'Global variables
dim float CalibrationEC
dim float TempCoef
Dim Float PPMconversion
dim R1 'resistance of EC Series resistor
dim Ra 'resistance of powering pins avg from Microchip data
dim float Vin
dim float K 'Cell Constant for Measurements, calculated in the Calibration routine
dim Float EC
dim float EC25
dim float Vdrop
dim float Rc


Dim ECPin=4 'EC input
dim ECGround=17 'EC Ground pin
dim ECpower=18 'EC Power pin
dim TrPin=16 'Temperature pin
Dim RV 'Reverse voltage period value to Cell for Depolarisation
Dim TempStart as float
dim TempFinish as float
Dim Keyin$
Dim ppm,backup,exittask,mode

'Define I/O
Setpin ECpin,ain
setpin ECGround,dout
setpin ECPower,dout

'intialise I/O
pin(ECGround)=0
pin(ECPower)=0


'init Modules
'Initialise Arrays



' Restore the settings. If this is the first time set the defaults
Var Restore
cls
Text MM.HRes/2, MM.VRes/2, "INITIALISE", CM, 1,2, RGB(white)
pause 1000

'****************************************************************************
'To restore defaults touch the centre of the LCD "INITIALISE" during startup.
'****************************************************************************
if Touch(x) <> -1 Then
cls
backup=0
Text MM.HRes/2, MM.VRes/2, "DEFAULTS RESTORED", CM, 1, 2, RGB(white)
end if
pause 1000

If backup = 0 Then
backup=1
rv=125 'Reverse voltage period value to Cell for Depolarisation
CalibrationEC=1.5 'standard calibration
TempCoef=0.019 'temp coefficient for Hydroponics solutions
PPMconversion=0.7 'Tranchen [Australia] PPM conversion value: 0.7
R1=470 'resistance of EC Series resistor
Ra=36 'resistance of powering pins avg from Microchip data
Vin=3.28 'Open circuit voltage reading of Cell
K=3.43 'Cell Constant for "RCA type plug" as Cell @ 1.5 EC
Var Save backup, CalibrationEC, PPMConversion,TempCoef,R1,Ra,Vin,K
EndIf

'interupts
'Settick 1000 ,T1,1 'establish seconds "Tick Timer"
' now draw the display
'init variables
R1=R1+Ra
mode=0 '0 for Console, 1 for LCD (not implemented)


cls
'*** start main program loop

do
consolemode
loop
'***** End main program loop
End If
end

'**************** sub routines *********************

'T1 - 1second Tick interrupt
'set up some time flags

sub ConsoleMode

Do
print ""
Print "EC/TDS Monitor (Console Mode) ";Sver$
Print "Defaults - Calibration @:";CalibrationEC;"EC - Temp Coefficient:";TempCoef;" - TDS/ppm Conversion factor:";ppmconversion
print "Cell Constant K:";k;" Resistance R1/Ra:";r1-Ra;" /";Ra;" ohms";" - Cell Voltage:";Vin;" Vdc"
Print "Temperature is in Degrees Celcius"
Print ""
Print "Waiting for Keypress (C or M)"
pause 500
DO
keyin$ = INKEY$
LOOP UNTIL keyin$ <> ""
'print "Keyin:";keyin$
If UCase$(keyin$)="C" Then
print
Print "Calibrate, press S (once) to save new Calibration"
Calibrate
elseif UCase$(keyin$)="M" then ' just measure
Print
Print "Measure"
Do
GetEC
printReadings
pause 10000
Loop
EndIf
Loop
end sub

sub PrintReadings 'Console
print "Volt drop:";str$(vdrop,1,3);
print " Temps:";tempstart;" / ";tempfinish;
print " Resistance:";str$(RC,4,3);" Ohms";
Print " EC:";str$(EC25,1,2);" S";
print " Concentration:";ppm;" ppm/TDS"
end Sub

sub GetEC 'Read the EC Cell
tempstart=tempr(TRpin) 'get start temperature
vdrop=EC_Cell() 'read EC cell
' Calculate R relating to Calibration fluid)
Rc=(Vdrop*R1)/(Vin-Vdrop)
Rc=Rc-Ra
EC=1000/(Rc*K)
'compensate for temperature
EC25=EC/(1+(tempcoef*(tempstart-25)))
ppm=(EC25)*(ppmconversion*1000)
end sub

function EC_Cell() as float
local raw as float
EC_Cell=9 'EC can't be 9 so this signals error
pin(ECpower)=1 'power on EC probe
raw=pin(ecpin)
pin(ECPower)=0 'power off EC probe
pin(ECGround)=1 'reverse voltage to minimise polarisation
pause RV 'pause at reverse polarity
pin(ECGround)=0
if raw<>0 then EC_Cell=raw
end function


Sub Calibrate
exittask=0
do
tempstart=tempr(TRpin) 'get start temperature
vdrop=EC_Cell() 'read EC cell
tempfinish=tempr(TRpin) 'get finish temperature
'compensate for temperature
EC=calibrationEC*(1+(tempcoef*(tempfinish-25)))
' Calculate R relating to Calibration fluid)
Rc=(Vdrop*R1)/(Vin-Vdrop)
Rc=Rc-Ra
K=1000/(Rc*EC)
print "Volt drop:";str$(vdrop,1,3);
print " Temps:";tempstart;" / ";tempfinish;
print " Resistance:";str$(RC,4,3);" Ohms";
Print " EC:";str$(CalibrationEC,1,2);" S";
print " Cell Constant K:";str$(K,1,2)
If tempstart=tempfinish then
'print "Safe to use the K value in main code"
else
print "Error - Wait for temperature to settle "
end if
pause 10000
keyin$ = INKEY$
If UCase$(keyin$)="S" Then
print "New Callibration has been saved"
print "Restart in Measure "
var save K
exittask=1
end if
Loop until exittask=1
End Sub










Edited by MikeO 2017-04-20
Codenquilts
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 10:03pm 18 Apr 2017
Copy link to clipboard 
Print this post

A very interesting instrument.
It looks easy to replicate so thanks for sharing.

Jim
VK7JH
MMedit   MMBasic Help
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 11:35am 19 Apr 2017
Copy link to clipboard 
Print this post

Very interesting.

Continuous pH monitoring is what I'd find really useful, but not sure if the readily available probes are suitable for 24/7 immersion for continuous monitoring.

I gather periodical re-calibration might be required, and have seen quite a few continuous pH monitors in service, but they usually have $$$$ price tags.

Anyone here know a good starting point for this type of pH monitoring.

Thanks

Phil.
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:32am 20 Apr 2017
Copy link to clipboard 
Print this post

You and I and a lot of other people would find that very useful Phil - in my case to control the pool pH. Unfortunately I don't think anyone has yet come up with a simple system that will do this at all reliably.

To be able to use pH for control (i.e. not just with colour indicators), pH pretty much universally is measured with a glass electrode which is very delicate and easily and quickly fouled when used for continuous monitoring. Even in pools, which normally have pretty clean water, they foul up fast and at a guess I'd say careful daily calibration with buffer solutions would be necessary. Over longer periods (and not that much longer) they would need cleaning and probably replacement of the electrode solution every week or so. The whole electrode itself won't last long (a few weeks ??) and still be able to give accurate results in a continuous monitoring mode.

In the laboratories I've worked in there have been good chemists who understand pH electrodes well, but most would admit having been frustrated by pH electrodes at some stage or other.

Greg
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 11:46am 20 Apr 2017
Copy link to clipboard 
Print this post

  paceman said   You and I and a lot of other people would find that very useful Phil - in my case to control the pool pH. Unfortunately I don't think anyone has yet come up with a simple system that will do this at all reliably.


Hi Greg,

One of the things that spurs my curiosity is a friends Aquaculture setup.
An indoor operation of about 1200m², & about 200,000 litres of water.

Runs Ozone generators & oxygen concentrators, but the monitoring hardware looks fairly primitive, (Some in service for 15+ years).

One of his monitors, runs 24/7, & yep it requires periodical recalibration, but certainly not daily. Gets checked against a higher grade hand held unit most days, but it's pretty low maintenance.

More recently he's put in a residential pool & it also has 24/7 ph monitoring & also on demand acid feed to keep pH correct.

I know the probes at the fish farm are readily accessible for cleaning etc, but the pool ones are inline & not so readily removed.

The couple of devices I've seen so far are these, & I could put both of them to use...









It seems to be getting more common for domestic pools to have automatic acid dosing, so there my be a fair degree of reliability available now, given how lax owners can be with correct maintenance.

If you could reliably read pH, it would be easy to calculate acid dose required for a pool to maintain the balance.

I'd assume it would be introduced slowly, main pump running, and the control would be required not to exceed specified 24 hour doses.

Phil.
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1805
Posted: 11:48am 20 Apr 2017
Copy link to clipboard 
Print this post

PH control would be great.I have another type of meter meant to be used in soil.
I bought it in Bunnings (Hardware Store), it has some type of metal probe that must generate a small current because it uses no batteries. It is just the probe with a meter on top it was cheap and is not very accurate but that is not to say it could not be if manufactured properly.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
SteveP
Newbie

Joined: 21/03/2013
Location: United States
Posts: 19
Posted: 05:40pm 20 Apr 2017
Copy link to clipboard 
Print this post

A pH electrode is a voltage source with high impedance output. Generally, a very low bias current op amp is used to measure its voltage, femtoamp is not unheard of. That can be followed by an offset and gain adjustment to convert the small voltage to a pH value.
I have seen circuits probably in a low bias current op amp data sheet.

pH 0 = +414.12m0V (Acidic). pH 4 = +177.480mV (Acidic). pH 7 = 0.000mV (Neutral).

Steve
"A chemist"
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:45am 21 Apr 2017
Copy link to clipboard 
Print this post

  Phil23 said  Runs Ozone generators & oxygen concentrators, but the monitoring hardware looks fairly primitive, (Some in service for 15+ years).
One of his monitors, runs 24/7, & yep it requires periodical recalibration, but certainly not daily. Gets checked against a higher grade hand held unit most days, but it's pretty low maintenance.

Are those monitors DO (dissolved oxygen) or pH? - DO's are quite a lot more robust. The accuracy needed for the pH measurement matters too of course - if the requirements aren't too strict (say +/- 0.2pH units is OK) then calibration can be let out a bit. I once asked our local pool shop how often they calibrated their electrode and they said 'three times a week'. That surprised me a bit because analytically it's done many times a day if the pH measurement is critical - but I shouldn't have been surprised because I'd checked a couple of pool shops against each other a couple of times and they usually didn't match too well.

Response speed is another important factor too - in the lab you can't hang around for ten minutes waiting for the electrode to stabilise; 30 seconds would be more likely. Electrodes are thrown out or relegated to less demanding work (pools? ) if their response time blows out.

  Quote  More recently he's put in a residential pool & it also has 24/7 pH monitoring & also on demand acid feed to keep pH correct.

Be interesting to hear his comments about how it's worked - electrode maintenance issue, setup cost etc. I haven't seen any automated pH control on pools around me in Melbourne but then I've only been involved with half a dozen or so and maybe we're backward.

  Quote  The couple of devices I've seen so far are these, & I could put both of them to use...

Yes I've looked at those too but don't trust the 'reliability' prospect. The meter (i.e. board) should be pretty reliable - it's amazing how far the chip amplifiers have come, and the temp. probe won't be a problem (you have to have temperature to adjust the pH), the electrode is the issue. Those ones are plastic on the outside and that makes them more robust but the membrane inside will still be very thin glass.

Those pumps are peristaltic pumps - rotating rollers squeezing a tube. They're commonly used for dosing small quantities intermittently; they're cheap-ish and pretty reliable.

  Quote  I'd assume it would be introduced slowly, main pump running, and the control would be required not to exceed specified 24 hour doses.

Yes, definitely with the filter pump running. I think just using a timing basis for dosing would be the way to go. Run it for a few secs, then off for a minute or so to disperse it, then run again etc. several times for a total of 'n' secs to deliver say 100 mls at a time. The acid should be pre-diluted too I'd say (maybe 10:1?). It takes an hour or two for most pools to circulate the water enough to stabilise pH after dosing any chemicals, so you probably wouldn't want to be dosing acid more than a couple of times a day because it will have to be done during the 'main pump on' filtration periods (2x2 hrs/day in winter and 4x2 in summer for me).

Greg
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:07am 21 Apr 2017
Copy link to clipboard 
Print this post

  palcal said   PH control would be great.I have another type of meter meant to be used in soil.
I bought it in Bunnings (Hardware Store), it has some type of metal probe that must generate a small current because it uses no batteries. It is just the probe with a meter on top it was cheap and is not very accurate but that is not to say it could not be if manufactured properly.

If it's a pH meter I wonder what the sensor principle is Paul? Soil moisture meters are just a probe with two electrodes, i.e. a rough conductivity meter, but they do need a little power supply, amplifier and some way of reading it.

@SteveP
Fempto-amps, wow! When I started my training in labs in 1966 a pH meter was real expensive and I guess that's why. Instrumentation amps with that sort of performance weren't common (to say the least). Things have sure come a long way when a cheap Chinese module can do it for you for a few bucks.

Greg
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 529
Posted: 09:29am 28 May 2017
Copy link to clipboard 
Print this post

I have been doing water treatment systems for a few years now and trying to
see if I can get the ok to put some of it up here. Till then I can post things
that got me to where Im at now as it is open hardware and open source.

sparkyswidgets
really helped getting some things working right. Lots of great info.

I'll have to boot up the old system to get more. I though it was
all moved to the new system.

Some of the pH probes have been online for at least 2 years with
site techs "doing ?" the calibrating and logs. But they do
get checked every month by the field rep's as chemical cost eats
in to their pay checks.

atlas-scientific
The PIC based units got me looking and finding MMBasic.

I'll add more here as I locate it.
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 09:34pm 28 May 2017
Copy link to clipboard 
Print this post

  Quote   it has some type of metal probe


There was an electrode for approximate pH based on antimony, I think. The potential depended on pH to an extent as it was an oxide/hydrogen ion system. I don't know if it was reliable or not, probably had interference effects from other ions eg chloride.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024