Author Topic: Reading tag from PLC using EthernetIPforCLXCom  (Read 3436 times)

jhaycee03

  • Newbie
  • *
  • Posts: 9
    • View Profile
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

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #1 on: October 06, 2018, 12:56:41 PM »
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)

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #2 on: October 06, 2018, 08:18:41 PM »
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

jhaycee03

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #3 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

Phrog30

  • Guest
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #4 on: October 07, 2018, 08:50:45 AM »
If you need to capture PLC data, whether it's a flat file or database, you need to have handshaking. What I'll do is create a buffer or queue in the PLC and once I get a response that the data was received I'll go to the next one.

What you seem to have now is the PLC and HMI have no idea what the other is doing. You are just hoping for the best, it won't work. What if you have a network blip, you need to be able to ride through it.

It's hard to read your post and determine exactly what you are trying to do, so maybe back up and explain clearly what you are trying to do, then we might be able to give you better ideas.

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #5 on: October 07, 2018, 11:19:48 AM »
From his other topic, they are connecting to client PLC using only VPN access and remote, which probably contributes to the speed of reading.

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #6 on: October 07, 2018, 11:36:51 AM »
The driver's PollRateOverride value needs to be set to 0 for maximum speed of reading.

Then maybe use the DataSubscriber component to subscribe to the tag, instead of the DigitalPanelMeter.

Phrog30

  • Guest
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #7 on: October 07, 2018, 02:22:09 PM »
The driver's PollRateOverride value needs to be set to 0 for maximum speed of reading.

Then maybe use the DataSubscriber component to subscribe to the tag, instead of the DigitalPanelMeter.

Even more reason to queue data. It's simple, stuff data into fifo and unload on handshake. I usually build a simple state machine, which makes it really easy to manage things.

bachphi

  • Hero Member
  • *****
  • Posts: 674
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #8 on: October 07, 2018, 04:00:25 PM »
These shitforbrain questions (R.I.P. Carl J Lydick) are not only ambiguous but also overly ambitious.
Raised questions by Archie, Godra continue to be ignored by him and his response is simply "still the same output".

Having said that I setup a following test:

A DataSubscriber monitoring an integer value from a PLC[Micrologix1400] and record it on a DataGridView.
Pollrate is set to 0 that is as fast as it can
The integer value is increased by one each time by a oneshot 20ms duration timer.
Recorded values does start skipping a little when changing timer to 15 ms.



Code: [Select]
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        dgv1.Columns.Add("col1", "value")
    End Sub

    Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        dgv1.Rows.Add(e.Values(0))
    End Sub

I can try to test a compactlogix tomorrow.
« Last Edit: October 08, 2018, 10:47:37 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 674
    • View Profile
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #9 on: October 08, 2018, 10:49:27 AM »
I tested a compactlogix 1769-L24ER , the result is about the same. At 20ms timer, out of 1000 value, it skipped 1.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Phrog30

  • Guest
Re: Reading tag from PLC using EthernetIPforCLXCom
« Reply #10 on: October 08, 2018, 08:51:18 PM »
I ran tests before and I saw similar results. I was seeing consistent 15ms cycles (ControlLogix - EN2T). But, that was just for giggles, only needed one every second.

One more thing to consider is threading. If he does something that temporarily locks the UI thread, then he will miss more than he already is.