A pH Measurement & Control System

for the Planted Aquarium

People all over the world many without a lot of electronics experience have built this aquarium pH measurement and control circuit both cheaply and easily.

View the latest latest changes (May 8, 1999)

Introduction

Planted aquarium enthusiasts have long known that carbon dioxide (CO2) is the limiting nutrient in their tanks, and that tanks with CO2 supplementation can have aquatic plant growth that borders on the miraculous.  But adding CO2 means tracking its concentration — too low an addition rate or excessive water movement can result in insufficient CO2 levels, whereas too much CO2 can stress or even kill fish.   A pH measurement and control system is the best way to know and control CO2 and pH levels, but for many people the equipment required has been prohibitively expensive.

The answer to this dilemma is to build your own pH measurement and control system, something which is within the budget and skill of many aquarists.  This pH measurement and control system has been made as simple and straightforward as possible.  The idea was to make it an fun and easy project, even for people without a lot of of electronics experience (but see the disclaimer at the end of this page).  It was was designed to be reliable and forgiving.  For example, electrical "noise" from the aquarium lights and heaters (a common problem) is filtered out in this circuit so that even an input with a lot of AC noise will give good results.  Finally (and importantly for many) this circuit was designed using inexpensive and easy-to-find parts — everything for this project is available from the local Radio Shack store.  (The one exception is the pH probe, a Broadly-James "Silver," which is available for less than $40 from Pet Warehouse.)

Getting Started

You can print a copy of this project's complete schematic diagram if you want to have it available as you read the explanatory text.

There is a parts list as well.  Note that there aren't many parts:  an inexpensive pH probe, two op amp ICs, a voltage regulator IC, a power supply, some sort of display (a voltmeter or panel display), and some passive components (resistors and capacitors).
 

Overview & Theory of Operation

A pH electrode works like a small battery.   When placed in the aquarium, the electrode puts out 60 millivolts (mV) for each pH unit that the aquarium water is above or below neutral (pH 7).  For example, the pH electrode puts out 0 volts when immersed in water that is pH 7, 60 mV at pH 6, 120 mV at pH 5, and so on.  The polarity reverses if the water's is above pH 7, so the electrode puts out  -60 mV at pH 8,  -120 mV at pH 9, and so on.   (For a more detailed discussion of pH and its measurement please see Omega Engineering's pH Primer and pH Electrode Basics.)  Fundamentally, all that's required to measure pH is to measure this electrode voltage.  The problem is that the pH electrode has a "source impedance" of about a billion ohms — it's as if you were trying to measure the voltage from a tiny 60 mV battery that had a billion-ohm resistor in series with it.  Because of this high source impedance, simply measuring the pH electrode voltage with a common voltmeter is out of the question.  Fortunately, this high source impedance signal isn't a problem for the inexpensive operational amplifier (op amp) integrated circuits (ICs) that are now cheaply and readily available, like the Texas Instruments TL082 which is the heart of this circuit.  When the pH electrode's output is connected to the TL082 op amp, it is simultaneously converted to a low source impedance signal and amplified about 17 times.  After passing through this stage a 60 mV signal equals one volt (17 * .06 = 1), so a change of one pH unit produces a change of one volt at the circuit output.

Because this circuit uses a cheap, easy-to-find DC power supply that doesn't provide plus and minus voltages plus ground, an artificial "reference ground" must be developed.  (This is covered in more detail below.)  Because this reference ground is set to be exactly 7 volts above the power supply negative voltage, the circuit output is 7.00 volts with a pH 7 input.  The only other difficulty is that the voltage from the pH probe gets more negative (that is, lower) as the pH gets higher.  By inverting the signal in the next stage, it's turned right-way-around so the voltages get smaller as pH gets lower, and a pH 6 solution gives an output of 6 volts, not 8.  This output can then be read with either a digital voltmeter or a digital panel display, the voltage being identical to the aquarium pH.

For the controller circuit, the output voltage is compared with a user-set reference voltage, the "turn on the CO2" pH-level.  A comparator circuit accomplishes this, and turns on both a light and a valve-actuating transistor at the appropriate, user-defined pH.

