Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Conor_Hyland

Pages: [1]
1
Open Discussion / Re: EthernetIPforCLXCom1.DataReceived Event
« on: September 24, 2019, 01:50:46 PM »
Hi Archie,

We have eliminated the need for a virtual machine now which is good.

1) OK, so if there is a way I can check what the sender object is I could possibly do something like the following?:

Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived

    If sender is Xxxxx then
        Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is Yyyyy then
        Chart1.Series(1).Points.AddXY(TimeNow, e.values(0))
    ElseIf sender is Zzzzz then
        Chart1.Series(2).Points.AddXY(TimeNow, e.values(0))
    EndIf

End Sub

2) What does the SubscriptionDataReceived event do so?

I can't check this on the machine, so I must have it pretty much bug free before i can connect to the PLC and start gathering data.

Thanks,
Conor

2
Open Discussion / EthernetIPforCLXCom1.DataReceived Event
« on: September 18, 2019, 06:12:49 PM »
Hello Everyone,

I have been testing my graph code using a timer on my development machine and it worked perfect.
I have since copied the code to the EthernetIPforCLXCom1.DataReceived event and i am getting strange results on a virtual machine.

(1) Does the EthernetIPforCLXCom1.DataReceived event fire only on the poll rate override interval of the driver, regardless of whether it is reading from 1 tag or 5 tags? i.e. will it fire once only for all 5 tags together, or will it fire 5 times one for each tag?

(2) I am experiencing weird behaviour using a virtual machine over a network - my code worked perfect locally using a timer to fire the plotting of the lines, but since i changed the plotting to the DataReceived event, weird stuff is happening that i can't explain - would you recommend using my analysis program for short term monitoring on a VM? It may very well be a bug in my code somewhere also, but it's pretty much the same code in the timer tick event as in the DataReceived event.

(3) See my 2 starred (*****) comments below in the code. Can you do this in each case:

Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived

  If Recording Then

            TimeNowAsDate = Now
            Dim TimeNow As String = TimeNowAsDate.ToString("HH:mm:ss")

‘Currently reading value from SevenSegments
          Chart1.Series(0).Points.AddXY(TimeNow, SevenSegment1.Value)
              Chart1.Series(1).Points.AddXY(TimeNow, SevenSegment2.Value)
              Chart1.Series(2).Points.AddXY(TimeNow, SevenSegment3.Value)
            Chart1.Series(3).Points.AddXY(TimeNow, SevenSegment4.Value)
            Chart1.Series(4).Points.AddXY(TimeNow, SevenSegment5.Value)

‘*****Can you do this, i.e. is e.values() an array?
Chart1.Series(0).Points.AddXY(TimeNow, e.values(0))
              Chart1.Series(1).Points.AddXY(TimeNow, e.values(1))
              Chart1.Series(2).Points.AddXY(TimeNow, e.values(2))
            Chart1.Series(3).Points.AddXY(TimeNow, e.values(3))
            Chart1.Series(4).Points.AddXY(TimeNow, e.values(4))

‘*****Or this?
Chart1.Series(0).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 1”))
              Chart1.Series(1).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 2”))
              Chart1.Series(2).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 3”))
            Chart1.Series(3).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 4”))
            Chart1.Series(4).Points.AddXY(TimeNow, EthernetIPforCLXCom1.Read(“Tag Address 5”))
           
    End If
End Sub

Thanks Folks,
Regards,
Conor

3
Hi Folks,

I'm developing an application where I can plot charts from PLC values.
The charts get saved as a .gif once the X axis plot value has been reached (NumericUpDown3.Value), points get cleared, new chart gets renamed and chart starts to fill again.
For development purposes away from the machine, I am using a timer to plot the data, instead of the SubscriptionDataReceived event.
All works great when the form is not minimised - all charts save perfectly (see FORM MAXIMISED attachment).
But when the form is minimised, it only plots a line 1 pixel wide x 324 pixels high (see FORM MINIMISED attachment).
If i maximise the form again, it plots again.
I need the data to still plot and save the chart when the form is minimised.
See simplified code below, I have omitted any code that is not needed to explain my issue:

Code: [Select]
Imports System.Windows.Forms.DataVisualization.Charting

Public Class Form1

Private Recording As Boolean
    Private Description As String
    Private Chart1 As Chart
    Private ChartDirectory As String
    Private ChartTitle As String
    Private ChartFileName As String

