mistake on ADC inputs, false read values
1149 Views - Created 03/08/2020
I face to a mistake on ADC inputs read on my expander pi, for my project I use 3 ADC inputs, 2 inputs are ok, value read on the 3rd one is always value of the 2nd.
my code seems to be ok, I tried to swap inputs ... always same issue, 2 inputs are ok, 3rd is same as 2nd.
Do this issue known, how should I solved it ?
Which programming language are you using with the Expander Pi?
There should be a demo_adcread program either in the Expander Pi directory or a demos subfolder. Can you try running the demo_adcread program and see if it has the same problem as your code?
I program in C++ with Qt.
I tried demo_adcread program With code blocks -> same issue ! same values read.
- input 1 read 1674 -> OK
- input 2 not connected, read same value as 1st
- input 3 not connected, read same value as 1st
- input 4 not connected, read same value as 1st
- input 5 read 3164 -> OK
- input 6 not connected, read same value as 5th
- input 7 not connected, read same value as 5th
- input 8 should be 1805, but read same value as 5th
If the python library works that will narrow the problem down to being a software issue either with the C++ library or with your own code. If the python library has the same problems then that would suggest a hardware problem.
it works with demo_adcread.py, so it's not an hardware problem ... I checked again my code, it seems to be in C++ library, i have same result with demo_adcread and my own code.
Do you have a spare SD card you could use to create a clean installation of Raspbian Linux? Enable I2C and SPI on the clean image using our I2C tutorial and SPI tutorial and download the Expander Pi C++ library from GitHub. Try compiling the demo-adcread program using g++ with the command:
g++ demo-adcread.cpp ABE_ExpanderPi.cpp -Wall -Wextra -Wpedantic -Woverflow -o demo-adcread
If the demo-adcread program works on the clean Raspbian image then that will narrow the problem down to a configuration issue on your Raspberry Pi installation.
In your QT program are you reading all the ADC channels from a single thread or are they being processed on separate threads? If you are using separate threads that could cause a problem if more than one thread tries to read from the ADC at the same time.
Also, do you have any other programs running on the Raspberry Pi that are trying to access the SPI bus?
good news, I made a clean installation of my Pi ... now my Expander Pi works, at least with code blocks. Next step test with Qt by end of the week.
Many Thanks for help
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.