ADC121C021 inconsistent

I am using the output from an inclinometer (0.5 to 4.5 volts) to the ADC121C021 board. With the inclinomter at a fixed angle I can read the voltage as a fixed value. In this test the voltage from the inclinometer was 2.56v. Using the python library and measuring every second the voltage ranged from 2.4 to 2.8 and kept changing. Yet when using the 4 channel 16bit board it does not change and reads perfectly.

Here is the code for the 12 bit board
bus.write_byte_data(0x50, 0x06, 0x20)
time.sleep(1.0)

    # ADC121C021 address, 0x50(80)
    # Read data back from 0x00(00), 2 bytes
    # raw_adc MSB, raw_adc LSB
    data = bus.read_i2c_block_data(0x50, 0x00, 2)

    # Convert the data to 12-bits
    raw_adc = (data[0] & 0x0F) * 256 + data[1]

    voltage = raw_adc*0.00122070312
    angle = round((voltage-2.5) / 10 * 300,1)

    print("%d" %voltage)

Does anyone have any ideas as to what I’m doing wrong?
Roger K

hi,
i will recommend trying out this lib

can you share the inclinometer part number ?

Thanks

inclinometer is Accustar-EA 02114002-000

I tried the library that bhaskar suggested and got the following output for a steady measured voltage of 2.47
'Digital Value of Analog Input : ', 2.38, -3.6)
('Digital Value of Analog Input : ', 2.52, 0.6)
('Digital Value of Analog Input : ', 2.59, 2.7)
('Digital Value of Analog Input : ', 2.43, -2.1)
('Digital Value of Analog Input : ', 2.56, 1.8)
('Digital Value of Analog Input : ', 2.32, -5.4)
('Digital Value of Analog Input : ', 2.52, 0.6)
('Digital Value of Analog Input : ', 2.32, -5.4)
('Digital Value of Analog Input : ', 2.57, 2.1)
('Digital Value of Analog Input : ', 2.54, 1.2)
('Digital Value of Analog Input : ', 2.32, -5.4)
('Digital Value of Analog Input : ', 2.65, 4.5)
('Digital Value of Analog Input : ', 2.34, -4.8)
('Digital Value of Analog Input : ', 2.32, -5.4)
('Digital Value of Analog Input : ', 2.33, -5.1)
('Digital Value of Analog Input : ', 2.6, 3.0)
('Digital Value of Analog Input : ', 2.66, 4.8)
('Digital Value of Analog Input : ', 2.42, -2.4)
('Digital Value of Analog Input : ', 2.67, 5.1)
('Digital Value of Analog Input : ', 2.41, -2.7)
('Digital Value of Analog Input : ', 2.47, -0.9)
('Digital Value of Analog Input : ', 2.63, 3.9)
('Digital Value of Analog Input : ', 2.67, 5.1)

Sorry, copied the wrong output … for a constant 2.47volt I get
Digital Value Analog Input : 2114
Voltage : 2.58056639568


Digital Value Analog Input : 2084
Voltage : 2.54394530208


Digital Value Analog Input : 2187
Voltage : 2.66967772344


Digital Value Analog Input : 2071
Voltage : 2.52807616152


Digital Value Analog Input : 2182
Voltage : 2.66357420784


Digital Value Analog Input : 2063
Voltage : 2.51831053656


Digital Value Analog Input : 2074
Voltage : 2.53173827088


i will recommend doing ADC avg or increasing the number of samples.

I did look at averaging but the readings are way too inconsistent to get a good average. eg the inclinometer reads 2.50 volts when level so 2.47 is a slight negative angle. if I was to average the samples from this test it would give me a positive angle the the leveling system would adjust the wrong way.

Why does it keep changing when the 4 channel ADC does not change?

The main reason will be vref. This ADC121 usages VCC as its ref voltage. and if the supply is not extremely clean you will see these inconsistent readings.
If i were working on this project i will use something like ADS1115.
Its has 15 bit resolutions and also has inbuilt vref.

Hi Reidwhitney,

I’m currently working on a similar project with the LOPYI2c and ADC121C021, and can’t find good example with these devices. Can you share your code that you used for it ?

Regards.

Richard.