PDA

View Full Version : rs485 to rs232 smart switch



RSSHARPE
- 12th June 2004, 11:44
I have an application were I need addressable switch to power on a rs232 device and switch on communications to this device. Ther will be 16 devices on this network. My concern is after PIC determines its addressed (valid command on) I need to make communications transparent through PIC ie bi directional from one
comm port to the other. I am concerned with loosing data and timing etc. I could buffer input / output data but data strings are not more than 256 or so at a time. Any thoghts or comments would be appreciated.

Thanks in advance

Scott

Melanie
- 12th June 2004, 13:50
If you don't want to lose data then here's the options...

1. Have a handshake protocol, (either embedded in software such as XON/XOFF) or in Hardware (such as RTS/CTS) etc. They were invented so that your tetraplegic Cray Supercomputer would not lose data being sent to it from your Golfball teletypewriter. Most folks don't bother with these any more (or have forgotten what they were invented for)... and then when they lose data or discover it's corrupt they cry into their coffee posting messages that it's all diluted and undrinkable.

2. Ensure the data being received is at a SLOWER speed than the data being transmitted. This has a neat side-effect of saving on having to buffer in the middle.

3. Ensure that the speed of your PIC is adequate to handle the dataprocessing involved. This usually means you can't run your PIC on a 32kHz watch crystal.

4. Ensure you have a sufficient data buffer in the middle to handle unexpected situations. Some folks have tried to do this with a 12C509 and wonder why they can't define a 512Mb RAM buffer (probably because they're using an old version of PBP).

You may need to implement some, any or all of the above.

Melanie

Squibcakes
- 16th June 2004, 23:14
2. Ensure the data being received is at a SLOWER speed than the data being transmitted. This has a neat side-effect of saving on having to buffer in the middle.

Hi Mel,

This sounds confusing, are you referring to a slower baud rate for the receiver?

Squib.

Melanie
- 17th June 2004, 08:44
Exactly. If the receive data is slower than the transmit data, the net result is you're disposing of your data faster than you're receiving it. It also means you have a little processing breather in the middle before the next byte is incomming. If it was the other way around, you start having to buffer your data because it is accumulating faster than it can be disposed of. You are then limited to your buffer size. Now there's nothing wrong with this as long as you know your limitations... if on the other hand your PIC is receiving a 700Mb episode of Enterprise at 600kb and spitting it out at 56kb to a PC, you just might have a teeny buffering problem in the middle...