rs232-rs485 tranceiver
nick bernard
Posts: 329
hi,
looking for a second opionion on this bi directional serial converter i just drew up for an sx application i've been working on. the trick is knowing what direction is data going because there is a tx/rx pin on the rs485 transceiver. i put an ac photo-coupler to detect the 232 signal. a seemingly good solution.
will this design work?
any questions and responses are greatly appreciated
thx
nick b
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If I lived back in the wild west days, instead of carrying a six-gun in my holster, I'd carry a soldering iron. That way, if some smart-aleck cowboy said something like "Hey, look. He's carrying a soldering iron!" and started laughing, and everybody else started laughing, I could just say, "That's right, it's a soldering iron. The soldering iron of justice." Then everybody would get real quiet and ashamed, because they had made fun of the soldering iron of justice, and I could probably hit them up for a free drink. - Jack Handy
looking for a second opionion on this bi directional serial converter i just drew up for an sx application i've been working on. the trick is knowing what direction is data going because there is a tx/rx pin on the rs485 transceiver. i put an ac photo-coupler to detect the 232 signal. a seemingly good solution.
will this design work?
any questions and responses are greatly appreciated
thx
nick b
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If I lived back in the wild west days, instead of carrying a six-gun in my holster, I'd carry a soldering iron. That way, if some smart-aleck cowboy said something like "Hey, look. He's carrying a soldering iron!" and started laughing, and everybody else started laughing, I could just say, "That's right, it's a soldering iron. The soldering iron of justice." Then everybody would get real quiet and ashamed, because they had made fun of the soldering iron of justice, and I could probably hit them up for a free drink. - Jack Handy
Comments
I think you'll have a problem because you'll be flipping the '485 chip back an forth between talk and listen every time an incoming bit changes.
Having said that, there are numerous products that use what is called "Auto direction detection". They basically watch for the transition of the start bit and hold the '485 chip in talk mode until the time for a complete word to go by. Depending on the baud rate, the timing has to be adjusted.
The B & B Electronics web-site has lots of technical data on everything serial.
Cheers,
Tom Sisk
First, the MAX232 is a bit redundant. Does it have 'built-in' isolation?
If you are using a BS24sx and use a second COM port [noparse][[/noparse]at +5v/0v], you can directly drive the optoisolators and they can connect to the RS-485 driver/reciever at TTL. You also don't need a 'fancy' bi-polar opto-isolator. That will leave your programming port free for Debug and programming.
If the SX you are refering to is a Ubicom SX-28, SX-48, or SX-52, the Max232 is useless as it doesn't output RS-232 levels [noparse][[/noparse]+9/-9].
Many schematics tie the two RS-485 together in a pull-up or pull-down configuration [noparse][[/noparse]it depends if you are the Master or the Slave]. This allows one pin to control both. Unless you really want to create a High-impedance on both lines, it seems to conserve programing and pins.
B & B Electronics has a lot, but you pay big bucks for their stuff. It is primarily a site for non-builders.
Regarding the opto-isolation, it seems to me that your 'isolation barrier is quite unclear. Isolation includes two isolated power supplies. One on each side of the isolators. If everything is sharing one supply, the isolation isn't there.
Additionally, each and every line on the RS-485 reciever/driver should be opto-isolated. Selectively isolating one seems to be piecemeal.
In sum, I would eliminated the MAX232 unless you must have data through the dedicated COM port reconverted to TTL. I would use two separate +5V power supplies. And, I would use 3 opto-isolators - one on the TX, one on the RX, and one on the Direction control. Obviously the opto-isolators must draw power from both +5 sources in an appropriate way. In sum the Sx would be on one side of the barrier with all it's connected circuitry and the RS-485 driver would sit on the otherside of the barrier.
About the only thing to consider after that is adding a 100ohm resistor to the properly terminate the Rs-485 reciever/driver as to avoid 'reflected' signals at the end of the line. All that is on the RS-485 side.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
G. Herzog in Taiwan
i havent been to clear on my sx application so allow me to clarify.
i've developed a distributed network that uses sx28s and 65LBC182's (485 xcvr by TI). there is one master and 4 slaves on the network. i simply want to delevop a circuit that can replace the existing master with a laptop for testing and such.
i made a small circuit that reads the network into hyperterminal using only a max232 and TI's tranceiver. that was easy. but to make a circuit that works in both directions is much more difficult. i added the ac isolator to detect the 232 signal and put the xcvr in transmit mode. Tom says that the ac isolator detection will fail because there is a delay between the rs232 1's and 0's causing the xcvr to toggle between transmit mode and receive mode and a device to hold the xcvr in transmit for the duration of the sentence is neccessary.
i think a small cap to hold bt rs232 lvl changes would suffice.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
sometimes never is better than sometimes.
Im trying to get an SX to be the address'ing etc part of a RS485 network, any chance of some code snippits / wiring diagram?
James
Assuming you have your software right and all your slaves tested, it should start right up.
I can't help Javalin with code as I am thinking hardware.
Conceptually.....
You can go so many places with the software code. I have been considering packets of 8 or so bytes with a CRC byte on the tail end - small, not too talky, but enough to convey some coherent information.
Javalin obviously wants something like an addressing byte on the head of the packet or maybe just a one byte call to get the attention of the slave that you want to send to and to shut down the others before you send a packet. Then the actual packet would come later and sign off. Not every device can talk at the same time-nothing gets done.· There other devices would have to know how long to wait before they start to listen again.
Jon keeps recommending a book by Jan ? and I am seriously considering buying it. The topic is quite large and a reference volume may be both worthwhile and necessary. But what you gain is stability and reliablity of a genuine network concept, not just fooling around with hardware on a table.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
G. Herzog in Taiwan
Post Edited (Kramer) : 9/4/2005 4:51:36 PM GMT
Thanks for that. Whats a 75156?
Yeah Jon's suggested the complete serial book, placed an order for it. (note he's a reviewer.....)
Cheers,
James
It is such an easy connect to a BasicStamp that I really feel RS-232 for 3 meters is a waste of time and effort. The MAX-232 costs quite a bit more, has 16 pins, needs external capacitors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
G. Herzog in Taiwan
Post Edited (Kramer) : 9/12/2005 4:18:57 PM GMT
sorry for the laggy response.
my system has 2 networks.
The FX network reads the position of an encoder and broadcasts the data to a few displays and one controller; therefore, addressing is not necessary.
the CX network is bidirectional with 1 master and a few slaves. the slaves are addressed by a rotary dipswitch. on startup the master polls all posible addresses ($00 to $0F) and stores the addresses of the slaves that respond. next the master transmits a commands to the network. something like "CX1200!". slaves examine the string first for the header CX, then for the address 1, then the command 2, and the value 00, and responds accordingly. i'll have to fix the headers though F & C appear in the value part of the buffer and could confuse the network
if you have questions about code and such start a new thread and i'll help you anyway i can.
ROX ON
nickB
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
engineer, fireman, bowler, father, WoW addict [noparse];)[/noparse]