spidev code for MCP3202 12-Bit A/D converter only reads 252 values
-
hello
I've connected a MCP3202 dual-channel 12-bit A/D converter to the Omega2+ to check battery voltage.
This is the datasheet of the MCP:
https://ww1.microchip.com/downloads/aemDocuments/documents/APID/ProductDocuments/DataSheets/21034F.pdfFor the measurements, I'm using Python 3 with this example code:
https://github.com/OnionIoT/python-spidev/blob/master/examples/xfer3.pyIt works but what I don't understand is that I only get values from 0 to 252. In theory, I should get values up to 4096, right?
Do I have to change the code in some way to get more values?
Thanks!
-
@Kazooie : Hadn't time top check the datasheet in depth, but you should indeed get values up to 4096 if Vin = Vdd (check p.13 of datasheet).
What is you Vdd and Vin to wich you get 252 (which is a very strange value by the way).
You could connect the analog input to you Vdd. The converter should output 4096.