06-11-2012 01:36 PM
Dear all
I'm a new Labview user. I'm trying to build a VI that syncronizes the DAQ acquisition of voltage from one or more channels to the acquisition (IMAQ) of a video AVI (including a bayer encoding process), recorderd by a digital camera.
I have built this VI that I attach.
The problem that I currently have is that I am able to get a video and a signal, but the duration of the video is always different from that of the signal, as far as I can read from the time vector in the LVM file.
Could you please tell me how I can fix this problem?
Perhaps this question might seem easy to you, but. being a new user, I do not know very well how to operate Labview in the more efficent way.
Thank you all for your time.
Emanuele
Solved! Go to Solution.
06-11-2012 04:23 PM
Without running the code, I'm going to take a stab.
When you set up the AVI, you tell it the FPS. So each successive frame will assume that it was gathered at the correct FPS.
You used the Wait (ms) which will wait that number of ms when it executes. This does not mean that each while loop iteration will be exactly that long. Doing image processing takes time, so at 30Hz, your time between loops will actually be 33ms+processing time. Since the AVI thinks each frame is exactly 33ms, you have a discrepancy.
Now, when you aquire from the DAQ, I believe it has a current time stamp. It will always have the correct time.
To avoid this, used the timed while loop structure. This will make sure that each iteration is at least the length required regardless of processing time. If you're still having problems, you may need a producer/consumer structure (hopefully not).
06-11-2012 04:35 PM
Dear JW,
thank you very uch for your answer.
Just for the record I acquire at no more than 10-20 frame per seconds and the DAQ sample frequency is about 20-50 Hz... I don't know whether I have to pay attention to the N samples i.e the buffer size, required in the DAQ assistant, in which I set the mode Continuous Sample.
tomorrow I will try to modify the program following your advice (I don't where you're from, but I live in Europe and it's almost 11pm).
So do you think it's fine to insert the DAQ assistant in the same loop as the IMAQ acquire+processing process?
I was also considering building two loops ant try to syncronize them, perhaps it's too difficult... please let me know what you think about it.
Thank you again
Emanuele
06-12-2012 05:08 AM
Another question: when I create the timed loop, how do I estabilish the timing also considering the processing time?
06-12-2012 05:48 AM
after creating a timed loop structure instead of the while loop, setting as the dt time the frame rate that in ms equalt to the frame ret set in the avi create box,I see that I record DAQ signals of duration which is not exatct and also the video seems to be accelerated or slowed down according to the sample rate I set.
Probably I have to adjust the timing properly, but I don't know I can do it... Please help me.
I attach the modified program
Emanuele
06-12-2012 06:38 AM
If both tasks (Video and DAQ) are independant, you could create a seconde loop for that, you don't have to, but at least you wouldn't have to worry about one task messing up with the other one.
Also, you've done a good job for the video acquisition without express VI, why don't you do the same for DAQ?
Start from the examples that ship with LabVIEW and use DAQmx functions, you'll be able to have much more control & flexibility than with Express VIs.
If your DAQ needs is just acquiring 1 or N analog signal between 20 and 50 Hz, it won't be too complicated!
good luck!
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
06-12-2012 08:09 AM
Dear CLD,
the video and daq are not independent in the sense that I would like to start and stop video and data acquisition at the same time. The sample frequency may be different, but they must be syncronized and therefore the length of the video and of the signal must be the same (or quite close, because of the different sample rates). In case I build two loops, do you have any suggestion on how I can link them toegether in this sense? Still, I think you haven't told me how to set the TIMING.
As for the second question of yours, I used the DAQ Express VI because if I put just the DAQ assistant and the Wite To Measurement Express in an isolated loop, then the code does the exact job I need, which is acquiring a continuous signal and logging data to a LVM file.
Please let me know how I can set the TIMING and possibily relate the two loops, if you think this might be better to split the loop I built.
Thank you again for your time.
Emanuele
06-13-2012 09:05 AM
If I create two loops, does anyone know how to make them start together?
Please let me know, I am little bit desperate....
06-13-2012 09:24 AM
@Emanuele_S wrote:
If I create two loops, does anyone know how to make them start together?
Please let me know, I am little bit desperate....
Just run the error wire down to the second while loop. Make sure you do this after all of the IMAQ setup like this:
Because of data flow, the second while loop will wait until the IMAQ setup is done to start exectution. This will cause them to start at the same time
06-13-2012 11:04 AM
Thank you very much, I am modifying the program, but I do not understand how you linked together the two error wires, I don't find the box you put just before the other box "error out", please let me know hat it is and what is used for.
Thank you very much alos four your patience.
Emanuele