RS-485 RTS Toggle

I

Thread Starter

Ivan Belca

I have problem with using mscomm in vc++ for modbus protocol over rs-485 line. The problem is that I can not control the rts toggle delay after transmiting data to 232/485 converter (and slave device). That's why slave try to transmit before rts is low so received data is bad.
I have obtained the same by using API windows functions.
Can anybody help?

Ivan
 
S

Sydney Deitch, Calta Computer

Hello Ivan,

Have you tried turning the serial port's transmit FIFO on or off from Control Panel to cause a change in behavior? When using a "dumb" converter (that needs RTS controlled), the transmit FIFO must be turned off.

If you can't get things to work, please check out SMRX at www.sapia-inc.com. SMRX is a Modbus/RTU Master ActiveX control that works great with VC++ and RS485 converters. You can download a working demo and examples and start talking Modbus/RTU today.

Best Regards,
[email protected]
 
If you use 232/485 converter, then you not must have problem.
May be you have bad converter?

I recomended MOXA and ICP CON converters.
Nienshans automatica provide ICP CON and MOXA in Russia.
 
R

Robert Scott

The is a common problem when using a Windows computer and a standard serial port to do RS-485. Unfortunately, there is no good answer using this hardware. I suggest that you get an actual RS-485 plug-in board, not a 232/485 converter. The actual RS-485 board has built-in perfectly-timed hardware control of the bus-enable. You may be able to do it in custom circuitry by sensing a time-out on the RS-232 start pulse to control bus-enable rather than giving that function to the host through the RTS line, like you 232/485 converter.

-Robert Scott
Real-Time Specialties
Embedded Systems Consulting
 
A

Alex Pavloff

Get a different convertor that does that all automatically. Controlling the RTS line with any sort of timing constraints can't be done reliably under Windows or Linux. Its possible to wiggle the line manually, but the time from the last-character transmission to the dropping of the RTS line will rather high, making it basically unusable.

Alex Pavloff - [email protected]
ESA Technology ---- www.esatechnology.com
------- Linux-based industrial HMI ------
-------- www.esatechnology.com/5k -------
 
Thanks for advice, but I still have to solve the problem by software. Nevertheless I can make 232/485 converter (automatic RTS) with PIC if I can't find software solution.
Ivan
 
Thank you. I will try that. Nevertheless everyting works in win98 environment. Problem is in XP environment.
Ivan
 
to ALL:

I develop simple little functions write() and read() for support RS-485.
It's functions ON/OFF DTR.
I test function on COM1270 or COM1210 of
http://www.eurotesh.it

If your board has support RS-485 contact with me.

I send to you sources (GPL) for QNX 4.25 and Linux.

Best Regards,
Yan.
[email protected]
 
Read the registry to find the port address. Access the UART directly at that port address. Assume 8250/16450 or 16550 and the registers are almost identical, especially for RTS control, etc. You can find data sheets for uarts at their manufacturer's web sites. Most UARTS maintain some common registers. Look at Exar or National Semiconductor to start with. You should not have a problem after that. If using a FIFO, if you use interrupts or are polling, be sure to check for these two conditions: TX register empty && TX FIFO empty BEFORE disabling the driver!
 
Can You plz tell me how to send the frame to the buffer in C & before sending the the frame how to make sure that the PLC to whom I am trying to communicate is also ready to communicate? So should I send Handshaking signals? if yes then How and after that how to trigger the frame to the UART. If possible can you send me a sample C code for refrence

Plz help me out.

Thank you
nitin
 
M
Hi, There are no control signals on RS-485 (i.e., RTS, CTS, DSR, DTR, DCD, etc.) - only two wires for both TxD and RxD (in half duplex), so there is no point in toggling them or listening to them (via the DCB - Device Control Block - in Win 32). Your problem should be solved by a convention implemented in all the partners communicating over RS485. Meir
 
A

Automation Linse

Nitin, in addition you should consider adding pre/post delays in Master/Client code. This is NOT easy in Windows, but since you cannot obtain feedback about when the slave "is ready", you may need to add an explicit 5 or 10msec delay (user settable) between each request. This is product dependant - some slaves need no extra time, while others literally have turned OFF their ports during another slave's response and so will not be back on-line for some vendor defined time delay beyond the response length.

There is no RTS/CTS low-level FIFO control since the protocols like Modbus (poll/response) assume enough buffer space for 1 request or response at all times.

- LynnL, www.digi.com
 
Top