Page 1 of 1
Modbus CRC problems
Posted: Thu Dec 14, 2023 1:34 pm
by walbeek
Hi there,
I'm testing the Modbus Master RTU program on RS485.
I have connected a BRX PLC to the serial port.
When I write a register (setholdingregister), the value in the PLC register changes.
However, there is a CRC error in the Modbus answhere.
The PLC is a Modbus slave, so no settings are nessecary.
The registers (MHR1 to ??) are available and writable.
There is no setting for Modbus CRC but we use it a lot on frequency-inverters.
There are no errers.
When I try to read a register (readholdingregister) there is no data.
Again the Modbus gives a CRC error back.
There is no data received.
I have included the FC10 program below for sending.
What am I doing wrong?
Re: Modbus CRC problems
Posted: Fri Dec 15, 2023 4:15 pm
by BenR
Hello,
I've recently done a change to the ModBus component where I lowered the number of expected bytes for each command. I tested this was working well here but with an existing piece of hardware it may work subtely differently.
Anyway please could you try the following for me.
Go into Help -> Library updates. Tick the Show up to date files check box. Then roll back the Modbus version from 7 to 6. Restart Flowcode and try compiling that program to your embedded device (or running in simulation).

- Version.jpg (78.32 KiB) Viewed 6895 times
Let me know how you get on and if this still ha sa CRC error or if the error is now gone. If the error is gone or not then a trace of the bytes sent and received would be very useful if you have the ability to do this.
Re: Modbus CRC problems
Posted: Wed Dec 20, 2023 9:39 am
by walbeek
Hello Ben,
Thanks for your reply.
I have downloaded the Modbus V6 file but this gives the same result.
I have made a Flowcode program that writes a holding register 40001.
Every second, 1 is added and send again, This works well to the PLC.
File Modbus 1 shows the PLC's memory, the red number is changed.
However, the CRC check gives an error (1) ant this should be zero (0)
I have connected a serial converter and a "sniffer" that reads the bus.
After a reset of the PIC controller, the value is zero (00) and it is changing.
Mayby this picture shows whats going on on the RS485 bus.
There is one thing that's remarkable.
The standard Serial settings for Modbus are baudrate 9600, 8 bits, 1 stopbit, Even parity.
In the test I have used None parity, this should be more standard on RS485.
I have set this in the PLC and in the Sniffer, I can't change it in Flowcode?
Or I don't know how to do it.
The result is still the same, I can write the register, but there is a CRC error.
I can't read a register, that is also a CRC error.
Please let me know if you have any ideas.
Rinie
Re: Modbus CRC problems
Posted: Thu Dec 21, 2023 8:37 am
by walbeek
Hi there,
I have done some more testing.
I have connected the RS485 port to my laptop with a USB to serial converter.
When I use the "write" function (software posted above) there is communicatio.
Register 40001 of slave 01 changes every second.
Flowcode still gives a CRC error.
When I use the "read" function, there is still no result.
The FC software that I use is included with this post.
I have also included the serial settings of the PC software.
When I change Parity to EVEN (Modbus default) it doesn't work.
So it is set to NONE parity.
Rinie
Re: Modbus CRC problems
Posted: Thu Dec 21, 2023 10:29 am
by walbeek
Hi there,
Another post about this problem.
I'm trying to read one holdingregister with the ReadHoldingRegister function.
I think that I'm using the function the wrong way.
I have SlaveID 1, RegAddress 3 (40004), this is all clear.
The next line is RegCount and I assumed that this was the Variable where the data goes to.
However, according Help I can read more registers with the same command.
The RegCount should than be the number of registers to be read.
The last line is Return, this should be the CRC data I think.
When I use it like this, where goes the data?
I'm getting confused here.
Rinie
Re: Modbus CRC problems
Posted: Mon Jan 08, 2024 9:03 am
by walbeek
Hi there,
Any news on the Modbus CRC problem?
Thanks for your tips and ideas on this.
RInie
Re: Modbus CRC problems
Posted: Fri Mar 14, 2025 1:10 pm
by walbeek
Hi there,
We have done some more testing on the CRC problems and it seems to be a timing problem.
When we read several ModBus addresses, than we have to wait for a while to read others.
Reading and writing an address works for now.
I have the following problem now.
We have to write 8 to 10 Modbus addresses, 40001 tot 40010 for example.
My idea was to write them one by one with the Modbus "SetHoldingRegister" macro.
Due to the timing problem i'm trying to send them all at once with "SetHoldingRegisters".

- Variable.png (27.12 KiB) Viewed 2028 times
In the "SetHoldingRegisters" macro properties, I try to use the WriteData[] array in RegValue.

- Properties.png (31.34 KiB) Viewed 2028 times
Then I get an error, the screen below.

- Error.png (10.77 KiB) Viewed 2028 times
I have tried the Variable with [], [0], [1], [10].... but no result.
How do I have to use this? I can't find any inrormation on this.
Please let me know.
Rinie
Re: Modbus CRC problems
Posted: Fri Mar 14, 2025 1:46 pm
by Steve-Matrix
Try just using WriteData without the square brackets.
Re: Modbus CRC problems
Posted: Wed Mar 19, 2025 12:44 pm
by walbeek
Solved, thanks Steve.