# Driver Software Equations

**A derivation of the equations implemented by the conductivity sensing software drivers**

This page describes the computations performed by the Conductivity Sensing Wildcard's software drivers. Those computations convert the voltage output of the Wildcard into an indication of the conductance/conductivity of the solution sampled by a conductivity probe/electrode.

However, if you use the board as a stand-alone instrument, and read its output voltage with a precision voltmeter, you will need to do the computations yourself. To make that easier, we provide an Excel spreadsheet that allows you to enter calibration data and the measured voltage, and computes the conductivity for you. While you may use that spreadsheet without a detailed understanding of how the computations are done, it helps to have a basic understanding. If you want to measure the output of the Conductivity Sensing Wildcard with an A/D or other embedded computer, you'll need to implement these equations in code on another processor.

**Summary**.

## Measuring resistance/conductance using a voltage divider

The Conductivity Sensing Wildcard uses a simple voltage divider network to measure the resistance of a solution between the electrodes of the conductivity sensor. The measurement resistance is just the inverse of the conductance to be measured, that is, *R _{m} = 1/G_{m}*. In essence, the circuit is like that of a simple voltage divider:

Knowing the value of the reference resistor, *R _{ref}*, the unknown resistance being measured,

*R*, is computed from the measured output voltage,

_{m}*v*, as,

_{o}The value of the reference resistor sets the middle point of the measurement range. We use a reference resistor of 1000 ohms, setting the midpoint of the measurement range to 1 mS (milliSiemen), assuming a conductivity cell constant near unity (*K*=1).

While the principle is simple, the Wildcard must take into account numerous subtleties. Most importantly, a DC voltage can not be used – instead a small AC voltage prevents electrode polarization and electrolysis of the solution. The AC voltage must then be precisely rectified, or demodulated, to determine its magnitude.

The following is a simplified schematic of the Wildcard's measurement circuitry and its connection to the conductivity probe:

As you can see, the circuit remains essentially a voltage divider. A precision square wave of ±0.5 V is applied to a series combination of a reference resistor (nominally 1 KΩ for a midrange conductance measurement of 1 mS) and the conductance to be measured, which is indicated as the resistor at the end of the probe, *R _{m}* (ignoring for the moment the other components). The voltage at the junction of the two resistors is synchronously demodulated to determine its magnitude, from which the unknown conductance is computed.

The circuit also shows two on-board calibration resistors, used in testing or to verify the board's operation. *R _{ch}* (calibration high) is sized at 10 KΩ and

*R*(calibration low) is 10 ohms. For time-of-manufacture testing they are switched into the circuit by installing jumpers.

_{cl}The measurement is complicated by several factors, represented by the other components in the schematic, each of which must be compensated with parameters determined by calibration. Let me describe these factors, and the calibration procedures they necessitate, in more detail:

### Tare or zero calibration

The cable, and the board itself to a much lesser degree, introduces capacitance, represented by *C _{p}* in the schematic, that limits the accuracy of low conductance measurements unless it is compensated for. The degree of its influence depends on the frequency of operation of the board, which varies a little board to board, and very much on the value of

*C*.

_{p}*C*arises from the cable used and its length, and so varies from cable to cable. Even when the probe is not immersed in a liquid, some current flows through the capacitance, causing a residual conductance. A zero conductance, or

_{p}*tare*, calibration is therefore needed. This calibration should be done with the cable and probe connected, but not immersed in a fluid. Once calibrated, the

*C*of a board/cable combination should not change with time, so the calibration should need to be done only once, or only before attempting precise measurements of low conductivity. For measuring moderate conductivities the calibration will not need to be repeated. As the cable capacitance influences the measurements at the low end of the conductance scale, a missing tare calibration affects only low conductance readings; mid-range or high conductance readings are not affected much. In short:

_{p}- Tare calibration is needed for accurate low conductivity measurements.
- A procedure for tare calibration should be available to the end user so that they can calibrate after changing probes or before precise measurements of low conductivity.

### Full scale calibration

