Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Error with reading and setting up voltage

The ADC-DAC Pi Zero is a 2 Channel ADC and 2 Channel DAC for the Raspberry Pi

08/12/2018

Posted by:
fredsharifi

fredsharifi Avatar

Hi, I'm a new user to Raspberry Pi, I bought this board to do some analog testing, I followed the setup instruction and when it comes to reading to setting a channel i get error calling the function (set_dac_voltage(1, 3.3) , Here is the error I get

>>>> adcdac.set_adc_refvoltage(3.3)

>>> set_dac_voltage(1, 3.3) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'set_dac_voltage' is not defined".

although the procedure is defined in the ADCDACPi.py , How do I test the program to know if its communicating with the board?

Thank you

08/12/2018

Posted by:
andrew

andrew Avatar

Hi

Can you try running one of the demo scripts in the python library demos folder? You can find a copy at ADC DAC Pi demos

If the demos fail to run then you may need to go through our SPI tutorial to make sure the SPI bus is configured correctly.

One reason for the code failing with the "not defined" error could be that the ADCDACPi.py library can not be found by your code. Try putting ADCDACPi.py in the same folder as your code and import it with "from ADCDACPi import ADCDACPi".

08/12/2018

Posted by:
fredsharifi

fredsharifi Avatar

Thanks for the suggestion, I followed the instruction for the python command line inteface without running any specifit python program; the link to the instruction I found :

https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/tree/master/ADCDACPi

the import instruction is working fine, the mode instruction is working fine, setting up max ref voltage works fine, only when trying to read or write is where I get the error, the SPI interface is set to enable, I solder the pin header and nothing else, and plug into the IO Pin socket.

here is the copy of the python command line interface:

>>> from ADCDACPi import ADCDACPi
>>> adcdac = ADCDACPi(2)
>>> adcdac.set_adc_refvoltage(3.3)
>>> read_adc_raw(1, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'read_adc_raw' is not defined

08/12/2018

Posted by:
fredsharifi

fredsharifi Avatar

Thanks again for the suggestion, I ran the demo as you suggested and its working and Im getting values. I guess it just does not work with command line interface. thanks again.

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