PH Monitor

markdem

Member
Hi all, i am tring to read a voltage coming out of a cheap digital PH meter. The meter have op amps to boost the voltage coming out of the probe to 0-3 volts. I have tried to just connect this up to a analog pin on a picaxe, and reaf the value, but the value is just garbage. Somtimes it is a 0, sotims it is at 255, and the rest of the time it is some random number. I have checke dthe output from the probe, and it is very still. The only strage thing i am doing is using the PH probes battreys (3v) to power the probe, and 5v to power the picaxe. The negitive rails are not the same. Will this be the problem?? I am just not sure of how to connect the probe directly to the picaxe.

I have cheaked the picaxe to make sure it is OK with a POT, and found it to be fine, so i am also thinking thatthe code is ok.

Can anyone think of anything i can try??

Thanks you

Mark
 

MartinM57

Moderator
Different power supplies are fine, but you must connect the earths/negatives together to provide a zero volt reference point for the ADC on the PICAXE...
 

Jeremy Leach

Senior Member
Are you able to confirm the voltage out of the PH device with a multimeter? You've got to connect one of the supplies together - and yes the negative is more conventional.

I would have thought the Op amp output from the PH device would have provided enough current to drive the PicAxe ADC input - so not sure.
 

markdem

Member
Hi All, thanks for you help so far. I have now connected the gounds together. Now my adc values are a bit better. The value will go up to about 55, then back down to 0, and then back up. Is there any chance that the op amp is not boosting the current up for the picaxe??

Thanks, Mark
 

Jeremy Leach

Senior Member
55 represents about 1 volt, with a 5volt PicAxe supply. So something strange is going on. It would be good to confirm that you really are getting 0-3V output from your PH device while it's unconnected from the PicAxe input.
 

BeanieBots

Moderator
A reading of 55 sounds a little low but because the pH meter has a lower supply rail than the PICAXE, it will always be less than the 255 maximum possible. The simplest way to increase the reading would be to reduce the PICAXE supply voltgage. Short of that, you will have to use another op-amp to get more gain.
Using readadc10 will increase the resolution and give you a bigger number to work with for the same input voltage but you will need to take precautions in your code in case the value exceeds 255.
 

Jeremy Leach

Senior Member
Sorry, 55 is a perfectly legitimate reading - it obviously depends on the PH being measured. What is strange though is how the reading jumps between 55 and 0.
 

markdem

Member
Thanks all again. I have now confurmed the voltage coming out of the probe to be the same even witht he picaxe not connected.

I agree the the adc value will never go very high, and i will use a 10 bit value after i finnish testing. One other thing to notice is that at a higher PH, therefore lower output from the probe, the reading will not go to 0. It will read what i expect to see. It is only a problem when the output voltage is high. Could it be that i am draning to much currert from the op amp, and would it help if i had two?

Thanks again, Mark
 

BeanieBots

Moderator
Should it actually go to 0v for that pH value?
The current drawn by a PICAXE analog input is extremely small and will have no affect on an op-amp output. What is probably happening is that the pH buffer op-amp is powered from a single rail supply and CANNOT drive all the way down to 0v.
 

markdem

Member
Hi All, sorry, i sould clear some thing up. I take a ADC sample every 1 second. When the PH is up near 7, the output value is about 135. This is fine, but every 5th or 6th sample, the value will go down to about half, then the next sample it will go down to 0, then back up to what it should be. The water sample does not change. The voltage on the probe output is also not changing. This does not happen when the PH goes up. The voltage on the probe goes down as it is inverted, but the adc value will now stay at the expected value, which is about 64.

Has anyone ever seen anything like this??

Thanks All
 

BeanieBots

Moderator
Interesting!
Are those results repeatable or is it random?
Are you using batteries or a mains power supply?

Maybe you should post your code even if just to eliminate it.
 

Jeremy Leach

Senior Member
If you get a stable ADC reading when you use a Pot, but an unstable reading when you connect your PH device, it would suggest the problem lies in your PH device.

It could be that the PH sensor doesn't give stable readings - although I wouldn't have thought so. Could it be an intermittent connection ?
 

pramac

New Member
Hi markdem, i haven't visited the forum in months and just thought i'd look in to see whats happening and was very pleased to see this thread. I've been trying to do this very thing on and off for probably close to 3 years now with exactly the same results. I bought a pH probe from a scientific supply company and built the op-amp circuit which amplifies the voltage from the probe so it corresponds to the ph level (0v for ph0, and +7v for ph7). Now like yours the voltage is stable on a multi-meter but hook it up to a picaxe (through a voltage divider) and it's just all over the place. I haven't come to any solutions so i hope we can have some luck here in the forums.
 

Jeremy Leach

Senior Member
A unity gain buffer, using a suitable op amp, would ensure that the output from the PH device would drive the ADC without any problems - but I wouldn't have thought this was necessary as you already describe an op amp stage.
 

nbw

