04-15-2013 09:05 AM
Hi,
I'm trying to control the movement of a piezo transducer and the acquisition of images from a camera with exact timing. Firstly, I'm trying to drive the piezo in a sinusoidal manner at a frequency, f. Secondly, I want to acquire images with my camera at a frequency of 2*f. i.e. I want to acquire when my piezo voltage is at the maximum and minimum values.
I'm relatively new to LabVIEW but I have figured out how to control my piezo and acquire images independently. However, I'm running into problems with timing when I try to do the two things in unison.
At the moment, I'm using a loop and the 'Simulate Signal' function to generate my voltage output to my piezo. I then have a second loop in parallel to drive my camera acquisition. I've gone to a bit of effort to make sure that the two loops start executing at the same time using 'Rendezvous'. I have my current VI attached. It kind-of works but I'm sure there's a better and simpler way of doing it. If one of the loops runs slightly off-time for some reason, the loops will fall out of sync after many iterations. Would I be right in saying that I'm going about the process the wrong way in not using just one loop? I've thought about this but I don't know how to implement it? If I put the image acqusition loop into the piezo loop, won't the process of acquiring an image knock out the timing of my piezo?
If anyone could offer any advice it would be great!
Thanks in advance,
Paul
Solved! Go to Solution.
04-16-2013 07:20 AM
Hi PaulNap,
Thanks for attaching your code along with your query!
Looking at what you want to achieve I think using two parallel loops is a good call. It means you can seperate the execution of the signal generation and the timing of the camera.
Of course, what you really want is to achieve some kind of co-ordination between the loops, such that the camera acquisition loop only runs when the signal generation loop generates a peak value.
I've written and attached a simple bit of code that illustrates this idea. I am using notifiers to co-ordinate the loops. The top loop only writes a value into the notifier when it generates a peak value. Since the bottom loop is waiting on the notifier, it will only ever run once the top loop has written a value into the notifier. In this way, the bottom loop will only ever run when the top loop generates a peak value.
Please let me know if you have any questions about this.
Kind regards,
04-16-2013 07:24 AM
Hi Josh,
Thanks a million for the reply. Unfortunately, I have an old version (2010) and cannon open your vi. Could you post a screen shot maybe?
Thanks,
Paul
04-16-2013 07:28 AM
Hi Paul,
Here's my attachment in LabVIEW 2010.
Kind regards,
04-16-2013 08:22 AM
I'm glad I was able to help!
Good luck with your application.
04-16-2013 08:24 AM
Josh,
That's exactly what I was looking for. I'm implementing it right now.I don't see any reason why it shouldn't work.
Thanks again,
Paul