Ok, Lets hope someone replies to this, so far the track record here is not too good.
I’m trying to implement Modbus RTU over 485.
I have proven my hardware works, I can read and write over 485. When the Modbus library goes to read the line it reads 100 characters and returns the bytecount as 100, there is a serial_timeout of 3 ms(quiet time @ 19200), it seems to ignore this. I switched over to 232 and everything works perfectly.
Can anyone think of what might cause modbus to fail to see the quiet time over 485?
Waiting for the transmit buffer to be empty is not good enough. Two bytes, one in the hardware “XMIT BUF” and the other in the transmitter are still going out. Turning off TX enable would cut them off.
By having the receive enable on the RS485 chip on, the bytes being transmitted are also being received. When all the received bytes are seen, as is being checked by the input byte count, then it is sure that all the bytes have been transmitted.
However, the Rabbit code is not very good; it is tying up the processor until the full message trasnmission is done. This is unacceptable in many situations.
A better, non-blocking way of checking the end of the transmission is to watch for the transmit buffer to be empty and then also check if the “XMIT BUFF FULL” (SxSR bit 3) and “XMIT SENDING BYTE” (SxSR bit 2) are both 0. Then the transmit enable can be turned off.
Figured out the problem, the PCB designer tied /RE to ground and that made every transmission also read into the input buffer. Apparently this is the way that Rabbit does it and it causes headaches with modbus.
Cutting the trace and tying /RE to DE solved the problem (as well as editing the Modbus lib on how to detect all bytes transmitted)