ADC on nicla vision

Hello, nicla vision is having trouble reading the analog values from a extremely precise sensor.

I am conecting a high precision linear encoder in the A0 input pin of nicla vision. Using de the IDE example modified to print the ADC reading:

import time
from pyb import ADC

adc = ADC("A0")

while True:
    # The ADC has 12-bits of resolution for 4096 values.
    print("ADC = %fv" % (adc.read()))
    time.sleep_ms(1000)

the obtained values are very wrong. They are extremely unstable. An output example for the sensor is:

Traceback (most recent call last):
File “”, line 17, in
Exception: IDE interrupt
OpenMV v4.5.1; MicroPython v1.20-omv-r17; NICLAVISION-STM32H747
Type “help()” for more information.

ADC = 193.000000v
ADC = 105.000000v
ADC = 123.000000v
ADC = 71.000000v
ADC = 133.000000v
ADC = 81.000000v
ADC = 93.000000v
ADC = 164.000000v

and the encoder was static without anybody even touching it. So I need a way to obtain the analog input value directly from the pin (like arduino IDE analog input) is it possible? If its not possible, is there a solution for this problem?

the IDE and the nicla vision firmware are in the latest version.

Thank you.

Just tested it and it works fine:

import time
from pyb import ADC

adc = ADC("A0")

while True:
    # The ADC has 12-bits of resolution for 4096 values.
    print("ADC = %fv" % (3.3 * adc.read()/4096))
    time.sleep_ms(1000)

You were looking at the raw output of the ADC which has 12-bit resolution. So, you need to scale that to a voltage…

The problem is not the value, the problem is that the sensor when plugged to a osciloscope has no variation of the tension, using the ADC function it varies as I posted

When you used it, the readings were fine how? fine the same reading forever withou any change or fine the code works but there is variation even when te tension stands the same?

let me be more specific, using some other hardware/software/arduino IDE/osciloscope the reading is something like:

100
100
100
99
100
100
100

using ADC function on OpenMV the reading is:

115
109
103
76
107
118
130
127
104

Hi, i just used a variable power supply to output an analog voltage and found that the ADC reading tracked within 0.01V of what the power supply was outputting.

These are different processors so the ADC input drive strength may be different. You should use an OpAmp to buffer the output of your sensor so that it has enough drive strength to force an analog voltage on the ADC pin of the nicla.