Community Forum Share your projects and post your questions

Register or Sign In

Error with reading and setting up voltage

393 Views - Created 44 days ago

44 days ago

Posted by:
fredsharifi

Users 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

44 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi

Can you try running one of the demo scripts in the python library demos folder? You can find a copy at https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/tree/master/ADCDACPi/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".

AB Electronics UK Tech Support

43 days ago

Posted by:
fredsharifi

Users 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

 

43 days ago

Posted by:
fredsharifi

Users 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.

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.