One limitation of this circuit is that it will only read pHs in the range of about 3.5 to 10.5.  This is a far broader range than any aquarist will ever encounter in the aquarium, and it still allows the use of the standard pH 4 or pH 10 electrode calibration solutions.

Fundamentals

This is not a complicated or subtle circuit.  It should be easy to build.  Those who don't have a lot of experience with electronic circuit assembly would do well to build the circuit in the sequence described below.  Build the regulator first.  Look at its output with a voltmeter and adjust it to the appropriate level.  If there's a problem at this point, it will be  easily recognized and fixed.  Build the reference ground circuitry and set it to 7.00 volts.  Proceed to the amplifier, and so on in the sequence given.  By proceeding methodically and sequentially through the circuit, much confusion and difficulty can be avoided.

There is really only one critical area in the whole circuit, and that is the connection of the electrode to the amplifier.  Keep the leads in this area as short and direct as possible to avoid problems.  (This is discussed in detail below.)

The rest of the circuit is non-critical.  Do try to keep wiring runs as short and direct as possible, especially around the op amp inputs.  Careful layout makes assembly, testing, and troubleshooting much easier.

An old trick to avoid problems with voltage drops and noise on the supply lines is to use a "star ground," with the separate ground wires all linking straight back to the supply, not daisy-chained across the circuit board.  This "star" approach can be used on all three of the supply lines here:  Vreg (the + supply), the - supply, and the reference ground.  Separate, direct wiring runs from the supply to each IC, voltage divider, and so on may be overkill, but practically guarantees problem-free operation.  If you're not confident about the subtleties of wiring, please consider using the star technique.  (A look at Morrison's classic book, Grounding and Shielding Techniques, may also be illuminating.)

Detailed Discussion:  Layout, Wiring, Assembly, and Operation

If you have not done so already, please print the complete schematic diagram for reference before proceeding.  To simplify the circuit discussion, the schematic has been cut into five pieces for the discussion that follows.

1. Voltage Regulator and 7-volt Reference Ground
2. pH Probe Input and Amplifier
3. Inverter and pH Display
4. Comparator
5. Valve Actuator

Voltage Regulator and 7-volt Ground Reference

The 12-volt DC power supply listed in the parts list is not voltage-regulated, so the first task is to put its output through a LM317 IC voltage regulator.  The unloaded output of the specified supply is about 15 volts.  This voltage drops under load (to about 13.5 volts at half its rated 500mA load), but setting the LM317 regulator's output to 11.5 volts allows it plenty of head room.  This 11.5 "Vreg" regulated voltage will let the op amp outputs get up to about 10.6 volts.  (It is this 10.6 volt maximum output voltage from the op amp outputs that limits the pH range that can this circuit can measure).  The 4.7k resistor R3, in parallel with the 15-turn trimmer R2, makes it easier to set the regulated voltage to the exact value.

This section of the schematic diagram also shows the 7-volt reference ground section.  As was noted in the overview, this design uses a cheap, readily available single voltage supply.  Since this supply doesn't have the usual ground, plus, and minus voltages used in most op amp circuits,  a "reference ground" must be generated.   Reference grounds are  usually set to one half the supply voltage, so you might expect the reference ground voltage here to be set at 5.75 volts (11.5 / 2 = 5.75).  But as was mentioned in the overview, the reference ground here has been set to 7.00 volts, so a zero input from the probe (neutral pH, pH 7.00) gives an output voltage of 7.00 volts.