Private Sub CheckExistsCreateFolderSaveChart()
        Dim ChartDirectoryPath As String = ChartDirectory & "\" & Description
        If Not Directory.Exists(ChartDirectoryPath) Then
            Directory.CreateDirectory(ChartDirectoryPath)
        End If
        Chart1.SaveImage(ChartDirectoryPath & "\" & ChartFileName, ChartImageFormat.Gif)
    End Sub



    Private Sub SetChartTitleAndFilename()
        Dim DateTimeNow As Date = Now
        ChartTitle = Description & DateTimeNow.ToString(" (yyyy-MM-dd HH:mm:ss)")
        Chart1.Titles(0).Text = ChartTitle
        ChartFileName = Description & DateTimeNow.ToString(" (yyyy_MM_dd_HH_mm_ss)") & ".gif"
    End Sub



    Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
        Static Generator As System.Random = New System.Random()
        Return Generator.Next(Min, Max)
    End Function



    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Chart1 = New Chart
        GroupBox4.Controls.Add(Chart1)

        With Chart1
            .BorderlineColor = Color.Black
            .Anchor = AnchorStyles.Left + AnchorStyles.Top + AnchorStyles.Right
            .Location = New Point(6, 25)
            .Size = New Size(1314, 324)
            .Visible = True
            .Enabled = True
        End With
    End Sub



Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        If Button8.Text = "Start Recording" Then
            'Clear all
            Chart1.Titles.Clear()
            Chart1.Legends.Clear()
            Chart1.ChartAreas.Clear()
            Chart1.Series.Clear()

            'Title
            Dim Title1 As New Title
            Chart1.Titles.Add(Title1)

            Description = TextBox7.Text

            With Title1
                .Font = New Font("Arial", 10)
                .Alignment = ContentAlignment.TopCenter
                .Position.Auto = False
                .Position.X = 0
                .Position.Y = 1
                .Position.Width = 50
                .Position.Height = 6
                .Text = Description
            End With

            SetChartTitleAndFilename()

            'Legend
            Dim Legend1 As New Legend
            Chart1.Legends.Add(Legend1)

            With Legend1
                .TitleFont = New Font("Arial", 10)
                .Font = New Font("Arial", 10)
                .Docking = Docking.Top
                .Alignment = StringAlignment.Center
                .Position.Auto = False
                .Position.X = 50
                .Position.Y = 1
                .Position.Width = 50
                .Position.Height = 5
                .BackColor = Color.Transparent
                .LegendItemOrder = LegendItemOrder.ReversedSeriesOrder
            End With

            'Chart area
            Dim ChartArea1 As New ChartArea
            Chart1.ChartAreas.Add(ChartArea1)

            With ChartArea1
                .Position.Auto = False
                .Position.X = 0
                .Position.Y = 0
                .Position.Width = 100
                .Position.Height = 100

                .InnerPlotPosition.Auto = False
                .InnerPlotPosition.X = 5
                .InnerPlotPosition.Y = 7
                .InnerPlotPosition.Width = 90
                .InnerPlotPosition.Height = 76

                .IsSameFontSizeForAllAxes = True

                'Primary X axis
                .Axes(0).MajorGrid.Enabled = True
                .Axes(0).MajorGrid.LineColor = Color.Gainsboro
                .Axes(0).LabelStyle.Font = New Font("Arial", 8)
                .Axes(0).MajorTickMark.Size = 1.5
                .Axes(0).MajorTickMark.Enabled = False
                .Axes(0).IsMarginVisible = False
                .Axes(0).IsLabelAutoFit = False
                .Axes(0).LabelStyle.Angle = -90
                .Axes(0).LineWidth = 0
                .Axes(0).IntervalAutoMode = IntervalAutoMode.FixedCount
                .Axes(0).Interval = NumericUpDown3.Value / 25

                'Primary Y axis
                .Axes(1).MajorGrid.Enabled = False
                .Axes(1).LabelStyle.Font = New Font("Arial", 8)
                .Axes(1).MajorTickMark.Size = 0.3
                .Axes(1).MajorTickMark.LineColor = Color.Gainsboro
                .Axes(1).IsMarginVisible = False
                .Axes(1).IsLabelAutoFit = False
                .Axes(1).IsStartedFromZero = False
                .Axes(1).LineColor = Color.Gainsboro
                .Axes(1).IntervalAutoMode = IntervalAutoMode.VariableCount

                .Axes(1).TitleFont = New Font("Arial", 10)
                .Axes(1).Title = "Primary Title"

                'Secondary X axis
                .Axes(2).Enabled = AxisEnabled.False

                'Secondary Y axis
                .Axes(3).MajorGrid.Enabled = False
                .Axes(3).LabelStyle.Font = New Font("Arial", 8)
                .Axes(3).MajorTickMark.Size = 0.3
                .Axes(3).MajorTickMark.LineColor = Color.Gainsboro
                .Axes(3).IsMarginVisible = False
                .Axes(3).IsLabelAutoFit = False
                .Axes(3).IsStartedFromZero = False
                .Axes(3).LineColor = Color.Gainsboro
                .Axes(3).IntervalAutoMode = IntervalAutoMode.VariableCount

                .Axes(3).TitleFont = New Font("Arial", 10)
                .Axes(3).Title = "Secondary Title"
            End With

            'Set recording flag
            Recording = True

            'Series 1
            If Not String.IsNullOrEmpty(TextBox8.Text) Then
                Dim Series1 As New Series
                Chart1.Series.Add(Series1)

                With Series1
                    .Name = TextBox8.Text
                    .Color = Button2.BackColor
                    If ComboBox1.Text = "Primary" Then
                        .YAxisType = AxisType.Primary
                    ElseIf ComboBox1.Text = "Secondary" Then
                        .YAxisType = AxisType.Secondary
                    End If
                    .ChartType = SeriesChartType.Line
                End With
            End If

            'Series 2
            If Not String.IsNullOrEmpty(TextBox9.Text) Then
                Dim Series2 As New Series
                Chart1.Series.Add(Series2)

                With Series2
                    .Name = TextBox9.Text
                    .Color = Button3.BackColor
                    If ComboBox2.Text = "Primary" Then
                        .YAxisType = AxisType.Primary
                    ElseIf ComboBox2.Text = "Secondary" Then
                        .YAxisType = AxisType.Secondary
                    End If
                    .ChartType = SeriesChartType.Line
                End With
            End If

            'Series 3
            If Not String.IsNullOrEmpty(TextBox10.Text) Then
                Dim Series3 As New Series
                Chart1.Series.Add(Series3)

                With Series3
                    .Name = TextBox10.Text
                    .Color = Button4.BackColor
                    If ComboBox3.Text = "Primary" Then
                        .YAxisType = AxisType.Primary
                    ElseIf ComboBox3.Text = "Secondary" Then
                        .YAxisType = AxisType.Secondary
                    End If
                    .ChartType = SeriesChartType.Line
                End With
            End If

            'Series 4
            If Not String.IsNullOrEmpty(TextBox11.Text) Then
                Dim Series4 As New Series
                Chart1.Series.Add(Series4)

                With Series4
                    .Name = TextBox11.Text
                    .Color = Button5.BackColor
                    If ComboBox4.Text = "Primary" Then
                        .YAxisType = AxisType.Primary
                    ElseIf ComboBox4.Text = "Secondary" Then
                        .YAxisType = AxisType.Secondary
                    End If
                    .ChartType = SeriesChartType.Line
                End With
            End If
        ElseIf Button8.Text = "Stop Recording" Then
            If MsgBox("Are you sure you want to stop recording?", vbQuestion + vbYesNo + vbDefaultButton2, "PLC Tag Logger") = DialogResult.Yes Then
               
'Set recording flag
                Recording = False
                CheckExistsCreateFolderSaveChart()
            End If
        End If
    End Sub



Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        SevenSegment1.Value = 10
        SevenSegment2.Value = 90
        SevenSegment3.Value = GetRandom(30, 71)
        SevenSegment4.Value = GetRandom(45, 56)

        If Recording Then
            Dim SeriesCount As Integer = Chart1.Series(0).Points.Count

            If SeriesCount = NumericUpDown3.Value + 1 Then

                CheckExistsCreateFolderSaveChart()

                For Each Series In Chart1.Series
                    Series.Points.Clear()
                Next

                SetChartTitleAndFilename()
            End If

            Dim TimeNow As String = Now.ToString("HH:mm:ss")

            Chart1.Series(0).Points.AddXY(TimeNow, SevenSegment1.Value)
            Chart1.Series(1).Points.AddXY(TimeNow, SevenSegment2.Value)
            Chart1.Series(2).Points.AddXY(TimeNow, SevenSegment3.Value)
            Chart1.Series(3).Points.AddXY(TimeNow, SevenSegment4.Value)
        End If
    End Sub

End Class

Any help much appreciated as always,
Thanks a million,
Regards,
Conor

4
Thank you Godra for your help also.

Regards,
Conor

5
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

6
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

7
Hi Archie,

Thank you for your reply.

Code: [Select]
Private Sub EthernetIPforCLXCom1_ComError_1(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.ComError
        EthernetIPforCLXCom1.DisableSubscriptions = True
        MsgBox(e.ErrorMessage)
    End Sub

The above worked great!

Neither of the following worked - the value of the SevenSegment1 keeps updating with TextBox2 cleared:

Code: [Select]
If String.IsNullOrEmpty(TextBox2.Text) Then
                SevenSegment1.PLCAddressValue = Nothing
            Else
                SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
            End If

Nor:

Code: [Select]
If String.IsNullOrEmpty(TextBox2.Text) Then
                SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(Nothing)
            Else
                SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
            End If

The SevenSegment1 value keeps updating in both cases.
Any help appreciated as always.

Regards,
Conor

8
Hi Archie,

I tried connecting to the Allen Bradley PLC with the CLX driver and it is working well, simplified code below:

Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Button1.Text = "Connect" Then
            EthernetIPforCLXCom1.IPAddress = TextBox1.Text
            EthernetIPforCLXCom1.Port = NumericUpDown1.Value
            EthernetIPforCLXCom1.PollRateOverride = NumericUpDown2.Value
            SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem(TextBox2.Text)
            EthernetIPforCLXCom1.DisableSubscriptions = False

            TextBox1.Enabled = False
            NumericUpDown1.Enabled = False
            NumericUpDown2.Enabled = False
            TextBox2.Enabled = False         
            Button1.Text = "Disconnect"
        ElseIf Button1.Text = "Disconnect" Then
            EthernetIPforCLXCom1.DisableSubscriptions = True

            TextBox1.Enabled = True
            NumericUpDown1.Enabled = True
            NumericUpDown2.Enabled = True
            TextBox2.Enabled = True
            Button1.Text = "Connect"
        End If
    End Sub

I have a few questions that i would kindly like you to help me with:

1) If i enter a tag address that doesn't exist and click connect, the sevensegment obviously doesn't update.
How can i report back to the user that the tag doesn't exist?

2) After connecting to an existing tag, then if i click disconnect and clear the tag address textbox, then click connect again, the seven segment keeps reporting back the previous tag address value.
How can i set the sevensegment to 0 for example and not have it keep updating from the previous tag value?

