ADC question
CodingChimp
Posts: 15
in Propeller 2
fltl pin wrpin ##( P_ADC | P_ADC_GIO ), pin wxpin #%00_1101, pin wypin #0, pin dirh pin waitx ##( 8192 << 2 ) rdpin callo_tmp, pin fltl pin wrpin ##( P_ADC | P_ADC_VIO ), pin wxpin #%00_1101, pin wypin #0, pin dirh pin waitx ##( 8192 << 2 ) rdpin calhi_tmp, pin
I used this bit of code to read the 0v and 3.3v on one of my analog inputs, but the level measured for 0v was around 2-3K counts which I found odd. And the 3.3V level was around 13K counts. Why is the spread between these so small when using 14 bit SINC2 sampling mode?
Comments
14 bits, max count is 2^14=16384. The scaling resistors allow for reading a little beyond the rails, so the 0v and 3.3v inputs are provided to calibrate the input levels. Being a sigma/delta type, the ADC is not a "multiplying" ADC, so it doesn't scale relative to supply voltage.
Here's a write-up I did - https://forums.parallax.com/discussion/comment/1484327/#Comment_1484327
It's not exactly how the ADC works but is a rough analogue. Basically there is a virtual ground at VIO/2 with scaling resistors. At x1, the scaling is roughly a 5.0 Volt span. There is measurable current pulling to VIO/2, and is higher at higher gains. The exact circuit is here - https://forums.parallax.com/discussion/comment/1510744/#Comment_1510744
This block diagram might also be of interest - https://forums.parallax.com/discussion/171420/smartpin-diagram-now-with-p-p-bit-mode-table
PS: And this too - https://forums.parallax.com/discussion/174441/measuring-floating-pin-voltage-adc-from-just-the-built-in-comparator/p1