Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

[TimeoutError]: read_raw: channel X conversion timed out

The ADC Pi is an Analogue to Digital converter for the Raspberry Pi

05/06/2023

Posted by:
Suhyun

Suhyun Avatar

Hello abelectronics.

your ADC Pi s doing a huge role in my project. Thanks for great work.

I've built the circuit connecting Raspberry pi Pico W and ADC pi, activating 3 channels(1,2,8) and it works well at first. However, after 2~3 minutes or longer, it throws out the error like:

[TimeoutError]: read_raw: channel X conversion timed out

The timeouterror did not happen when I built the same system with Raspberry pi 4, but It started happening at connection with Pico W(fyi, I used different ADC pis, but I've build 3 same circuits and the error happens same at all 3, i think faultiness of a single one is not the problem).

Channels throwing out TimeoutError are random.

I searched on the forum to find some clues, and found some library modification was done for full-sized raspberry pi boards but I'm not sure it was done for micropython library(https://github.com/abelectronicsuk/ABElectronics_MicroPython_Libraries) as well.

If it was done, can I get some clues about causes of TimeoutError I mentioned above to fix my work?

Sorry if the question was stupid, and if more information is needed, I'd be more then happy to give it to you.

Regards,
Suhyun

report

05/06/2023

Posted by:
andrew

andrew Avatar

Hello Suhyun

The timeout error could be cause by the ADC library not giving the Pico W enough time to fetch the ADC sample.  Try modifying the ADCPi.py library to increase the timeout_time value and see if that fixes the problem. 

On line 218 in ADCPi.py change:

timeout_time = time.time() + (100 * seconds_per_sample)
to
timeout_time = time.time() + (1000 * seconds_per_sample)

report

06/06/2023

Posted by:
Suhyun

Suhyun Avatar

Dear Andrew.
Your solution absolutely fixed the problem. I ran the code for last 12 hours and it worked well.
I appreciate your help. Have a nice day.
Suhyu

report

28 days ago

Posted by:
captain_kringel

captain_kringel Avatar

Hello everyone,

I face the same issue.
I got a Raspberry Pi 4b.

I did everything in the instructions.
Set the Baudrate to 1000000.
I see both adresses 68 and 69.

When I uses the samples from github I will encouter this:

Traceback (most recent call last):
File "/home/michael/analog real test.py", line 8, in

report

28 days ago

Posted by:
andrew

andrew Avatar

Hello

Can you try changing the bus speed to 400000 or 100000? The ADC supports 1MHz but you will not see much performance gains in the sample rate and the higher speed could be causing the timeout issues you are having.

In the ADCPi.py library try changing line 314 from

timeout_time = time.monotonic() + (100 * seconds_per_sample)

to

timeout_time = time.monotonic() + (1000 * seconds_per_sample)

and see if that fixes the issue.

report

27 days ago

Posted by:
captain_kringel

captain_kringel Avatar

Hi Andrew,
somehome my last post was cutted.
I tried it out right now to change the baudrate to 100000.
No changes....
If i change line 314 to 1000 nothing happens anymore. I don't get any messages, the code is running and I see nothing.

from ADCPi import ADCPi

import time

adc = ADCPi(0x68, 0x69, 18)

while True:
voltage1 = adc.read_voltage(1)
voltage2 = adc.read_voltage(2)
voltage3 = adc.read_voltage(3)
voltage4 = adc.read_voltage(4)
print(f"Kanal 1: " + str(voltage1) + "V")
print(f"Kanal 2: " + str(voltage2) + "V")
print(f"Kanal 3: " + str(voltage3) + "V")
print(f"Kanal 4: " + str(voltage4) + "V")
time.sleep(1)


That's how I tried it out.

If I change it back to 100 instead of 1000, that is what happens:

Traceback (most recent call last):
File "/home/michael/Test/test analog.py", line 8, in

report

27 days ago

Posted by:
captain_kringel

captain_kringel Avatar

Traceback (most recent call last):
File "/home/michael/Test/test analog.py", line 8, in

report

27 days ago

Posted by:
andrew

andrew Avatar

I'm not sure why the forum is cutting off the end of your error message. Please can you try sending the error to me using our contact form https://www.abelectronics.co.uk/contact so I can get a better understanding of the problem?

report

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.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout