Showing results for 
Search instead for 
Did you mean: 

Generate File on host PC - Read on RT target // Achieve better sampling rates.

Hello everybody, I'm fairly new to LabVIEW, so bear with me. I'll start with my configuration:

>>> Host PC connected via LAN to a PXI-1042Q chassis containing a PXI-8820 controller + PXI-6259 DAQmx


The basic idea is the following:


1) I have created a State Machine VI where the user can create a velocity profile by adding subsequent linear segments. Once the user is done adding segments, he hits the finished button and the VI generates a position plot (integrating numerically the velocity) and also creates a file containing every sample in that position plot. The objective is to use each of this samples as the setpoint later in a PID control algorithm. The file contains the sample rate in the first line, and after that all the position samples. No need for timing since the sample rate is determined in the VI, hence the 1st sample corresponds to time zero, then the 2nd sample is time zero + 1 sample time, etc.

This VI runs on the host PC and uses event structure with value changes to detect user input and transition between states. 


2) Running on the RT target, I have another VI where I want to read the file created on (1), using every position line of the file as a set point for my PID block. This VI will also adquire some signals like the motor voltage, current and a position (based of a quadrature encoder reading) within a timed loop running the same sample rate as the one defined in (1). In another non-deterministic loop, all of these 3 signals are plotted and logged into a file. 


The problem I am having right now is how to read the file on my RT target. I've tried to move the whole VI (1) to the RT target (so that the file will already be in the target HDD), but RT targets don't support event structures based on front panel value changes. How can I move the file in question to the RT target ?? I'm guessing reading off the host PC would add significant jitter. 


Also, is there any better way to do this??? WIthout doing any PID control, just adquiring data in my VI (2) I haven't been able to achieve anything better than 200Hz sample rate (5ms timed loop) without getting a "Finished Late" flag on the timed loop. This is probably due to my inefficient programming. Could you point out what changes should I make to achieve something like 1Khz sample rate on my main loop? 


I have attached both VIs. 

Please feel free to suggest any changes, or structure changes to achieve the same result with more efficient programming techniques. 


Thanks in advance,





Download All
0 Kudos
Message 1 of 5

I'm assuming that the number of segments used to generate the waveform is much smaller than the file you want to send to the PXI.  Why not send the segments (which you generate on the PC interactively) and let the PXI generate the waveform itself?  It is probably much faster to compute the waveform than to transmit and read a file.  There are a number of ways to transfer data to the PXI, including VI Server, Network Shared Variables, the TCP/IP functions, and Network Streams -- all these methods use TCP/IP as the underlying protocol.  The first two are fairly simple, and should work well for small amounts of data.


Bob Schor

0 Kudos
Message 2 of 5



Bob has a good point about the speed in computing the waveform rather than sending and reading a file.  The file transfer will also make it harder to keep the determinism that you look for in real-time system especially in performing gain calculations.  Here is some information that do give some informaiton on some options if you still feel like going that route:

Aaron L.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 5

Is they any replacement for an event case with value change on an RT target? I'm thinking about integrating the 2 VI's as a whole in the RT target. 

0 Kudos
Message 4 of 5

You do realize that on an RT Target, there is no "Front Panel" as such (except for passing arguments back and forth).  In particular, you can't Push a Push Button (but you can call it with True or False as a Boolean input) and can't "see" a Graph or Chart.


It's not clear what you want to do on the RT Target, but I can't think why you'd want an Event Loop or Events.  Have you thought about a Queue-driven State Machine or a Producer/Consumer pattern (whichever fits what you want to do)?


Here's a suggestion.  Take an hour and write a Document that says, in as much detail as seems reasonable, what you want to have happen on the RT Target.  Describe the kinds of data, the sampling rates, the Start and Stop conditions, etc.  Sometimes this exercise, by itself, leads you to suddenly see what you have to do to accomplish your task (I started doing this about a year ago, and it made a HUGE difference!).  And, if it doesn't help you, then posting it, along with your VI, will lead to much better and targetted suggestions from us.


Bob Schor

0 Kudos
Message 5 of 5