RS programming

Hello.
I'm beginner in RS programing. I've two devices, measure with RS485 interface and pc witch RS485 interface. I'd like this communicate.
I once programme devices with RS232 interface. What are difference (in program code) between RS232 and RS485 programing ?
Thank for Your help GG
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

The main difference is in how you handle the direction control. RS485 is a half-duplex bus technology where both directions share the same wires. You must program so that two devices don't try to send at the same time. The biggest hangup for using standard UARTS to do RS-485 is that it is hard to precisely control when to turn off the transmitter after a packet has been sent. Most UARTS do a good job informing the software about when the holding register is empty, so that the softare can write out another character. But these same UARTS do not do such a good job telling the software when the shift register is empty. And that's what you need to know to turn off the transmitter. Some UARTS provide a bit that can be polled that says if the shift register is empty, but usually this status bit does not cause an interrupt. So unless your software is sitting in a tight loop watching this bit, it will be hard to turn off the transmitter at just the right time. Fortunately, there are interface circuits designed to handle the transmitter-enable signal for you. Then the software has an easier time of it.
-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Robert Scott wrote:

If you can afford to spend (waste) the time, simply wait ten bit times after THRE (transmit holding register empty) is asserted. In one situation where looping for a character time was unacceptable, I redirected the UART transmitter-ready interrupt instead of turning it off after the last character. Instead of the routine that sent another character from the buffer, it started a timer which called the line turn-around interrupt routine when it timed out. The idea is simple, but the details have to be worked out carefully.
Jerry
--
Engineering is the art of making what you want from things you can get.

  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Yes, especially the part about reacting in 10 bit times. Since you are sending out an extra dummy character, the start bit of that character would create errors if it were allowed to get out. So you must disable the transmitter some time after the last real data bit and before the end of the stop bit (or bits). Not too difficult in an dedicated embedded system, but try doing that in a Windows app without writing a kernel-mode device driver.
Jerry, you seem to hang out in all the same newsgroups that I hang out in :-)
-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Robert Scott wrote:

Similar interests, evidently.
Windows is hardly real-time, and there's more code than anyone concerned with reliability can undertake responsibility for. The best one can do is keep one's fingers crossed. If there's no reliable way to turn off the transmitter promptly after the last character, then one can wait 15 or 20 bit times or however long it takes. At 115,200 bits/sec, that ought to be tolerable in any procedure that Windows can reliably handle.
jerry
--
Engineering is the art of making what you want from things you can get.

  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Yes, it will be tolerable for Windows, but it may not be tolerable for the devices you are talking to. There is no way to prevent them from trying to respond to you before you have turned off your transmitter.
-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Call me a wimp or sissy, but I ring up B&B Electronics and get one of those cool '485 cards that does all that in hardware.
Time and life in general is worth way more than the $100 or so cost.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Steve Cothran wrote:

Yup, that's the way to go. Nevertheless, I consider any half-duplex protocol without a specifiable hold off deficient. (The world abounds with deficient things!)
Jerry
--
Engineering is the art of making what you want from things you can get.

  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Nevertheless, I consider any half-duplex

Interesting.
Back in the dark days we built a board with a plain-vanilla 8051 and '485 via a 75176. The direction control was handled with a port pin. There was a SCON bit that indicated txbuf was empty (can't remember the name) and we used it to switch the port pin. It never worked right until we added a few ticks delay between the internal bit toggle and the port pin.
I guess that the buffer is empty don't mean that it ain't transmittin'.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
GG wrote:

GG,
You should know that the "RS" in RS-232 and such stood for "recommended standard" when it was promulgated by EIA -- Electronic Industries Alliance. Now that EIA's standards activity is absorbed into ANSI, it's just there for historical reasons.
Jerry
--
Engineering is the art of making what you want from things you can get.

  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

interface.
programing ?

..and I, for one, am amazed at the many manufacturers of "RS232" industrial equipment that have pushed the boundaries of "recommended" to the limit.
Rotork's Pakscan RS232 host interfaces are a case in point - they don't drive any of the signal lines to the "recommended" level, so if you connect one to, say, a Siemens CP341 RS232 comms card, the blasted Siemens card doesn't transmit 'cause it thinks nothing is connected!
We got around this by installing a couple of B&B fibre modems in the link and now it works a treat.. So much for the KISS principle. ;-)
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
What is when I'm going to use some popular protocol, example Modbus, Profibus ??? Problem with direction control is actual ??

interface.
?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.