Shop OBEX P1 Docs P2 Docs Learn Events
How to measure voltage below 1.65v. — Parallax Forums

How to measure voltage below 1.65v.

lyassalyassa Posts: 52
edited 2011-10-02 22:19 in Propeller 1
[B]Pin[/B] ----+--R---[B](v)[/B]-+
        |          |
        C          |
        |          |
       ///        ///
I can use te circuit above to measure voltage (v) by setting Pin to 0v to discharge the capacitor, then set Pin to input mode and count how many ticks it take to to charge the capacitor back to 1.65V.

What kind of RC circuit can I use to measure voltage between 0 and 1.65V? I mean other than using a ADC chip. I want to keep it as simple as possible. If You think I can use the sigma-delta circuit descibed here http://www.gadgetgangster.com/tutorials/382, will you please explain how it works?

I want to use the circuit with the temp. sensor LM34.

Comments

  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-09-23 18:06
    Exactly the same circuit except set the pin to a high, presumably 3.3V, instead and measure the time to discharge.

    BTW, we commonly connect 2 capacitors of the same value, one to 0V an the other to VCC.
    This tends to reduces the effects of noise on the power lines from influencing the measurement.

    Duane
  • lyassalyassa Posts: 52
    edited 2011-09-23 19:12
    Exactly the same circuit except set the pin to a high, presumably 3.3V, instead and measure the time to discharge.

    BTW, we commonly connect 2 capacitors of the same value, one to 0V an the other to VCC.
    This tends to reduces the effects of noise on the power lines from influencing the measurement.

    Duane

    I see. Thanks Duane. So the capacitor will charge to 3.3v, then I count how long it take to go below 1.65v. Got it. This lead me to another question, what if the voltage I am measuring fluctuate between 0 and 2v?
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-09-23 20:31
    You could write a routine that tests the circuit both ways.
    First outputting a high and then a low. However this is probably
    not that desirable.
           3.3V
           ---
    	|          
        1/2 C          
            | 
    Pin ----+--R--(v)-+
            |         |
        1/2 C         |
            |         |
           ///       ///
    

    A better way is to add bias resisters.
    By suitably choosing values for R2 and R3 you can get it to read nearly any voltage
    and voltage range one wishes. Even voltages higher than 3.3V or lower than 0V.
           3.3V 3.3V
           ---  ---
    	|    |   
        1/2 C    R3     
            |    |
    Pin ----+----+--R1--(v)-+
            |    |          |
        1/2 C    R2         |
            |    |          |
           ///  ///        ///
    

    Duane
  • RinksCustomsRinksCustoms Posts: 531
    edited 2011-09-23 22:15
    lyassa wrote: »
    I see. Thanks Duane. So the capacitor will charge to 3.3v, then I count how long it take to go below 1.65v. Got it. This lead me to another question, what if the voltage I am measuring fluctuate between 0 and 2v?

    If your using the R/C decay technique (which only works on resistive OR capacitive sensors) then a fluctuation from 0 to 2V will invalidate your reading. Also, if your trying to measure a voltage fluctuation, (and less than 1.65V) then perhaps an op-amp connected to your input voltage to amplify the voltage by maybe a factor of 2x? If that is your voltage range (0-2V). Sigma Delta is probably going to be the best bang for your buck, but if your circuit is measuring/monitoring a complex waveform for change then a cheap ADC (usually with multiple channels) are readily available, and can simplify the design/technique for complex voltages (like Vin > 3.3V and Vin < 1.65V). As the GG article shows, there are more advantages to using an ADC on complex voltages (read: out of the range of the prop). Some ADC's have separate logic and analog supply voltages allowing Vref to be tied to a much higher voltage like 12V.
  • pjvpjv Posts: 1,903
    edited 2011-09-24 10:50
    Hi Lyassa;

    If simplicity is what you want, and if high precision and rapid response are not required, then the SigmaDelta approach is the right choice. The simple RC method is nowhere near as good, and not as simple in my opinion.

    The voltage range selected for the SigmaDelta can be any reasonable value, including positive as well as negative input voltages.... it's simply a case of resistor ratios all hinging around the "half Vcc" threshold value of the Prop; 1.65 Volts. One does need to take into account the rsistance of the source signal. 100K or so resistor and 0.01 uF capacitor ranges should give you good results.

    Cheers,

    Peter (pjv)
  • lyassalyassa Posts: 52
    edited 2011-09-24 17:20
    I will give Sigma-Dela a try. Found this really usefull article: http://huarobotics.com/appnotes/AN008-SigmaDeltaADC-v1.0_0.pdf
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-09-24 17:38
    You can also find that appnote here.
  • lyassalyassa Posts: 52
    edited 2011-09-25 23:42
    Ok ... I think I need serious help with Sigma-Delta ADC. I connected the circuit in this link http://www.gadgetgangster.com/tutorials/382. I used 10nF for both caps, and 100k for both resistors. I used pins 0 and 1 of the Propeller and modified ADC.spin accordingly.
    - When I don't connect "input signal" to anything, my voltmeter reads 1.43 volts and the propeller spits out numbers between 40,654 and 42,568. That is 1,914 range.
    - When I connect "input signal" to 3.3 volts, I get solid 65535.
    - When I connect "input signal" to ground, I get numbers between 0 and 32,768.
    - I also connected "input signal" to AA battery, that is 1.62V and I got numbers between 43,020 and 45,265. That is 2,245 variance.

    My Spin program looks like this:

    CON
    _xinfreq = 5_000_000
    _clkmode = xtal1 + pll16x 
    OBJ
    pst : "Parallax serial Terminal"
    adc : "ADC" 
    VAR
    long adcValue
     
    pub main
    pst.start(115_200)
    repeat
       adc.SigmaDelta(@adcValue) 
       waitcnt(clkfreq/2 +cnt)
       pst.dec(adcValue)
       pst.str(string(","))
       pst.newline
    

    I am not sure what to make of these numbers. Any insight is greatly appreciated.
  • RaymanRayman Posts: 14,867
    edited 2011-09-26 16:54
    lyassa,

    I've got some ADC info here that might help a little:
    http://www.rayslogic.com/propeller/Programming/ADC.htm
  • lyassalyassa Posts: 52
    edited 2011-10-02 22:19
    I gave up on sigma-delta. May be it just can't be done on a breadboard. MCP3208 ADC works beautifully and effortlessly, and consumes only 3 pins for 8 input channels.
Sign In or Register to comment.