I’m looking for the libraries and code samples for the single channel NCD Raspberry Pi 0-10V Board. And any other documentation would be great. I picked this board as the product page mentions Pi libraries and code samples but I cant find them.
I’ve tried to compile the code from both the read and write examples, but I’m still getting inconsistent readings when checking against a voltage meter.
This is kind of a strange chip. On most chips the standard packet would be [address, register, [value]] for a write. Usually the [value] is just a single byte that you want that register to be set at.
This is just [address, [value]] where value is a series of bytes to determine the voltage.
What you’re sending on line 36 is [address, register, [value]]. Try just bus. write_byte_data(DEVICE_ADDRESS, (raw_value >> 4), ((raw_value & 15) << 4)
let me know if that works. Also send over any error messages you’re getting.
The only trouble I have left is converting the data I’m getting back from the registers into voltage.
@Bhaskar gave me two examples that are listed as functions in my original code gist, convert_to_12bits(data) and convert_to_voltage(raw_adc).
The results I’m getting don’t seem right. For example, I’ve succesfully written 4095 to the register, and the multimedia is reading 10v, however reversing the process and reading 2 bytes from 0x60 with an offset 0x60 (or 0x00 for that matter) is producing the following results.
Raw Data: [192, 255]
Raw ADC Output: 255
Voltage:: 0.09V
Any thoughts would be much appreciated. All the registers are seeming to give me the same raw data.
It doesn’t have anything for setting an output on the MCP3428, but the read functions worked for me.
The register on that particular chip is different depending on the particular options with an OR operand self.mode | self.sample_rate | self.gain | (32*channel)