Shop OBEX P1 Docs P2 Docs Learn Events
Smartpin adc value question — Parallax Forums

Smartpin adc value question

I just got the new replacement eval board, thank you very much again Chip and Ken, and I was testing the analog smartpin inputs. This time with the 3.3 and gnd pins on the eval board!! The first two pins were about 700 at 0 volts and 3600 at 3.3 volts, both about the same I think within 1 or 2. I tried another and it was about 100 higher with the same voltage. A third and fourth were off a little more each. Is this normal and each pin will have to be adjusted in the program to make them all equal? For now I just added or subtracted to equalize them and set 0 volts equal to 0 digital reading.
Is this the correct way or is there a better way to do it?

Thanks

Comments

  • evanhevanh Posts: 15,187
    There is internal selections of voltage sources for the ADC input. For calibrating you want both GIO and VIO sources. These will tell you the numerical work range of 0 volts to 3.3 volts.

    Select config details are in ADC section here - https://forums.parallax.com/discussion/comment/1452036/#Comment_1452036

  • evanhevanh Posts: 15,187
    edited 2020-01-19 01:29
    There has been discussions on best ways to continuously run live calibration for optimal DC drift elimination. Latest one was a follow on from the discussion over cutting a track on the silicon (the Rev C change) to reduce crosstalk on pin-pairs.

    It was suggested that instrumentation use would benefit from tying the pin-pairs together and alternating the sampling between signal and calibration. While one pin is reading the signal the other pin is being recalibrated.

  • Ok, so you do have to calibrate the pins for any variances. That's fine and I don't need any exact reading for what I'm doing with the gauges in the vehicle for fuel, oil, temp and O2 sensors.
    Just wanted to make sure it was normal.
  • I've been reading the posts on calibrating the adc and although most of it is over my head I see comments on GIO and VIO calibration being internal. Is there a way to read the GIO and VIO on a pin with a voltage connected to that pin. I have yet to find how you would do that in code.
    Am I just reading this wrong or can you somehow switch the mode to read GIO, VIO or actual pin voltage in the code?

    Tubular wrote: »

    It'll be interesting to see how they vary from pin to pin and chip to chip. Since those VIO and GIO calibration connections are purely internal, perhaps this is a way of obtaining a 'unique signature' of the silicon being tested. That would make for a kind of organic serial number.
  • OK I think I answered my question. I finally found a post about it. I see the first two adc modes are what I want, is that correct? So you switch the mode to GIO or VIO and read the pin.
    Some of this may sink in to this old head sometime.
  • cgraceycgracey Posts: 14,133
    The thing about switching ADC sources is that the first good SINC2 conversion is the 3rd one after the source change.
  • evanhevanh Posts: 15,187
    edited 2020-01-19 05:42
    CRST1 wrote: »
    OK I think I answered my question. I finally found a post about it. I see the first two adc modes are what I want, is that correct? So you switch the mode to GIO or VIO and read the pin.
    Some of this may sink in to this old head sometime.

    Yes, the WRPIN mode number contains the input selection in the %P bits.

    As Chip indicates, SINC2 mode provides highest resolution and it takes at least three "decimation" samples to settle.

    EDIT: Err, SINC3 mode is highest resolution. Just use the same conversion mode for the calibration as you're using for signal sampling.

  • I'm just about to test the smartpin ADCs. I tried a sampling period of 8192 clocks and SINC2 filtering. According to the docs it should give around 14 ENOB. I have some noise at the last bits but it's still much better than what I saw at other processors.

    I tookj the example from the google document and modified it for 14 instead of 8 bits resolution. It works but I had to place a zerox instruction after the shift.
    		shr	adc,#12	' log2(8192)-1 = 13-1
    		zerox	adc,#13	' 14 ENOB
    
    Without the zerox I sometimes get garbage in the bits above 13. I'm using the same waitse1 as in the example and my loop is quite short so I don't think I get overflows due to missed events.
  • evanhevanh Posts: 15,187
    The untruncated resolution is log2(8192) * 2 = 26 bits. 26 - 12 = 14 bits, so if you're getting more then there has to be a bug. Can't say I've tested the hardware itself that precisely.
Sign In or Register to comment.