Modbus/TCP communications problems - SOLVED!


#1

Update: [B]Solved![/B] Turns out there was a line of code missing in the function 15 subroutine. The developers are aware of the issue and will be implementing the fix in the next release. Thanks for all of your help!

I’ve been working with the Modbus integration kit for the last few days and I still can’t get it working with my slave device.

The general behavior is that the slave device responds to Modbus commands from a standalone utilty, but doesn’t respond as expected to Pac Control. More specifically, I’m turning on a digital output (coil) from the standalone utility and the PAC Control routine is turning off the output unexpectedly. Autostepping through the main chart (Modbus_Master_M1) shows that it’s being turned off when it enters the sub “PACModbusMaster15_Force_Multiple_Coils”. I’m watching the default watch-window for that sub and it indicates that the connection is open, the status is “OK” and the number of successful messages transmitted increments each time through the main loop.

At this point I think it must be an offset issue, but the standalone doesn’t seem to require any unusual offsets. Perhaps there’s something else that I haven’t initialized?


#2

The Function 15 master subroutine in the kit uses the table ntMB_Coils_0xM1 to store the coils it forces.

Each index is a coil.
If offset = 0 and start coil = 1 and quantity = 2
It will force coil 1 in the slave to the value of index 1 (0 or 1).
It will force coil 2 in the slave to the value of index 2 (0 or 1).

If offset = 10 and start coil = 21 and quantity = 2
It will force coil 21 in the slave to the value of index 31 of the table (0 or 1).
It will force coil 22 in the slave to the value of index 32 of the table (0 or 1).

If the value in the table is not changing the coil should not change.


#3

After installing a packet sniffer on the development system, it seems that there is only TCP traffic going from the PAC to the development system. I have a second computer that is running the standalone utility and a packet sniffer, and that is only able to see its own data. All of the components (both computers, SNAP-PAC, Modbus slave) are all connected to an unmanaged hub, so all of the data being sent between nodes [I]should[/I] be visible to the other nodes.

Any help you can offer would be greatly appreciated!


#4

Hmm, sounds like you might want to contact our Product Support Group (click here). They’ve got loads of experience with Modbus and sniffing (we mostly use Wireshark). And it’s FREE!


#5

Yep, that’s where I’m trying to turn them on and off via the “inspection” window.

Each index is a coil.
If offset = 0 and start coil = 1 and quantity = 2
It will force coil 1 in the slave to the value of index 1 (0 or 1).
It will force coil 2 in the slave to the value of index 2 (0 or 1).

If offset = 10 and start coil = 21 and quantity = 2
It will force coil 21 in the slave to the value of index 31 of the table (0 or 1).
It will force coil 22 in the slave to the value of index 32 of the table (0 or 1).

Offset is 0, start is 1, qty is 8, Coils_0xM1 is {0, 1, 0, 1, 0, 0, 0, 0}.

If the value in the table is not changing the coil should not change.

The values in the table are static after I change them, but it’s essentially turning off all the coils every time it loops through the function 15 sub. Perhaps there’s some scope issue? I.e. global vs local copies of the coils table.


#6

I’m using Wireshark as well, but I’m not very skilled with it. I’ve filed a phone ticket with the support team, so hopefully we can get this cleared up in short order. Thanks!