Using RTS as RS485 control line in rcm3000

Hi, can anyone please tell me how to use RTS line to control the control pin of 485 by activating flow control? I set the RTS & CTS pins in the code as explained in the function list but it’s not working. please tell me if i’m missing somethng.

You will probably need to disable RTS/CTS control for the serial port and drive the RTS pin directly to control switching of the serial driver direction.

The BACnet stack uses RS485 for it’s MS/TP and I have examples of it with different boards (all R4000/R5000/R6000 so for DC10.xx) based in the mstp.c file.

Also have a look at the modbus slave sample libraries with DC for examples of this.

Regards,
Peter

Hi Peter,
Thanks for the reply. When u say “drive the RTS pin directly”, do u mean to make it an ordinary i/o pin and make it high whenever i’m sending data? coz i already tried it and it works with an accuracy of 99%. The product we are developing is an Ethernet to serial converter and it worked perfectly well on almost all the protocols for more than a year now but when they recently introduced a new protocol it gets hanged, for that particular protocol only, after about every 8 hours. We found out that it happens only when the slave reply back with only one byte 0x06 (ACK) as its response.

Thats right, thats the only way to explicitly control the direction of the RS485 comms.

When you say hanged, do you mean your app crashes or just that response does not get received? Do other single byte responses get through (i.e. different single byte responses or other instances of the 0x06 response)?

Regards,
Peter

no, the application never crashes. When the master doesn’t receive 06 it keeps on sending the same command again and again but the slave has already ack’ed it once so it replies with 0x15 which again never reaches to the master. After some seven or eight tries the master stops sending the command and slave stops itself due to break in communication. the system gets back on track when u restart the slave device. This only happens once in about 100 times but it completely stops the system and then someone has to manually restart the slave device to turn the communication on again.

The only thing I can think of there in terms of the RS485 direction switching is that if you switch the direction too late you may miss a character coming back. You might want to put an oscilloscope on the RTS line and on the RS485 data line and see what is happening. Alternativly you could put a PC on the 485 line to log the data and see if it is always being sent correctly.

Regards,
Peter

well peter as i said, it happens once in about 100 times. i tried to simulate command and response in my lab and it took two days for that same problem to occur. As for the log, i have already did that and the single byte (06) is detected on the 485 line but it never came on the Ethernet side.

This is the rs485 side at the time problem occured:

02 30 30 31 30 30 32 32 32 30 31 03 01
06
02 30 30 31 30 30 32 32 32 30 31 03 01
15
02 30 30 31 30 30 32 32 32 30 31 03 01
15
02 30 30 31 30 30 32 32 32 30 31 03 01
15
02 30 30 31 30 30 32 32 32 30 31 03 01
15
02 30 30 31 30 30 32 32 32 30 31 03 01
15
02 30 30 31 30 30 32 32 32 30 31 03 01
15

This is the ethernet side at the time problem occured:

2011/08/30 14:59:22:832> IN: Authorize Req (Pump: 2)
2011/08/30 14:59:22:832> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:23:328> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:23:328> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:23:838> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:23:838> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:24:349> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:24:349> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:24:858> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:24:858> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:25:373> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:25:373> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:25:879> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:25:879> send:02 30 30 31 30 30 32 32 32 30 31 03 01
2011/08/30 14:59:26:388> rec : ** Timeout Expired Exp(1), Got:(0)**
2011/08/30 14:59:26:388> OUT: Authorize Failed(Pump: 2)

Are thes logs generated by the Rabbit dievice or externally?

Regards,
Peter

They are external. one is from master directly and the other is traced by attaching a computer to the rs485 line.

i’m just trying to find a way in which i don’t have to make the control pin high or low manually. Configuring a pin to RTS should take control of this procedure by itself.