Besides the regular SerialDF1 & EthernetIPforSLCMicro communication, Micrologix 1400 also offer Modbus RTU & modbus TCP. It's very nice to have this flexibility. I am not sure why Rockwell did not integrate modbus into their Compactlogix line.
First, Enable it in the channel configuration
Once it enabled, Channel 1 modbus tab will appear and here you can config your file number accordingly
Dont forget to recycle power to ML1400. Next some codings:
Imports AdvancedHMIDrivers
Public Class Form1
Public PLC As ModbusTCPCom = New ModbusTCPCom()
Private SubID, SubID2, SubID3 As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PLC.IPAddress = "192.168.1.10"
PLC.PollRateOverride = "0"
'
SubID = PLC.Subscribe("30001", 1, 0, AddressOf DataReturned) '
SubID2 = PLC.Subscribe("40001", 1, 0, AddressOf DataReturned)
'SubID3 = PLC.Subscribe("B3:1", 2, 0, AddressOf DataReturned)
End Sub
Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If e.PlcAddress = "30001" Then
Label1.Text = e.Values(0)
End If
If e.PlcAddress = "40001" Then
Label2.Text = e.Values(0)
End If
End Sub
Note:
Modbus TCP devices use client/server model. Client established a connection to server, then request info from server.
Modbus RTU devices use master/slave model. A Slave resides on a serial network (e.g. RS485) and listens for requests from a Modbus Master.