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?
Modbus problems
Moderator: Benj
Modbus problems
- Attachments
-
- Modbus slave.fcfx
- (12.36 KiB) Downloaded 136 times
-
- Modbus master.fcfx
- (12.07 KiB) Downloaded 135 times
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Modbus problems
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.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Modbus problems
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.