Thanks Archie,
Regards,
Conor

9
Hi Archie,

OK thanks for this info.
I'll have a go at connecting / disconnecting to the PLC via the EthernetIPForCLXCom driver tomorrow and see how i get on.
If there is a better method you recommend connecting to an Allen Bradley PLC, then let me know!

Regards,
Conor

10
Hi Archie,

Again thank you for this quick support.
SevenSegment1.PLCAddressValue = New Drivers.PLCAddressItem("MyTag") worked perfect!

Any advice on why it is not disconnecting correctly when i set the OpcDaCom1.DisableSubscriptions = True?

Regards,
Conor

11
Hi Archie,

Thank you for your quick response!  :D

My code is below:

Code: [Select]
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        If Button7.Text = "Connect" Then
            OpcDaCom1.OPCServer = TextBox1.Text
            OpcDaCom1.OPCServerPath = TextBox2.Text
            'SevenSegment1.PLCAddressValue.PLCAddress = TextBox3.Text
            OpcDaCom1.DisableSubscriptions = False
            Button7.Text = "Disconnect"
        ElseIf Button7.Text = "Disconnect" Then
            OpcDaCom1.OPCServer = TextBox1.Text
            OpcDaCom1.OPCServerPath = TextBox2.Text
            OpcDaCom1.DisableSubscriptions = True
            Button7.Text = "Connect"
        End If
    End Sub

