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?
Modbus CRC problems
-
- Posts: 20
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 17, 2020 3:25 pm
- Location: Netherlands
- Been thanked: 2 times
Modbus CRC problems
- Attachments
-
- Modbus in 16F1937 V002.fcfx
- (20.72 KiB) Downloaded 579 times
Best regards,
Rinie
Rinie
-
- Matrix Staff
- Posts: 1913
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 497 times
- Been thanked: 675 times
Re: Modbus CRC problems
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).
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.
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).
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Modbus CRC problems
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
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
- Attachments
-
- Modbus 3 - serial settings PLC.jpg (36.61 KiB) Viewed 4197 times
-
- Modbus 2 - Sniffer data.jpg (107.02 KiB) Viewed 4197 times
-
- Modbus 1 - PLC memory.jpg (52.15 KiB) Viewed 4197 times
Best regards,
Rinie
Rinie
Re: Modbus CRC problems
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
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
- Attachments
-
- MB - slave registers.jpg (35.46 KiB) Viewed 4161 times
-
- MB - settings 485.jpg (46.14 KiB) Viewed 4161 times
-
- Modbus ontvanger in 16F1937 V003.fcfx
- (20.76 KiB) Downloaded 546 times
Best regards,
Rinie
Rinie
Re: Modbus CRC problems
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
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
- Attachments
-
- ReadHoldingRegister Help.jpg (40.54 KiB) Viewed 4153 times
-
- ReadHoldingRegister Use.jpg (36.66 KiB) Viewed 4153 times
Best regards,
Rinie
Rinie
Re: Modbus CRC problems
Hi there,
Any news on the Modbus CRC problem?
Thanks for your tips and ideas on this.
RInie
Any news on the Modbus CRC problem?
Thanks for your tips and ideas on this.
RInie
Best regards,
Rinie
Rinie