LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Log data before a Trigger Condition

Solved!
Go to solution

I need help with my VI, I currently use producer consumer loop and dequeue element to log my data from my daq device,after a trigger function has been pressed on the front panel (Boolean) I need to log 5 seconds of pre data that has been acquired after this trigger. I have been reading and saw that this can be done with lossy Enqueue? I need help with adding a buffer so the user can set how much pre data they want to save. How can I add this to my while loop ?

LabVIEW Developer / Sr Engineer
0 Kudos
Message 1 of 6
(2,998 Views)
Solution
Accepted by topic author Maestro_Sanchez

Well, you see this function in your Producer queue ... oops, I just realized you didn't post your code, so it isn't easy to tell you how to fix it.

 

You state that you want to save data 5 seconds of pre-data after the trigger function has been pressed.  This is a little confusing -- I think you mean that you want to log five seconds of the data that was coming in before the trigger function (I presume this is an "Acquire" Boolean control, right?) is pressed.  You say nothing about how much data you want to take after the trigger ...

 

There are several ways to do this.  Here's a verbal description --

  • Consider a State Machine with three States -- Waiting for Trigger, Got Trigger, Acquire. 
    • Waiting for Trigger saves data in a circular buffer of depth 5 seconds (a Lossy Queue is a good model for this.
    • Got Trigger is called when Trigger is pressed, and dumps the Lossy Queue into the P/C Queue, then switches to Acquire.
    • Acquire takes points and puts them on P/C Queue, staying in this State until the "Finish Acquire" condition is met, when it goes back to Waiting for Trigger.

 Hmm -- that pretty much sums it up.  Implement that and you should be Good to Go.  Since you are learning LabVIEW, I'm not going to "post the solution", as you'll learn much more if you "try it yourself".  If you have a specific question, post it along with some code and help will (probably) be provided.

 

Bob Schor

Message 2 of 6
(2,955 Views)

Code.png

LabVIEW Developer / Sr Engineer
0 Kudos
Message 3 of 6
(2,952 Views)

Use Ctrl + U

Its not quite as ugly as your wiring. Smiley Wink (Work on that OK?)

 

The trouble is you've shown a picture on an implementation of your logger without the logger.  And, then you said "dac device"  What is this unnamed daq device?  Many DAQmx devices can use Start Triggers with Pre Trigger samples.  Likely that would be a better way to go since it uses the hardware buffer to store pre-triggers rather than a "Lossy Queue" that uses memory.


"Should be" isn't "Is" -Jay
Message 4 of 6
(2,944 Views)

Take a look at the meet of Bob's post (granted he's a bit...rough, but not wrong 🙂 )


@Bob_Schor wrote:

 


There are several ways to do this.  Here's a verbal description --

  • Consider a State Machine with three States -- Waiting for Trigger, Got Trigger, Acquire. 
    • Waiting for Trigger saves data in a circular buffer of depth 5 seconds (a Lossy Queue is a good model for this.
    • Got Trigger is called when Trigger is pressed, and dumps the Lossy Queue into the P/C Queue, then switches to Acquire.
    • Acquire takes points and puts them on P/C Queue, staying in this State until the "Finish Acquire" condition is met, when it goes back to Waiting for Trigger. 

You can look here for a description of state machines in general and here for an example that is close to what you're looking for.

Message 5 of 6
(2,941 Views)

thanks for all the help, I feel in a better position than before. I also appreciate the ctrl-u Tip. I am still learning on a daily basis and get stuck from time to time.

LabVIEW Developer / Sr Engineer
0 Kudos
Message 6 of 6
(2,929 Views)