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 - hektop

Pages: [1] 2
1
Support Questions / Re: Minimum required to read CLX data
« on: March 08, 2016, 06:52:16 PM »
Great! I like the IoT part. Please keep us posted on this.

2
Support Questions / Re: Minimum required to read CLX data
« on: March 08, 2016, 04:32:12 PM »
This sounds great Archie, will it be a DLL? If so WPF projects could be created using it. I am very interested if this is the case.

3
Support Questions / Re: Newbie at AHMI and Visual Studio
« on: March 04, 2016, 04:08:53 PM »
There is a Tips & Tricks under the general category, there you can find some useful Information. In there I found this article that talks about DataSubscribers hope it helps.

http://advancedhmi.com/forum/index.php?topic=1119.0

4
Support Questions / Re: Subcribers not working?
« on: March 04, 2016, 03:22:58 PM »
Archie,

why synchronizingObject made the difference and why Me?

5
Support Questions / Re: Subcribers not working?
« on: March 04, 2016, 01:42:32 PM »
Archie,

It worked. I guess I just needed the following line of code "PLCCom.SynchronizingObject = Me". Thanks for the help Archie, the little details always matter.

6
Support Questions / Re: Subcribers not working?
« on: March 04, 2016, 12:21:26 PM »
rbelknap,

I did as suggested, but my labels continue without updating. Any other thoughts? Is there an example you might know somewhere in this fórum for me to take a look and compare?

    Private CLXComm As New EthernetIPforCLXCom()
    Private MicroComm As New EthernetIPforSLCMicroCom()
    Private DataSubsMicro As New AdvancedHMIControls.DataSubscriber2()
    Private PLCAddressItem(0) As Drivers.PLCAddressItem
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       'all my previous code
    End Sub


7
Support Questions / Re: Subcribers not working?
« on: March 04, 2016, 11:32:11 AM »
I tried both sugestions, but none of them worked. I am still getting no data from the driver intance nor getting the event being triggered. I do get data from the PLC if I just use the Read function from the PLC no matter where I place the driver instance. Also it I get data and it gets updated if I just use the GUI forms. Is just that for the project I am working on I have to do everything by code since the PLC data (IPs and tags) might change over time since the PLC data it is being retrieved from a database. Any more suggestions?

1.)
    Moving the driver instance to the top of the mainform_load Sub as private.

2.) Using a dataSubcriber2. I am not sure if I have the correct code though.

Private MicroComm As New EthernetIPforSLCMicroCom()
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            'MicroLogix
            MicroComm.IPAddress = "10.103.12.23"
            MicroComm.PollRateOverride = 500
            Dim DataSubsMicro As New AdvancedHMIControls.DataSubscriber2()
            Dim PLCAddressItem(0) As Drivers.PLCAddressItem
            Dim indexPLCAddressItem As Integer = 1
            If IsNothing(PLCAddressItem(0)) Then 'if PLCAddressPLC has not been initialized
                PLCAddressItem(0) = New Drivers.PLCAddressItem 'PLCAddressItem is initialized
            End If
            PLCAddressItem(0).LastValue = Nothing 'assigns last value
            PLCAddressItem(0).NumberOfElements = 1 'assigns number of elements
            PLCAddressItem(0).PLCAddress = "ST41:0" 'assigns PLC address
            PLCAddressItem(0).ScaleFactor = 1.0R 'assigns scale factor
            PLCAddressItem(0).ScaleOffset = 0R 'assigns scale off set
            PLCAddressItem(0).SubscriptionID = 0 'assigns subscription ID
            DataSubsMicro.CommComponent = MicroComm 'assigns driver to datasubscriber
            DataSubsMicro.PLCAddressValueItems.Add(PLCAddressItem(0)) 'adds to DataSubcriber2 the recently created PLCAddressItem
            DataSubsMicro.PollRate = 1000 'assigns to DataSubscriber2 the poll rate
            DataSubsMicro.SynchronizingObject = Me 'assigns to DataSubscriber2 the synchronizing object
            DataSubsMicro.Value = Nothing 'assigns to DataSubscriber2 the value
            AddHandler DataSubsMicro.DataChanged, AddressOf MicroDataReturned 'adds a event handler to data changed
     Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
End Sub

Private Sub MicroDataReturned(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs)
        Try
            If e.PlcAddress = "ST41:0" Then
                Label2.Text = e.Values(0).ToString()
            End If
            If e.PlcAddress = "F8:1" Then
                Label3.Text = e.Values(0).ToString()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
End Sub


8
Hi Mvlawn,

Let me see if I got this correct. You want to add a background image to a BasicButton? If so just add the BasicButton to the advancedHMI form > Select the recently added BasicButton > Go to the properties tab and look for the BackgroundImage property > Select it and you will see a 3 doted button > Click on it > Select Local resource > Click on the Import button > look for the desired image > Click Open > Click OK. If needed change the BackColor property from the Properties tab from transparent to black, or the desired color.

If this is not what you want can you be a little more detailed?

