Read analog inputs&send via UART

08 Mar 2011

I have LPC1768 kit.I need to read the 5 analog inputs and transfer this data via UART for every 2 minutes. Can you give the steps for coding?

08 Mar 2011

If I would like this code...

#include "mbed.h"

Serial pc(USBTX, USBRX);

AnalogIn ain_UseA(p15);
AnalogIn ain_UseB(p16);
AnalogIn ain_UseC(p17);
AnalogIn ain_UseD(p18);
AnalogIn ain_UseE(p19);

int main()
{
    float ad[5];
    float vdiv = (3.3 / 65535);
    while( 1 ){
        ad[0] = (float)ain_UseA.read_u16() * vdiv;
        ad[1] = (float)ain_UseB.read_u16() * vdiv;
        ad[2] = (float)ain_UseC.read_u16() * vdiv;
        ad[3] = (float)ain_UseD.read_u16() * vdiv;
        ad[4] = (float)ain_UseE.read_u16() * vdiv;
        pc.printf("%5.3f,%5.3f,%5.3f,%5.3f,%5.3f\r\n ", ad[0],ad[1],ad[2],ad[3],ad[4]);
    }
}
08 Mar 2011

Thanks for your reply. In the above code how can i view the result (5 analog data) in the host pc? I interfaced P27,P28 of mbed pins to serial port of host pc.

08 Mar 2011

Also include the timer inside the while loop.

wait(120.0)

08 Mar 2011

The view the data, please use a terminal. Normally the serial port is initialized to 9600Bd.

Have a look at this site ( of the Handbook )

http://mbed.org/handbook/Serial

09 Mar 2011

That Code is for USB. As follow for UART(p27/p28):

Serial pc(p28, p27);  //pc(USBTX, USBRX);
09 Mar 2011

I need to transmit this 5 analog inputs to RF module.so I need to connect mbed kit(LPC1768) with RFmodule.RFmodule has UART_RX,UART_TX,/MT_RTS,/MT_CTS,/SP_CTS and \TIME signals. How can i connect the RF module with MBED LPC1768 UART. Also give me steps for coding?

09 Mar 2011

'RTS' means 'Request to Send'. 'CTS' means 'Clear To Send'.

Both Signal is used for handshake. At First, You should study the steps of signal communication.

Sorry, I don't know named signal '/MT_xxx', '/SP_xxx' and '\TIME' .

09 Mar 2011

If That is XDM2510, Handshake signal is not required.

'/SP_CTS' signal on XDM2510, You set pull-down connect.

09 Mar 2011

I interfaced with XDM2510 only.Could you help me the coding for handshaking? how to initialize?

10 Mar 2011

I have not used XDM2510. So I can't explain it. You should read carefully reference manual on yourself.

Example.... mbed set low on'SP_CTS'.

If you want to send message to XDM2510, you should check the 'MT_RTS'. If 'MT_RTS' is low, you send to message . If 'MT_RTS' is high, you should not send to message.