The conductance sensor does not contact the solution to be measured perfectly, but has a series impedance, represented by *Z _{s}* in the schematic. The series impedance arises from the capacitance and conductance of the microscopic electrical double layer of charge on the electrode surface. For probe electrodes with a very high microscopic surface area the series impedance is low, and doesn't affect readings much. But for less nearly ideal probes the finite series impedance adds to the solution resistance measured and so affects high conductance readings. Mid-range and low conductivities represent much higher resistance, so adding a little additional series impedance doesn't affect them much. We don't yet know to what extent this series impedance varies from probe to probe or over time, but for accurate high conductivity measurements it must be accounted for. The full scale calibration must be performed by immersing the probe in a solution of high conductivity. Once a probe is calibrated the full scale calibration will not need to be repeated. (Although, if a probe is used over a long period of time, or if it is used in a caustic solution, electrode reactions may change its impedance.) Consequently, full scale calibration may be done at time-of-manufacture of the probe/sensor, and the resulting calibration parameter should follow the probe/sensor.

- Full scale calibration must be done for each sensor.
- A procedure for full scale calibration should be embedded in the instrument, but not generally accessible to the end user.
- A user should be able to input the full-scale calibration parameter,
*Z*, so it can be updated if needed when a probe is changed._{s}

### Calibration of the conductivity probe's cell constant

Mid-range conductances are measured by the board with a very high inherent accuracy. However, the conversion of the measured conductance to the solution conductivity depends on a geometrical scale factor, also called the cell constant *K*, of the sensor probe. Consequently, the scale factor must be determined for each probe/sensor (assuming the geometry changes a bit from probe to probe). If the sensors are sufficiently reproducible, a single *K* value may be used for all of them. In the most general case, you may not know how much *K* might vary from probe to probe. So, a calibration procedure may be used to determine *K*. This calibration is done by immersing the probe in a solution of mid-range conductivity and performing a measurement. Again, if you are manufacturing an end-user instrument, this is a time-of-manufacture procedure that the end user should not need to perform. Because the cell constant is purely a geometrical factor, once the cell constant is determined for a probe, it does not change with aging of the probe.

- Cell constant calibration must be done for each sensor.
- A procedure for cell constant calibration should be embedded in the instrument, but not generally accessible to the end user.
- A user should be able to input the cell constant,
*K*, so it can be updated if needed when a probe is replaced with one of a different cell constant.

### Compensation for demodulator nonlinearities

The demodulator on the Conductance Sensing Wildcard was designed to allow precision readings with less than 0.1% error over a wide conductance range. However, after its design the board was modified to operate at greater frequencies (at about 40 KHz rather than 1 KHz)^{1)} to allow reading sensors with poor electrode impedance. Unfortunately, demodulator errors are frequency dependent, and increased 40x, to the 2-4% error range. Even so, the nonlinearities of the demodulator can be compensated with correction factors to remove virtually all of the error, as described later in this document.

## Deriving the calibration equations

We'll now derive some measurement equations that ultimately will enable us to convert measured A/D counts into solution conductivity, while taking into account the three calibration parameters (the tare conductance/resistance, the full scale conductance/resistance, and the cell constant).

Referring to the above schematic, we measure the solution resistance by measuring the average demodulated output of the circuit, *v _{o}*, as a portion of the reference voltage,

*v*. The reference will be applied to the A/D reference so that

_{ref}*v*is measured as a number of counts from 0 to 65535, corresponding to a voltage from zero to just less than

_{o}*v*. The counts should be divided by 65536 to produce a floating point number between zero and one.

_{ref}To derive the calibration equations we'll assume that the sensor's series impedance, *Z _{s}* in the schematic, appears resistive. While in fact the impedance is a series combination of the electrode's electrical double layer capacitance, electrode spreading resistance and wire/contact resistance, owing to the synchronous detection/demodulation method used, its influence is, to a first approximation, equivalent to a simple series resistance.

In analyzing the above circuit so that we can understand how the cable capacitance influences the output, we'll combine the reference resistor and measurement resistor into a single Thevenin source impedance, driven by a Thevenin voltage.

*R _{t}* and

*v*are related to the measurement and reference resistances as,

_{t}where *R* = *R _{m}* +

*Z*for probe measurements, or

