# DIY pH Contorller - New and Improved



## DarkCobra (Jun 22, 2004)

Cool, another electronics geek! :thumbsup: 

It appears that the hysteresis loop is wrong.

When the output of the the comparator goes high, the hysteresis circuit tries to raise the setpoint voltage, which would turn the comparator off. When the comparator is off, it tries to lower the setpoint voltage, which would turn the comparator back on.

In short, this is not wired as hysteresis - it's wired as an oscillator! And it would be oscillating like crazy if it were not for the fact that the setpoint voltage regulator is connected to the comparator's negative input *without* a resistor - meaning the LM317 is actively cancelling the effects of your erroneous hysteresis circuit. 

Hysteresis should be on the positive side of the op-amp. Connect LM411 pin 6 to LM339 pin 3 with a resistor. Connect LM339 output to to LM339 pin 3 with a fixed resistor and variable resistor in series. That's a proper hysteresis circuit. The actual hysteresis is determined by the ratio between the resistance of the hysteresis circuit and the resistor on the input from the previous op-amp. This is a good page to see how hysteresis works.

The relay driver could use some cleanup too, but that's not a functional change.


----------



## g8wayg8r (Dec 24, 2003)

Thanks for the advice. It may be that I've got them connected properly but that's doubtful. I'll take another look.

Ok. Here's the scoop. I've checked my wiring and my notes. I started out with the hysteresis on the non-inverting input but it altered the pH reading due to the additional voltage. I changed it to the non-inverting input hoping it would move the set point so that the meter reading would be the same regardless of a high or low state from the LF411. I would work to drive down the pH after a water change but I guess it was ocillating very slowlywhen it reached the set point. Oh well. Maybe I could could invert the output through another op amp and get what I want. That's another day.

The 1K pull-up resistor on the out put of the LM339 gives me almost 12V. I've got a 220ohm reisistor connecting pin 6 of the LF411 and pin 3 of the LM339. I'm using around 500K for the feedback and that gives me about 0.1 volts hysteresis. It doesn't make much sense given the ratio. I've got a decent Fluke meter - not a $10 home utility type - so I'll go with the volts for now.


----------



## g8wayg8r (Dec 24, 2003)

Ok, I've got it working in a 0.1 pH range with the hysteresis on the non-inverting input. I still don't understand the apparant lack of control with the hysteresis voltage but it's working and I continue to experiment with the ratios.


----------



## DarkCobra (Jun 22, 2004)

g8wayg8r said:


> I've checked my wiring and my notes.


Notes! Wow, you're more organized than me. 



g8wayg8r said:


> I started out with the hysteresis on the non-inverting input but it altered the pH reading due to the additional voltage.


Connect the selector switch for the display directly to the output of the LF411. The new resistor between the LF411 and the LM339 + input will shield it from the hysteresis voltage. 220 ohms sounds low, try 1k as a starting point.



g8wayg8r said:


> The 1K pull-up resistor on the out put of the LM339 gives me almost 12V.


If you still have a pull-up resistor on the hysteresis circuit/LM339 output, remove it. That will throw the ratio for sure.


----------



## g8wayg8r (Dec 24, 2003)

Ok. I'm starting anew again using an quad op-amp as a comparator circuit because the voltages from the LM339 are driving me nuts. I've feed the output from the pH meter and the set-point reference into seperate op-amps that are wired as a voltage follower. Both go into another op amp that does the controlling. The pH goes into the inverting input and the set-point into the non-inverting input with positive feedback to give it some hysteresis. That output is inverted to turn the transistor on when the pH is high and off when it low. The transistor circuit is rather simple and I have only had success using either a power transistor or a reed selonoid as an emitter follower. I've also noticed that I can clamp the output using two zenor diodes and it has a profound effect on the reading and hysteresis. So, I've not figured out how to make the controller and the meter independent of the power handling portion of the circuit. Sometimes I wonder if I would have done better starting with something programable like BasicStamps. Oh well. The good new is, however, is that it appears to work. The best I can do now is plus and minus 0.03 pH units.

