I have been trying to find a good USB to RS485 serial adapter. I have
a small contract to modify some code to add MODBUS capability to a
product. I found one item on Amazon that had USB to serial
TTL/RS232/RS485 that really fit the bill, so I got one.
It came in, and seemed to work, then just kinda stopped. I think it
is that TTL capability - makes the whole thing really static
sensitive! I ordered another one, and today right in the middle of
testing, it has gone bad as well. All my commands suddenly started
failing CRC. After spending all day (on a Saturday!) trying to 'fix'
my code, I finally pulled out my old USB to RS232 dongle, and my code
is fine! Not a fun way to spend a weekend, especially since my
customer is supposed to demo the MODBUS capability to the customer on
Monday!
Well, at least on RS232 it works fine...
Which end showed CRC errors, the one that received messages from the
adapter or your reading on the USB side ?
A typical bug with RS-485 adapters is that the transmitter is turned
off (into idle state) too early, while the last few bits are still
being transmitted. Does the chip handle the TxEnable control
internally and does it do so, when the last stop bit(s) have actually
been shifted out of the Tx shift register or does it start to turn
off, when the last character into the shift register ? In the latter
case, the failure rate increases with _lower_ line speeds.
Or do you command the TxEnable across the USB ? In this case, how do
you know when that last character has actually been transmitted out of
the shift register ? One way to handle this is to keep the Rx side
enabled all the time, so that you hear your own transmissions on the
RS-485 line. When you hear the echo of the last character, then you
can disable the transmitter.
To satisfy the formal Modbus RTU specifications, you should wait 3.5
character times after the echo of the last character, before turning
of the Tx. Well actually In this echo case, 2.5 character times is
enough, since the echo Rx shift register consumes one character time.
Look also on the transmit turn on sequence before transmitting a
Modbus frame.The standard requires that the transmitter is turned on
(sending "idle") 3.5 character times, before sending the actual frame.
This is very important, if you do _not_ use "fail safe" termination.
With fail-safe termination, the passive pull-up resistors will keep
the bus in the idle state when no transmitters are active.