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.


Topics - 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 / 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

3
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]