_{s}*R*=

*R*or

_{cl}*R*=

*R*for calibration jumpers, and,

_{ch}During each half cycle of the drive waveform the voltage across the cable capacitance follows an exponential decay trajectory. At the end of each half cycle, the capacitor voltage reaches its maximum excursion, *v'*, given by,

in which *Δt* is the duration of one half cycle of the AC waveform; that is,

where *f* is the frequency of operation.

Note that the effective parallel impedance presented by the capacitor, which we'll call *R _{p}*, can be represented as,

The demodulator averages half cycles of *v _{o}*, inverting alternate half cycles and summing positive halves with the inverted negative halves. Within each half cycle the voltage waveform as a function of time is given by,

Note that at *t* = *±Δt*, this expression gives Equation 4, with *v* = ±*v'*.

The output of the demodulator is the average of the positive and negative half cycles, or,

where the expression on the right is evaluated over the interval from *t* = 0 to *t* = *Δt*,

or

Note that the *TANH()* function is the hyperbolic tangent function. As we will see, we won’t really need it, as we’ll use a simple approximation. If we did need it, and it was not available as a library function, exponential functions could be used, as,

Let's recast Equation 8 in terms of the quantity actually measured by the A/D, that is *v _{o}/v_{ref}*, which is related to

*v*as,

_{o}/(2v_{t})from which we can compute *R _{m}* as,

The *TANH()* function is a bit intimidating, but for *R _{p}/R_{t}* > 4 it becomes unity to within better than 0.1%. As

*R*>

_{p}/R_{t}*R*(since

_{p}/R_{ref}*R*is always less than

_{t}*R*), and

_{ref}*R*is likely to be greater than 4 for even long cables, we can use the approximation. (Actually, a typical 12 foot long cable may have

_{p}/R_{ref}*R*>7.) Consequently, we can approximate Equation 11 as,

_{p}/R_{ref}which is much easier to compute.

This equation is a little deceptive, because *R _{m}* doesn’t appear just on the left side of the equation, but it also appears implicitly on the right side, embedded within

*R*. From Equation 2 above,

_{t}*R*is given by,

_{t}Because Equations 12 and 13 depend on each other, to solve them you can combine them and solve the resulting quadratic equation, or they can be solved iteratively. Solving the quadratic equation, Equations 12 and 13 are combined and solved for *R _{m}* as,

There is one parameter in the equation, *R _{p}*, that we can relate to a calibration condition,

*v*. When a probe is plugged in, but not immersed in a solution,

_{po}*R*is effectively infinite. Solving the above equation for

_{m}*R*in the limit of infinite

_{p}*R*yields,

_{m}In which *v _{po}* is the measurement of the board’s output when a probe is connected but not immersed in solution. Substituting

*R*into Equation 14 produces the equation we’ll use to calculating the unknown resistance,

_{p}*R*, as,

_{m}This equation allows us to compute the resistance of the solution given the voltage output of the board, *v _{o}*, and several calibration parameters including the probe’s tare output,

*v*, and series impedance,

_{po}*Z*. Simplifying the fraction allows us to cast it into a form more amenable to integer arithmetic, as,

_{s}We'll consider the case of using the board with a 16-bit A/D, which uses *v _{ref}* as its full scale reference voltage (i.e.,

*v*is represented as 2

_{ref}^{16}=65536). In that case, the measured voltages are represented as a fraction of

*v*as 16-bit unsigned integers. If we let

_{ref}**f**() represent casting from integer representation to floating point representation, then the calculation of Equation 16b can be implemented as,

Equation 16c poses only a minor computational hazard if data acquisition errors when reading low conductances cause the denominator to become zero or negative. Consequently, before doing the division, the denominator should be limited to positive values. If data acquisition errors cause a conversion of *v _{o}* greater or equal to

*v*, then the computation should return zero conductance or infinite resistance

_{po}^{2)}. There are no other hazards; for all

*v*<

_{o}*v*the argument of the square root function is always positive.

_{po}Despite its seeming complexity, the above equation essentially remains the voltage divider equation, just a bit ornamented. Note that if the cable capacitance can be neglected (that is, *R _{p}* is very large and

*v*becomes

_{po}*v*), and the sensor's series impedance is neglected (that is,

