11-01-2013 01:33 PM
Loaded my shiny new LV13 with RT module and will be running RT code on a stand alone PXI 8186 inside a 1042 chassis.
I plan to implement control and status communication through a LV windows host computer passing values over TCP/IP directly connected.
Starting with the example from page 14 of the NI example NI's RT example I have been successful running this example (two RT concurrent tasks (low and high priorty), while passing values back to the host computer VI to be plotted (all from the NI example).
The functionality I want:
I will have the high priority task sequence D/A outputs, as read from a file, with a resolution of 1msec in a timed loop with loops varying from 5msecs to 10's of seconds.
As a secondary function (lower priority) I intend to collect data in the RT module (at about 50 samples/sec X 8 = 400 samp/sec) and then push it back to the host during waits in the high priority tasking (D/A sequencing).
I intend for collected data to buffer in memory (if necessary) on the RT platform as it streams to the host to be stored on the hard drive.
My problem:
The host code, as it is now, writes duplicate values as it is servicing the data stream write because the host loop is faster than the RT data is being generated. Can someone suggest the "proper" way to write back serial data such that writes do NOT occur if there is no new data. I am using network variables to pass the data back to the host and I chose "buffering" as an option but I dont know if that is doing what I expect it to do.
I was going to devise some scheme of buffer flags to control this but there must be a method built in for this functionality that I dont know about.
Thanks for any help or pointers to examples. I'm feeling a pretty steep learning curve as I come up with problems and how to solve them the best way using built in methods.
11-01-2013 04:16 PM
In your shiny new LV 2013, open a New Project, choose Sample Projects, Real-Time, LabVIEW Real-Time Waveform Acquisition and Logging (NI-DAQmx). This uses Network Streams to send the data from the PXI to the PC, and it basically transfers data at the speed it is collected. There are also other "goodies" there, not all of which you might use, such as pretty robust error tracking/logging, use of Shared Variables to send Status information to the Host, etc. I learned a lot adapting (and "abusing") this code, even after All These Years ...
11-04-2013 10:12 AM
I've been deep into that examples for a few days now. One thing that eludes me and that is how to keep track of the network buffer so that I'm not pulling the same data point off when my reading service of the network variable is faster than the what is being written.
It appears that an error is thrown when I read the variable when the buffer is empty and it returns the last value that was there.
It looks like the error is the same for an overflow or an underflow. I would like to handle both situations so that all the data read in my RT loop is accounted for in the host .vi. Seems like that would be a handle on a network variable that would provide buffer utilization. Or maybe a seperate error condition for overflow opposed to a Read that would return the same data point due to no new data being on the stack. Is there an example showing how to implement this?
Thanks for any help.
11-05-2013 07:41 AM
Your example code uses Network Shared Variables. The Sample Project I mentioned uses Network Streams, a different mechanism. Network Shared Variables do have the problem you noted, namely dealing with underflow and overflow. Network Streams are a different mechanism, more like a TCP/IP-based Queue. The Sender "sends", the Receiver "receives", with the capability of blocking (waiting) if there is nothing there to receive. Go look at the example -- if you are not running LabVIEW 2012 or 2013, you can look up Network Streams (though the functionality was improved, and bugs fixed, in the more recent LabVIEW versions).
11-05-2013 04:31 PM
Oh, sorry I thought you just pointed me back to the same example I was using. I spent the whole day today trying things to try and get the network variables to behave.
I'll look at your new example. Sorry for being a dope and assuming you were sending me back to what I had already seen.
11-06-2013 07:11 AM
I dont seem to have exactly what you listed. When I do a create project what I do see available is:
"Labview FPGA Waveform Acquisition and Logging (NI-DAQmx)"
I dont see:
"LabVIEW Real-Time Waveform Acquisition and Logging (NI-DAQmx)".
There is no Real time sub project heading but there are two "real time" projects under "sample projects", (one for FPGA and one for CompactRIO).
Did I not get something loaded when I installed Labview 2013?
11-06-2013 09:55 AM
I did some sleuthing and found an example of streaming real time in a labview sub directory. I was able to load it and run it on my PXI system so...Thanks for your help and now I know where to look for examples that were already on my system.