10-05-2017 09:43 AM
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 ?
Solved! Go to Solution.
10-05-2017 03:35 PM
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 --
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
10-05-2017 03:45 PM
10-05-2017 04:01 PM
Use Ctrl + U
Its not quite as ugly as your wiring. (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.
10-05-2017 04:06 PM
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.
10-05-2017 04:40 PM
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.