Modbus RS-485 RTS

How do I enable RTS on COM2 when using Modbus RTU Master?

This is on the SC20260D dev board.

I didn’t try but I think it should work like this:

modbusUart = UartController.FromName(SC20100.UartPort.Usart2);
modbusUart.SetActiveSettings(2400, 8, UartParity.None, UartStopBitCount.One,
UartHandshake.RequestToSend);
modbusRtu = new ModbusRtuInterface(modbusUart, 2400, 8, UartStopBitCount.One, UartParity.None);
modbusRtu.UartController.Enable();

UartHandshake.RequestToSend doesn’t seem to work with RS-485. The logic of the RTS line doesn’t seem to be correct. The RTS should be low while transmitting. Instead it toggles during receive operations. From what I can tell this is the difference between Full Duplex and Half Duplex operation. RTS is different from DE (Driver Enable) which is the same pin but different processor register settings.

(I also had to have CTS tied to GND to start transmitting data. Since it didn’t work with RS-485 driver I tested with an RS-232 driver so I could observe the signals with the scope.)

Does there need to be a Driver Enable mode added to setup the hardware registers correctly?

This is one of the reasons why I use the auto enable driver IC’s as the control from RTS requires low level access to the registers to know when the last byte was sent out so that you can switch the line to RX. Failure to switch in time, loses the first few bytes from fast turnaround devices. Since I switched to hardware control, I’ve had no issues with running this in MASTER although I do know there is a timing issue with SLAVE but not yet got around to fixing this.

The MAX13487 is a suitable driver IC but it is 5V only. I use an isolated setup so I can power the transceiver from the DC-DC converter.

RTS is an outline signal that indicates that the system has to much data and the sender should stop. It should but toggle with every byte. This is not an RS485 pin. Are you seeing something different?

@Dave_McLaughlin - I am familiar with the MAX13487, I have used it a few times and it could work, but for this application, a true DE signal would be best.

@Gus_Issa - Yes it does appear to be working correctly as an RTS should be.

Maybe what you need to do is to control the RTS line as a GPIO instead of allowing the system to do this.

I’ve checked the DOC’s and there is an option for the RTS to be used to control the enable of the TX line as per RS485 rules. I’ve come across a number of processors that have this functionality. Does TinyCLR2.0 have this capability? Do we need this to be added by GHI? Beta testing is a good time for this to be considered? Gus?

@Gus_Issa Has there been any decision on enabling the Driver Enable pin (same pin as RTS) for use with RS-485 drivers? I believe the associated bits are in register USART_CR3 of the H7.

Not yet, next on the list

So I am safe to include it in a hardware design? Will it be part of Preview 7?

Not yet. We may know in 2 weeks

@Gus_Issa, thanks for getting DE pin in the Release Candidate! Just in time before I sent my hardware design out this week. Now I can use standard RS-485 chips instead of being limited to the MAX13487 and its 5V logic requirement.

1 Like