Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

mistake on ADC inputs, false read values

1149 Views - Created 03/08/2020

03/08/2020

Posted by:
belette

belette Avatar

Hi,

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 ?

Regards

03/08/2020

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi

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?

03/08/2020

Posted by:
belette

belette Avatar

Hi,

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

03/08/2020

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Can you try our Expander Pi Python library and see if that has the same problem? There is a demo_adcread.py in the demos folder which should read all 8 ADC channels.

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.

04/08/2020

Posted by:
belette

belette Avatar

Thanks for replies,

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.

regards

04/08/2020

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Can you check that you are using the most recent version of the Expander Pi C++ library? I uploaded a new version 4 days ago which fixed a problem with reading ADC values. You can download it from https://github.com/abelectronicsuk/ABElectronics_CPP_Libraries/tree/master/ExpanderPi

05/08/2020

Posted by:
belette

belette Avatar

Sorry, this latest version of library doesn't solve my mistake :-(

05/08/2020

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

I have just tested the Expander Pi C++ library with the demo-adcread.cpp program on a Raspberry Pi 4 and 3+ using the latest version of Raspbian Linux and it appears to be working correctly with voltages showing up on each channel.

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?

05/08/2020

Posted by:
belette

belette Avatar

ok I'll try to make a clean installation of Raspbian Linux, keep you in touch

07/08/2020

Posted by:
belette

belette Avatar

Hello !

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

Sign in to post your reply

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.