Searching \ for 'Measuring Conductivity w/ 16c54' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=16C
Search entire site for: 'Measuring Conductivity w/ 16c54'.

Truncated match.
'Measuring Conductivity w/ 16c54'
1997\07\25@020652 by

Greetings,

If anybody has knowledge measuring conductivity of water (total dissolved
solids) with a pic, your input would be greatly appreciated.

This is my first PIC project, which was given to me because the guy who
started it couldn't get it working properly.  I've spent the last few
months learning the language, and trying to decode a nest of goto's in the
program I was given.

I believe I have found the problem... electron depletion (or polarization,
or electrolisys, all essentially the same I think?) on the electrodes.  I
have been sending a 5 volt signal (RA1) through the probe (two stainless
steel elecrodes), and then through a cap that is wired to ground. The probe
end of the cap is wired to TIMER0. The length of time it takes the cap to
charge is dependant on the resistance of the solution that I insert the
probe into. This works ok, for a the first few measurements.

The trouble is, every measurement causes the a higher degree of
polarization, causing it to take longer to charge the cap for the same
solution...

All I can find in reference books, or on the net, is I should be sending a
small amplitude sinusoidal wave to the probe. I'm unsure of a few things:

1) How to generate a "small amplitude sine wave" with a PIC, and what
constitutes small amplitude?
2) How will the conductivity of the solution affect this signal?
3) What technique should I be using to measure the signal?
Hi,

firstly conductivity is not necessarily a good measure of total dissolved
solids as it depends on the species present.

To measure conductivity you ideally want an AC signal with no DC component,
otherwise (as you have discovered) you polarise your cell, and eventually
start electrolysing water.

You might consider clamping one electrode at V(supply)/2 and switching the
other alternately low and high with a 50% duty cycle (zero net current).
This makes measurement a bit tricky but it's the simplest option.

Another option is to connect both electrodes to outputs and switch one high
and the other low then vice-versa, but I suspect that 5V will probably be
too much for your cell and will result in electrolysis.

One other problem has occured to me. If you are looking at high purity water
you could be facing resistances in the region of 10M ohm/cm in which case
the current through the input of the PIC might be significant.

Hope this helps,

Keith.
------------------------------------------------------------
Keith Dowsett         "Variables won't; constants aren't."

E-mail: kdowsettrpms.ac.uk  or kdowsettgeocities.com

WWW: http://kd.rpms.ac.uk/index.htm
www.geocities.com/CapeCanaveral/Lab/8979
Greetings,

If anybody has knowledge measuring conductivity of water (total dissolved
solids) with a pic, your input would be greatly appreciated.

This is my first PIC project, which was given to me because the guy who
started it couldn't get it working properly.  I've spent the last few
months learning the language, and trying to decode a nest of goto's in the
program I was given.

I believe I have found the problem... electron depletion (or polarization,
or electrolisys, all essentially the same I think?) on the electrodes.  I

You will need a little signal conditioning ahead of you're A/D.  If you put the
leads of an ohmmeter in a glass of salt water, you will see it stabilize at some
reading after a few moments, but if you stir the water, the conductivity will
increase.
What is happening is that you are biasing the water around the probes.

You must use an alternating field to avoid charging up the water around
your probes.  You can use synchronous detection to
convert the AC to DC, and an op amp to buffer it to the D/A
>If anybody has knowledge measuring conductivity of water (total dissolved
>solids) with a pic, your input would be greatly appreciated.

Hi Shane,

as I can see, you have already received some input, and although all the
advise was quite right, it was maybe too general. If you want to measure
conductivity of solution and calculate approximate amount of dissolved
salts, it is possible, but be prepared to use much fancier circuit than a
capacitor connected to T0CKI.

1. electrodes - mostly used platinum may be replaced with stainless steel
ones if you do not dipp them in agresive solutions (strong acids, bases,
oxidants).

