Modbus TCP

Use this section to discuss your embedded Flowcode projects.
Post Reply
pilot123
Posts: 24
http://meble-kuchenne.info.pl
Joined: Fri Feb 26, 2021 1:50 pm
Has thanked: 1 time
Been thanked: 2 times

Modbus TCP

Post by pilot123 »

Hi
I am trying to integrate Modbus TCP into my project, I have basically copied the Modbus TCP Part 1 video, where you set a coil on the Master and read the value of the coil on the Slave.
I am using two BL0080 boards connected by a cisco switch using the W5500 Wiz ethernet modules. I can ping both of my devices successfully, I have also used wireshark and I can see the TCP packets port 502 being sent when the switch is pressed on my master and acknowleged by the slave.
But my LED never illuminates on the slave, I have written a loop at the start of my slave programme which flashes the LED 10 times to check its integrity.
I have attached my Master and Slave programmes, I would appreciate any help.
Attachments
Modbus_Master.fcfx
(13.23 KiB) Downloaded 112 times
Modbus_Slave_Test.fcfx
(14.15 KiB) Downloaded 105 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: Modbus TCP

Post by BenR »

Hello,

Only thing I can spot is the calculation in the master

Code: Select all

switch = oldswitch


should instead be

Code: Select all

oldswitch = switch
The program worked in the simulation for me after changing the IP. Might be worth trying the slave simulation with the hardware master and visa versa to see if you can nail down a bit more which side isn't behaiving as expected. The console window might be useful here so you can better see the communications being sent and received.

pilot123
Posts: 24
Joined: Fri Feb 26, 2021 1:50 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Modbus TCP

Post by pilot123 »

Hi Ben
Thanks for your reply, I have changed the calculation, and have tried using Master hardware and Slave simulation.
i have disconnected the W5500 module and used my interface 0 on the laptop with the IP address set to the Slave IP.
When I run the simulation the LED flashes 10 times to prove led functionality as expected, but I never get any RX/TX leds flashing on the Modbus Slave Icon or the Network Comms Icon .On the Console display for Modbus Slave I get the following:

Socket Open: OK
Listening: OK
Master Connected
Master Connected
Master Connected
Master Connected
Master Connected
Master Connected

But my LED does not repond to the master switch.
I assume the Rx/Tx Leds should flash on the simulation icons, but nothing happens on mine.
Am i doing something wrong, could you please point me in the right direction?

Post Reply