Enquiry on UART

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enquiry on UART

241 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jx1 on Tue Jul 09 23:51:00 MST 2013
I am currently working on a serial UART ( DALI Master and Maxsonar). I have problems writing it in LPC Xpresso. I would like to light up an LED when less than 6 inches is detected and led will not light up when more than 6 inches in example to test out. Could anyone please guide me how to start working on it ? The sequence of TX is what I am working on in datasheet. Thanks in advance  :D .

Datasheet of Maxsonar I am using:
http://www.maxbotix.com/documents/MB1010_Datasheet.pdf
0 Kudos
3 Replies

229 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Thu Jul 11 08:42:02 MST 2013
No I don't, but the code would look something like this

#define ON 1
#define OFF 0

char my_array[4];
int distance;

c = readchar(); // or whatever function you have to read a bytes from the UART
if (c == 'R') {
   my_array[0] = readchar(); 
   my_array[1] = readchar();
   my_array[2] = readchar();
   my_array[3] = 0;
   distance = atoi(my_array);
   if (distance > 6)
          set_led (ON);
   else
          set_led (OFF);
}
I've just made up the function names, presumably you have (or can write) functions to get a character and set the LED.
0 Kudos

229 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jx1 on Wed Jul 10 07:30:52 MST 2013
Hi graynomad,

Do you have any similar sample program to test out the range of the Maxsonar which it can detect?
0 Kudos

229 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Wed Jul 10 01:09:05 MST 2013
The data sheet says


Quote:
The output is an ASCII capital “R”, followed by three ASCII
character digits representing the range in inches up to a maximum of
255, followed by a carriage return (ASCII 13). The baud rate is
9600, 8 bits, no parity, with one stop bit.



What bit don't you know how to do?
0 Kudos