LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start VI's Simultaneously

Hi all, I'm writing a program that requires two vi's to start exactly at the same time. I need the motor to rotate 360 degrees/sec and to simultaneously acquire data for that one sec. My motor setting is set to rotate for exactly 1 second and so is my exposure time. But I can't seem to get the vi's to start simultaneously. I tried searching for this topic and there were a few posts in the past but they don't seem to help. I've attached picture file that shows a section of my code, I need the "Write/Read" vi to start exactly the same time as the "Start Acquisition" vi. In this picture I tried placing a time delay between the two vi's but it doesn't seems to work (for any time delay, msec or otherwise). Any suggestions?

0 Kudos
Message 1 of 10
(2,983 Views)

You need to understand the concept of dataflow.

Your two vi's will never start togetther because they are not in parallel.

You have a delay in series between the READ/WRITE and the StartAcquisition.

0 Kudos
Message 2 of 10
(2,977 Views)

@JinKazama wrote:

Hi all, I'm writing a program that requires two vi's to start exactly at the same time. I need the motor to rotate 360 degrees/sec and to simultaneously acquire data for that one sec. My motor setting is set to rotate for exactly 1 second and so is my exposure time. But I can't seem to get the vi's to start simultaneously. I tried searching for this topic and there were a few posts in the past but they don't seem to help. I've attached picture file that shows a section of my code, I need the "Write/Read" vi to start exactly the same time as the "Start Acquisition" vi. In this picture I tried placing a time delay between the two vi's but it doesn't seems to work (for any time delay, msec or otherwise). Any suggestions?


did you look in the examples? you can start 2 task at the same time using the same clock....

 

\examples\DAQmx\Synchronization\Analog Input - Synchronization.vi

0 Kudos
Message 3 of 10
(2,971 Views)

I tried to modify your image properly, but I noticed that the delays do not make sense...

Plus, you need to merge the errors before exiting the sequence frame.

 

As a matter of fact, it looks like you have wires (and potentially other objects) hidden behind the sequence structure.

That's an indication that there are more "issues" elsewhere in the code..

 

Why do you have a Delay -AND- an Image time (Wait unitl next ms) delay?  You should not need both... well.. you might, but not if you want the two vi's to run simultaneously...

 

Anyway, here is the slightly modified image...

 

 

 

 

 

 

 

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

0 Kudos
Message 4 of 10
(2,963 Views)

@JinKazama wrote:

Hi all, I'm writing a program that requires two vi's to start exactly at the same time. I need the motor to rotate 360 degrees/sec and to simultaneously acquire data for that one sec. My motor setting is set to rotate for exactly 1 second and so is my exposure time. But I can't seem to get the vi's to start simultaneously. I tried searching for this topic and there were a few posts in the past but they don't seem to help. I've attached picture file that shows a section of my code, I need the "Write/Read" vi to start exactly the same time as the "Start Acquisition" vi. In this picture I tried placing a time delay between the two vi's but it doesn't seems to work (for any time delay, msec or otherwise). Any suggestions?


As has been said, your data flow is keeping them from running at the same time.  At currently written, your Write/Read has to complete before the delay can even start.  Then after the delay will the Start Acq run.

 

How are you writing to the motor?  If using an analog or digital output, you can synchronize your output and input DAQmx tasks.

 

The next question is how exactly at the same time do you need?  Can the acquisition start a little before the write/read?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 10
(2,954 Views)

Thanks for the quick replies...

 

apok: I will definitely look at that

 

Ray.R:

 

1. I tried your suggestion I get the same result.

 

2. Sorry for the messy vi, this is just a test vi but in regards to the wires in the back. What you are seeing is the sequence structure, which is in a case structure, which is in a while loop. There is nothing at the back of the sequence loop just a staright wire to the other end (in another case the wires are used, just not in this case. This particular case is just to rotate and acquire data)

 

3. The image time: I have that so the sequence will pause to allow for the motor to rotate for a second and for the acquision to complete. Had I not place that the motor will not complete it's full 360 Degrees and assuming I get the acquisition to start at the same time, that 1 second (image time) will allow for it to complete. So it's necessary. The Delay was used to allow the motor to delay until the acquistion vi to start, then when both starts, image time comes into play to allow both to complete it's job.

 

crossrulz:

The motor is writing digitally

I would like both to start at exactly the same time. But maybe the aquisition could be delayed for .01 sec then the motor starts. (Write/Read with a command of "A", starts the motor)

0 Kudos
Message 6 of 10
(2,937 Views)

#2 Correction - sequence structure NOT sequence loop

 

crossrulz:

The motor is WRITTEN digitally

 

Sorry no coffe today!!!!

0 Kudos
Message 7 of 10
(2,932 Views)

JinKazama wrote:

3. The image time: I have that so the sequence will pause to allow for the motor to rotate for a second and for the acquision to complete. Had I not place that the motor will not complete it's full 360 Degrees and assuming I get the acquisition to start at the same time, that 1 second (image time) will allow for it to complete. So it's necessary. The Delay was used to allow the motor to delay until the acquistion vi to start, then when both starts, image time comes into play to allow both to complete it's job.

 


This is probably the culprit..

 

The wait until next ms is not placing a delay until the motor finishes the rotation..  You need to read the context help for that function to understand what it does... but in this case it will surely not do what you expected..  I think it is best that I simply quote what the context help says...

 

 

Waits until the value of the millisecond timer becomes a multiple of the specified millisecond multiple. Use this function to synchronize activities. You can call this function in a loop to control the loop execution rate. However, it is possible that the first loop period might be short. Wiring a value of 0 to the milliseconds multiple input forces the current thread to yield control of the CPU.

This function makes asynchronous system calls, but the nodes themselves function synchronously. Therefore, it does not complete execution until the specified time has elapsed.

 

Wait Until Next ms Multiple Details

When LabVIEW calls a VI for example, if millisecond multiple is 10 ms and millisecond timer value is 112 ms, the VI waits 8 more milliseconds until the millisecond timer value is 120 ms, a multiple of 10.

 

 

 

 

 

0 Kudos
Message 8 of 10
(2,928 Views)

Ray.R, although that makes sense, it still does not work like it should.

0 Kudos
Message 9 of 10
(2,895 Views)

Can you attach your code?

0 Kudos
Message 10 of 10
(2,880 Views)