LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help understanding Scan Engine

LV 2010

PXI 1040

EtherCAT 9144 (2)

Various modules.

 

I'm and old hand at LabVIEW, but I'm brand new (3 days now!) to EtherCAT, shared variabled, and the Scan Engine.

 

I've got configuration figured out. Now I need to plan the best way to sample the data into my program.

(I've already got a program doing 1000 things on the PXI, so I need to be time efficient).

 

I wrote a test program to read a single chassis (72 channels) in a timed loop.

The loop is using a 1 MHz clock with a counter of 100, that's 10 kHz.

I'm recording the duration of the loop and it comes out as 16 uSec.  That's fine.

I take it that it takes that long to read 72 values from the Scen Engine into my program.

 

I'm also extracting the first channel (which has a Thermocouple connected) ,and counting the number of samples that are repeats, i.e. duplicate reads of a previous value.

 

Here's the code:

 

Scan 1.PNG
 
When I run this, here are the results:
Scan 2.PNG
 
With the Scan Engine set to 1 mSec, I see 200 loops with one value, then 200 loops with another value, and so on.
 
That seems exactly right: 200 loops x 100 uSec each = 20 mSec.  The Data Sheet for 9219 says it's 50 Hz for a TC type. So far, so good.
 
I thought I would change the Scan Engine Rate:
--- PXI - Utilities - Scan Engine Mode - Change to Configure.
--- PXI - Properties - Scan Engine - Scan Period = 2 mSec
--- PXI - Deploy
--- PXI - Utilities - Scan Engine Mode - Change to Active.
And run the program again.  Here's what happened:
 
 Scan 3.PNG
 
I don't understand this at all.  Why should that number change?
My loop is still running at 10000 Hz.  So why does it now take 220 x 100 uSec = 22 mSec to sample?
 
I continued changing the Scan Engine period and got more results:
 
3 mSec --> 240 loops
4 mSec --> 234 loops (!)
5 mSec --> 245 loops
10 mSec --> 300 loops
20 mSec --> 400 loops
40 mSec --> 400 loops
 
It's quite repeatable, and quite solid, if you ignore the first run or two after a change.
 
Obviously I'm misunderstanding something, because I am expecting the sample rate to be constant. In that case the number of repeats would be constant.
 
What am I misunderstanding? Why is the actual sample rate dependent on the Scan Engine period?
 

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 4
(2,817 Views)

If I go the other direction, it seems to correspond:

 

750 uSec --> 195 loops

500 uSec --> 190 loops

400 uSec --> 188 loops (execution time rises to 15-19 uSec)

300 uSec --> 186 loops (execution time average is higher)

200 uSec --> "Cyclic Telegram size has been exceeded"

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 4
(2,802 Views)

Hi

As you must know the for loop is going to iterate as many times the size array indicates, due to the indexed input, this may be related with the scan engine period, since that array is built in the timed loop, just a couple of questions:

  1. Does the size of the array at the input of the for loop varies with the scan engine period?
  2. What code runs at the false state? (just to have a better understanding of the whole code)
Chris S.
0 Kudos
Message 3 of 4
(2,699 Views)

As you must know the for loop is going to iterate as many times the size array indicates, due to the indexed input,

 

--- Yes, that's 10,000 times.  It's initialized at the far left with a constant array where 9999 and 71 are the last valid elements.

 

 this may be related with the scan engine period, since that array is built in the timed loop.

 

--- No, it's not.  The array is initialized to 10,000x72 and never changed (in size).

 

Does the size of the array at the input of the for loop varies with the scan engine period?

 

--- No, and there's no reason it should.  The timed loop simply replaces elements in an already-initialized array.

 

What code runs at the false state? 


--- In that case, the sample value has changed.  I append the current sample count (the bottom shift reg) to the array of sample counts I'm building, and set the current sample count to 1.

 

The code at the right is simply looking for changes in value of the one channel, and counting samples that are identical.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 4
(2,686 Views)