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

Pages: [1]
1
Support Questions / Re: CompactLogix and MicroLogix questions
« on: August 28, 2013, 07:33:34 AM »
Thanks for the feedback. I am now using version 358 and there is a dramatic improvement in driver performance. WOW.
It is great that the NumberOfElements function  is working.

====================================================================================================================
As per your post, I did the following:
        Dim sTemp As String
        Dim iLoop As Integer

        Dim values1(300) As String

        values1 = EthernetIPforPLCSLCMicroCom1.Read("N50:0", 200)

        For iLoop = 0 To 199
            sTemp = "N50:" + iLoop.ToString
            dgvMicroLogix.Item(0, iLoop).Value = sTemp
            dgvMicroLogix.Item(1, iLoop).Value = values1(iLoop)
        Next

It errors at iLoop = 82

====================================================================================================================
BUT doing this works and returns all the variables:

        Dim sTemp As String
        Dim iLoop As Integer

        Dim values1(300) As String
        Dim values2(300) As String

        values1 = EthernetIPforPLCSLCMicroCom1.Read("N50:0", 101)
        values2 = EthernetIPforPLCSLCMicroCom1.Read("N50:100", 101)

        For iLoop = 0 To 100
            sTemp = "N50:" + iLoop.ToString
            dgvMicroLogix.Item(0, iLoop).Value = sTemp
            dgvMicroLogix.Item(1, iLoop).Value = values1(iLoop)
        Next

        For iLoop = 100 To 199
            sTemp = "N50:" + iLoop.ToString
            dgvMicroLogix.Item(0, iLoop).Value = sTemp
            dgvMicroLogix.Item(1, iLoop).Value = values2(iLoop - 100)
        Next
====================================================================================================================

2
Support Questions / Re: CompactLogix and MicroLogix questions
« on: August 27, 2013, 12:20:51 PM »
Sorry, I am 17 versions behind, we are slow in South Africa.

So if I want to use the subscribe method, I will have to create 250 instances of the Subscribe function. When will the subscribe method handle arrays?

It sounds like the best option for me would be to use Asynchronous read with NumberOfElements with the DataReceived event handler?

Thanks again for this product.

Barry

3
Support Questions / CompactLogix and MicroLogix questions
« on: August 27, 2013, 09:01:48 AM »
WARNING: Please be gentle, very much a NOOOOOOOB. Sorry for the long post.
Archie, this product is sheer brilliance.

I have a Compact Logix L32E and a Micrologix1400 SerB.
The code in both PLC's is to put the accumulator of a timer into array "Test[0]" till "Test[200]" for the Compact Logix and "N223:0" till N223:200" for the MicroLogix as fast as possible.
I can connect to both PLC's and receive the tag name and the tag data into 2 separate data grids. I read 201 integers per PLC.


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I currently run off a timer executing every 5 Seconds which calls ReadCompactLogix() and ReadMicroLogix()

Private Sub ReadCompactLogix()

        Dim sTemp As String
        Dim iLoop As Integer

        EthernetIPforCLXComm1.AsyncMode = True
        For iLoop = 0 To 200
            sTemp = "Test[" + iLoop.ToString + "]"
            EthernetIPforCLXComm1.ReadAny(sTemp, 1)
        Next
        EthernetIPforCLXComm1.AsyncMode = False
End Sub



Private Sub ReadMicroLogix()

        Dim sTemp As String
        Dim iLoop As Integer

        EthernetIPforPLCSLCMicroComm1.AsyncMode = True
        For iLoop = 0 To 200
            sTemp = "N223:" + iLoop.ToString
            EthernetIPforPLCSLCMicroComm1.ReadAny(sTemp, 1)
        Next
        EthernetIPforPLCSLCMicroComm1.AsyncMode = False

