Hello,
I noticed that reading the analog inputs of a NUCLEO-F446RE returns a lot of noise:
These analog inputs have a resolution of 12 bits.
I connected one input to ground, another to a voltage source and I take measurements every 15us.
The following remarks are valid for both inputs.
- I noticed a 10 LSB (Least Significant Bit) offset, so why not.
- I noticed a noise of + or - 2 LSB on a few tens of successive measurements, which brings the measurement precision to 1000 LSB (= approximately 10 bits), it is a little less nice.
- I have noticed that peaks which reach + or - 10LSB appear randomly, generally spaced a few tens of measurements apart, which brings the measurement precision to 200 LSB (<8 bits),
that’s much more annoying.
Here is the read program used with MBED-OS 6.2:
#include “mbed.h”
#define WAIT_TIME_MS 500
#define Imax 1000BufferedSerial port_USB(USBTX,USBRX); // tx, rx
//DigitalOut led1(LED1);
DigitalOut led1(PB_2);
AnalogIn PosVerin(PC_4);
AnalogIn MasseVerin(PA_7);Timer MyTimer;
char TabChar [300];
int indice;
long TempsMesure[Imax];
double MesurePosVerin[Imax];
double MesureMasse[Imax];int main()
{
port_USB.set_baud(115200);//vitesse de transmission 9600; 19200; 38400; 57600; 115200; 230400; 460800; 921600 bauds
MyTimer.start();
for (indice=0; indice<Imax; indice++)
{
TempsMesure[indice] = MyTimer.elapsed_time().count(); //Temps en us
MesurePosVerin[indice] = PosVerin.read();
MesureMasse[indice] = MasseVerin.read();
}
sprintf(TabChar, "\nTemps ");
sprintf(TabChar, "%sPosVerin ", TabChar);
sprintf(TabChar, "%sMasse ", TabChar);
sprintf(TabChar, “%s\n”, TabChar);
port_USB.write(TabChar,strlen(TabChar));for (indice=0; indice<Imax; indice++)
{
sprintf(TabChar, "%ld ",TempsMesure[indice]);
sprintf(TabChar, "%s%ld ", TabChar, (long)(MesurePosVerin[indice]*1E9));
sprintf(TabChar, "%s%ld ", TabChar, (long)(MesureMasse[indice]*1E9));
sprintf(TabChar, “%s\n”, TabChar);
port_USB.write(TabChar,strlen(TabChar));
}
sprintf(TabChar, “\n\n”);
port_USB.write(TabChar,strlen(TabChar));while (true)
{
led1 = !led1;
thread_sleep_for(WAIT_TIME_MS);
}
}
Do you have any idea how the read () statement works? Or the origin of the problem?
I know that to correctly read an analog to digital converter you need to use a sample and hold (which can be integrated into the component). This could be related to the problem, it is a hypothesis.
Do you know of any other way to read an analog input?
Marc.