Senior Member
I have seen a similar thing, even when putting a multimeter across the BNC plug of a pH meter / probe. You will find the values jump around. I found that as you watch the values, the swings become much less pronounced. After about 40 - 50 seconds, the multimeter reads a steady mV, and the pH meter has stopped jumping around. Plotting a graph of the steady pH values and steady mV readings shows a nice correlation.

No idea why it does this, maybe someone has some ideas to explain it / counteract it?
 

premelec

Senior Member
It seems like the PH meter could be putting out pulsed voltages rather than steady - if possible put an oscilloscope on he PH meter output to see if the voltage swings around.

Another 'solution' would be a sample hold circuit or simply try a capacitor on the PH meter output - .1 to 1 uF see if it calms down... good luck...
 

markdem

Member
Thanks you all for you rinput. I am glad to hear other people are having the same problems, and not just me. At lease it rules out problems with PIC.

I was thinking about putting some filter caps in to smoth out the output, but would do anything to the ph value reading?

Thanks, Mark
 

premelec

Senior Member
Probably not... what I had in mind in my earlier post was that there could be a glitch when the reading updates to the meter output port - since this is asynchronous with the PICAXE it could occassionally try teading on a glitch point -

Two things: Read the PH meter manual on its output characteristics.

Try software averaging readings -
symbol PH = b1
symbol PHSUM = w2
input 1 'get ready for READADC

MORE:
FOR b0 = 1 to 100
READADC 1,PH 'assuming READADC is on pin 1
PHSUM = PH + PHSUM
NEXT

PH = PHSUM/100
DEBUG PH 'display average of 100 reads
PHSUM = 0 'reset accumulator var.
GOTO MORE

If this gives a more consistent read then it's likely occasional glitch - depending on the duty cycle of the glitches [percent time they occur] should be more accurate....
 

Jeremy Leach

Senior Member
Or use a moving averaging method in software to smooth out fluctuations. Along the lines of:

NewSum = LastSum + NewReading - OldestReading
NewAv = NewSum/AveragedOver

Where AveragedOver is the number of samples to perform the moving average over.

Need to store array of samples in RAM. Need pointer to most recent value. When a 'NewReading' is stored, the value it replaces is 'OldestReading'.

Must keep the overall Sum below the limits of a word variable (if you want to avoid tricky maths).

Edited by - Jeremy Leach on 12/20/2005 6:56:11 AM
 

BeanieBots

Moderator
There is a published circuit which has appeared on this forum before which might be the culprit. A pH probe has an EXTREMELY high output impedance and in most cases cannot be measured directly with a multimeter because even the high impedance of a DVM will load its output. The circuit used to buffer the probe uses a special op-amp as a buffer. Such op-amps do not have internal frequency compensation and can easily fall into high frequency oscillation.
Try adding capacitive negative feedback to the buffer amp. (about 10nF between output and inverting input). If it is not obvious where to put the cap, then try adding about 100nF across the PICAXE input and feed the pH output into it via a resistor of around 2k.
I tried to find the thread on this forum where a link to the circuit had been published but was unsuccessful.
 

pramac

New Member
http://www.thekrib.com/Plants/CO2/hurley-schemat.gif

This is the circuit I have tried, except after U2 I invert it to a positive value with an op-amp (no gain) then through a voltage divider then to the picaxe.

This is the one BeanieBots will be talking about, he gave me some advise about it some time ago but I haven't had the time to get back to it.
 

markdem

Member
Hi All, i have now built the op amp device as stated, and it is working OK. It would still be nice to know why it did not work before

Thank you all for your help everone

Mark
 

BeanieBots

Moderator
markdem, if you can be more specific about what changes you made then we can probably determine the reason.
Was it the circuit posted by pramac?
Did you need the extra cap shown?
Was it simply a further op-amp buffer?
 

markdem

Member
Hi all, the http://www.thekrib.com circuit is the one that works. The only thing that may be diffrent in your case maybe that i am using one of those cheap PH probes from ebay. It has a op amp on the sensor it self, but i can't see how it is connected to the probe, so i am not to sure how it works.

Hope this helps you all.

Mark
 

nbw

Senior Member
hi mark, did you build all of the circuit in the thekrib schematic, or a cut-down version? It seems like a heck of a lot just to get a sensible reading out of the pH probe....
 

nbw

Senior Member
I'm thinking perhaps the first stage with U1 and U2 might be enough to get a sensible, calm reading of around 53mV per unit of pH. I don't require the LM337 parts to calibrate the probe, nor the solenoid actuation.

I just want a stable reading to see on a multimeter if required, but mainly as an input to a PICAXE. Because the useful pH range for me is 7 to 9, I could pass the output through a x10 op-amp to make the most of the PICAXE's 10-bit ADC 1024 step range. Plus some trickies to ensure that I can use more of the resulting 3.5 to 4.8V inputs.

Although... LF411s are real expensive, and I see LF357s are obsolete. Can anyone recommend or suggest alternatives that would work as / just about as well?

p.s. thought for the day: A PICAXE pin that can act as either an input or an output should be called an inpout......
 
Top