End Sub


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I then use the DataReceived event handler as follows:

 Private Sub EthernetIPforCLXComm1_DataReceived(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXComm1.DataReceived
        Dim sTemp As String
        Dim iLoop As Integer

        Try
            sTemp = e.PlcAddress
            Dim iLength As Integer = sTemp.Length
            Dim sLoop As String = Mid(sTemp, 6, iLength - 6)
            iLoop = CInt(sLoop)
            dgvCompactLogix.Item(0, iLoop).Value = e.PlcAddress
            dgvCompactLogix.Item(1, iLoop).Value = e.Values(0)

            'Calculate the time to return all the variables
            If iLoop = 200 Then
                If dgvCompactLogix.Item(1, 200).Value > dgvCompactLogix.Item(1, 0).Value Then
                    txtCompactLogix.Text = dgvCompactLogix.Item(1, 200).Value - dgvCompactLogix.Item(1, 0).Value
                Else
                    txtCompactLogix.Text = dgvCompactLogix.Item(1, 200).Value - dgvCompactLogix.Item(1, 0).Value + 9999
                End If
            End If

        Catch ex As Exception

        End Try
End Sub




 Private Sub EthernetIPforPLCSLCMicroComm1_DataReceived(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforPLCSLCMicroComm1.DataReceived
        Dim sTemp As String
        Dim iLoop As Integer
        Dim iStringLength As Integer
        Dim iStringPosition As Integer

        Try
            sTemp = e.PlcAddress
            iStringLength = sTemp.Length
            iStringPosition = InStr(sTemp, ":")
            Dim sLoop As String = Mid(sTemp, iStringPosition + 1, iStringLength - iStringPosition)
            iLoop = CInt(sLoop)
            dgvMicroLogix.Item(0, iLoop).Value = e.PlcAddress
            dgvMicroLogix.Item(1, iLoop).Value = e.Values(0)

            'Calculate the time to return all the variables
            If iLoop = 200 Then
                If dgvMicroLogix.Item(1, 200).Value > dgvMicroLogix.Item(1, 0).Value Then
                    txtMicroLogix.Text = CInt(dgvMicroLogix.Item(1, 200).Value) - CInt(dgvMicroLogix.Item(1, 0).Value)
                Else
                    txtMicroLogix.Text = CInt(dgvMicroLogix.Item(1, 200).Value) - CInt(dgvMicroLogix.Item(1, 0).Value) + 32765
                End If
            End If

        Catch ex As Exception

        End Try

End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Data is returned to the respective grids.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Question 1: NumberOfElements

I was hoping to address the array by using the 200 value below. By doing this, it only returns "Test[0]" and "N50:0" only. How do I correctly address NumberOfElements?

Private Sub cmdCompactLogixArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompactLogixArray.Click
        EthernetIPforCLXComm1.AsyncMode = True
        EthernetIPforCLXComm1.ReadAny("Test[0]", 200)
        EthernetIPforCLXComm1.AsyncMode = False
End Sub


Private Sub cmdMicroLogixArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMicroLogixArray.Click
        EthernetIPforPLCSLCMicroComm1.AsyncMode = True
        EthernetIPforPLCSLCMicroComm1.ReadAny("N50:0", 200)
        EthernetIPforPLCSLCMicroComm1.AsyncMode = False
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Question 2: Subscribe method

In another post, Archie gives an example.

Public Class frmSubscribe
    Private SubscriptionID As Integer

    Private Sub frmSubscribe_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        EthernetIPforCLXComm1.UnSubscribe(SubscriptionID)
    End Sub

    Private Sub frmSubscribe_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        EthernetIPforCLXComm1.IPAddress = "192.168.101.253"
        SubscriptionID = EthernetIPforCLXComm1.Subscribe("MyTag", 1, 250, AddressOf SubscribedDataReturned)
    End Sub

    '* Show the value when it is returned
    Private Sub SubscribedDataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        'Me.Text = e.Values(0)
        TextBox1.Text = e.Values(0)
    End Sub

End Class


Modifications Made to Archies code was EthernetIPforCLXCom1 replaced with EthernetIPforCLXComm1 (Running Ver 3.41 of driver)

There is an error and I do not know how to fix it.
SubscribedDataReturned has a blue squiggle under it and the error is:
Method "Private Sub SubscribedDataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)" does not have a signature compatible with 'Delegate Sub ReturnValues(values() as String)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Question 3: Performance
In my real life application, I need to read 250 integers as quickly as possible (i.e. every 2 seconds would be great).
What is the best way to handle this? As per timer above OR to use the Subscribe method OR ?????

Pages: [1]