LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cRIO two channel acuisiiton with pre trigger data

I would like to perform the following using a cRIO and a 9205 analog input card (using two channels at this time)

 

1) Main loop just reads/scales/displays the two channels of data at a relatively slow rate (maybe 200 ms update or so).

2) Operator clicks a button to go into a "trigger wait" mode. The system now waits for a positive going edge on channel 1.

3) After the trigger, data is captured from both channels at a faster rate (probably 10KHZ) for about 1 second or so.

4) This triggered data should include about 200ms-500ms of pre-trigger data.

5) Graph the two channels, send the data to an excel spreadsheet. (If spreadsheet is already open, add to existing spreadsheet.

 6) Go back to Main loop ..

 

I am using a cRIO for reasons which I won't get in to. (yes it's overkill but I'll need it later).

 

I was thinking of setting up a DMA FIFO of xx size and having that always run with timeout of 0. My thought was that it would always have data in the buffer.

 

I'm just looking for advice on where to put what sections of the code. What (if any) should go in the FPGA? What should to in the RT controller? If I want to export to Excel, I need something running on a PC.

Also, what's the best way to set up an array of acquired data that will trigger and fill the array, but also include some pre-trigger data.

 

Hoping to get some ideas to get me started, not necessarily needing actual code samples.

 

Thanks!

Jeff

0 Kudos
Message 1 of 3
(2,841 Views)

Hi,

 

It sounds like a fun application. There are many ways to do it, and you will probably find a few good methods. My suggestion would to first make sure you do your aquasition on the fpga, and any processing and scaling on the real time controller. Sometimes, this isnt a clear cut division, but when possible, try to adhear to it. It will make for a cleaner application. The exception to this is when you need inputs to directly control your outputs. Then you want your control algorythm to be housed in the FPGA.

 

In this specific situation, I would suggest a single loop in the FPGA with an internal case structure controlled by a boolean front panel control. The two cases would represent your two modes of operation. One for your slow rate aquazition, and the other for your fast rate read. Manipulating the control will change the loop rates among other things. You can use just one fifo for both cases, in order to simplify operation.

 

In your trigger wait mode, you can spcify the higher loop rate, as well as monitor for your rising edge. But while your monitoring, you can continue to transfer samples up to the RT VI. Then, when you recieve the required trigger, you can transfer a special value into the fifo, somthing impossible to recieve from the 9205, as a flag denoting where in the sample stream the trigger occoured. You can then continue to loop.

 

In the real time side, you can manipulate the mode control based on user input. If your in trigger wait mode, you can take the samples input and place them in an array, and begin overwriting the array when 200ms-500ms of pretrigger data has been met (you may even consider using a modified RT FIFO for this.) All the while, monitoring for the flag sample. When you recieve it, you can discard it, and then start storing the data in your array and the incoming samples to the array, or to disk.

 

And finally, keep in mind you can save data to a spreadsheet stored on the cRIOs disk. Then later FTP into the controller and retrieve the file. You may also consider programmatically sending the file at a certain time. If you want somthing viewable as it is recorded. I would suggest using Shared Variables to transfer data back to a VI on your PC and then sending it to Excel.

 

Hope this gets you started.
Asa Kirby
CompactRIO Product Marketing Manager
________________
Sail Fast!
0 Kudos
Message 2 of 3
(2,813 Views)

This is exactaly what I need to do also, I have a C-rio and using the 9205 to record and watch for a trigger line.  I need to capture about 5 seconds of pretrigger data and then record some set amoutn of time after the trigger.  My recording rates will chage between 1kHz to 5kHz.  I am new to programming so if you have some code that you could share on how you did this that would be very helpful

 

Thanks 

0 Kudos
Message 3 of 3
(2,684 Views)