2. Excitation voltage - 10V pk-pk squarewave will certainly not work. Must
use AC with no DC component, sinewave is preferred. Frequency about 1 kHz,
amplitude few hundred milivolts. At these conditions the solution behaves
like (variable) resistor in parallel with (constant) capacitor. Since the
capacitor has water with pretty high dielectric constant (~80) between its
electrodes, its capacitance is much higher than one would expect from its
dimensions. Therefore a lower frequency is suggested for low conductivity
solutions, on the other hand a higher frequency is better for high
conductivity solutions (to defeat polarization).

3. Sinewave generator - I use Wien-bridge type, amplitude stabilized with
two antiparallel diodes. This works fine for fixed frequency oscilator,
several % of THD is not critical.

4. Rectification - I use synchronous detector (analogue multiplexor 4053)
and RC filter.

5. The conductivity meter together with the cell is calibrated by KCl standards.
0.1 M : gamma=12.88 mS/cm
0.01 M : gamma=1.413 mS/cm (both at 25 C)

6. Total concentration (salinity) - can be estimated from conductivity as
follows:
c=75*gamma (c in weight %, gamma in S/cm)
This equation is based on quite similar specific molar ion conductivities of
most ions and is only approximate.

7. There is some temperature dependance - the specific conductance of most
ions increases by ~2% per degree Celsius.

8. PIC will not be much involved in the measurement. It may poll data from
the A/D convertor, scale them appropriate, take care of the temperature
compensation (if used) and calibration and display/transmit the result.

practical details.

Regards,

Josef
Previous Input Considered, Presently Instigating Comments.

Hi,

Over the last week I've adjusted my programming and
circuit to use an AC square wave of aprox 272Hz.
This obviously works way better than a DC signal did.

But I am still noticing a slight plating effect,
so want to increase the frequency further, which is easy to
do.  The reason I haven't increased it beyond 272Hz,
is that this frequency still allows the cap to charge
in one half cycle.  This allowed me to take the measurement
as if I were using DC. Which I believe simplifies
the hardware involved.  Increaing the frequency further,
will cause the cap to start discharging before it
finishes charging.  So, before the signal reaches the cap,
I have to rectify it.

In my limited experience, the easiest (and only) way,
I can think to do this is to use a diode to chop off
the negative cycle. However diodes seem to be
rather noisy. I'm worried this may affect my reading,
so am looking for a better way.

Thanks for all your help so far!

