About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

ADC successive reading wrong 1 out of 2

29 Views - Created 8 days ago

8 days ago

Posted by:
spacinover

Users Avatar

Location:
France

Hi,

I am using the RPI3+expander Pi  ADC to read 2 analog voltage coming from another RPI3+expander Pi DAC used as a simulator. To make sure that the analog signal is smooth I have a RC filter  (470ohm + 22µF) on each line. All is written in Python3.7

In most conditions I have a stable readout of the voltage with

adc = ExpanderPi.ADC()

adc.set_adc_refvoltage(4.096)

VB = adc.read_adc_voltage(1,0) 

VT = adc.read_adc_voltage(2,0) 

But in part off the program I call VB and VT is succession to time stamp the values and evolution (it is a pseudo real time controller) and I get for example

VB=0.405V which is OK but next readout 4ms later gives: VB = 0.283V which is wrong . 4ms later another sample readout gives 0.438V again OK  followed 4ms later by 0.318V wrong again! 

Statitsics shows about 110 to 120mV difference between successive reading.

Any hint at what could cause such behaviour? 

Regards, Robert A.L.

8 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi Robert
There are a few things you can try to improve the ADC performance.

First check that there is a good ground connection between the two Expander Pis.

Have you checked the output from the DAC to make sure it is stable?  If the power supply for the Raspberry Pi is noisy or the voltage is dropping for some reason that could create instability in the DAC output.

Similarly, if the power supply for the ADC is unstable that could cause errors in the measurements.

One other thing you could try is to reduce the SPI speed for the ADC chip which can improve its performace.  In the Expander Pi python library on line 108 you can set the clock speed; it should be set at 200KHz.  Try a speed of 100KHz and see if that makes any difference.

 

 

AB Electronics UK Tech Support

7 days ago

Posted by:
spacinover

Users Avatar

Location:
France

Quote from andrew
Hi Robert There are a few things you can try to improve the ADC performance....  

Thank you Andrew for the tips. 

I already identified the ground issue between the 2 Pi Expanders, gained some 50mV.

I add on pin8 a readout of 5V at Expander header (through divider 1.2k-1.2k) and there I see some 0 +58mV fluctuation which is surprising as my RPI is fed via buck converters from 12V.

I will sniff voltage stability here with a scope and see to reducing clock speed.  

Regards, Robert A.L.

6 days ago

Posted by:
spacinover

Users Avatar

Location:
France

Andrew,

I looked in the ExpanderPi.py (no version date in file which I downloaded about 2 years ago) and in class ADC I found :

    # Define SPI bus and init
    __spiADC = spidev.SpiDev()
    __spiADC.open(0, 0)
    __spiADC.max_speed_hz = (1900000)
Looks to me that line 102 set the spi bus to 1.9MHz, a bit more than the 200kHz you mentionned.

For the DAC spi speed seems set to 20 MHz ! ( spiDAC.max_speed_hz = (20000000) )

IO class I could not find a spi speed ?

Is that normal? should I modify them to (200000) to start with?

Regards, Robert A.L.

6 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi Robert

Try changing the __spiADC.max_speed_hz = (1900000)  to __spiADC.max_speed_hz = (200000)

The DAC should be ok at 20MHz.

I changed the speed of the ADC down to 200KHz as the ADC does sometimes give incorrect readings if the clock rate is too fast.

AB Electronics UK Tech Support

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.