I think I'm going to stick with this basic set-up and work with it from here.

Cobra: I really appreciate the help. I can go months and learn less. Anyway, I'm still not certain about the panel meter wiring. Maybe I'm not clear. I've got an on-on two position switch. One wire is attached on the non-inverting input and the other to the inverting input. Another wire goes to the panel meter to read the voltage. I know somthing is missing.


----------



## DarkCobra (Jun 22, 2004)

g8wayg8r said:


> I've feed the output from the pH meter and the set-point reference into seperate op-amps that are wired as a voltage follower.


Probably unnecessary, but as long as it works and you're comfortable with it, go with it. I see no functional problems in your arrangement.



g8wayg8r said:


> That output is inverted to turn the transistor on when the pH is high and off when it low.


What's the purpose of R15/R16?



g8wayg8r said:


> I've also noticed that I can clamp the output using two zenor diodes and it has a profound effect on the reading and hysteresis. So, I've not figured out how to make the controller and the meter independent of the power handling portion of the circuit.


I'm not sure exactly where you're placing the zeners, or the value. Let me know and maybe I can explain why this is causing a problem.



g8wayg8r said:


> Sometimes I wonder if I would have done better starting with something programable like BasicStamps.


It wouldn't have simplified much. Although I admit, I have a secret desire to see a cheap DIY pH meter with USB interface. 



g8wayg8r said:


> Cobra: I really appreciate the help. I can go months and learn less. Anyway, I'm still not certain about the panel meter wiring. Maybe I'm not clear. I've got an on-on two position switch. One wire is attached on the non-inverting input and the other to the inverting input. Another wire goes to the panel meter to read the voltage. I know somthing is missing.


No problem on the help.

If it's working, nothing is missing.  Meter input attached to center switch terminal, inverting/non-inverting inputs attached to outer switch terminals, and that's it.

Other notes: D3 in the diagram is backwards. D1 may be backwards also, but I'm not familiar with your use of an LED as a voltage-control device, so I'm not sure.


----------



## g8wayg8r (Dec 24, 2003)

1. The voltage followers are being used because they are there. I guess I could just use a singel op amp and wire a PNP transistor to accomplish the same thing as the quad amp and the NPN transistor. Transistors! I get so confused with them at times.

2. The R15 and R16 are there. It was like they were there and it worked and they were easier to use than cutting another wire. It's not like you need a bunch of volts to turn on a transistor. 

3. I tried to clamp the voltage between the 4.7K resistor and the last op amp that inverts the voltage. 

4. The LED do light up so I guess I have them drawn in like a zenor diode. In a way, that's how I'm using them. 

I've got to rethink one and two above. No sense in over building the circuit.


----------



## berler_d (Oct 26, 2006)

Hi All,
I'm new in this forum, I'v just looked around and afound this interesting post.


g8wayg8r: what kind of electronic editor did you use.
Do you have a lateset working update of the monitor ?

I want to try and build one.

Thanks,


----------



## g8wayg8r (Dec 24, 2003)

Here the old controller and a circuit of a barebones meter I'll try to design a better controller around buy nulling out the 20 millivolts from the 20 pico amps of current from the 1 gigaohm probe.


----------



## intermediate_noob (Jan 23, 2007)

Don't mean to take any fun out of this project, but here is a complete circuit, parts and step by step to create it. Have not had a chance to do it yet, but think it would be pretty cool.

http://www.66pacific.com/ph/ph_1.htm


----------



## g8wayg8r (Dec 24, 2003)

The purpose is never to save money or time. This was a learning exercise for me. I now have a spreadsheet that I can input resistor values and make all of my gain and summing addition calculations.

I assembled and had the project that guy on yoru link based his design on. The advantage of his approach is that it gives you the correct ph on the display with no negative DC. I'm at the amp part of the circuit now and I'm having trouble with the reference ground working for some reason. I have no clue why. I've also discovered the reason why a Fluke RMS meter cost a bunch more than the little $10 POS multimeter I bought online. That meter and an oscilloscope really opened my eyes.


----------

