Author Topic: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue  (Read 1235 times)

Conor_Hyland

  • Newbie
  • *
  • Posts: 12
    • View Profile
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:

Code: [Select]
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:

Code: [Select]
'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:

Code: [Select]
'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

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue
« Reply #1 on: May 21, 2019, 08:11:03 PM »
- In Solution Explorer expand down the AdvancedHMIControls project
- Right click SubscriptionHandler.vb and select View Code
- Go to line 243 and look for this line of code:
Code: [Select]
                    If Not (String.IsNullOrEmpty(PLCAddress)) Then

- Change the code to this:
Code: [Select]
                    If True Or Not (String.IsNullOrEmpty(PLCAddress)) Then

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue
« Reply #2 on: May 22, 2019, 08:48:25 PM »
Depending on your version, the code mentioned above may be closer to line 234

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue
« Reply #3 on: May 23, 2019, 12:57:12 AM »
I would suggest that Conor modify his code instead, to something like this:

Code: [Select]
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
            MessageBox.Show("Either IPAddress or PLCAddressValue is missing!")
            Exit Sub
        End If

        'CompactLogix / ControlLogix driver
        With EthernetIPforCLXCom1
            .IPAddress = TextBox1.Text
            .Port = NumericUpDown1.Value
            .PollRateOverride = NumericUpDown2.Value
        End With

        SevenSegment1.ComComponent = EthernetIPforCLXCom1
        SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)

        'Enable subscriptions
        EthernetIPforCLXCom1.DisableSubscriptions = False
    End Sub

Everything else might just be time consuming and possibly create new bugs.
« Last Edit: May 23, 2019, 10:13:47 PM by Godra »

Conor_Hyland

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue
« Reply #4 on: May 26, 2019, 07:32:59 AM »
Hi Archie,

Yep you were right, it was on a different line number, but i found it no problem.
I commented out that line and added the line you suggested and it worked perfectly.
I have completed some testing on every scenario and it is working perfectly.
So once again thank you very much for your help.

Hi Godra,

I simplified the code to only one PLC address TextBox for one SevenSegment.
I have 5 TextBoxes to input PLC addresses for 5 SevenSegments.
There will be many situations where we will only need to monitor say 3 tags out of the 5, so 2 may be blank.

Simplified code below:

Code: [Select]
                'Driver
                With EthernetIPforCLXCom1
                    .IPAddress = TextBox1.Text
                    .Port = NumericUpDown1.Value
                    .PollRateOverride = NumericUpDown2.Value
                End With

                'SevenSegment1
                If String.IsNullOrEmpty(TextBox2.Text) Then
                    SevenSegment1.PLCAddressValue = Nothing
                Else
                    SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
                End If

                'SevenSegment2
                If String.IsNullOrEmpty(TextBox3.Text) Then
                    SevenSegment2.PLCAddressValue = Nothing
                Else
                    SevenSegment2.PLCAddressValue = New Drivers.PLCAddressItem(TextBox3.Text)
                End If

                'SevenSegment3
                If String.IsNullOrEmpty(TextBox4.Text) Then
                    SevenSegment3.PLCAddressValue = Nothing
                Else
                    SevenSegment3.PLCAddressValue = New Drivers.PLCAddressItem(TextBox4.Text)
                End If

                'SevenSegment4
                If String.IsNullOrEmpty(TextBox5.Text) Then
                    SevenSegment4.PLCAddressValue = Nothing
                Else
                    SevenSegment4.PLCAddressValue = New Drivers.PLCAddressItem(TextBox5.Text)
                End If

                'SevenSegment5
                If String.IsNullOrEmpty(TextBox6.Text) Then
                    SevenSegment5.PLCAddressValue = Nothing
                Else
                    SevenSegment5.PLCAddressValue = New Drivers.PLCAddressItem(TextBox6.Text)
                End If

                'Enable subscriptions
                EthernetIPforCLXCom1.DisableSubscriptions = False

Regards,
Conor

Conor_Hyland

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: EthernetIPforCLXCom SevenSegment PLCAddressValue Change Issue
« Reply #5 on: May 26, 2019, 07:34:47 AM »
Thank you Godra for your help also.

Regards,
Conor