Simple Analog -- Could Use Some Help
JonnyMac
Posts: 9,104
I have this constant:
con ' %AAAA_BBBB_FFF_PPP_PPP_PPPPPPP_TT_MMMMM_0 ANALOG = %0000_0000_000_100_011_0000000_00_11000_0...and this little snippet of code using a 10K pot with between 3.3v and ground, with the wiper attached to pin 40.
pinstart(40, ANALOG, %00_1011, 0) repeat waitms(100) level := rdpin(40) term.fstr1(string("POT = %d\r"), level)It works, but instead of 0..4095 I am getting 705..3389.
Comments
when we take a 16 bit ADC sample (0..65535),
"0" corresponds to around -0.7v DC
"10~12000" corresponds to 0v GND
"53~55000" corresponds to 3v3
"65535" corresponds to around 4v
You're working on 12 bits, so divide the above values by 16, gives you around 700 to 3400 that you are seeing