Author Topic: RSLinx running changes update rate?  (Read 9789 times)

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
RSLinx running changes update rate?
« on: April 22, 2015, 01:57:52 PM »
This is my first AdvancedHMI project. Previously I've done one project with a paid-for 3rd party driver and a few projects with RSLinx OPC. This is a C# project, I've subscribed to about 80 tags in a CompactLogix L18ERM.

On my development laptop (i5, 4GB RAM, Win7 Pro 32bit) the AdvancedHMI project ran great, quick response and the update rate looked really good. Things dramatically slowed down when I installed the application on the target PCs (i5, 4GB RAM, Win7 Pro x64). I updated all the chipset and NIC drivers, also ran Windows update with no change in performance. I ran the project on a coworker's 64 bit Win7 laptop and it worked fine. I tried it on a 64 bit Win 8.1 spare computer and it was slow. I put some code in to look at refresh time (time between updates to one particular tag) and the good computers were around 365ms, the bad ones were over 1800ms.

The customer wants to switch to RSLinx and as I'm installing it I realize the difference between the fast computers and slow computers is an installation of RSLinx. Sure enough, as soon as the RSLinx installation finishes and starts up (even before I reboot), the refresh rate goes from 1800ms to 365ms. No RSLinx drivers have been configured, the only one present is the default "Linx Gateways, Ethernet". As soon as I shutdown RSLinx the scan rate goes back up.

What am I missing? It doesn't seem like a driver issue because it changes on the fly. Is the PLC choosing to communicate faster because it sees RSLinx?

I appreciate all the work you put into this Archie. It's a fantastic piece of software. Thanks also to all the forumites. This is my first post because usually you've already asked and answered all my questions.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #1 on: April 22, 2015, 02:05:12 PM »
Can you post some Wireshark captures of the 2 different scenarios?

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #2 on: April 22, 2015, 02:33:39 PM »
Not much experience with Wireshark, hopefully this is what you wanted.

I was shutting down Rockwell services and I had most of them stopped and it wasn't until I turned off "RSLinx Enterprise" that the scan rate jumped. I see the same effect with "RSLinx Classic" service.

v3.98d of AdvancedHMI, btw.

Thanks a lot.
-Dave

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #3 on: April 22, 2015, 02:37:21 PM »
My counterpart has a deployment that is running slow. He is going to install RSLinx to see if he gets the same effect. In the mean time I will look through these captures.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #4 on: April 22, 2015, 03:24:20 PM »
What is the PollRateOverride set to on the driver?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #5 on: April 22, 2015, 03:37:32 PM »
These are some of the fastest round trip rates that I have ever seen. They average 3-4ms from request to response. The difference between the 2 different captures is the amount of time between the last response and the next request. This is determined by the driver based on the PollRateOverride divided by the number of subscription reads. You can see this at line 1034 in EthernetIPforCLXCom.vb

Go to line 1032 and try changing that line of code to a fixed value:

              '* Evenly space out the reads to avoid SendQue Full
              If Convert.ToInt32(ReadTime.ElapsedMilliseconds) < DelayBetweenPackets Then
                  Threading.Thread.Sleep(2)
              End If

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #6 on: April 22, 2015, 03:48:51 PM »
Currently PollRateOverride is 250 but I've experimented with higher values. 300 and up make my refresh rate go up when RSLinx is running. Without RSLinx running I don't start to see an effect until I set it higher than 1600.


I made the change you suggested. It doesn't appear to make much difference.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #7 on: April 22, 2015, 04:06:30 PM »
Somewhere something gets delayed, but I'm not sure where. If you stop RSLinx on your laptop, does it slow down? If so, we can try some debugging.

At line 1000 and 1001 is where the read for the subscription is called and the wait for the response:

                    TransactionNumber = Me.BeginRead(GroupedSubscriptionReads(key).TagName, GroupedSubscriptionReads(key).NumberToRead)
                    response = WaitForResponse(TransactionNumber, 750)


After the response comes back, it sends the data back to the subscribers:

                        If response = 0 Then
                           SendToSubscriptions(Responses(TransactionNumber And 255))


After that happens, it then sleeps if necessary. So we need to clock each of those actions to see where the delay occurs.

Are you handling the data returned from subscriptions within your own code?

