Author Topic: Data Subscriber question  (Read 3575 times)

Lixoudis

  • Newbie
  • *
  • Posts: 14
    • View Profile
Data Subscriber question
« on: September 26, 2017, 04:51:30 PM »
Hello guys  i have a question on data subscriber 2. The question is if the poll rate is working because i want to pull data every minute for around 11 tags and if yes the time is in milliseconds.Am using ethernet CLX driver for communication

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Data Subscriber question
« Reply #1 on: September 26, 2017, 05:35:32 PM »
The problem you will run into is that about every 20 seconds the connection with the PLC closes. Therefore if you set the PollRateOverride to 2 minutes, then it will have to reconnect for every read. I would recommend a 15 second rate and only process your data every 4th time.

Phrog30

  • Guest
Re: Data Subscriber question
« Reply #2 on: September 26, 2017, 06:58:55 PM »
Hello guys  i have a question on data subscriber 2. The question is if the poll rate is working because i want to pull data every minute for around 11 tags and if yes the time is in milliseconds.Am using ethernet CLX driver for communication

I thought the poll rate inside the datasubscriber didn't do anything?  The way I read the post is he is asking about this poll rate, not the driver poll rate.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Data Subscriber question
« Reply #3 on: September 26, 2017, 10:24:33 PM »
Hello guys  i have a question on data subscriber 2. The question is if the poll rate is working because i want to pull data every minute for around 11 tags and if yes the time is in milliseconds.Am using ethernet CLX driver for communication

I thought the poll rate inside the datasubscriber didn't do anything?  The way I read the post is he is asking about this poll rate, not the driver poll rate.
That is true. This does need to be clarified.

The DataSubscriber poll rate is controlled by the driver PollRateOverride. The PollRate property of the DataSubsciber does nothing.

Lixoudis

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Data Subscriber question
« Reply #4 on: September 27, 2017, 12:12:12 AM »
So if I understand correctly poll rate of the data subscriber doesn't work.Any other way to make this work. Can I use subscribing for every tag seperately or is another control that could help me achieve that. Or maybe another way is to pull data continiously put in an array and then with a timer and background worker I can write them into my sql database. Your thoughts are welcome.
« Last Edit: September 27, 2017, 12:14:30 AM by Lixoudis »

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Data Subscriber question
« Reply #5 on: September 27, 2017, 09:58:36 AM »
I would let the DataSubscriber go crazy and poll as often as it wants to.  Add some local variables in the declarations area of the Forms Class, then in the DataReturned event of the Subscriber just constantly be moving the values for your subscribed tags into their respective local variables.  Next during the Form_Load event just start a 1 minute timer you create and on the Timer_Tick event you can do whatever you want with the local variables.
Still just trying to figure out this thing called Life.

Lixoudis

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Data Subscriber question
« Reply #6 on: September 30, 2017, 11:59:24 AM »
Sorry guys for all my questions since i new to the project i need some clarifications.My question is if in the data subscriber 2 i can read the Boolean values of individuals bits of a tag(DINT).

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Data Subscriber question
« Reply #7 on: September 30, 2017, 12:25:35 PM »
Yes for a Compact or a ControlLogix you need only to use the following.   TagName[Element].BitNumber.     (HMI_A_FAULTS[0].0)
Still just trying to figure out this thing called Life.

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Data Subscriber question
« Reply #8 on: September 30, 2017, 12:27:22 PM »
I forgot to mention it will return a hex value as a string. But since it's a Boolean it'll be 1 or 0.
Still just trying to figure out this thing called Life.

Lixoudis

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Data Subscriber question
« Reply #9 on: September 30, 2017, 12:56:22 PM »
Let me see if i get it correctly or explain correctly.My ControlLogix PLC has a tag named "HMI_A_Faults" that has 16 individual bits.So first alarm is linked to bit 0,second alarm is set to bit 1 and so on.So in the data subscriber i have to set in the plcaddressitem the following number of elements=16 and plc address= HMI_A_Fault .Is that correct or not?
And then to check for the true value of bit i add the below code in the DataSubscriber2_DataChanged
Code: [Select]
If e.PlcAddress = "HMI_A_FAULTS[0].0" And e.Values(0) = "True" Then
            Dim lvi As ListViewItem = New ListViewItem()
            lvi.Text = Now.ToString("dd/MM/yyyy")
            lvi.SubItems.Add(Now.ToString("HH:mm"))
            lvi.SubItems.Add("E-Stop has been pressed")
            ListViewExAlarm.Items.Add(lvi)
        End If



« Last Edit: September 30, 2017, 01:33:11 PM by Lixoudis »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Data Subscriber question
« Reply #10 on: September 30, 2017, 02:06:12 PM »
Any reason you are not using the MessageListByBit for this?

Phrog30

  • Guest
Re: Data Subscriber question
« Reply #11 on: September 30, 2017, 02:14:48 PM »
I would only watch the word, then in the HMI look at the bits, here's an example:

Code: [Select]
Private Sub Alarm_Triggers_DS_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles Alarm_Triggers_DS.DataChanged

        For i = 0 To Alarm_Triggers_DS.PLCAddressValueItems.Count - 1
            Dim Binary_Offset As Integer
            Binary_Offset = i * Binary_Length

            If e.PlcAddress = "HMI_Alarm_Array[" & i & "]" Then
                For b = 0 To Binary_Length - 1
                    If (e.Values(0) And (1 << b)) <> 0 Then
                        MsgBox(b + Binary_Offset) 'This will return the alarm number in the array
                    End If
                Next
            End If

        Next i

    End Sub

Binary length is 16, 32, etc.
Binary offset is the word in the array, I think I have 10 DINTs in my array

You can look at individual bits but that is a lot of extra communication when all you need is the word.

James

Lixoudis

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Data Subscriber question
« Reply #12 on: September 30, 2017, 02:50:42 PM »
Am not using the MessageListByBit because i have set up already a listview with columns and also am loggin the items of list view into a text file for history of faults.Also i tried the MessageListByBit, but first i cant make columns,second its shows the bit value that the alarm is coming and i dont want to see this, and there is no way to remove it and last i have 3 different tags for alarms(level of alarms) so i have to create 3 different MessageListByBit and also i cant make any changes to the plc code because my project is only for remote viewing and data logging.
One more question the code i put it will work or not because the other code that Phrog30 posted i did not understand how i will implement in my code.(Sorry my knowledge of visual basic is somewhere on the starting point yet).
« Last Edit: September 30, 2017, 03:02:26 PM by Lixoudis »

Phrog30

  • Guest
Re: Data Subscriber question
« Reply #13 on: September 30, 2017, 05:02:29 PM »
The code I posted should work with all DINT arrays.  So, Word[0].Bit1 is alarm #1, Word[1].Bit.1 is alarm #32, etc.  You set the bit in the PLC, this code takes care of the reset.  You basically replace the msgbox with whatever code you need to do.