_{ref}*Z*is very small), then Equation 16 simplifies to the voltage divider equation we started with (Equation 1),

_{s}### Using other full scale values for A/D conversion

In the above derivation we assumed that a 16-bit A/D converter uses as its reference voltage the reference voltage of the board, *v _{ref}*, which is nominally 1.00 V. The output of the board is then measured as a fraction of that reference voltage and represented as a number in the range of 0-65535.

However, if another voltage measurement method is used that does not
use the Conductivity Wildcard's reference voltage as the reference for
a 16-bit conversion, the result should simply be mapped into the range
in which 2^{16} represents the full-scale reference voltage.

In the case in which the Conductivity Wildcard's reference voltage is
measured with a 16-bit ADC as an integer number of counts *v _{ref'}*, any further measurement taken with the same ADC would thus be scaled by a factor equal to

*2*, which can be accomplished using integer arithmetic by shifting the 16-bit measurement into the upper word of a 32-bit integer, adding half of

^{16}/v_{ref'}*v*for proper rounding, and dividing by

_{ref'}*v*.

_{ref'}## Corrections for nonlinearities

Owing to phase errors when there is appreciable cable capacitance, there are some small nonlinearities in the output of the demodulator. These nonlinearities can be compensated with two correction factors. The first correction accounts for the demodulator’s phase sensitivity, and requires that the value of *R _{ref}* be modified. Instead of simply using a value equal to the onboard resistance, which we'll call

*R*, we use a slightly inflated value based on the actual voltage output of the board, as,

_{o}The parameter, 0.21, was found empirically to produce the least error over a wide measurement range (30 μS to 100 mS) and for many boards. *R _{o}* is the onboard reference resistor of value 1000 ohms. This value of

*R*should then be used in Equation 16 when computing the resistance

_{ref}*R*.

_{m}The second correction removes residual nonlinearities. After the resistance is computed, it is corrected as,

in which the Ln(*R _{m}*) represents the natural logarithm of the computed resistance. This equation reduces integral nonlinearity errors over the resistance range from about ±0.5% to ±0.1%. The coefficients of the polynomial terms were found empirically to best fit the data over 10 boards (20 channels) and a conductance range of 10 μS to 500 mS.

The correction factor of Equation 18, (that is, the quantity that multiplies *R _{m}*) happens to cross unity at

*R*= 10 ohms. Consequently, some computations can be saved when doing a full scale calibration if a value of liquid conductance of 100 mS is used (if

_{m}*K*=1).

## Computing conductance in normal operation

In normal operation, A/D readings are taken to quantify *v _{o}/v_{ref}*. As

*v*is used as the reference voltage for the A/D, the A/D counts are simply divided by the A/D’s full scale counts (65536) to get

_{ref}*v*as a floating point number between 0 and 1.

_{o}/v_{ref}*R _{ref}* is computed using Equation 17 (this needs to be done only once, at the time of tare calibration),

*R*is computed from Equation 16, and it is corrected using Equation 18.

_{m}The liquid conductivity is then computed from its resistance using the cell constant as a proportionality constant, as,

in which *K* is the cell constant in cm^{-1}. If *R _{mc}* is in kohms, σ is in mS/cm. If the instrument’s output will be generally expressed in mS, then it is most convenient to always express

*R*,

_{ref}*R*and

_{m}*R*in kohms.

_{mc}To summarize, we compute the conductivity by implementing Equations 16, 17, 18, and 19, in that order. These equations provide the conductivity in terms of the following:

- The measured voltage,
*v*, as a portion of the A/D converter's reference voltage,_{o}*v*._{ref} - A highly accurate fixed internal reference resistor,
*R*, of 1000 ohms._{o} - And three calibration parameters,
*v*,_{po}/v_{ref}*Z*, and_{s}*K*. Of these,*v*is found by doing a tare (zero scale) calibration with the probe connected but not immersed in solution, and_{po}/v_{ref}*Z*and_{s}*K*are found at the time of manufacture and assigned to the specific probe.

## Computing the calibration coefficients

Before conductances can be computed, the three calibration coefficients must be determined. Here’s how to do it:

### Tare calibration - finding the cable leakage conductance

The calibration coefficient *v _{po}/v_{ref}* represents the influence of the cable capacitance as well as any small stray on-board capacitance. It can be thought of as representing a stray, or leakage, conductance as the AC current leaks through the cable capacitance. So, before placing the probe in a solution there will be a little leakage conductance. Ideally, the leakage conductance should be small, and

*v*should be nearly unity; as the leakage conductance or cable capacitance increases,

_{po}/v_{ref}*v*is reduced. As it will vary from board to board and from cable/probe to cable/probe, we should calibrate it when a new cable/probe is connected to an instrument.

_{po}/v_{ref}To find it, the cable/probe should be installed but not immersed in any solution, and a calibrate button pressed. A measurement is then performed to quantify *v _{o}*. We'll call this value of

*v*with the cable connected but the probe not contacting solution,

_{o}*v*. Because we use

_{po}*v*as the A/D reference voltage, we need only to divide the A/D counts by 65536 to obtain

_{ref}*v*as a floating point number between zero and one. A typical value may be around 0.85 for a long (10 to 12 foot, or 3 m) cable.

_{po}/v_{ref}At this time, *R _{ref}* should be computed using Equation 17.

The *v _{po}/v_{ref}* and

*R*found should be stored in nonvolatile memory so they can be used in subsequent conductance computations. The other calibration coefficients,

_{ref}*Z*and

_{s}*K*, are not used in finding

*v*, so

_{po}/v_{ref}*v*should be the first calibration coefficient computed.

_{po}/v_{ref}### Finding the cell constant, K

The cell constant of the conductivity probe is found by measuring a known solution of moderate conductivity. I suggest a solution of 1 mS. That is small enough that errors caused by an as yet unknown *Z _{s}* are small (an average

*Z*may be used), yet it is in the range of the best accuracy for the instrument.

_{s}Let's call the measured output voltage, *v _{mid}*, (for mid-range). To find

*K*, first assume a

*K*=1 and compute the measured conductivity, σ

_{mid}, from Equations 17, 16, 18, and 19. That is, compute the conductivity as in normal instrument operation, but assuming

*K*=1. Then compare the measured conductivity, σ

_{mid}, with the actual conductivity, σ

_{a}, and compute the true

*K*as,

### Finding the sensor impedance, Zs

*Z _{s}* represents the effective series resistance of an individual sensor probe. Ideally, the sensor electrodes would have a very large microscopic surface area and

*Z*would be zero. But, it’s likely to be several ohms. Since it is in series with the solution being measured, even an infinite conductance solution would be measured as a finite conductance. That is, when measuring high conductance solutions, the measured value would saturate at

_{s}*1/Z*, and go no higher. Readings of conductance less than that would be affected too, but to a lesser degree. Much smaller conductance would not be much affected. For example, if

_{s}*Z*=1 ohm, its inverse is 1 S. When trying to measure a conductance of 1 S, an uncompensated reading would yield ½ S. When trying to measure a much lower conductance, say 1 mS, the reading would be influenced to the extent of only one part in one thousand. Calibration of the probe is then needed to allow it to accurately measure high conductances.

_{s}To find *Z _{s}*, calibrations for

*v*and

_{po}/v_{ref}*K*must first be done. Then the probe is placed in a very conductive solution, and the A/D reading is taken. The conductivity used should be an appreciable fraction of the top end of the instrument's measurement range, that is, near full scale. We'll call the solution conductivity used σ

_{m}(for maximum conductivity), and the result of the A/D reading,

*v*(for output voltage under conditions of maximum conductivity). Using the known

_{mo}*K*and σ

_{m},

*R*is computed using Equation 19 (which we'll call

_{m}*R*), as,

_{mm}In the general case, this value should be run backwards through the correction equation, Equation 18, to produce an "uncorrected" version. However, if a conductance of 100 mS, corresponding to *R _{m}*=10 ohms is used for the full scale calibration, the correction factor (generated by Equation 18) is just unity, so we don't need to "uncorrect" the value.

Then *Z _{s}* is then computed from Equations 17 and 16, as,

and,

For a good probe, *Z _{s}* should be a small value, just an ohm or so. If you are using high surface area electrodes, for example a graphite or platinized probe,

*Z*should be less than 0.1 Ω, but if you are using a microfabricated electrode of small surface area

_{s}*Z*may be greater than 10 Ω.

_{s}## Order of calibrations

As *v _{po}/v_{ref}* doesn’t depend on knowing

*K*or

*Z*, it should be determined first. Its measurement requires plugging in the cable/probe, but no immersion in solution. The computation of

_{s}*K*is not very sensitive to the assumed value of

*Z*, whereas calibrating

_{s}*Z*is sensitive to the value used for

_{s}*K*. Consequently,

*K*should be found before

*Z*.

_{s}*K*is found by calibrating in a moderate conductivity solution, presumably 1 mS/cm. Then

*Z*should be found by measurement in a high conductance solution. As the values of

_{s}*K*and

*Z*are somewhat interdependent, they can be refined by recomputing them from saved values of the Conductivity Wildcard board output from the two calibrations. Use saved outputs so that immersion in the two solutions is not needed again.

_{s}## Summary

The calibration and measurement equations described here are implemented two ways:

- in the Wildcard's software drivers, which you should use if you are mating the Wildcard to an Analog I/O Wildcard and Mosaic Controller, and,
- in this Excel spreadsheet, which you will find helpful if you are using the Wildcard manually.

The following is a step-by-step procedure for calibrating a conductivity probe and using it to measure a solution's conductivity.

### Calibration

Before using the board and your probe for measurement you should first calibrate it. There are three calibration coefficients that fully characterize the board and your probe/electrodes. These are:

*v*(zero scale) – The board's output when the probe is dry (i.e., zero conductance) is used to compensate for stray capacitance on the board in in the sensor cable and probe._{po}*K*(scale factor) – The probe's cell constant characterizes the probe's geometrical factor that relates the solutions conductivity to its measured conductance.*Z*(full scale) – The effective series impedance of the sensor electrodes, probe, cable, and on-board isolation capacitors all affect the board's ability to accurately measure very high conductivity, and so is compensated for by this calibration coefficient._{s}

To calibrate:

Tare calibration – measure

*v*and_{po}*v*_{ref}Attach your probe and electrode assembly to the board, and with the electrode dry, that is, not immersed in an electrolyte, measure the board's output voltage,

*v*, and its reference voltage,_{po}*v*._{ref}*v*is the tare (zero-scale) calibration coefficient._{po}Calculate the corrected value of

*R*using Equation 17. As this correction depends only on_{ref}*v*and doesn't change from measurement to measurement, you can store it with the other calibration coefficients._{po}Determine the cell constant,

*K*Immerse the conductivity probe in a solution of nominally 1 mS/cm conductivity, and measure the board's output voltage,

*v*. Implementing the equations above, as described in Finding the cell constant K, compute the cell constant, or scale-factor calibration coefficient,_{mid}*K*.Full scale conductance calibration – measure

*Z*_{s}Measure

*Z*, the effective series resistance of your sensing electrodes, by placing the probe in an electrolyte solution of the greatest conductance you expect to analyze, and measuring the board's output. Calculate_{s}*Z*using the equations described above in Finding the sensor impedance Zs._{s}*Z*is the full-scale calibration coefficient._{s}

Save these calibration coefficients for use later when measuring the conductance of an unknown solution.

### Measurement

To measure the conductivity of a solution, do the following:

Place the probe into the solution, at the same depth and position as when the calibrations were done, and measure the board's output,

*v*, and its reference voltage,_{o}*v*._{ref}If the corrected

*R*had not been stored at the time of calibration calculate it from Equation 17._{ref}Using Equations 16 above (you may use any of the forms, Equations 16a, 16b, or 16c), calculate the solution resistance,

*R*._{m}Perform the correction to the measured resistance of Equation 18.

Then, convert the resistance into conductivity using Equation 19.

^{7}ohms corresponding to 0.1 μS