Modbus problems

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Walbeek
Flowcode v5 User
Posts: 68
Joined: Thu Mar 01, 2007 10:48 am
Location: Netherlands
Been thanked: 3 times
Contact:

Modbus problems

Post by Walbeek »

Hi there,

I have a PIC 16F1936 that I want to use as a Modbus Master.
A LCD is connected to the PIC, together with a MAX485 and some pushbuttons.
I have tested all kinds of communication but I can't get the communication working.
I have inserted a simple program with the instruction "read coil status" every second.
The program is attached below.

Settings are:
Slave ID = 1
Coil address = 0
Number of coils = 4
Functioncode of "Read coil status" should be 1.

According Modbus specs, the software should send 01 (slave), 01 (function), 00, 00, (coil), 04,00 (number) and checksum.
When the simmulation runs, Flowcode shows that the following code is send:
ReadCoilStatus -> SlaveID:1 FunctionCode:1 Address:0 CoilCount:4 CRC:0xc93d

I use a Modbus sniffer that is called Modsim64.
I have connected this to the RS484 Modbus-port and the software is running.
The software shows traffic on the Modbus port.

The software receives 06, 06, 00, 00, 60, e6, 98, 18 (hex) or 006, 006, 000, 000, 000, 096, 230, 152, 024 (dec)
What is going wrong? please let me know if you have any suggestions.

Rinie
Attachments
Modbus test 0011 24-02-2018.fcfx
(13.27 KiB) Downloaded 222 times
Greetings, Rinie
Flowcode V7 user

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

Re: Modbus problems

Post by EtsDriver »

Using looped back serial port and slave simulator, i got traffic correctly, but simulations hangs on this after slave sends reply... But data looks correct.
I dont have any hardware at the hand for this moment to test this on. :cry:
mbtest.PNG
(177.57 KiB) Downloaded 1299 times
Request:
01 01 0000 0004 3DC9
01 - Slave
01 - Function
0000 - Start register
0004 - Amount to read
3DC9 - CRC

Response
01 - SlaveID
01 - Function
01 - Bytes to follow (1, as 8 coils fit into one byte)
0F - Lower four are all on state 1.
118C - CRC

**************
Ill just keep the good work up!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Modbus problems

Post by Benj »

Hi Rinie,

Can you confirm you are using a 19.6608MHz crystal to match the clock speed in the Project options? Also have you confirmed the micro is running at the right rate using the 1 second flasher test?

https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

Post Reply