Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

reading rs232

Status
Not open for further replies.

jbchrist

New Member
I bought a RF Link - 4800bps - 315MHz from www.sparkfun.com. Using two PIC12F675 and the RF link I want to communite wirelessly between them. I have created some code using an example that sends the letter r to the hyperterminal window. That works beautifully.

Now I need to receive the r from the transimitting PIC. I don't know how to decode the RS232. I understand that you need to watch out for the start and stop bits, but how do you discern those bits from the regular bits?

Are there any tutorials/examples of receiving rs232?

John
 
the 12f675 is a small pic, any reason to use such a limited pic, especially since you're just starting out?

you need a soft-uart to 'decode' the serial signal. rs232 implies a certain signaling level (voltages and such), your wireless link is not rs232, it's just regular asynchronous serial ... if you were to connect it to a max232, you'd have rs232, or a different chip you'd have rs485, etc.

alternately if you used a more robust pic, such as the 16F88 (a good choice for beginners), the chip contains a UART built in, then all you need to do is read bytes from the receive buffer, and load bytes into the transmit buffer.
 
I chose the 12F675 because it is small. My application is pretty simple. I just need to read in a signal from a sensor, convert to digital, transmit the data, recieve it, and then light up 1 of three status LEDs (red, yellow, green). So you can see that I don't need a lot of extra pins.

If it is too difficult to write a program that will read the asynchronous serial, then I will look into getting one of those PIC16F88. If I can I would like to keep the extra pins to a min.
 
what programming language are you using? high level langs like basic and such have soft-uart libraries, easily accessed with commands such as "SEROUT and SERIN". low level langs like assembler leave it all up to you. you'll want to search out serial comms routines for your language. go ahead and search for rs232 examples, even though that's not technically what you need - the com routines will still be the same, you just won't need a level shifter (max232) like the examples probably describe.
 
jbchrist said:
Now I need to receive the r from the transimitting PIC. I don't know how to decode the RS232. I understand that you need to watch out for the start and stop bits, but how do you discern those bits from the regular bits?

Are there any tutorials/examples of receiving rs232?

John

Yes, Have a look at Nigel's tutorials (from this forum). He has documented how to send and receive serial data in software and you should be able to easily adapt it to the 12F675 that you are using.
Here is the link to his serial data tutorial:
 
Note: I am using the pic c lite complier.

Thanks for the tutorial. That answers a lot of my questions. But how do I know if my signal has been synced?
 
syncd to what? your serial gizmo is asynchronous - there is no external clock to sync with. the soft-uart routines will do the clock recovery for you. your C compiler should have some high level commands to handle asynchronous serial, Nigels tutorials are at a much lower level.

you might want to consider some sort of encoding to protect the data during transmission. Manchester is a popular scheme, but there are others as well.
 
I'm guess I am using the wrong terms.


Using Nigel's program, how do I know that I havn't started reading in the middle of the byte?
 
jbchrist said:
I'm guess I am using the wrong terms.


Using Nigel's program, how do I know that I havn't started reading in the middle of the byte?

Manchester coding takes care of that - it's one reason NOT to try and use RS232 over a radio link.
 
you can try something simple like pad your data with all ones at the start

like 0xFF, 0xFF, 0xFF, Data, Data, repeat

your receiver will keep sampling the data, looking for three 0xFF's in a row, and then it will know that sensor data is to follow. this is just a basic example, there's lots more on google
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top