R300 is simply a voltage divider used to set the reference ground level.  Its output is buffered by a unity gain op amp, U300A.  The 100 ohm resistor, R302, promotes circuit stability by isolating the op amp output from load circuit capacitance (including the considerable capacitance of the pH probe cable to which it is connected).   The output voltage is fed back to the op amp inverting input via R301.  AC gain is cut by feedback capacitor C303.  C301 and C302 bypass noise.  (Further discussion of generating reference grounds in this way can be found in the Horowitz and Hill's The Art of Electronics.)

pH Probe Input and Amplifier

This is the only critical part of the entire circuit — the wiring from the pH electrode BNC connector to pin 5 of U300B must be as short and direct as possible.  The reason for this is that this is an extremely high impedance point, and any extra wire length here will act as a very effective antenna,  picking up any electrical noise in the area.  If the wiring in this area is kept short, there will be no problems.  In my controller, the IC butts up against the front panel BNC jack so that there is only about 1/4 inch of lead length between the BNC connector and the IC.  Note that the pH probe's shield connection is not connected to the minus supply, but to the reference ground.  Since the BNC jack will be electrically common with the case, this means that the case (if metal) will be at the reference ground potential as well.  (A metal case is strongly recommended to help shield  out interference.)

C352, combined with the probe input resistance, forms a low-pass filter at the amplifier input.  It will prevent even a sizable amount of electrical noise at the input from getting into the circuit and causing trouble.  (Additional components yet to be discussed also help in this regard.)   The 3 dB point for this capacitor and the probe resistance is 1/(6.28*R*C), which is less than 1 Hz.  The tradeoff is that the RC time constant (the product of the the capacitance and the gigaohm source resistance) is about 1 second.  This means it will take a few seconds for the capacitor to charge when there's a change in pH, which will cause a noticeable settling time during calibration.  If you feel you don't need C352, please feel free not to use it.  If you're not sure, please include it, as it is capable of converting a very noisy input signal into a quiet one.  Since this is a very high impedance part of the circuit, capacitor leakage here could be a problem.  Usually, one uses low leakage (for example, polystyrene) capacitors at points like this.  In practice, the garden-variety ceramic Radio Shack capacitor listed in the parts list works well, and is what is used in my controller.  This ends the discussion of the circuit's only critical area.  Keep the lead lengths here short and direct to prevent noise pickup and no problems should be encountered.

C351 is a simple bypass capacitor.  Ideally, it should run directly between pins 4 and 8 to bypass electrical supply noise to ground.  C350 is an nonpolarized electrolytic capacitor.  It, like C352, is not strictly necessary, but exists to cut down the AC gain.  If any 60 Hz noise gets past C352, C350 will help to keep it from being amplified to any significant extent.  Again, unless you are sure you don't need it, please include it.

R352 is set to about 8500 ohms, giving a circuit gain of about 17.  This is what is sometimes referred to as the "slope" adjustment in a pH circuit.

R354, R351, R355, and R353 are the offset nulling resistors.  This offset array compensates for the input offset voltage of the op amp, and for the error voltage caused by the approximately 20 picoamp input current.  (20 pA * 1gigaohm = 20 millivolts, which would be amplified to about 0.3 volts (0.3 pH error) if it wasn't canceled here.  During calibration, R354 will be adjusted to give a reading of 7.00 when the probe is in the pH 7 calibration buffer.  (Potentiometer R354 is sometimes referred to as the "Zero" adjustment in a pH circuit.)   R352 and R354 are the two potentiometers that will have to be adjusted at calibration time, so make them easily accessible.  (On my controller, all the 15-turn potentiometers can be reached through holes in the front panel.)    Further discussion of this sort of nulling arrangement can be found in The IC Op Amp Cookbook.
 
 

Inverter and pH Display

The output of the amplifier stage is 1 volt per pH unit, but it is inverted, so a pH of 6 produces an 8 volt output, and a pH of 4 gives 10 volts out.  The inverter's sole task is to change polarity of the amplifier's signal before it is sent to the pH display so that the pH reads correctly.  Note that the non-inverting input, pin 5, is not connected to the minus supply but to the reference ground.  47k resistors were used to keep the loading on the amplifier stage light to help limit heating and drift.   Another 10 uF unpolarized capacitor, C400, has been included here to reduce noise.  C401 is a bypass capacitor.  It's leads should be short, and it should be kept close to pins 8 and 4.

Comparator

The signal from the amplifier is fed to the comparator via R450 and C450.  These two components form a simple low pass RC filter with a 3 dB point of about 3 Hz.  Again, these noise-reducing components are optional but recommended.  Potentiometer R451 sets the voltage at which the CO2 turns on and off.   Since this comparator gets the uninverted signal straight from the amplifier, this voltage must be set to (for example) 7.2 to get a trip point of pH 6.8.

As was mentioned earlier, there is 0.1 volt of hysteresis here to prevent the comparator from chattering on and off at the set point.  If the CO2 is set to turn on at pH 6.8, it will not turn off again until the pH drops to 6.7.  This type of circuit is described in detail in both the IC Op Amp Cookbook and The Art of Electronics.  Briefly, the hysteresis equals the output swing of the op amp (about 10.6 volts) times the parallel value of the two sides of voltage divider potentiometer R451, divided by R452.  For example, if R451 is set to 6300 and 3700 ohms for a divider voltage of 7.2, the parallel resistance value is 2330.  This value is then divided by that of R452: 2320/220,000 = 0.0106.   The op amp's output swing of 10.6 volts times 0.0106 gives a hysteresis of 0.1 volt.  This value shifts little over the range of pH's aquarists are likely to use.  Doing the preceding calculations isn't necessary to build the circuit, of course.  The circuit designed by Jim Hurley (see the link at the bottom of the page) uses a different and somewhat easier to understand approach at this stage at the cost of merely another IC.

C451 is a speedup capacitor that helps the comparator's output to "snap around" once the output starts to change.

R500 is an isolation resistor, included in case there is a long wire run to the next stage (the actuator).  To be effective, it should be kept close to pin 1 of U400A.

D450 and R453 are the front panel "CO2 is On" light.  Note that if this LED flickers near the turn-on / turn-off point, it is evidence of noise on the signal.  Chances are the circuit will still work fine, but if the noise-reducing circuitry discussed earlier has been left out and this symptom is seen, it should be taken as warning to go ahead and install it.

The 22k/10k divider (R00 & R00) is an optional takeoff for those using my pumped CO2 system.  (The divider output goes to pin 4 of the pump controller 555, which must be disconnected from Vcc.)  You don't need to include these two resistors if you're not using the pumped system.  (Conversely, those using the pumped system can skip the next section.)

Valve Actuator

The last stage is simply a power MOSFET transistor that turns the solenoid valve on and off.  This circuit is simplicity itself:  the unregulated 12 volt (or whatever) supply is connected to the coil of the solenoid valve, which in turn is connected to the transistor drain.  The transistor gate is connected the comparator output.   The value of R501 is not at all critical; it is simply there to keep the Gate/Source resistance at a reasonably low level and to provide a light load for the comparator.  The diode across the coil is standard practice; it prevents the coil's collapsing magnetic field from generating a big voltage spike that damages and deranges other circuitry.

If you have never used a MOSFET transistor before, here's a word of caution:  Leave the conductive foam it comes with in place until you are ready to solder the transistor in place.  Better yet, wind a piece of fine wire around the three leads of the transistor, shorting them together before you remove the foam.  Then leave the wire in place, pushed up against the transistor body, until the MOSFET is fully soldered in place.  (But remember to remove the wire when you are done soldering!)  MOSFETS are wonderful devices, but they really do get blown by static electricity.  Keeping the pins shorted until the transistor is safely soldered into the circuit will prevent this from happening.

Final Setup and Calibration

    1. This circuit has been designed to be able to function well even with a lot of electrical interference from lights and heaters.  Running a ground wire from the 7-volt reference ground (the case, if you have used a metal case) to a stainless steel bolt suspended in the tank water will help to reduce interference considerably, and is recommended.  (Secure the copper wire to the bolt by pinching it between stainless steel nuts.  (I used a 1/4 inch diameter, 3-inch long bolt.)  If your tank already has a ground probe, connect to that.
    2. Adjust R2 to set the LM317 voltage regulator output to 11.5 volts.
    3. Adjust R300 to set the reference ground voltage to 7.00 volts (measured at the side of R302 farthest from U300A).
    4. Place the probe in a sample of tank-temperature pH 7 calibration buffer.  Adjust the R354 "Zero" potentiometer for a reading of 7.00 at the pH display.  (Some tweaking of R352 may be necessary the first time.)
    5. Rinse the probe, then gently blot the tip with a tissue to prevent solution carryover.  Immerse the probe in pH 4 buffer.  Adjust R352 ("Slope") for a reading of pH 4.00  (You can use pH 10 buffer here instead of pH 4, but don't; it picks up CO2 from the air which lowers its pH value, and is therefore less stable.)
    Rinse the probe and blot, repeating steps 3 and 4 until no further adjustments are necessary.   A few repetitions should be sufficient.
    6. When the tank pH is at the correct level, adjust R451 to set the CO2 On/Off point .

Final Thoughts and Cautions

Ideally, the CO2 input level will be set so that even if for some reason the electronic controller turns the CO2 on all the time, the pH will only fall to a non-lethal level for the tank's inhabitants.  In my setup, the pH hovers around 6.7.  If the CO2 is on non-stop, the pH will only fall to 6.5.

Be careful if you have easily accessible front panel controls.  I have a front panel bypass switch that allows me to turn the CO2 to constant "on."  I accidentally hit this switch one day and couldn't figure out why the pH had dropped.  Knobs that are easily bumped into a wrong setting present a similar hazard.

pH Calibration buffers are available from Pet Warehouse in convenient one-time-use foil packets (though it appears that these buffers can be stored for some time in sealed plastic film canisters).  I got larger bottles of calibration buffer from the local hydroponics shop for only $5.00 each.

The pH probe should be kept away from light to prevent algae growth.  Mine sits in a gray perforated PVC tube at the top corner of the tank, inside of which is a sleeve of plastic screen door screening to help keep particulates off of it.  Readings will be more accurate if there is some water flow in the vicinity of the probe.  The probe should be cleaned and recalibrated periodically.  I use a soft artist's paint brush to gently clean the delicate probe tip at each water change.  Don't let the probe tip dry out!  This is most likely to happen at water changes.

ANY surface agitation of the aquarium's water will cause a surprisingly large amount of CO2 to be lost.  If you can't get the aquarium's pH down, or if it seems like it's taking a lot of CO2 to do it, try reducing the surface agitation.  Conversely, if you get the surface agitation down to almost nothing (by returning filter water to the tank bottom, for example), CO2 won't off-gas at lights out, and the pH may fall more than you want it to during the night.  Oxygen exchange can suffer with low surface water agitation, which can be a problem with heavily stocked tanks, especially in the morning just before the lights come on.  My setup shuts off CO2 delivery at lights out, and the pH still falls a little.  It's best to watch the tank carefully when CO2 is first being used.

READ THIS DISCLAIMER:  This circuit uses potentially deadly levels of voltage and current.  BE CAREFUL!  If you are not sure of what you are doing, particularly when it comes to circuitry powered by the AC mains, IT IS YOUR RESPONSIBILITY to get help or leave this project for another day.  Don't kill yourself.  Don't build sloppy circuits that may kill or injure others, start fires, or otherwise generate bad vibes.  This information is made available as a service to any person who finds it of interest.  Because of possible variances in the quality and condition of materials and workmanship used by the builder, any and all responsibility for the safe and proper functioning of this circuitry is disclaimed.
 

Links for more information:

Jim Hurley's pH measurement and control system at the Krib.  Hurley's circuit was the inspiration for this one.
Omega Engineering's pH primer  A good overview of  pH  and its measurement.
Omega Engineering's pH electrode basics  Brief overview of pH probes — how they work and how to take care of them.  Worth a look.
Good pH probe info at the Krib, (the ultimate aquarist information source).
National's LM 317 Voltage Regulator Page  All about the voltage regulator used in this project.
The Texas Instruments Home Page   Search for "TL082" for information on the op-amps used here (No direct link available :(
Aquatic Concepts  George Booth's site has lots of CO2 & planted tank information.
People who are new to electronics, and those whose electronic skills have grown rusty, can learn a lot from Forrest Mims' Getting Started in Electronics, which is available at Radio Shack stores for $5.00.  Don't let its simple format fool you; there's a lot of good information there (as well as fun and instructive projects).  For the slightly more experienced or ambitious, Horowitz and Hill's The Art of Electronics ($50) is a wonderful once-over-lightly of the world of electronics theory and practice.  Also recommended:  The IC Op Amp Cookbook.

Comments, questions, suggestions, and criticisms are welcome.  I am especially interested in feedback (and digital photos!) from people who have built the circuit.  Please send them to Sherman Lovell, lovell at drizzle dot com.

 <--- BACK to the Swim Fishy Swim index page.

Copyright (c) 1999, Sherman Lovell
1