Shop OBEX P1 Docs P2 Docs Learn Events
ph meter circuit — Parallax Forums

ph meter circuit

Greg LaPollaGreg LaPolla Posts: 323
edited 2009-08-08 17:56 in General Discussion
I am using the attached circuit. This is from Tracy Allens website. I have the circuit on a breadboard but my readings are not what they should be. One of the components has been discontinued. The CA3160 is no longer available according to digikey so I purchased a CA3140. The specs are different so I am not sure how to compensate for them. My other issue is with the LM385-1.2. How should the FB pin be connected in this case. Currently FB is connected back to the - pin.

Differences between the 3140 and 3160 are as follows:

slew rate on the 3160 is 10V/us
slew rate on the 3140 is 9V/us

input bias on the 3160 is 5Pa
input bias on the 3140 is 10Pa

voltage input offset on the 3160 is 6000uV
voltage input offset on the 3140 is 2000uV

Also I an using 220K resistors because I don't have any 221K's. I dont think that would make as big a difference as I am seeing.

Placing the probe in a glass of water (ph is 7.01 according to my bench meter) I get a reading of .84 volts, that is the highest I can get by adjusting rt1. I should be able to adjust to 1 volt.

Is this wrong because of the resistors or the differences between the op amps?

(Hopefully Tracy is lurking about smile.gif)
510 x 276 - 7K
«1

