Hi Folks,
I'm relatively new to vb.net, so bear with me.
I'm connecting to an Allen-Bradley PLC 1756-L55, with a ControlLogix 5555 controller.
I'm scratching my head at this over the last week, tried numerous ideas, but to no avail.
I have simplified my code to the following to explain it better:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'CompactLogix / ControlLogix driver
With EthernetIPforCLXCom1
.IPAddress = TextBox1.Text
.Port = NumericUpDown1.Value
.PollRateOverride = NumericUpDown2.Value
End With
'SevenSegment1
If String.IsNullOrEmpty(TextBox2.Text) Then
SevenSegment1.ComComponent = Nothing
SevenSegment1.PLCAddressValue = Nothing
Else
SevenSegment1.ComComponent = EthernetIPforCLXCom1
SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
End If
'Enable subscriptions
EthernetIPforCLXCom1.DisableSubscriptions = False
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Disable subscriptions
EthernetIPforCLXCom1.DisableSubscriptions = True
End Sub
Private Sub EthernetIPforCLXCom1_ComError(sender As Object, e As PlcComEventArgs) Handles EthernetIPforCLXCom1.ComError
ListBox1.Items.Add(e.ErrorMessage)
End Sub
Private Sub EthernetIPforCLXCom1_ConnectionEstablished(sender As Object, e As EventArgs) Handles EthernetIPforCLXCom1.ConnectionEstablished
ListBox1.Items.Add("Connection established.")
End Sub
Private Sub EthernetIPforCLXCom1_ConnectionClosed(sender As Object, e As EventArgs) Handles EthernetIPforCLXCom1.ConnectionClosed
SevenSegment1.Value = 0
ListBox1.Items.Add("Connection closed.")
End Sub
Consider the following code:
'SevenSegment1
If String.IsNullOrEmpty(TextBox2.Text) Then
SevenSegment1.ComComponent = Nothing
SevenSegment1.PLCAddressValue = Nothing
Else
SevenSegment1.ComComponent = EthernetIPforCLXCom1
SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
End If
'Enable subscriptions
EthernetIPforCLXCom1.DisableSubscriptions = False
1. If I input an address, connect, disconnect, then change to another address, connect, the value updates to the new value (good).
2. If I clear the first address, connect, the value doesn't update (good).
3. If I enter in the first address again (after step 2.), connect, the value doesn't update (not good).
4. If I enter in a different address (after step 2.), connect, the value updates to the new value (good).
Now consider the following code:
'SevenSegment1
If String.IsNullOrEmpty(TextBox2.Text) Then
SevenSegment1.PLCAddressValue = Nothing
Else
SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
End If
'Enable subscriptions
EthernetIPforCLXCom1.DisableSubscriptions = False
1. If I input an address, connect, disconnect, then change to another address, connect, the value updates to the new value (good).
2. If I remove the first address, connect, the old value keeps updating (not good).
3. If I enter in first address again (after step 2.), connect, the value keeps updating (good).
4. If I enter in a different address (after step 2.), connect, the value updates to the new value (good).
Basically after entering an address, connect, disconnect, clearing the old address, connect, disconnect, then entering in same address again, it doesn't like if the same address is entered.
This is bound to happen in a real life situation, so I'm testing every combination.
If a different address is entered the second time, then it works fine.
I have 4 other SevenSegment objects that i have omitted to make it simpler.
Any help anyone can give me is greatly appreciated.
Thanks,
Conor