12 years, 10 months ago.

Analog In, Output @ PC

Hello,

can someone help me? I need a program that reads the voltage at the analog input and output of a terminal program on the PC as analog and digital output. Is that possible?

Thanks in advance

3 Answers

12 years, 10 months ago.

Are you after something like this?

#include "mbed.h"

AnalogIn ain(p19);
Serial pc(USBTX,USBRX);

int main() {
    while(1) {
        pc.printf("\r ain = %f V   ",ain.read()*3.3);
    }
}

Accepted Answer

Yes, I am!

posted by Michael Amling 09 Apr 2013

Hello, can someone help me? I need a program that send the 20v voltage from mbed analog output pin 18 to a device. also, I can read that on a tear terminal program on the PC. Is that possible? thank you

posted by sasa sasa 09 Feb 2016
12 years, 10 months ago.

Hi Michael,

If you are new to mbed, I am recommending the getting starting guides! Choose the right one for your board: LPC1768 or LPC11U24 or FRDM-KL25Z. After that, this should help you: /handbook/AnalogIn

12 years, 10 months ago.

Hello David,

thx for your fast answer. you're right i'm new with mbed and i read a lot about it.

I am a student and working in a project. I need to read from a rear wheel travel sensor (-3V to +3 V) voltage and provide it to a CAN message. I know that the mbed controller can not have negative voltages at the analog input. This is prevented with a prescreening.

I can do that the voltage at the analog input could be read and send to the serial port. (multiplier 3.3). Unfortunately, I do not know now how I can proceed in the program code to provide these analog signals for the CAN bus. Can you help me maybe?

Sorry I hadn't worked with CAN so far. You may already found this one: /handbook/CAN. The mbed can't also handle negative voltages at any other pins. So it's really important to secure your mbed. Am I right you throw the negative voltages away? Did you think about an operational amplifier? An inverting op-amp with an absolute gain < 1 and summing a positive voltage, so the range will be inside 0V to 3.3V.

posted by David Golz 09 Apr 2013