Reputation: 1
I am currently testing a circuit that I've put together on a carrier board for a Raspberry Pi CM4. It connects RS485 to USB via SP3485CN and CH340E.
I've set up a PC with the software Modbus Slave and connected to it using a standard RS485 to USB adapter.
On the raspberry Pi I'm currently using minimalmodbus.
My issue is an additional 0x00 byte being added to the beginning of the response message. This means that it cuts off the final byte of data because it has a set length it's expecting in response. The last byte is unfortunately the second half of the checksum meaning the software believes the data to be a failed transmission.
The debugging mode in minimalmodbus returns the following messages when I run the code:
MinimalModbus debug mode. Will write to instrument (expecting 9 bytes back): 01 04 00 00 00 02 71 CB (8 bytes)
MinimalModbus debug mode. Clearing serial buffers for port /dev/ttyUSB0
MinimalModbus debug mode. No sleep required before write. Time since previous read: 104832.80 ms, minimum silent period: 4.01 ms
MinimalModbus debug mode. Closing port /dev/ttyUSB0
MinimalModbus debug mode. Response from instrument: 00 01 04 04 01 BD 01 BC 6A (9 bytes), roundtrip time: 0.1 ms. Timeout for reading: 500.0 ms.
...
minimalmodbus. InvalidResponseError: Checksum error in rte mode: '1/4j' instead of '\x0bq' . The response is: '\x00\x01\x04\x04\x011/2\x011/4j' (plain response: '\x00\x01\x04\x04\x011/2\x011/4j')
So far I've double checked all the data sheets of the components and I'm confident I've integrated each part correctly (but always appreciate corrections)
When doing some research I've come across lines bias that can cause the issue and I've tested it but without success or change.
The part I'm very confused about is the readings I'm getting from the oscilloscope. When connected to RO pin of the SP3485CN, I'm getting the results shown in the image. As you can see - the oscilloscope is able to interpret the response perfectly. The response "01 04 04 01 BD 01 BC 6A 7D" is exactly what is expected. Unfortunately - as shown in the debugging messages above, I'm getting "00 01 04 04 01 BD 01 BC 6A"
As far as I understand, the beginning of the message waveform is correct with a single low bit to indicate the message start, followed by the LSB of the first byte.
I'm at a complete loss as to why this is happening and would love any additional suggestions besides lines bias.
Upvotes: 0
Views: 726