LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How Fast are cRIO Inputs Updated?

Solved!
Go to solution

I am using a cRIO for the first time (cRIO-9063) with 4 modules: 9375, 9213, 9205, and 9208.

 

The module I am concerned with now is the 9208. I want to read its analog inputs periodically (say 100ms) and add it to a running average. So I have a VI running on the PC that gets the value at 10 of its analog inputs every 100ms, but I seem to be getting duplicate values, which makes me think that the scan engine has not updated yet.

 

My scan period is 10ms and network publishing period is 100ms, so I am unsure why I am getting any duplicate values. Can you explain how I should set this up so that a new value gets updated at least every 100ms? Are there other settings I should be looking at? Thanks!

0 Kudos
Message 1 of 15
(3,931 Views)

From the sounds of it there is no real synchronization going on. Although the timed loop on the PC is set to execute every 100ms, the timing may change slightly from iteration to iteration....depending on how you are doing it. You might be catching the very beginning and the very end of one network publish period. From my understanding, network publishing type events can differ in their execution times from iteration to iteration as well.

 

To get a value every 100ms I would use the sync-to-scan engine VI described in the link below. That way you can tell something to happen every 10 scan periods.

 

http://zone.ni.com/reference/en-XX/help/371361M-01/lvioscan/synctoscanengine/

 

That being said, I do not have much experience with NI Scan Engine; normally I use the FPGA module to write whatever is needed. Writing the code I think makes it easier to understand synchronization between FPGA DMA channels and consumer loops on the host side. If you own the FPGA module it might be worth a quick read.

 

Corey


Corey Rotunno

Message 2 of 15
(3,926 Views)

Thank you Corey!

 

I should mention that it is often more than one duplicate value. I am most often getting 10 values all the same, so 1 second's worth of data with no change in it...

0 Kudos
Message 3 of 15
(3,919 Views)

Oh wow...yea seems like something else going on than just being out of sync, huh? Any snippets or code you can post?


Corey Rotunno

0 Kudos
Message 4 of 15
(3,915 Views)

Here is a picture of the code that I call every 100ms to keep my running average. (I know pictures are less preferable than code, but it will take me a while to save copies and disconnect the typedefs). The SubVI that says "Get PD Curren" just bundles the 10 inputs together from the cRIO into an array. Below, you can see what values I got during the last ~1 second of run time. Each row corresponds to a different AI, and each column is spaced apart by about 100ms in time.

 

Keep Running Average.PNG

0 Kudos
Message 5 of 15
(3,906 Views)

@Gregory wrote:

My scan period is 10ms and network publishing period is 100ms,


I have not used the Network Publishing part of the Scan Engine.  I like to keep my communications very direct: either use Network Streams or TCP directly communicating between PC and RT.

 

My suspision is that you have something in your RT that is keeping your Scan Engine from running.  Are you monitoring the CPU usage?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 15
(3,901 Views)

Yea, I dont see anything wrong either in the small section of code. I guess I missed you were going from RT to a PC host via network published shared variables. I haven't used those in a constantly polling type of fashion before so I dont know much about what you are seeing from that end. However, if you are polling 10X a second, every second maybe a network stream as crossrulz mentioned might be worth a look. They are relatively painless to use once you get the connection points made. From there they behave a lot like an RT FIFO. Then you can execute your loop everytime there is new data available, and not until then.


Corey Rotunno

0 Kudos
Message 7 of 15
(3,884 Views)
0 Kudos
Message 8 of 15
(3,859 Views)

All I did to read inputs from the cRIO is drag the variables from the c-series module in the project explorer onto a block diagram (picture below), I don't know if this constitutes a "network published shared variable". 

 

I will check the CPU usage on the cRIO. I did not create any VIs to run on the cRIO yet, so I expect it to be pretty low.

 

Read from cRIO.PNG

0 Kudos
Message 9 of 15
(3,845 Views)

@Gregory wrote:

All I did to read inputs from the cRIO is drag the variables from the c-series module in the project explorer onto a block diagram (picture below), I don't know if this constitutes a "network published shared variable". 

 

I will check the CPU usage on the cRIO. I did not create any VIs to run on the cRIO yet, so I expect it to be pretty low.


Yes, the Scan Engine's network published attributes use the Network Published Shared Variable Engine.  NPSVs are horrible about latency for many many reasons.  I never use them in a real application.  In this case, I would use a Network Stream.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 15
(3,841 Views)