Comments

  • kwinnkwinn Posts: 8,697
    edited 2009-07-24 18:39
    Greg, the input op-amp is essentially a high impedance gain of 1 or 2 circuit, so having a 220K instead of 221K resistor should only change the gain by less than 1.0%. If the 2 220k resistors are well matched it should make no difference. Do not think the resistor is the problem.

    The slew rate difference is minimal, and since this circuit is basically measuring a DC voltage it is not really a concern.

    The input offset voltage is less (better) on the 3140, so I do not think that is the problem.

    The input bias current is twice that of the 3160 and may be the problem, but it would depend on the impedance and output signal of the ph probe.

    First verify that the power supply voltages are good and that output voltage of the 3140 is close to 0V when the input is shorted.

    Then make sure that the output from the Vref op amp can be adjusted from -1.2 to -0.8V.

    Then connect a 1 meg or so pot across the +-5V supplies and use the wiper output as input to the 3140 to verify that the output tracks the input voltage. If it does then add a 1 meg series resistor and see if you get close to the same min and max voltages.

    If all the above checks outthe electronics should be working.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-24 19:55
    Putting a meter on pin 7 of the lm358 (vref op amp out) I can adjust rt 1 and I get a range of -355.8 mv to -0.518v. This must be the source of my problem.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-25 00:55
    kwinn,

    Thanks for the input, I found 2 issues, first I had to un-jumper fb to - on the lm385. Then I crossed on of the 220K with a 20K. The circuit is now working almost as expected, I can seem to adjust the output to 1 volt when the prob is in 7 ph test solution. It keeps bouncing between .999 and 1.001 I think this may just be the breadboard connections causing this.


    Greg
  • kwinnkwinn Posts: 8,697
    edited 2009-07-25 03:50
    You're welcome, and you are most likely correct in concluding that the slight fluctuation in the voltage is connection noise. It could also be "last digit bobble" from he meter is half of it.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-25 16:50
    One more issue it may be related to the previous concerning noise. I attached the ph meter circuit to an ADC and started sampling the readings. Its very erratic, placing the ph probe in neutral solution the reading on the adc bounces from the high 800's to almost 1500.

    Is it normal to see this while reading a ph probe. I have tried a 2 second interval on the adc and I still get very erratic behavior.

    would placing an cap of say 100u or so smooth this out without sufficiently skewing the results ?

    here is the code its very simple:

    {{
    
    }}
    CON
    
      _clkmode = xtal1 + pll16x                                                     ' set clock mode
      _xinfreq = 5_000_000                                                          ' set external crystal freq
      
      EOC    = 0                                                                    ' tlv2543 config  EOC Pin
      CLK    = 1                                                                    ' tlv2543 config  CLK Pin
      SDI    = 2                                                                    ' tlv2543 config  SDI Pin
      SDO    = 3                                                                    ' tlv2543 config  SDO Pin
      CS     = 4                                                                    ' tlv2543 config  CS Pin
                               
    VAR
      
    OBJ
    
         output : "Parallax Serial Terminal"                                        ' Routines for the display
            adc : "TLV2543"                                                         ' Driver for TLV2543      
            'num : "simple_numbers"                                                  ' Number to string conversion                                                                                                                                                                                                                                ' Steinhart_Hart Calculations
             fm : "Float32"                                                         ' Floating point math
             fs : "FloatString"
              
    PUB Main | ph, frac, offset, adjust, mv, mvf, pha 
    
      adc.start(CS, CLK, SDI, SDO, EOC)                                             ' start TLV2543 driver
      output.Start(57600)  
      output.Str(String(output#CS,"PH = "))
      output.Str(output#CE)
      output.Str(output#NL)
      fm.start
    
      repeat 
    
        mv := fm.FFloat(adc.GetData(0))
        frac := fm.FDiv(700,828)
        offset := fm.FMul(mv,frac)
        adjust := fm.FSub(offset,845.0)
        pha := fm.FSub(700.0,adjust)
        ph := fm.FDiv(pha,100.0)
        
        output.Position(5, 0)
        output.str(fs.FloatToString(ph))
        output.ClearEnd
        output.NewLine
        output.Str(fs.FloatToString(frac))
        output.ClearEnd    
        output.NewLine
        output.Str(fs.FloatToString(offset))
        output.ClearEnd
        output.NewLine
        output.Str(fs.FloatToString(adjust))
        output.ClearEnd
        output.NewLine
        output.Str(fs.FloatToString(pha))
        output.ClearEnd
        output.NewLine
        output.Str(fs.FloatToString(mv))
        output.ClearEnd
        output.NewLine
        
        waitcnt(clkfreq * 2 + cnt)     
    
    
  • kwinnkwinn Posts: 8,697
    edited 2009-07-25 18:35
    First thing I would do is take readings with the meter attached to the output of the circuit you posted to make sure it is stable.

    If you are breadboarding the ADC it may be noise pickup. ADC chips generally have a high impedance input which makes them
    susceptible to noise pickup, so the pc board layout needs to be done properly. They do not work well on breadboards of any kind.
    A capacitor very close to the input pin would help, as would averaging several readings.

    Most likely it is 60Hz noise being picked up and the ADC is taking a reading at different points on the resulting signal.

    What ADC are you using, and how fast can it sample?
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-25 19:09
    kwinn,

    I am using a TLV2543(spec sheet attached). I also have 2 thermistors attached, and I don't see this fluctuation with them.

    Greg
  • kwinnkwinn Posts: 8,697
    edited 2009-07-26 02:21
    Thermistors are usually fairly low impedance so noise is not usually an issue for them. First thing to try is a capacitor on the ADC input pin, but 100uF is too high. Try 0.1 to 1.0Uf.

    If you have access to a scope check the signal at the ADC pin and also see how fast you are accessing the ADC to get some idea of how many readings per second from the ph channel.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-26 03:16
    kwinn,

    I have the parallax scope, I am still learning how to use it. I attached a screen shot of it. That is a reading without a cap attached.

    I tried a .01, .1,1 and a 10. The 10uf cap will smooth it out fairly well, however the scope is nearly flat when a cap is attached.
    1019 x 611 - 104K
  • kwinnkwinn Posts: 8,697
    edited 2009-07-26 08:19
    That's a lot of noise. Since the input changes pretty slowly I guess a 10uF won't hurt.

    What kind of readings do you get with the 10uF in?

    Is this circuit laid out on a pc board or built on some type of prototyping board?

    Is there anything nearby that is generating a 40KHz signal?
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-26 17:32
    kwinn,


    here is a shot with the 10uf cap attached. I am doing this on a pe board.

    I also noticed that the scope is picking up some noise even when the board is not powered up.

    The only thing around is wireless keyboards.


    Greg
    984 x 603 - 100K
  • kwinnkwinn Posts: 8,697
    edited 2009-07-26 18:15
    It could be the keyboards, however it is more likely pickup from the 7660 that generates the -5V. Scope the signal on the -5V filter cap.
    In any case breadboarding analog circuits is a problem.

    You really need to make a pc board and pay close attention to the layout. I'm not an analog expert but you should:

    - Bring the signal in as close as possible to the ADC pin and go directly to the pin (no trace winding an inch or two around other signal lines).

    - Surround the input pins and traces with as much grounded copper as possible.

    - Separate the analog and digital parts of the circuit on the board (analog on one end of the board, ADC in the middle, digital on the other end).

    - Provide separate power supplies for the analog portion if possible, or filter the power to the analog portion very very well.

    - Put bypass capacitors near the power pins of all the chips.

    One of the chip makers (analog devices I think) had an excellent application note on laying out a pcb for adc`s and precision analog circuits. Take a look on the internet
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-29 20:20
    kwinn,

    I picked up a little project board at radio shack and soldered this thing together (See attachment). It now looks very clean in the scope.
    Almost a flat line with a little blip every now and then. The problem is now that the voltage adjust when shorted is 1.159 to 2.130.

    I cant get it to 1V. I have picked up some 20K's and put them in place to the 22K's, that brought me closer.

    Pin5 on the lm358n puts out -1.905 to -2.868. Not even close to -1.2 to -0.8V that you said it should be. The only other difference is the 220K resistors.

    Do you think 221K is going to bring it down enogh to make a difference?

    I guess I need to understand this a bit better mathematically.

    Greg
    800 x 600 - 799K
  • phil kennyphil kenny Posts: 233
    edited 2009-07-29 22:01
    Do you have 1.2 volts across the LM385 zener diode?

    phil
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-29 22:23
    Phil

    it measures -2.8. If I jump fb to - it will drop to .8 volts.


    Greg
  • phil kennyphil kenny Posts: 233
    edited 2009-07-30 02:07
    The LM385 zener should be reversed from the way it is drawn.

    Pin 2 should be connected to ground. Pin 3 should connect to the
    junction of RT1 and R1. Leave Pin 1 unconnected or you can tie it to
    Pin 2.

    When you have it hooked up correctly you should measure about
    -1.2 volts from Pin 2 to ground.

    Where is the 'fb' pin you mentioned?

    phil

    Post Edited (phil kenny) : 7/30/2009 1:37:53 PM GMT
  • kwinnkwinn Posts: 8,697
    edited 2009-07-30 02:13
    Double check the wiring. You should not have -2.8 across the zener unless it is bad. Should be very close to 1.2V.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-30 02:29
    Here is the spec sheet. I must be way off here. Right now fb is not connected to anything.
    the - pin goes to ground, the + pin goes to the 7660 pin 5 via a 20K resistor

    That what I got from the schematic. Do I have it backwards?


    Greg
  • phil kennyphil kenny Posts: 233
    edited 2009-07-30 02:59
    The data sheet schematic is for a +5 volt only power supply.

    You are using both a + 5 volt supply AND a - 5 volt supply.

    When using a negative power supply the orientation of the LM385
    must be reversed. This isn't spelled out in the data sheet, so
    your confusion is understandable.

    Pin 2 (what you are referring to as the + pin) must go to a
    more positive voltage than Pin 3 (what you call the - pin).
    In this case Pin 2 must be connected to ground.

    Pin 3 must go to a voltage more negative than Pin 2.

    If you reverse he polarity of the LM385 in your schematic,
    then the circuit will function correctly.

    phil

    Post Edited (phil kenny) : 7/30/2009 3:19:18 AM GMT
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-30 04:10
    Phill,


    tried it both ways, even got a new 385, no go either way reversing it just changes the the sign from plus to minus on the meter.
  • kwinnkwinn Posts: 8,697
    edited 2009-07-30 05:40
    Greg, according to the data sheet the + terminal of the LM385 should go to the com (common), and the - terminal and FB (feedback) both go to the junction of R1-RT1 just like in your diagram.
    If you reversed it at some point you may have damaged the LM385.

    The LM385 in the circuit with FB connected to the - terminal should draw about 150uA. Not having FB connected may account for the noise and instability.

    I should have looked at the data sheet instead of assuming it was a 2 terminal reference. Sorry about that.

    The junction of R1-RT1 should be at about -1.24V from common, and the voltage on the wiper of RT1 should be adjustable from approximately -1.24 to -0.8 volts.
    If you do not have -1.24V at the R1-RT1 junction you have a problem. Most likely the LM385, but possibly wiring or the components connected to the wiper of RT1.
    Measure the voltage at both the junction of R1-RT1 and the wiper while adjusting RT1 over its entire range. The voltage at the junction of R1-RT1 should not change much.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-31 00:44
    kwinn,

    You are correct. I tried it again with your suggestion and all the readings are correct. however, I still cannot zero it out with the center probe pin grounded out.

    the reading on my meter is 81.9mv to .479v. could this be the difference between the 3140 and 3160 causing this?
    digikey has some 221K resistors, I am going to order a few in the morning.
  • kwinnkwinn Posts: 8,697
    edited 2009-07-31 04:58
    Pin 7 of LM358a should read the same (or within a few mV) voltage as pin 5 does.

    Pin 2 of LM358b should be very close to 0V.

    With the input shorted pin 7 (output) of the CA3140 should be very close to 0V.

    The output on pin 1 of LM358b should track the output of pin 7 of LM358a but be of opposite polarity.
    ie if pin 5 is - 0.9V then pin 7 should be -0.9V and pin 1 of LM358b should be +0.9V

    Measure and record the voltages on these pins with pot RT1 at both ends of it`s range.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-31 15:11
    kwinn,


    Pin 7 & 5 follow each other pretty close.

    Pin 2 is -380mv

    pin 6 (pin 7 is +5V) on ca3140 is -.770v constantly when shorted, when not shorted its -4.6 volts

    pin 1 on the lm258b dos not track, ie if pin 7 is -1.24v pin 1 will be +.480v

    Something else that is interesting that may be related:

    measuring all the 220K resistors related to the ca3140 give a reading of 161K if I disconnect R6 from ground then they all read 219K.


    Greg
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2009-07-31 16:27
    Hi Greg,

    I have to go back and read through this whole thread, but it looks like you are getting a lot of good advice. That circuit on my web site was adapted from one in Don Lancaster's CMOS cookbook. As you noticed, the CA31xx series is old news. These days I would choose one of the many other CMOS op-amps that are on the market. The LM385 is still a great little reference, and it should indeed be giving you a stable reading.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-31 17:06
    Tracy,

    I found this chip TLE2141IP from TI, It is supposedly a direct replacement for ca3160. I ordered one today from digikey.

    I still haven't got my head wrapped around this circuit completely. Thankfully there are a lot of very knowledgeable people here to help.

    Greg
  • kwinnkwinn Posts: 8,697
    edited 2009-07-31 17:08
    > Pin 7 & 5 follow each other pretty close. - Good. That means LM358a and the associated circuitry is working properly.

    > Pin 2 is -380mv. Good. That is about what I would expect if pin 7 of the LM358 is at -0.8V.

    > pin 1 on the lm258b dos not track, ie if pin 7 is -1.24v pin 1 will be +.480v. I think this is good. Pin 7 goes through R3 to the inverting input of LM358b.
    If pin 7 goes from -0.8 to -0.9V then pin 1 should go 0.1V more positive. Double check that that happens.

    I suspect the problem is in the area of the CA3140. An offset of 0.77V is pretty high with 0V input (shorted). First thing to check is the power supply.

    Make sure the +- 5V levels are closely matched (+5.0 and -5.0 not +5.2 and -4.75). A 5 to 10mV difference is ok, but hundreds of mV is not .

    If the power supplies are ok measure the voltage on both sides of R4. The voltage on the left should be twice the voltage on the right.
    If that is the case the problem is almost certainly with the CA3140 side. Check the voltage at the junction of R6-R7. It should be about half the output
    voltage of the CA3140.

    If the voltage on the right of R4 is higher than on the left the problem is most likely with the LM358 side.

    > measuring all the 220K resistors related to the ca3140 give a reading of 161K if I disconnect R6 from ground then they all read 219K.
    This is normal. The rest of the circuit is affecting the measurement. Removing R6 from ground reduces that somewhat.

    Double check all your connections and clean off as much flux and such as possible from the board. It looks like you have some leakage on the CA3140
    causing the -0.77V offset and the RT1 adjustment is not enough to balance it out.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-07-31 21:24
    Kwinn,

    The power supplies are off a little the output of the 7660 is -4.75 the +5v rail is 4.96v This is off because my battery is getting low, They are usually both 4.96. I'll pick a few more 9v tonight at the store. I also just
    bought a professional developer board today (yeah deal of the day!)

    I brushed the board down with nail polish remover last night before I posted just to make sure [noparse]:)[/noparse]

    So with the center pin shorted we have

    The junction of R6-R7 is -173.5mv

    The output of pin 6 on the ca3140 is -.759v.

    right side of r4 is -365.5mv the left is -.749 volts

    Is this looking like the 3140 is having issues ?


    I ordered a couple of TLE2141IP today.

    Greg
  • kwinnkwinn Posts: 8,697
    edited 2009-08-01 02:01
    It certainly looks like the problem is with the 3140 or the circuitry associated with it. I would expect the voltage on the right side of R4 to be about half of what the left side is, but I would expect the output of the 3140 to be close to 0V. This could be due to the imbalance of the power supplies, a bad 3140, or a miswired circuit. Fix the power supply first then check the voltages again.

    If adjusting RT1 over it's entire range results in the voltage on pin 1 of the LM358 changing by .4 volts that circuit is working. The problem is that if the 3140 is putting out -.759 volts instead of 0V the output from pin 7 of the LM358 is not enough to cancel it out and bring the output on pin 1 of the 358 to 1V.
    The best it can do is bring it to about +.4V.

    In a perfect situation the output of the 3140 should be 0V with the input shorted, RT1 should adjust the output on pin 7 of 358a between -0.8 and -1.2V and the output on pin 1 of 358b should go from +0.8 to +1.2V.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-08-03 21:32
    @kwinn,

    I got the new tle2141IP chip today to replace the ca3140. Success!!!! the output now adjusts from .8 to 1.2 volts.

    One other Issue I Found, When I adjust to 1 volt using my meter, the ADC is reading 1230. shouldn't the ADC be reading 1000 ?


    Greg

    Post Edited (Greg LaPolla) : 8/3/2009 9:38:28 PM GMT
Sign In or Register to comment.