Comments (8)
Hello
The timeout error in the ADC Differential Pi library normally occurs because the ADC did not return a sample before the timeout timer reached its end. This can happen for a few reasons such as other processes holding the I2C bus open or another part of your python program is causing a delay.
The easiest way to get around the timeout problem is to increase the amount of the time the ADC Differential Pi library waits for a response from the ADC.
In the ADCDifferentialPi.py file on lines 171 to 180 is the code that controls the timeout period.
# determine a reasonable amount of time to wait for a conversion if self.__bitrate == 18: seconds_per_sample = 0.26666 elif self.__bitrate == 16: seconds_per_sample = 0.06666 elif self.__bitrate == 14: seconds_per_sample = 0.01666 elif self.__bitrate == 12: seconds_per_sample = 0.00416 timeout_time = time.time() + (10 * seconds_per_sample)
Change the 10 in the last time to a larger number such as 20 or 50 and this should solve the problem.
timeout_time = time.time() + (50 * seconds_per_sample)
from abelectronics_python_libraries.
Hi,
Thanks for that info. I have increased to 20 then 50 and it seems to be more reliable but it still happens and causes some issues. Maybe I have to handle the timeout better. I notice the library is written in python2.7 and I am using 3.5, could switching to 2.7 possibly resolve the issue?
Thank you
from abelectronics_python_libraries.
The library should work on python 2.7 or 3.5. Do you have anything other devices connected to the I2C port that could be holding the port open?
from abelectronics_python_libraries.
I do not, however I just noticed another error:
Unexpected:
Traceback (most recent call last):
File "/home/pi/scmeter/strom_diagnostic.py", line 86, in __read_adc
self.dataset[1] = (self.__adc.read_voltage(4) - self.config.icor) / self.config.vgain
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 136, in read_voltage
raw = self.read_raw(channel)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 184, in read_raw
__adcreading = self.__bus.read_i2c_block_data(address, config, 4)
OSError: [Errno 5] Input/output error
I'm trying to watch for when the timeout occurs to restart the thread, that may fix it.
Thanks.
from abelectronics_python_libraries.
An Input/output error normally means the library is having trouble communicating with the ADC over the I2C bus.
Try checking all of the solder connections on the ADC Differential Pi. A dry solder joint or bad connection could cause an I/O error.
You could also try running the command "sudo i2cdetect -y 1" to check that both ADC chips are appearing on the correct I2C addresses.
from abelectronics_python_libraries.
I will try with a backup ADC board I purchased to see if the i/o errors go away but currently I get a couple of these errors:
Unexpected:
Traceback (most recent call last):
File "/home/pi/scmeter/strom_diagnostic.py", line 88, in __read_adc
self.dataset[1] = (self.__adc.read_voltage(4) - self.config.icor) / self.config.vgain
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 136, in read_voltage
raw = self.read_raw(channel)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 184, in read_raw
__adcreading = self.__bus.read_i2c_block_data(address, config, 4)
OSError: [Errno 5] Input/output error
Unexpected:
Traceback (most recent call last):
File "/home/pi/scmeter/strom_diagnostic.py", line 87, in __read_adc
self.dataset[0] = ((self.__adc.read_voltage(1) + self.config.vcor) * self.config.Gv)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 136, in read_voltage
raw = self.read_raw(channel)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 184, in read_raw
__adcreading = self.__bus.read_i2c_block_data(address, config, 4)
TimeoutError: [Errno 110] Connection timed out
Unexpected:
Traceback (most recent call last):
File "/home/pi/scmeter/strom_diagnostic.py", line 87, in __read_adc
self.dataset[0] = ((self.__adc.read_voltage(1) + self.config.vcor) * self.config.Gv)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 136, in read_voltage
raw = self.read_raw(channel)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 184, in read_raw
__adcreading = self.__bus.read_i2c_block_data(address, config, 4)
OSError: [Errno 5] Input/output error
I changed the timeout to 50 * seconds_per_sample and increased the time.sleep delay to 0.4. I rarely get timeouts now. Also I replaced the sys.exit to restart the thread and it seems to be working better. The above errors are just ignored and the ADC just retries and reads voltages successfully so I think its fine now.
from abelectronics_python_libraries.
I'm having a strange issue where sometimes one of the 2 adc addresses doesn't show up. I get this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/scmeter/strom_diagnostic.py", line 81, in __read_adc
self.__adc = ADCDifferentialPi(0x6a, 0x69, 18)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 130, in __init__
self.set_bit_rate(rate)
File "/usr/local/lib/python3.5/dist-packages/ADCDifferentialPi/ADCDifferentialPi.py", line 298, in set_bit_rate
self.__bus.write_byte(self.__adc1_address, self.__adc1_conf)
OSError: [Errno 121] Remote I/O error
sudo i2cdetect -y 1 shows
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I should be seeing 6a as well. Do you think this is solder damage?
from abelectronics_python_libraries.
If the problem only occurs some of the time then that does sound like a bad solder connection somewhere on the board. Try reflowing all of the solder joints on the address select header and the GPIO header. You could also reflow the pins on the ADC chip in case that has a dry joint.
from abelectronics_python_libraries.
Related Issues (20)
- Bug fixes and suggestion for ABElectronics_IOPi.py HOT 1
- ADCPi Plus -- can't get example to work HOT 2
- [ServoPi.py] Invalid servo range in the Servo.move method HOT 2
- Error running demo_pwm.py HOT 3
- Use smbus2 from PyPI HOT 1
- Publish this project on PyPI
- MPC23017 works with Thinkpad Laptop i2c bus but it seems like it times out when writing to it too fast HOT 2
- ADCPi.read_voltage() freezes without raising an exception
- SPI Bus too fast HOT 2
- TimeoutError not defined in Python 2.7 HOT 2
- Setting channel 0 or negative in read_raw in ADCPi does not raise a ValueError HOT 1
- IOPi.py more "generic" constructor HOT 2
- Add exceptions for errors HOT 2
- Resistance on ADC Pi HOT 2
- Can not install libraries as GitHub removed password support HOT 2
- Errno16 HOT 5
- Convert this to python library HOT 2
- Duplicate readings of channels HOT 4
- Whitespace issues in ABE_helpers.py HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abelectronics_python_libraries.