Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Question on the read_voltage() function

1739 Views - Created 25/07/2018

25/07/2018

Posted by:
WayneA

WayneA Avatar

Does anyone have any example C code using the 'read_voltage() function'



We want to use the ADC Pi to read a varying voltage, send it out as a serial 16/17 bit number and then store it

in the R-Pi's memory as a parallel number.

Any examples of C code to do this would be greatly appreciated.

Regards,

Wayne

25/07/2018

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello Wayne

You can find a demo application using the read_voltage() function in our GitHub repository at https://github.com/abelectronicsuk/ABElectronics_C_Libraries/blob/master/ADCPi/demos/demo-adcread.c

read_voltage() takes 5 parameters:

address - I2C address for the target device e.g. 0x68
channel - 1 to 4
bitrate - 12, 14, 16 or 18
pga - 1, 2, 4 or 8
conversionmode - 0 = one-shot conversion, 1 = continuous conversion

The function returns a double-typed voltage from the ADC.

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.