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

Pages: [1]
1
Open Discussion / Saving Array Tags data to excel csv file
« on: October 11, 2018, 11:52:54 PM »
I've seen this code in some topics similar to my target output (credits to bob1371)
Code: [Select]
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged

        If e.ErrorId = 0 AndAlso e.Values.Count > 0 AndAlso e.Values(0) = "True" Then
            Console.WriteLine("About to read the data")
            Dim MyValues0() As String = EthernetIPforCLXCom1.Read("VCell1B_FES_Cycle_Average[0]", 500)
            Dim MyValues1() As String = EthernetIPforCLXCom1.Read("VCell_1A_FES_Cycle_Average[0]", 500)
            Dim MyValues2() As String = EthernetIPforCLXCom1.Read("VCell_2B_FES_Cycle_Average[0]", 500)
            Dim MyValues3() As String = EthernetIPforCLXCom1.Read("VCell_2A_FES_Cycle_Average[0]", 500)
            Dim MyValues4() As String = EthernetIPforCLXCom1.Read("VCell_3B_FES_Cycle_Average[0]", 500)
            Dim MyValues5() As String = EthernetIPforCLXCom1.Read("VCell_3A_FES_Cycle_Average[0]", 500)
            Dim MyValues6() As String = EthernetIPforCLXCom1.Read("Inspect_FES_Cycle_Average[0]", 500)
            Dim MyValues7() As String = EthernetIPforCLXCom1.Read("Repair_FES_Cycle_Average[0]", 500)
            Dim MyValues8 As String = EthernetIPforCLXCom1.Read("MDY5")

            Console.WriteLine(MyValues0.Length & "elements read VCell_1B.")
            Console.WriteLine(MyValues1.Length & "elements read VCell_1A.")
            Console.WriteLine(MyValues2.Length & "elements read VCell_2B.")
            Console.WriteLine(MyValues3.Length & "elements read VCell_2A.")
            Console.WriteLine(MyValues4.Length & "elements read VCell_3B.")
            Console.WriteLine(MyValues5.Length & "elements read VCell_3A.")
            Console.WriteLine(MyValues6.Length & "elements read Inspect.")
            Console.WriteLine(MyValues7.Length & "elements read Repair.")
            Console.WriteLine("All Data Read")

            '*Transfer the values to Excel

            '*Creates Excel file
            Using ExcelPackage As New OfficeOpenXml.ExcelPackage(New IO.FileInfo("C:\Data.xlsx"))
                ExcelPackage.Workbook.Worksheets.Add(MyValues8)
                Console.WriteLine("ws creation ok")

                '*Writes the Headers in Row 1
                ExcelPackage.Workbook.Worksheets(1).Cells("A1").Value = "VCell 1B"
                ExcelPackage.Workbook.Worksheets(1).Cells("C1").Value = "VCell 1A"
                ExcelPackage.Workbook.Worksheets(1).Cells("E1").Value = "VCell 2B"
                ExcelPackage.Workbook.Worksheets(1).Cells("G1").Value = "VCell 2A"
                ExcelPackage.Workbook.Worksheets(1).Cells("I1").Value = "VCell 3B"
                ExcelPackage.Workbook.Worksheets(1).Cells("K1").Value = "VCell 3A"
                ExcelPackage.Workbook.Worksheets(1).Cells("M1").Value = "Inspect"
                ExcelPackage.Workbook.Worksheets(1).Cells("O1").Value = "Repair"
                Console.WriteLine("header creation ok")

                '*Loops to write data in correct columns
                For Index = 0 To MyValues0.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues0(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "A" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues0(Index)
                Next
                Console.WriteLine("Worksheet OK 1B")

                For Index = 0 To MyValues1.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues1(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "C" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues1(Index)
                Next
                Console.WriteLine("Worksheet OK 1A")

                For Index = 0 To MyValues2.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues2(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "E" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues2(Index)
                Next
                Console.WriteLine("Worksheet OK 2B")

                For Index = 0 To MyValues3.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues3(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "G" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues3(Index)
                Next
                Console.WriteLine("Worksheet OK 2A")

                For Index = 0 To MyValues4.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues4(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "I" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues4(Index)
                Next
                Console.WriteLine("Worksheet OK 3B")

                For Index = 0 To MyValues5.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues5(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "K" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues5(Index)
                Next
                Console.WriteLine("Worksheet OK 3A")
                For Index = 0 To MyValues6.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues6(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "M" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues6(Index)
                Next
                Console.WriteLine("Worksheet OK Inspect")

                For Index = 0 To MyValues7.Length - 1
                    Console.WriteLine("Element " & Index & "=" & MyValues7(Index))
                    Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(1)
                    Dim CellNum As String = "O" & (Index + 3)
                    ws.Cells(CellNum).Value = MyValues7(Index)
                Next
                Console.WriteLine("Worksheet OK Repair")

                '*Saves.xlsl file
                ExcelPackage.Save()

            End Using
        End If
    End Sub


Is this applicable also in my scenario? I have an array of tags which is Test_Tags[0] to Test_Tags[12] which need to save data in .csv file per date and append all data changes every row. In this example it has a limit of 500, so I just remove the 500 from every code of array on this syntax?
Code: [Select]
EthernetIPforCLXCom1.Read("VCell1B_FES_Cycle_Average[0]", 500) Also instructed to put PLCAddressValue to DataSubscriber the tagname, how to input tagname of arrays as PLCAddress Value? or I just need to run first the BeginReadMultiple to achieve that. Im sorry for the question, I'm new in the process of AdvancedHMI but have knowledge on VB. Thanks in advance

2
Open Discussion / Re: Reading tag from PLC using EthernetIPforCLXCom
« on: October 07, 2018, 07:23:37 AM »
The DataReceived event will fire at the rate of PollRateOverride or the rate the PLC and network responds, whichever is slower. How fast is your vale changing?

You are doing a double read in your DataReceived event. Just use e.Values(0)

jhaycee03,

Unless there are more details that you didn't provide then your approach seems to be somewhat wrong.

It should be similar to this:

1) Setup your driver  (meaning the EthernetIPforCLXCom1 driver should be set for "192.168.1.220" and its PollRateOverride value as you need it)

2) Setup the DigitaPanelMeter control to use that driver and to also subscribe automatically to your tag (meaning to populate its PLCAddressValue property with "Tag_test"). The value will be refreshed automatically and there is no need for the DataSubscriber component.

3) Use either the meter's ValueChanged event or the driver's DataReceived event to update your label (this would be dependent on whether you want it updated only when the value has changed or in regular interval as set by the driver's PollRateOverride value):

Code: [Select]
    Private Sub DigitalPanelMeter2_ValueChanged(sender As Object, e As EventArgs) Handles DigitalPanelMeter2.ValueChanged
        Label2.Text = DigitalPanelMeter2.Value
    End Sub

Code: [Select]
    Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived
        Label2.Text = e.Values(0)
    End Sub


Hi Godra and Archie,

Thank you for the tip, but still the same output. In this case, is this the limit of reading in advacendHMI? We have same output of jump to 5 or 6 counts like 1,7,13,18,24,30,36,41... so on... Or there is another way to match the recorded data to +1 only? like 1,2,3,4,5,6,7,8.... the PLC also set to fast load to test it's maximum limit of reading tag. But the idea is to reflect also in AdvacendHMI. Is this possible? Thank you

3
Open Discussion / Reading tag from PLC using EthernetIPforCLXCom
« on: October 06, 2018, 10:29:29 AM »
Hello,

We're trying to read tag from PLC and save data to text file. But the speed assign to PLC doesn't meet when reading to the AdvancedHMI. When we open the file the record shows that the number jump 5 or 6 counts, we need the record of +1 only eg. 1,2,3,4,5,6... but for now it is 1,7,12,18..... I already change the PollRateOveride of the driver and apply below code that I've seen on this forum. Please guide me on this issue, I'm new in PLC and AdvancedHMi but I know VB. Thank you

Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived
        Dim MyDriver As New EthernetIPforCLXCom
        MyDriver.IPAddress = "192.168.1.220"
        Dim MyValue As String
        MyValue = MyDriver.Read("Tag_test")
        Label2.Text = MyValue
End Sub

Code: [Select]
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        DigitalPanelMeter2.Value = e.Values(0)

    End Sub

I've seen that there are code using
Code: [Select]
EthernetIPforCLXCom.BeginReadMultiple(Tag) but it doesn't work fine with me. Can anyone help me on this? Thanks in advance

4
Open Discussion / Re: Connecting CLX PLC to advancedHMI
« on: October 06, 2018, 12:40:43 AM »
@dmroeder Thank you to the great info. I will request that details to the client. How about how can I read the Tags from CLX to VB? what toolbar I need to use to detect the Tags?

Well it depends on what you want to do with the data in the tag.  If you simply want to display a value, then the quick start guide walks you through adding a driver, adding a component to display the tag, then setting their properties.

If you want to read the tag in code and do something custom with the data (like log it somewhere), check the end of this and see if it helps:

https://www.advancedhmi.com/documentation/index.php?title=EthernetIPforCLXCom

Hi, Thank you for your guide it help me a lot. But now we try to monitor the Tag using DigitalPanelMeter but we think it is delay. what is the most accurate toolbar to read time to time changes? Thanks

If you are not happy with the update rate of the DigitalPanelMeter, find the driver on your form and look for the property "PollRateOverride", it will probably be a value of 500(ms).  As a test, drop it to 0, this will update your DigitalPanelMeter at the fastest possible rate.  You probably wouldn't want it at 0 if you have a lot of controls using that instance of the driver.  You probably could have 2 drivers, one set to update fast for some objects, the other set to slow for other non critical objects.

Each visual control has a property "ComComponent", which is the driver that the control is assigned to.

Also, there is a better way to read a tag in code that I should have mentioned.  I said use a button and use the button click event.  If you don't want to interact with the application but have the tag read and used in code, check out the "DataSubscriber" control. It's pretty slick, it subscribes to the tag in the same way that a visual control does, but it provides "DataChanged" and "DataReturned" methods that you can use to do things in code with the value.

Thankyou for the options to try. I will try this and update you the progress result. Thank you

Hi, we applied the changing of poll rate from the driver and it works fine thankyou very much for that. For now, let me understand things about the PLC. Once we connect the advancedhmi and PLC, can we control it now? My client want to speed up the reading and push the limits of the PLC or how much PLC can do more. Correct me I'm wrong my understanding is that advancedHMI will just read what is the actual reading of the PLC itself, is that correct? Please guide me more about the PLC or you can give me any article that will me to understand the process. Thank you so much for the help

5
Open Discussion / Re: Connecting CLX PLC to advancedHMI
« on: October 04, 2018, 08:58:37 PM »
@dmroeder Thank you to the great info. I will request that details to the client. How about how can I read the Tags from CLX to VB? what toolbar I need to use to detect the Tags?

Well it depends on what you want to do with the data in the tag.  If you simply want to display a value, then the quick start guide walks you through adding a driver, adding a component to display the tag, then setting their properties.

If you want to read the tag in code and do something custom with the data (like log it somewhere), check the end of this and see if it helps:

https://www.advancedhmi.com/documentation/index.php?title=EthernetIPforCLXCom

Hi, Thank you for your guide it help me a lot. But now we try to monitor the Tag using DigitalPanelMeter but we think it is delay. what is the most accurate toolbar to read time to time changes? Thanks

If you are not happy with the update rate of the DigitalPanelMeter, find the driver on your form and look for the property "PollRateOverride", it will probably be a value of 500(ms).  As a test, drop it to 0, this will update your DigitalPanelMeter at the fastest possible rate.  You probably wouldn't want it at 0 if you have a lot of controls using that instance of the driver.  You probably could have 2 drivers, one set to update fast for some objects, the other set to slow for other non critical objects.

Each visual control has a property "ComComponent", which is the driver that the control is assigned to.

Also, there is a better way to read a tag in code that I should have mentioned.  I said use a button and use the button click event.  If you don't want to interact with the application but have the tag read and used in code, check out the "DataSubscriber" control. It's pretty slick, it subscribes to the tag in the same way that a visual control does, but it provides "DataChanged" and "DataReturned" methods that you can use to do things in code with the value.

Thankyou for the options to try. I will try this and update you the progress result. Thank you

6
Open Discussion / Re: Connecting CLX PLC to advancedHMI
« on: October 04, 2018, 07:54:25 AM »
@dmroeder Thank you to the great info. I will request that details to the client. How about how can I read the Tags from CLX to VB? what toolbar I need to use to detect the Tags?

Well it depends on what you want to do with the data in the tag.  If you simply want to display a value, then the quick start guide walks you through adding a driver, adding a component to display the tag, then setting their properties.

If you want to read the tag in code and do something custom with the data (like log it somewhere), check the end of this and see if it helps:

https://www.advancedhmi.com/documentation/index.php?title=EthernetIPforCLXCom

Hi, Thank you for your guide it help me a lot. But now we try to monitor the Tag using DigitalPanelMeter but we think it is delay. what is the most accurate toolbar to read time to time changes? Thanks

7
Open Discussion / Re: Connecting CLX PLC to advancedHMI
« on: October 03, 2018, 08:05:23 PM »
@bachphi I will ask. But the setup of my client is only connected via VPN to the PLC, I just remote his PC to apply and monitor via AdvancedHMI. May I know how the CLX PLC control since it has dedicated IP, is there a way to have GUI of its control and how? Sorry Im not familiar with PLC.

8
Open Discussion / Re: Connecting CLX PLC to advancedHMI
« on: October 03, 2018, 08:01:27 PM »
@dmroeder Thank you to the great info. I will request that details to the client. How about how can I read the Tags from CLX to VB? what toolbar I need to use to detect the Tags?

9
Open Discussion / Connecting CLX PLC to advancedHMI
« on: October 03, 2018, 11:54:20 AM »
Hi There,

I'm new with PLC but I have some knowledge on VB. We are connecting our client PLC using only VPN access and remote. May I know what other details I need to connect it? They just give me the IP of the PLC and told me that they what to monitor a Tag Name. Is the PLC have an access to see their settings? I'm sorry for the ignorant question about PLC. Appreciate your help with this. Thanks in advance

Pages: [1]