(btw, the solutions I'm measuring are in the ranges of

'Measuring Conductivity w/ 16c54'
1997\08\03@033215 by
>Hi,

>Over the last week I've adjusted my programming and
>circuit to use an AC square wave of aprox 272Hz.
>This obviously works way better than a DC signal did.

>But I am still noticing a slight plating effect,
>so want to increase the frequency further, which is easy to
>do.  The reason I haven't increased it beyond 272Hz,
>is that this frequency still allows the cap to charge
>in one half cycle.  This allowed me to take the measurement
>as if I were using DC. Which I believe simplifies
>the hardware involved.  Increaing the frequency further,
>will cause the cap to start discharging before it
>finishes charging.  So, before the signal reaches the cap,
>I have to rectify it.

I am not sure, what your setup is. Is your conductivity probe still
connected one wire to the Vdd and the other to some PIC input and thru
capacitor to the ground ? In this way even if you charge and discharge the
capacitor often enough, there is still some DC voltage across the solution,
causing necessarily some plating effect (also called polarization).

>(btw, the solutions I'm measuring are in the ranges of

For this range, 272Hz is OK.

Keep in mind, that there is always some voltage limit, above which you will
make changes to the solution, possibly irreversible, and that will increase
you problems with polarization. That is why the peak (not average) voltage
across the probe should not exceed this limit. For most solutions, the limit
is 1V - 2V, so 5 V is for sure too much, several hundred mV is generally
considered safe. For your precission and resolution requirements, you can
certainly use square-wave instead of ideal sinus-wave, but the no DC rule is
still valid. I cannot come up with any simple way like the resistor +
capacitor for DC measurement. What I have in the simplest instrument is one
TL064 + one 4053 (+ ICL7136), no PICs. Maybe you could try RC oscilator and
convert R to frequency. I would opt for 2 OZ type with modification - two
antiparallel diodes will limit the voltage on the probe to about 650 mV:

+-------------------------------------------------------------+
|                    C                                        |
|             +------||----+
+------/\/\/-----------+--|<|---->Vdd/2
|        R    | |\         |           |       R2             |
|      probe  | | \        |    R1     |   |\                 | 2x 1N4148
+------/\/\/--+-|- \       |           |   | \                |
|   >------+---/\/\/---+---|+ \               |
Vdd/2 <--|+ /                       |
>--+--/\/\/----+--|>|---->Vdd/2
| /               Vdd/2 <--|- /               |
|/                         | /                |
|/                 +---> to PIC

GND <-----/\/\/-----+-----/\/\/------>Vdd
|
| |\
| | \
+-|+ \
|   >--+-->Vdd/2
+-|- /   |
| | /    |             3/4 LM324 (TL064 ...)
| |/     |
|        |
+--------+
R1 < R2

f = const. / RC

Regards,

Josef
Josef Hanzal wrote:

> In this way even if you charge and discharge the capacitor often
> enough, there is still some DC voltage across the solution, causing
> necessarily some plating effect (also called polarization).

Am I missing something?  Two details seem to me stunningly obvious:
Firstly, that as indeed you want to avoid DC voltage across the
solution, you would ensure this by providing a "blocking" capacitor
between the electrode and the measuring circuit; a polycarbonate of
several microfarads if you could afford the space, or a tantalum
electrolytic configured so that was forward biassed throughout the
waveform.  If it became necessary to compensate for the reactance of
the blocking capacitor, a second capacitor could be introduced
between electrode and AC source:

Rref     C             C
VAC >----/\/\/----||-----+------||-----> Metering/ DAC
|
+-----------+  |
|           |  |
|       (~~~+~~+~~~)
=       (   I  I   ) solution
Gnd      (   I  I   )
(__________)
^  ^
electrodes

The second point which I have assumed in the diagram, is that the
reference electrode is grounded, though if another metallic part of
the solution path was also grounded, this could itself lead to
electrolytic problems.  Commonly, some metallic part of the
container already IS grounded, and the "sense" electrode would be
deliberately chosen to be the same material.

While I realise this is not "set in stone", I am always
uncomfortable to have large ungrounded objects (such as containers
of liquid) connected to small-signal circuitry.  If it MUST be so,
surely the signal circuitry should be "floating" from isolation
devices and shielded in common with the "sense" electrode, by the
reference electrode?

I am visualising something like a pipe through which the liquid
passes, forming the reference electrode, and containing a central
sense electrode which connects fairly directly with the measurement
circuit, itself encased in a shield attached to the outer reference
"pipe".  Something similar would seem to be in order whether the
shield was grounded or isolated.

Just some musings,

Cheers,
Paul B.
Josef,

> I am not sure, what your setup is. Is your conductivity probe still
> connected one wire to the Vdd and the other to some PIC input and thru
> capacitor to the ground ?

Right now I have:
---      +--------------------+
|   |     |                    |
|  \ /    |    8.2k            |
RA0   ------------ PROBE ---/\/\/\--+--/\/\/\--+        ---
1.6k   |          |        --- .47uF
|          |         |
RA3   -----------------------------------------+         |
|                  -----
TMR0   -----------------------------+                   ---
-

The program switches +5 and gnd between RA0 and RA3, at aprox 270Hz,
which gives enough time for the cap to charge and TMR0 to charge in one
half cycle. (while RA0 is high)

It does the cycle only once, before allowing ample discharge
time and taking another measurment.

> Keep in mind, that there is always some voltage limit, above which you will
> make changes to the solution, possibly irreversible, and that will increase
> you problems with polarization. That is why the peak (not average) voltage
> across the probe should not exceed this limit. For most solutions, the limit
> is 1V - 2V, so 5 V is for sure too much, several hundred mV is generally
> considered safe.

Right. That's probably what is happening now. A question tho:  Is it volts
that changes the solution, or amps? What I've seen suggests it's amps, so
if I can limit the current below 1mA then no changes should occur. I
think?

> For your precission and resolution requirements, you can
> certainly use square-wave instead of ideal sinus-wave, but the no DC rule is
> still valid. I cannot come up with any simple way like the resistor +
> capacitor for DC measurement.

Maybe I could use a RMS measuring technique to convert the square wave to
a DC value, and get a PIC with an ADC on it to do the conversion...?

> What I have in the simplest instrument is one
> TL064 + one 4053 (+ ICL7136), no PICs. Maybe you could try RC oscilator and
> convert R to frequency. I would opt for 2 OZ type with modification - two
> antiparallel diodes will limit the voltage on the probe to about 650 mV:

I'm gonna keep that in mind for the future. Right now tho, I'm trying to
do it with very little modifications to the original circuit; because we
already have over 250 boards printed and populated.

Thanks everyone, for your help. With a little luck this project should be
done real soon! :)

-Shane.
On Mon, 4 Aug 1997, Paul B. Webster wrote:

>   I am visualising something like a pipe through which the liquid
> passes, forming the reference electrode, and containing a central
> sense electrode which connects fairly directly with the measurement
> circuit, itself encased in a shield attached to the outer reference
> "pipe".  Something similar would seem to be in order whether the
> shield was grounded or isolated.

Just to clarify the situation:

In this case, I'll be measuring solutions in a small plastic resevoir,
about bathtub sized. The measuring device is hand held, and will just be
dipped into the resevoir.

-Shane.

>Right. That's probably what is happening now. A question tho:  Is it volts
>that changes the solution, or amps? What I've seen suggests it's amps, so
>if I can limit the current below 1mA then no changes should occur. I
>think?

Both, maybe charge is more precise. There is a big difference in conducting
electricity in metals and solutions. While electrons carry the current in
metals, ions do that in solutions. At the boundary of metal and solution can
various things happen. The very first ions close to the metal form so called
double-layer. From an electrical point of view, it acts as (big) capacitor
in series with the resistance of the solution. When you force current thru
the solution, you charge this capacitor. But when you overcharge it, then
positive ions will combine with electrons from the metal and form neutral
molecules, negative ions will give away its electrons and also become
neutral molecules - the solution undergoes electrolysis. This is boring
theory, but it concludes, that you have to pass thru the solution the same
(and not too big) charge in both directions. One way to ensure that is
symetrical (no DC) waveform with limited voltage.

Yes! Maybe there is a way how to do it. Remove the 8.2k resistor to RA3.
Keep RA0 always as output. Connect big enough resistor R in series with
probe. It should have about 5 times higher resistance than your least
conductive solution - you will limit voltage across the solution to less
than 1V. Although you loose some resolution, your need is to distinguish
4-36 units. Maybe reduce the capacitance of the .47uF capacitor - it depends
on the surface of your probe electrodes, need to try. Charge and discharge
the capacitor only thru PROBE + R + Pot. In this way you pass exactly the
same charge thru the solution in both direcitions. But your probe may suffer
from leakage current at TMR0 - small but continuous in one direction. Need
to try. Maybe some SMD FET operating amplifier from the solder side as a
voltage folower, or better as a comparator (but two more resistors) will help.

---      +--------------------+
R      |   |     |                    |
|  \ /    |                    |
RA0   ---PROBE---/\/\/\-----/\/\/\--+                   ---
1.6k   |                   --- .47uF
|                    |
|                    |
|                  -----
TMR0   -----------------------------+                   ---
-

>Maybe I could use a RMS measuring technique to convert the square wave to
>a DC value, and get a PIC with an ADC on it to do the conversion...?

I guess not...

>I'm gonna keep that in mind for the future. Right now tho, I'm trying to
>do it with very little modifications to the original circuit; because we
>already have over 250 boards printed and populated.

I can imagine, how difficult amending those bords could be.

Good luck,

Josef

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...