LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute two loops alternately

Solved!
Go to solution

Hello,

 

I want to execute a loop in 1 second then a second loop for 1 second and that's repeated before pressing the button stops. if you can give me some examples it will be better.

0 Kudos
Message 1 of 13
(3,356 Views)

Can you give us more detail on what you are trying to accomplish?

0 Kudos
Message 2 of 13
(3,349 Views)

 I want to read and save in tdms file the analog input A0 for 1 second and the analog input A1 for 1 second in daq 6008, but not simultaneously. and that's repeated before pressing the button stops

0 Kudos
Message 3 of 13
(3,338 Views)
Solution
Accepted by topic author anouardz

Something like this?

 

Execute_Two_Loops_Alternatively.png

 

This is the best I can do without more information.



Message 4 of 13
(3,336 Views)

this 3 loops, are they a while loops?

0 Kudos
Message 5 of 13
(3,329 Views)

What you need is a state machine that execute state A then state B until the stop button is pressed.

 

Ben64

Message 6 of 13
(3,315 Views)

yes, but not simultaneously

0 Kudos
Message 7 of 13
(3,306 Views)

yes, but not simultaneously

0 Kudos
Message 8 of 13
(3,305 Views)
I think it would be simpler to just acquire both channels and alternatively write to your separate files. You need to stop and clear each task before starting another.
0 Kudos
Message 9 of 13
(3,291 Views)

@anouardz wrote:

yes, but not simultaneously


You should always quote the previous post, because it is not clear what you are replying to.

 

A state machine is the correct architecture, only one loop needed. Simply switch states every desired time interval.

 

Don't gum up the gears with loops inside loops, etc. It makes the code hard to manage and hard to add functionality later and hard to branch out in case of problems or exceptions.

0 Kudos
Message 10 of 13
(3,282 Views)