Let's do some benchmarks to see if we can pin this down. Modify the driver code like this:

                    Dim T1, T2, T3, T4 As Long
                    'index = 0
                    For Each key In GroupedSubscriptionReads.Keys
                        'While index < GroupedSubscriptionReads.Count And Not StopSubscriptions
                        '* Evenly space out read requests to avoid Send Que Full
                        DelayBetweenPackets = Convert.ToInt32(Math.Max(1, Math.Floor(m_PollRateOverride / GroupedSubscriptionReads.Count)))
                        ReadTime.Start()
                        Try
                            If Not m_DisableSubscriptions And Not StopSubscriptions Then
                                TransactionNumber = Me.BeginRead(GroupedSubscriptionReads(key).TagName, GroupedSubscriptionReads(key).NumberToRead)
                                T1 = ReadTime.ElapsedMilliseconds()
                                response = WaitForResponse(TransactionNumber, 750)
                                T2 = ReadTime.ElapsedMilliseconds()

                                Try
                                    If response = 0 Then
                                        SendToSubscriptions(Responses(TransactionNumber And 255))
                                        T3 = ReadTime.ElapsedMilliseconds()
                                    Else


Them start the application, once it is running put a breakpoint at ReadTime.Reset.  After it hits the breakpoint, see what T1, T2, and T3 are.

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #8 on: April 22, 2015, 04:33:58 PM »
I am handling the data returned from the subscription. Most tags are one element and I simply assign the value returned to a string. I have a couple 4-5 element REAL and DINT arrays. Some DINTs get broken up into their bits. I couldn't get BOOL arrays to work so they're all handled individually. Last count, 77 subscriptions.



T1 is almost always 0 whether RSLinx is running or not. I think I saw it as 1 once out of 60 tests.
T2 and T3 are almost always equal. I'd say less than 5% of the time T3 was 1 more than T2.

With RSLinx running, T2 and T3 ranged from 3 to 17 most of the time. Occasionally in the 20's and rarely in the 30's.

Without RSLinx running, T2 and T3 ranged from 20 to 38 most of the time. Occasionally in the 8 to 11 range and occasionally in the 40's.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #9 on: April 22, 2015, 05:24:34 PM »
I'm going to take a stab in the dark with something before I start digging deep into this. Attached is a patch.

- Download and unzip the attached file
- replace the file in AdvancedHMIDrivers\Support
- Rebuild Solution

Although it is a patch for 3.98f, it should still work with 3.98d
« Last Edit: April 22, 2015, 06:43:18 PM by Archie »

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #10 on: April 23, 2015, 07:57:29 AM »
Sorry, no change with the patched dll.

I also updated to 3.98f. No difference.
« Last Edit: April 23, 2015, 08:07:03 AM by davidshaner »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #11 on: April 23, 2015, 08:19:43 AM »
I'm scratching my head on this one. I tested it with and without RSLinx running on my laptop, but there is no difference. Wireshark shows the response from the PLC is the same, but it's the receiving and processing of the data by AdvancedHMI is where the difference is. Almost like .NET holds the packet.

Can you do another Wireshark capture with the patch on the fast one? Some changes I made in that patch should shave almost 1ms from each read giving you an additional 50-70ms off  the update of all the subscriptions.

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #12 on: April 23, 2015, 09:04:08 AM »
Looks like it did drop around 30ms from my faster scan time.

The fact that you don't see a difference on your laptop is good. Makes me wonder if I could have done something wrong integrating AdvancedHMI into my project that could cause this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: RSLinx running changes update rate?
« Reply #13 on: April 23, 2015, 09:15:39 AM »
One of my earlier thoughts was the processing of the data from the subscriptions, but the stopwatch data showed the delay was coming from the WaitForResponse. Wireshark shows the data returns from the PLC in 3-4ms in both cases. So something is happening with the processing of the data or the wait for the asynchronous thread to complete.

Try starting with a blank project, add the driver to the form and set PollRateOverride to 0. Add 2 BasicLabels and set PLCAddress to different addresses.  Start Wireshark, then run the app without RSLinx. That capture will tell me if the bare bones app still has the problem.

davidshaner

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: RSLinx running changes update rate?
« Reply #14 on: April 23, 2015, 09:37:51 AM »
Looks really fast with only 2 tags.