demo code for ADC does not run
The ADC Pi is an Analogue to Digital converter for the Raspberry Pi
21/07/2015
Posted by:
Peter Thejll
I have plugged the board into the RPi 2's GPIO bus.
I did the pip install spidev thing
I have done the git clone thing, assuming python 2.X (and it does show 2.7.3 when I start python, so...)
I have gone to the resulting directory ~/ABElectronics_Python_Libraries/ADCDACPi
and there done the export PYTHONPATH thing
I then try to run the demo code, and this happens:
~/ABElectronics_Python_Libraries/ADCDACPi $ python demo-adcread.pyTraceback (most recent call last):File "demo-adcread.py", line 3, in from ABE_ADCDACPi import ADCDACPiFile "/home/pi/ABElectronics_Python_Libraries/ADCDACPi/ADCDACPi.py", line 17, in class ADCDACPi:File "/home/pi/ABElectronics_Python_Libraries/ADCDACPi/ADCDACPi.py", line 24, in ADCDACPispiADC.open(0, 0)IOError: [Errno 2] No such file or directory
Any ideas on what's wrong?
21/07/2015
Posted by:
andrew
It appears that you are trying to use the wrong library with the ADC Pi Plus board. The ADCDACPi library is designed for our ADC DAC Pi board, the library you need can be downloaded from ADCPi library
You will also need to enable the I2C bus first before using the board which you can do by following the tutorial at Enabling I2C on the Raspberry Pi.
21/07/2015
Posted by:
Peter Thejll
It appears that you are trying to use the wrong library with the ADC Pi Plus board.
Hmmm - not sure I understand - I did those things. Perplexingly, I can get the board to run if I go into the DeltaSIgmaPi directory ... not sure what this means?
21/07/2015
Posted by:
andrew
21/07/2015
Posted by:
Peter Thejll
Thanks. I see what I did - I do not have an ADC-DAC - just the ADC. Fine.
I tried the above advice and that code runs - but returns 0.000000 on all 8 channels despite having a light sensor attached to channel 1's inputs. The similarly-named code over in DeltaSigmaPi/ runs there (as explained earlier) and returns numbers that do seem to vary with the light level on the sensor.
I guess I have started out trying to jump in too fast, but was also a bit mystified by documentation that did seem to assume that various things had already been installed. If I were to 'start all over' which is the most complete set of howto instructions to follow for the ADC Pi Plus?
21/07/2015
Posted by:
andrew
If the ADC is reading 0.00 when you connect a sensor try checking that the polarity of the sensor is connected the correct way around as negative values on the ADC Pi always return as 0.
21/07/2015
Posted by:
Peter Thejll
Yes! That was it! Thanks!
I see the point about the scale starting at 0. Is there a nice reason why, running (mistakenly) under the DeltaSigmaPi/ directory I can read signals with plus and minus signs?
21/07/2015
Posted by:
andrew
With the ADC Pi, the ADC is configured in the single-ended mode so it can only measure between 0V and 5V. As the voltage should never go below 0V any readings below that value are normally noise within the ADC chip so we made the library display those values as 0.
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.