Modbus problems

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

Moderator: Benj

Post Reply
Khormy
Posts: 3
Joined: Mon Oct 28, 2019 7:52 am
Contact:

Modbus problems

Post by Khormy »

Hi,

I am trying to set up some communication via modbus between 2 Stm32f4-discovery boards with a MAX 485 connected to each. At the moment I am just trying to set some basic communication up between the two boards.
Both boards have a display attached, so first the slave board is started and it places 0x02 into the holding registry under address 40001. Then the board prints the same number on the screen. After this is done the slave should enter a loop and check for incoming, if it receives anything it should print "someone called" on the screen.
Next the master board is started up. The only thing it is trying to do is start up, read the holding register of the slave and display the number read from the register on the screen.
What instead happens is the master displaying the number 255 on the screen. As far as I see the hardware is set up correctly, so the problem is related to the code somehow, however after 2 days of trying to find the error I am still clueless what the problem is.
Can anyone please check if there is an obvious problem with my code which could cause the problem?
Attachments
Modbus slave.fcfx
(12.36 KiB) Downloaded 136 times
Modbus master.fcfx
(12.07 KiB) Downloaded 135 times

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 »

Hello,

Your addressing is a bit incorrect. Where you have the address 40001 this should be address 0, this needs to be changed for both the master and slave.
Tooltip.jpg
Tooltip.jpg (19.89 KiB) Viewed 1805 times

Khormy
Posts: 3
Joined: Mon Oct 28, 2019 7:52 am
Contact:

Re: Modbus problems

Post by Khormy »

Thanks a lot for the quick reply. I did change the adresses, however the problem seem to persist still. So I suspect something else might be wrong also.

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 »

Hello,

The RS485 ReadDDR state is mismatched in the two programs. These likely need to be the same and depend on your attached RS485 line driver.

Khormy
Posts: 3
Joined: Mon Oct 28, 2019 7:52 am
Contact:

Re: Modbus problems

Post by Khormy »

Thanks. Changed both to active high, that did not fix the problem. So changed them both to active low, but still having the same problem.

Post Reply