Shop OBEX P1 Docs P2 Docs Learn Events
10V Analog input — Parallax Forums

10V Analog input

RaymanRayman Posts: 15,213
edited 2025-05-23 14:43 in Propeller 2

Have this gas pressure measuring thing that want to connect to a P2 based controller:
https://www.ashcroft.com/wp-content/uploads/2020/09/datasheet-pressure-transducer-g2.pdf

Output is 10V analog. Have 2 free P2 pins to do it...
Was thinking of an I2C ADC, but now think will just use P2 ADC instead.

Want to do it in a safe way though...
Thinking this circuit should do it.

The big thing is a TVS diode with 3.3V working voltage:
https://www.digikey.com/en/products/detail/bourns-inc/CDSOD323-T03C/3742077

Thoughts?

Comments

  • RaymanRayman Posts: 15,213
    edited 2025-05-23 15:00

    Know response time is slow and accuracy may be off, but don't care too much about these.

    Just need to make sure there's enough pressure to operate some pneumatic valves (in an automated way)...

  • JonnyMacJonnyMac Posts: 9,302

    I'm doing that to monitor a battery in a device, but I'm using higher value resistors to minimize the load added to the battery (the great thing about resistors these days is we can get any value in 1%). I'm using a 39K and 11K stack; even if the 11K opens at 12V in the current into the pin is limited to 0.3mA. The stack keeps input to the pin safe up to 15V; necessary because 12v batteries typically charge up to past 13V.

    My ADC object allows me to set the low and high output in millivolts, so I start it like this:

      badc.startx(BATT_MON, 0_000, 15_000)
    

    ...which lets me get a direct reading of the battery with

      battVolts := badc.read() / 100
    

    This is in 0.1 volt units and goes to the Nextion display.

  • evanhevanh Posts: 16,488

    The internal resistance of the ADC at x1 gain is around 500 k ohm. For a rough 10 Volt range use a 1.5 M ohm for R1 straight into the pin. No need for other resistors nor even the diode since R1 is so high already.

  • RaymanRayman Posts: 15,213

    @evanh interesting idea. Doesn’t the input resistance depend on the sample rate? I’ve forgotten how that works inside…

  • evanhevanh Posts: 16,488
    edited 2025-05-23 17:53

    The gain setting affects it. x10 will be 50 k ohm.

    EDIT: The schematic says 53 k for x10 gain and 538 k for x1 gain.
    EDIT2: Huh, so 1.5 M ohm external resistor works for a 10 Volt signal at any gain setting. The 53 k internal is 10 times smaller signal at the pin but is then amplified by 10 again internally.

    5513 x 3143 - 310K
  • RaymanRayman Posts: 15,213

    @evanh Guess have to give that a try... Maybe get a giant 2512 resistor so no chance of breakdown across it.

    But, now have to think about if it needs a capacitor on P2 pin to get a reliable response.
    And, has to be a small one to get a decent RC time...

  • evanhevanh Posts: 16,488
    edited 2025-05-23 18:13

    The downside will be the offset. Using the low value 1 k ohm resistor mostly negates the offset, giving you the full 3.3 Volt input range. But using the high value of 1.5 M ohm the internal virtual ground referenced to VIO / 2 (1.67 Volts) will play a big role. You'll lose a chunk at the bottom of the numerical range.

    My knowledge of analogue is a tad vague though, so I'm not sure if linearity is affected. If it is then your solution is far better. If not then losing some resolution isn't a big deal.

    EDIT: Oops, oh, the offset means probably needs 3 M ohms then. Everywhere I wrote 1.5 M, replace it with 3 M instead.

  • ErNaErNa Posts: 1,826

    As the ADC is discussed here: I have to replicate results I had with the simple P1 ADC: Normally we have an input resistor to the cap and the compensation resistor, both actually work as current sources, that is, the current to the cap (constant voltage) is proportional to the voltage drop at the input resistor. In my application I have an real current source, so I omit the input resistor.
    The signal to measure is not the current, but the charge, transferred during an interval. Whenever the interval starts, I read the counter, when it stops, I do another read and calculate the difference.
    This said: I have to do this with the P2 now, using the counter mode:

     setup ADC Pin 43 Shunt
    
       DAT            adc_modSh       long    p_adc_1x  |  P_COUNT_HIGHS
       CODE
                    fltl    pinAdcSh                      'set pins to count mode
                    wrpin   adc_modSH,   pinAdcSh
                    wxpin   #0,          pinAdcSh         '
                    drvl    pinAdcSh                      'start pins on same clock
    

    I already tries to change p_adc_1x, but without success

  • evanhevanh Posts: 16,488
    edited 2025-05-23 19:00

    Oh, yeah, I guess the Prop1 feedback is also creating a virtual ground centred on the CMOS input threshold. So it's very similar offsetting, albeit a lot more noisy.

  • evanhevanh Posts: 16,488

    @ErNa said:
    I already tries to change p_adc_1x, but without success

    what change attempted?

  • @Rayman said:
    @evanh Guess have to give that a try... Maybe get a giant 2512 resistor so no chance of breakdown across it.

    But, now have to think about if it needs a capacitor on P2 pin to get a reliable response.
    And, has to be a small one to get a decent RC time...

    My concern there would be relying on the stability of the ADC input impedance. On some board I used 93.1k over 3.41k as a divider. Nothing special about those values, I just had reels of them. Which allowed measurement up to about 93v. That put the source impedance at about 3k which is 2 orders of magnitude less than the ADC input. And 2 orders of magnitude higher than the resistance of the pin output drivers. My ADC library would drive the pin to calibrate instead of using the ADC mux.

    I studied ADC attenuators quite a bit. The Vcc/2 bias voltage does affect the ADC calibration. Linearity is fine. For the values I mentioned above the calibration points were 93.931v to -0.269v. It takes a negative input voltage to drive the ADC input to zero. Keep in mind that the ADC can measure negative voltage until the protection diodes start conducting, somewhere between -0.3 and -0.7. So you could measure a voltage that is outside of the calibration range.

    It is also possible to add a divider resistor to 3.3v as well as 0v to get a nearly symmetric measurement range.

    I don't think a capacitor is necessary for the P2 ADC pins. At least not like it is for other ADC that do sample and hold. The window filter does a good job at filtering out noise.

  • RaymanRayman Posts: 15,213

    @SaucySoliton Thanks. No cap. Still, worried about noise from other signals on same cable connected to P2. Maybe I'll add pad for cap, but try without.

  • RaymanRayman Posts: 15,213

    That may be the problem with the large value resistor approach... Makes it susceptible to noise...

    This is going to be in a different box that the P2, connected via short RJ45 cable with three other signal pins...

  • evanhevanh Posts: 16,488

    Thanks James. Great read as usual.

    What's the symmetrical divider circuit look like?

  • 9.96M input divider from four 2.49M resistors. The two 64.9k bias resistors are equivalent to a 32.45k bias to 1.65v. Or 30.673k when including the ADC's 560k to 1.65v. If the ADC bias resistance falls to 500k, a reduction of 10.7%, the full scale measurement range will increase by 0.6%. If Radc is 560k the full scale measurement range is -536 to 539.2v. I used to have pads for capacitors in case I needed to build a full P1 type ADC. The feedback resistor spot stuck around, maybe as a place to solder a jumper to if I wanted to access an extra pin.

    Differential measurement is a neat technique too.

  • evanhevanh Posts: 16,488

    Ah, oh, reading all you've written, the symmetrical divider is just the resistors at C7 and C12, right? So that would be important if signal is bipolar then.

  • OMG, way too complicated. For all stuff that doesn't need ultra high precision like battery and temperature monitors I use a simple resistor divider, something like 100k and 10kOhm. This way I can measure up to 33V with around 4mV resolution. I only calibrate the ADC pin once at power up against GIO and VIO. The resistors have 1% tolerance and I haven't seen much thermal drift so far. That's sufficient for most cases.

  • @ManAtWork said:
    OMG, way too complicated. For all stuff that doesn't need ultra high precision like battery and temperature monitors I use a simple resistor divider, something like 100k and 10kOhm.

    some sort of TVS still makes sense, though, for "industrial" use with external user connections.... right?

Sign In or Register to comment.