Hi, I am new to Advanced HMI, but can already see that it is a great solution to many of the problems I have! well done!
However, I need to connect to two ControlLogix PLCs at the same time, from the same form. I spent a lot of time checking and rechecking that I have not made any mistakes, and I just can't figure out the problem.
I made the simplest form that I could based on the solution downloaded in AdvancedHMIBetaV399d
the 2 PLCs are a test PLC (192.168.0.81) and a live PLC (192.168.1.8 ). The test PLC has a tag address "Test_Bool" that is set to 1. The live PLC has a tag address "Sorting_Room_Puffers_Auto_En" that is also set to 1.
I placed a PilotLight control on the form, and allowed it to automatically create an EthernetIPforCLXCom driver. I then set the IP of the driver to my test PLC (192.168.0.81). I set the PLCAddressValue of the PilotLight to my test address (Test_Bool). I debugged the application and the pilotlight read the value and turned on faultlessly. I restarted the application several times and the pilotlight always came on.
I then changed the IP address of the driver to the address of the live PLC (192.168.1.8 ). I set the PLCAddressValue of the pilotlight to the required address (Sorting_Room_Puffers_Auto_En). I tested this in the same way and the pilot light always came on.
I changed the IP of the driver and the tag of the pilotlight back to that of the test PLC and retested to be sure
I then placed another PilotLight on the form, and allowed it to create another EthernetIPforCLXCom driver. I set the IP of the driver to my live PLC, and the address of the PilotLight to the live address.
This is when it becomes very flaky. When starting the application, sometimes the test PLC will connect, sometimes the live PLC will connect, sometimes neither PLC will connect, and very occasionally both PLCs will connect.
Here is the relevant section from InitializeComponent
'EthernetIPforCLXCom1
'
Me.EthernetIPforCLXCom1.CIPConnectionSize = 508
Me.EthernetIPforCLXCom1.DisableMultiServiceRequest = False
Me.EthernetIPforCLXCom1.DisableSubscriptions = False
Me.EthernetIPforCLXCom1.IPAddress = "192.168.0.81"
Me.EthernetIPforCLXCom1.PollRateOverride = 500
Me.EthernetIPforCLXCom1.Port = 44818
Me.EthernetIPforCLXCom1.ProcessorSlot = 0
'
'PilotLight1
'
Me.PilotLight1.Blink = False
Me.PilotLight1.CommComponent = Me.EthernetIPforCLXCom1
Me.PilotLight1.LegendPlate = MfgControl.AdvancedHMI.Controls.PilotLight.LegendPlates.Large
Me.PilotLight1.LightColor = MfgControl.AdvancedHMI.Controls.PilotLight.LightColors.Green
Me.PilotLight1.LightColorOff = MfgControl.AdvancedHMI.Controls.PilotLight.LightColors.Red
Me.PilotLight1.Location = New System.Drawing.Point(163, 312)
Me.PilotLight1.Name = "PilotLight1"
Me.PilotLight1.OutputType = MfgControl.AdvancedHMI.Controls.OutputType.MomentarySet
Me.PilotLight1.PLCAddressClick = ""
Me.PilotLight1.PLCAddressText = ""
Me.PilotLight1.PLCAddressValue = "Test_Bool"
Me.PilotLight1.PLCAddressVisible = ""
Me.PilotLight1.Size = New System.Drawing.Size(75, 110)
Me.PilotLight1.TabIndex = 45
Me.PilotLight1.Text = "PilotLight1"
Me.PilotLight1.Value = False
'
'PilotLight2
'
Me.PilotLight2.Blink = False
Me.PilotLight2.CommComponent = Me.EthernetIPforCLXCom2
Me.PilotLight2.LegendPlate = MfgControl.AdvancedHMI.Controls.PilotLight.LegendPlates.Large
Me.PilotLight2.LightColor = MfgControl.AdvancedHMI.Controls.PilotLight.LightColors.Green
Me.PilotLight2.LightColorOff = MfgControl.AdvancedHMI.Controls.PilotLight.LightColors.White
Me.PilotLight2.Location = New System.Drawing.Point(459, 312)
Me.PilotLight2.Name = "PilotLight2"
Me.PilotLight2.OutputType = MfgControl.AdvancedHMI.Controls.OutputType.MomentarySet
Me.PilotLight2.PLCAddressClick = ""
Me.PilotLight2.PLCAddressText = ""
Me.PilotLight2.PLCAddressValue = "Sorting_Room_Puffers_Auto_En"
Me.PilotLight2.PLCAddressVisible = ""
Me.PilotLight2.Size = New System.Drawing.Size(75, 110)
Me.PilotLight2.TabIndex = 46
Me.PilotLight2.Text = "PilotLight2"
Me.PilotLight2.Value = False
'
'EthernetIPforCLXCom2
'
Me.EthernetIPforCLXCom2.CIPConnectionSize = 508
Me.EthernetIPforCLXCom2.DisableMultiServiceRequest = False
Me.EthernetIPforCLXCom2.DisableSubscriptions = False
Me.EthernetIPforCLXCom2.IPAddress = "192.168.1.8"
Me.EthernetIPforCLXCom2.PollRateOverride = 500
Me.EthernetIPforCLXCom2.Port = 44818
Me.EthernetIPforCLXCom2.ProcessorSlot = 0
I then added an event handler for each of the drivers for the ComError event, along with a handler for the Connected event - this is the only custom code in the application, everything else is drag and drop from the toolbox and set via properties:
Private Sub EthernetIPforCLXCom1_ComError(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.ComError
If (e.ErrorMessage.StartsWith("Could not connect to ")) Then
Diagnostics.Debug.WriteLine("CLXCom1_ComError " & e.ErrorMessage & " but should connect to " & CType(sender, AdvancedHMIDrivers.EthernetIPforCLXCom).IPAddress)
Else
Diagnostics.Debug.WriteLine("CLXCom1_ComError " & e.ErrorMessage)
End If
End Sub
Private Sub EthernetIPforCLXCom2_ComError(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom2.ComError
If (e.ErrorMessage.StartsWith("Could not connect to ")) Then
Diagnostics.Debug.WriteLine("CLXCom2_ComError " & e.ErrorMessage & " but should connect to " & CType(sender, AdvancedHMIDrivers.EthernetIPforCLXCom).IPAddress)
Else
Diagnostics.Debug.WriteLine("CLXCom2_ComError " & e.ErrorMessage)
End If
End Sub
Private Sub EthernetIPforCLXCom1_ConnectionEstablished(sender As Object, e As EventArgs) Handles EthernetIPforCLXCom1.ConnectionEstablished
Diagnostics.Debug.WriteLine("CLXCom1 connected")
End Sub
Private Sub EthernetIPforCLXCom2_ConnectionEstablished(sender As Object, e As EventArgs) Handles EthernetIPforCLXCom2.ConnectionEstablished
Diagnostics.Debug.WriteLine("CLXCom2 connected")
End Sub
After starting the application, it does nothing for 3-4 seconds, then the error handlers start writing debug messages. I get many different errors, but the error shown here concerns me the most
CLXCom2_ComError Could not connect to 192.168.0.81, port 44818. Timed out but should connect to 192.168.1.8
CLXCom1_ComError Could not connect to 192.168.0.81, port 44818. Timed out but should connect to 192.168.0.81
CLXCom2_ComError 192.168.0.81 An invalid argument was supplied
CLXCom1_ComError 192.168.0.81 An invalid argument was supplied
EthernetIPforCLXCom2 is configured to connect to 192.168.1.8, but is attempting to connect to 192.168.0.81
It seems like the drivers may be cross threading or somehow sharing the IP addresses and other resources when trying to connect.
The next time I ran it, the situation reversed, EthernetIPFormCLXCom1 was trying to use the IP for the other driver!
CLXCom1_ComError Could not connect to 192.168.1.8, port 44818. Timed out but should connect to 192.168.0.81
CLXCom2_ComError Could not connect to 192.168.1.8, port 44818. Timed out but should connect to 192.168.1.8
CLXCom1 connected
CLXCom2 connected
CLXCom1_ComError Unknown Code 256
CLXCom2_ComError Unknown Code 256
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
.... continuing
I do get some other error messages, and I can only assume that they're all related to something like a threading issue
CLXCom2_ComError No Response from PLC(21)
CLXCom1_ComError No Response from PLC(21)
CLXCom2_ComError No Response from PLC(22)
CLXCom1_ComError No Response from PLC(22)
CLXCom2 connected
CLXCom1 connected
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
CLXCom1_ComError CIP - Path Segment Error (Invalid Tag Name)
...
I am very eager to use this tool, but I must be able to connect to multiple PLCs!
thanks very much
Simon