9
Support Questions / Subcribers not working?
« on: March 03, 2016, 05:08:38 PM »
I am using VS 2015 community edition, Advanced HMI 3.99d, Windows 10 Pro. I am trying to subscribe two different tags to one AB MicroLogix controller and two different tags to one AB Compact logix controller. The problem is that the Event Handlers are not being triggered, when the data is changed. attached is my code. Any suggestions? Do any of you see something wrong with my code?

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim MicroComm As New EthernetIPforSLCMicroCom()
        Dim CLXComm As New EthernetIPforCLXCom()
        Try
            'MicroLogix
            MicroComm.IPAddress = "10.103.12.23"
            MicroComm.PollRateOverride = 500
            MicroComm.Subscribe("ST41:0", 1, 500, AddressOf MicroDataReturned)
            MicroComm.Subscribe("F8:1", 1, 500, AddressOf MicroDataReturned)
            'CompactLogix
            CLXComm.IPAddress = "10.103.12.14" 'saves IP address into driver
            CLXComm.PollRateOverride = 500 'everytime the driver gets data from PLC
            CLXComm.Subscribe("CYCLE_COUNTER.CYCLE1", 1, 500, AddressOf CLXDataReturned)
            CLXComm.Subscribe("Current_Recipe", 1, 500, AddressOf CLXDataReturned)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub MicroDataReturned(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs)
        Try
            If e.PlcAddress = "ST41:0" Then
                Label2.Text = e.Values(0).ToString()
            End If
            If e.PlcAddress = "F8:1" Then
                Label3.Text = e.Values(0).ToString()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub CLXDataReturned(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs)
        Try
            If e.PlcAddress = "CYCLE_COUNT.CYCLE1" Then
                Label4.Text = e.Values(0).ToString()
            End If
            If e.PlcAddress = "Current_Recipe" Then
                Label5.Text = e.Values(0).ToString()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

10
Support Questions / Re: MicroLogix DataSubcriber2 and SQL
« on: October 23, 2015, 04:31:33 PM »
I forgot to reply back but I found a way to do it without creating multiple DataReturn subs

Private Sub CLXDataReturned(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs)
        Dim PlcIp, PlcTag, PlcValue As String
        Try
            Dim DriverComm As AdvancedHMIDrivers.EthernetIPforCLXCom = CType(sender, AdvancedHMIDrivers.EthernetIPforCLXCom) This is the important part
            PlcIp = DriverComm.IPAddress This is how I get the IP value
            PlcTag = e.PlcAddress
            PlcValue = e.Values(0).ToString()
            comparePLCDataWithSQL(PlcIP, PlcTag, PlcValue)
        Catch ex As Exception
            SQLQuery.InsertInto4FieldsQuery("tblErrorLog", "IP", sender.IPAddress, "LogTime", Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "Error", ex.Message, "Tag", e.PlcAddress)
        End Try

    End Sub

11
haha, it happens.

12
I made a lot of changes to the code and now the error is not showing. I am not sure what was the problem though. Thanks for your reply, and sorry for the hustle.

13
 EthernetIPforCLXCom is created from code like so:

Dim driverType As New AdvancedHMIDrivers.EthernetIPforSLCMicroCom 'creates a micrologix driver
driverType.IPAddress = _PLCinfo.IP 'saves SQL IP address into driver
driverType.PollRateOverride = 10000 'how often the driver gets data from PLC

After hovering the MyDLLInstance value is 0 and the DLL length is 101, each value from the DLL is equal to nothing.

After ignoring the error everything continues like normal.

14
Using v399 and VS express 2015, I get the error "Object reference not set to an instance of an object" in the EthernetIPforCLXCom.vb line 464. The following is the exception thrown:

Exception thrown: 'System.NullReferenceException' in AdvancedHMIDrivers.dll

Additional information: Object reference not set to an instance of an object.

If there is a handler for this exception, the program may be safely continued.


Line 464 has the following code "address.TransactionNumber = CUShort(DLL(MyDLLInstance).GetNextTransactionNumber(32767))" where transactionNumber = 0 and MyDLLInstance = 0.

I am recording all the PLC data into a SQL database. I am not using non of the graphical components, everything is hand coded. I create a thread for every PLC and inside that thread I loop all the tags that belong to the specific IP/PLC. I could ignore the error if I wanted to I just wanted to know if this was a bug or maybe I am doing something wrong how I am calling the Com driver.

15
Support Questions / Re: MicroLogix DataSubcriber2 and SQL
« on: October 08, 2015, 06:51:53 PM »
Archie, one more question. Is there a way to know from which IP the data is coming using subscribers. Lets take the following example.


EthernetIPforCLXCom1.Subscribe("MyTag", 1, 500, AddressOf DataReturned)
 EthernetIPforCLXCom2.Subscribe("MyTag", 1, 500, AddressOf DataReturned)

Private LastValue As String
Private Sub DataReturned(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs)
        If e.PlcAddress = "ST41:11" And e.IP = "1.1.1.1" Then
            If e.Values(0) <> LastValue Then
                'Write to SQL
                LastValue = e.Values(0)
            End If
        ElseIf e.PlcAddress = "ST41:11" And e.IP = "2.2.2.2" Then
            If e.Values(0) <> LastValue Then
                'Write to SQL
                LastValue = e.Values(0)
            End If
        End If
    End Sub

Pages: [1] 2