From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data parsing, cRio and PC

I have a cRio 9073 connected to a data source on its serial port, passing it to a PC. The issue I am running into is that the data ‘stutters’ (see test.txt).

 

Could it be that the data is being buffered in the shared variable? 

 

Is there a way to make a loop run only once per activation?  What I have been trying to generate is a loop that runs only once, but can be reused.

Download All
0 Kudos
Message 1 of 9
(2,896 Views)
Hello rbergs,

I think you should take a look at our Developer Zone article Using the LabVIEW Shared Variable. The section about half way down titled Network-Published Shared Variables and LabVIEW Real-Time. This section will describes a couple of options you can have. You could use the timestamp output of the variables to compare with previous iterations or you could use the built in RT FIFO function.

Let me know if this helps.
Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 2 of 9
(2,873 Views)
I'll give it a shot and let you know.  The info speaks specifically about LV 8.5, but I would assume this would work under 8.6, correct?  The cRio is only 8.6 compatible.  I am not sure if time stampng the variable will help, since it seems to be writing the same variable multiple times because the 'syncing' variable is true for too long.  What I have been trying to do is make it so the data writing loop runs once per activation, however I have been unsuccessful.  The data rate and transfering works fine, I just need to make sure it writes one data 'point' per activation.
0 Kudos
Message 3 of 9
(2,867 Views)

It should work pretty much the same in 8.6.

 

Also, I was looking at where you had the write to spreadsheet file.  When a new value is written to a variable the timestamp is updated.  You could do a comparison between the current timestamp value and the timestamp value from the previous iteration.  If they are the same, a new value has not been written to the variable.  If they are different, a new value has been written to the variable.  By using this logic before the write to spreadsheet file you can determine whether or not to write a new value to your spreadsheet.

Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 4 of 9
(2,864 Views)

I am confused.  Say the shared variable leaves the cRio with 'A' as the time stamp.  The PC reads the data, time stamped 'A', writes the file, but runs the loop again, with the data still time stamped 'A'.  Is the time stamp 'stamped' by the cRio or the PC?  If by the cRio, the PC will not see a change.

 

I have tried comparing the data with a PC local variable to see if they are the same.  If so, I would not write.  LV would not let me do this because of it being a 2d array.  Is there a command that I should use?

 

The program works in that I am able to get the data.  The issue is that the 'true' I send to record stays on too long and the loop runs again.  What I need is a loop that will run once and only once, but I can reuse.  I am thinking a for loop, but I need to reset the counter.  In a text based programming language I could make this work, but I am not sure how to do it in Labview.

0 Kudos
Message 5 of 9
(2,854 Views)

I have tinkered in LV with just two vi's (leaving the cRio out of the equation) and have been able to find a way that seems to make this work.  I am comparing the string sent to the string I wrote, if they are not equal and I have the command to write, it writes.  On the computer this works, and I'll find out tomorrow if it works with the cRio.

 

Since I will have a vi running on the PC as well as the cRio, is there a way to have one of the vi's start the other? I can cause one to wait for a signal from the other, and send a stop command.  What I am wondering is if there is something equivalent to clicking the 'run button'.  

0 Kudos
Message 6 of 9
(2,837 Views)
The easiest way to start one VI from another is through VI Server. Also this KnowledgeBase gives you a couple of options for starting a Real-Time executable.

What you are doing with comparing strings is about the same thing I mentioned with timestamps. When you WRITE to a shared variable the timestamp is updated. When you read from it you can compare the timestamp with the previous iterations timestamp. If they are different, then you should write the value to the spreadsheet file. Also, the easiest way to stop two VI's running in parallel on different targets is through shared variables.

Take a look at the attached image.
Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 7 of 9
(2,825 Views)

What I came up with is pretty close to what you have.  I was able to compare the string to the string I recorded.  If they are not equal, then it records.

 

This works, but is a little convoluted.

 

Is there a way to nest the PC program in the cRio's so all I need to do is hit run once?

0 Kudos
Message 8 of 9
(2,816 Views)

Yes.  You can use VI server to programmatically start another VI, even if it is on another system.  Take a look at the image I have attached (This code should be on your RT target).  Also, make sure that you have enabled VI Server on both the host and the RT target.  Also you need to make sure that you have added access for each device to talk to one another.  Take a look at this KnowledgeBase for more information on VI server.

Message Edited by Jon S. on 04-22-2009 12:08 PM
Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 9 of 9
(2,814 Views)