LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Syncing the start of N-Sample/N-Frame captures via Express VIs?

Hello wonderful folks in NI LV Land!

 

I'm running into a bit of a challenge with syncing. After a week of looking at examples, reading manuals, and trying to work through this myself, I'm not yet collapsing on a solution path. And here we are! Maybe someone here has a great insight that can get me moving again?

 

What am I trying to accomplish? (for context)

I work at a fitness center and have been building an application to run a force plate. When people jump on the force plate, the application outputs force and hang time and jump height and other [interesting] data points. The personal trainers then use this information to help with training programs. Force plate waveforms from a jump (countermovement jump) can sometimes be confusing to the new eye - I thought it would be useful to implement a video capture with the jump. I purchased IMAQdx and a Basler camera and got started. 

 

What have I tried?

Initially I was way overthinking it - trying to start DAQmx captures, writing chunks of data to an array while running frame by frame captures in For Loops... but ran into challenges with the Data side b/c I needed very specific capture rates and also needed multiple channels with some Voltage to Force conversions done on them. I looked at every example I could find online - learned little bits here and there, but my use case required more. It was getting very complicated. I did find several solutions with the full blown Vision package, but don't have funds to purchase that - so I've been working with what I have to make it happen.

 

I took a step back and realized that I really just need a "pretty close" match (for instructional purposes only) of a side by side 5 second 120 frames per second AVI and a 5 second capture @5k samples/sec. It didn't need to be anything fancy - so I went back to simple - no fancy playbacks or other things. Using the DAQ Assitant and the Vision Aquisition Express VIs got me around several of the issues I was previously encountering and it became easy to then tie cursor position of the graph to the frame count on the AVI (via propery nodes). Put in some scaling math and 5 seconds of video is tied to 5 seconds of data capture. See attached for my current prototype (I try to build a functional VI before implementing into my bigger project). Don't mind all the Image Out instances - I've been trying lots of things to see how it impacts the application function. Additionally - in the bigger picture, I plan to make this application into one that will let the user open a data file and an AVI file and scroll/scrub the AVI file with the cursor linked to that motion on the data. I've built a prototype of this, but there is still the problem of needing the two data sources to capture at "nearly" the same time. 

 

BTW - I've only been using Labview for about 8 months on and off, so I'm by no means experienced at any of this - just learning by doing as often as I can. And this work is being done in Labview 14 on a PXI chasis. 

 

Current Challenge...

When I run this current prototype VI, the DAQ and Vision VIs start at different times. Scrubbing the capture shows a delay of about 3/4 sec with the AVI being the lagger. I've looked into many syncing options/ forum posts, and examples such as Rendezvous with SubVIs.vi - with no luck. I've considered putting in a delay to offset the time delta, but that feels wrong to me. I've considered allowing the user to find a "tare" position and lock the two from that point (not the best experience)... so now I'm wondering if it's a Labview thing - a limitation of Express VIs - but I'm probably just doing something wrong. Hear me out: The "N-Sample" DAQ Assitant data can execute without a loop and the Express VI just outputs the 5 second data capture from all the channels I want (and I can run some math between the output and graph if needed) --- BUT the Vision Aquisition needs a For Loop with the frame count of an "N-Sample" capture. When I Highlight Execution - the Vision Aquisition is still capturing after the DAQ assitant has finished, which confirms what I'm seeing on the Front Panel with the Image Output lagging the Graph by about 3/4 sec. I'm unfamiliar with and could not find information (maybe I'm not using the correct terminology) on how to sync things that are happening inside and outside of loops - such that they start at the roughly the same time (within ~50ms?) and capture roughly the same 5 second event (the person jumping).

 

Any ideas? Thoughts? Things I could read or try Examples I may be missing? In my gut this seems like it should be simple, but that probably inexperience talking.

 

Thank you in advance,

Brandon

0 Kudos
Message 1 of 4
(3,001 Views)

DOh.

 

Just realized I put in the wrong image. Updated here:

 

N_Sample_Express_Sync.jpg

0 Kudos
Message 2 of 4
(2,974 Views)

Hello BLarson04,

 

the Basler acA640-120um has an option for an external trigger. The DAQmx hardware can generate a trigger when starting the acquisition and this starts the camera then both are synchronised with an start trigger. If the camera acquire a picture with every thrigger a DAQmx counter task can be used to generate the needed trigger signals. The counter task can also be synchron started with the acquisition.

best regards
Alexander
0 Kudos
Message 3 of 4
(2,955 Views)

This is definitely "very do-able".  About five years ago, I was involved in an animal behavioral study where we were interested in capturing behavior events triggered by an external signal (in our case, it was a change in the weight registered by a Mettler balance -- you would use a change in force measured by your Force Platform).  We wanted to capture videos from, say, 2 seconds before the Event to five seconds after.  The other "gotcha" is that the study lasted several hours (Events occurred 5-20 times/hour) and, largely because doing one animal at a time was not "human-labor efficient", our Experiments used 24 stations, with 24 cameras and 24 balances, recording videos at 30fps.  If we could pull this off with LabVIEW 2010, Windows XP (later Win 7), and older technology, you can certainly do it with the current hardware and software.

 

In our case, we didn't try to synchronize the video with the Event.  What we did was set up the camera(s) with fairly large buffers (certainly large enough to hold all of the "pre-event" frames) and just start it running.  We basically used the Event to "mark" the buffer that was recorded when the Event fired (at 30 fps, this means that we have a time "uncertainty" of ±16 msec).  So when the Event is fired, we start a loop that grabs all of the "Pre-Event" frames and saves them as the first part of our Video, appending the "Event" frame and sufficient Post-Event frames to complete our video.  So if we assume that we were on Frame 1000 when the Event fired, we'd save the images from Frames 940-999 (the "Pre-Event" frames) and then Frames 1000-150 (the Event + Post-Event frames).

 

The advantage of this "sloppy Synchronization" method is that it allows us to look "backwards in time" without needing to "predict the future", but to just let the camera record at its own rate and simply "tag" a frame as "Time 0", using the Frame interval as the "tick" of our clock, but allowing the Clock to run asynchronously with the "trigger".  This means that the Trigger doesn't need to interact with the video hardware at all -- we do it all in software.  If this model works for you, then our experience can serve as a "Proof of Concept" that this is, indeed, possible.

 

Bob Schor

 

P.S. -- I just re-read your title.  You should probably not use Express VIs anywhere in this project (except, perhaps, for the Elapsed Time EVI).  Certainly do NOT use the Dreaded DAQ Assistant, nor its Evil Twin, the Dynamic Data Wire ...  To pull this off, you need to be in control.

 

P.P.S. -- if you are going to post Code, then post "Code we can Use", i.e. attach either a VI, a compressed folder representing the entire Project (i.e. a Zip file), or create a LabVIEW Snippet.

0 Kudos
Message 4 of 4
(2,937 Views)