4 years ago.

LPC1768 : Voltage on AnalogIn pin with no input

Hello, I'm sorry if my tittle was not explicit.

I have a problem with my MBED, for a project I send a signal to pin17. This pin was set as an AnalogIn at the beginning of my code. When I only link the mbed to the computer by usb or provide energy to the mbed with a battery the pin17 send 2.4volt. The problem is that this output go to my circuit and false the signal I try to measure when i link the pin 17 to my measure circuit

Is it possible to set the output of pin17 to 0V and just keep him for reading ?

This is what I understood your question to be asking. Please correct me if I have it wrong:

I have a problem with my MBED, for a project I want to connect a signal to pin17. This pin is set as an AnalogIn at the beginning of my code. When I supply power to the mbed from either the USB or battery pin 17 goes to 2.4 volts.

The problem is that when I connect pin 17 to my circuit this output goes into my circuit and causes errors in the signal I am trying to measure.

Is it possible to set the output of pin17 to 0V so that it doesn't influence the reading?

posted by Andy A 05 Jul 2017

I am having the same problem, trying to sample signal from an electric guitar (in range +/- 0.5v or so) but my analog pin (PA_6) is stuck at 1.75V before I even connect anything. I'm using a development board with STM32F407ZET6, the Seeed Arch Max target has been working well for everything else I've tried.

posted by iforce2d Chris 10 Jul 2017

1 Answer

4 years ago.

What is the source of the signal you want to measure?

The analogIn pin won't be driven to any level (and certainly not to 2.4V, only the analog out pin could do that) but there will be a natural drift to some voltage level due to internal resistances. If the signal you are trying to measure is particularly high impedance then this bias could have an impact. Even if the bias could be set to 0V that would still have an influence, just towards a different voltage.

It is standard practice when connecting a very high impedance signal to an ADC input to add a buffer in order to prevent the ADC from influencing the measured signal. For most simple applications an op-amp in a non-inverting unity gain configuration will work fine.

Alternatively it may be possible to decrease the impedance of your driving circuit, it depends on what it is.

The source of the signal was a photodiode current transformed in voltage by a TIA and process by a low pass, then a high pass filter (Sallen Key). The last stage of the processing was a non inverter additionner aop with a gain of 20

But I think the current from pin was not due to my circuit, since i have the same voltage on pin20 where nothing (literally nothing) was connected.

posted by Panchevre Loic 06 Jul 2017

Pin 20 or pin 17? What you are seeing seems odd, there shouldn't be any output on those pins. Can you post code and schematics?

posted by Andy A 06 Jul 2017

The pin16 is the one i used on my circuit (Sorry i make a mistake on the first post), the pin20 was just a try to see if i observe output here, since he was not used in my circuit and not connect to anything

Here is my code :


Serial pc(USBTX, USBRX);

Sensor sensor(p16);

LedP *selected(&sensor.getRed());

char buffer('n');
bool progress(true);

int main()
    pc.puts("debut du programme\r\n");
    while(progress) {
        buffer = pc.getc();
        pc.printf("Ordre : %c\r\n", buffer);
        if(buffer == '1') {
            selected = &sensor.getRed();
        } else if(buffer == '2') {
            selected = &sensor.getIRed();
        } else if(buffer == 'a') {
        } else if(buffer == 'e') {
        } else if(buffer == 's') {
            if(sensor.getRed().getEstAllumer()) {
                pc.puts("Led rouge allumer\r\n");
            } else {
                pc.puts("Led rouge etainte\r\n");
            if(sensor.getIRed().getEstAllumer()) {
                pc.puts("Led infrarouge allumer\r\n");
            } else {
                pc.puts("Led infrarouge etainte\r\n");
        } else if(buffer =='m') {
            string stime;
            string sfrequency;
            char car('y');

            //pc.puts("Time(s) : ");
            pc.puts("\r\nFrequency(Hz) : ");
            do {
                car = pc.getc();
                if(car != ' ') {
            } while(car != ' ');
            float frequency = atof(sfrequency.c_str());


        } else if(buffer == '*') {
            progress = false;
    pc.puts("Fin de la boucle\r\n");
    return 0;

I observe the output when i'm in or out of the while and even if I don't give any order

Here is the constructor for Sensor and Led, the other methode was only call when I give an order, but the output was observable without this so they are not useful I think



//Constructeur qui prend un PinName comme argument pour l'AnalogIn
Sensor::Sensor(PinName pin) : a_signal(pin),a_local("local"),a_red(p26),a_iRed(p25),a_pc(USBTX, USBRX)

AnalogIn a_signal();
LocalFileSystem a_local();
LedP a_red();
LedP a_iRed();
Serial a_pc();



//Constructeur qui prend un nom de pin comme argument
LedP::LedP(PinName pin): a_led(pin)
    a_led = 0;

PwmOut a_led();
bool a_estAllumer(false);

And the schematic of my board : https://img4.hostingpics.net/pics/781851ScreenShot20170707at112302.png

posted by Panchevre Loic 07 Jul 2017