SevenSegment1 PLCAddressValue is not populated in the properties window.
SevenSegment2 PLCAddressValue is populated in the properties window.

First Issue:
When I click connect, SevenSegment2 will start updating, but when i click disconnect, it does not stop updating.

Second Issue:
If i un-comment the line 'SevenSegment1.PLCAddressValue.PLCAddress = TextBox3.Text, it gives a system null reference exception of object reference not set to an instance of an object.

Any help is much appreciated!

Thanks,
Conor

12
Hi Folks,

First of all, thanks for a great HMI application.
I'm new to VB.net development and am learning programming as a hobby.

I'm developing an application that will allow the user to connect to a PLC, enter PLC tags / topics in textboxes and plot the variables in a chart, then it will save the chart as a .gif image at a set time interval.
For the final version I'll be using EthernetIPForCLXCom driver to connect to the PLC.
PLCs are Allen Bradley.

I'm currently developing with OpcDaCom driver as I'm testing with KepServerEX6 with simulation tags.
I can get it to work perfectly when the form loads / unloads, but:

1) How can I connect when the user clicks a connect button, instead of when the form loads?
2) How can i disconnect when the user clicks a disconnect button, instead of when the form closes?
3) How can i achieve this with an example for each of the driver components above?

Idea is that the user can disconnect using button, enter new tag address / topic in textbox, click connect, then it starts plotting again, without closing / opening the form.
The plotting is the easy bit, the hard part for me is wondering what code to update in the driver code.

Note:
OpcDaCom driver is for development only, reading KepServerEx 6 simulation tags.
EthernetIPForCLXCom driver will be used to connect to Allen Bradley PLC when project is complete.

Any advice would be greatly appreciated, as i am struggling to figure out the connect / disconnect using buttons part.

Thanks in advance,
Regards,
Conor

Pages: [1]