LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with for loop and timing

Hello,
 
I have to make a program that should the following:
 
the users gives the number of cycles.
every cycle consists of three steps:
step 1: let a motor run for 5 seconds
step 2: acquire data for 1 second and calculate the mean
step 3: ask the user input and write the data to an arry
 
if these steps have been executed the data has to be fitted.
 
My problem is with the loop.
 
I tried to make this with a for loop and Elapsed time in combination with cases.
I get two possible results.
 
In the first cycle the three steps are executed and in the following cycles only the last step is executed. This problem I had resolved with the reset function but the I get the following problem:
Every step is executed but the loop doesn't stop after the desired number of cycles, I keeps executing the first cycle.
 
I think I have started with a wrong design method but I can't find a better way to do this.
 
 

 

0 Kudos
Message 1 of 5
(2,871 Views)
Would like to help you, but could not really understand what exactly you want
 
can you be a bit more clearer??
0 Kudos
Message 2 of 5
(2,860 Views)

You should easily be able to do this with a state machine architecture.

States:

initialize

run motor

acquire data

user input

more points?

done

error

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 5
(2,852 Views)

I will try to explain it better.

I have to make a program to 'calibrate' an instrument.

On the main VI the user is asked how many measerments he wants.
Let say he wants to have 8 measurements.

When the user clicks on the OK button, the motor has to run for 5 seconds.
After the five seconds, the motor stops and the DAQ has to acquire data from the sensor and calcutate the mean.
If that is done the user recieves a pop-up window with the question to fill in the value of fysical dimension (displacement, force,...)
The data from the sensor and the user has to be inserted into an array.

If the user has filled in the value and clicked on OK, the next cycle should start (5 seconds motor turning, 1 second data acquisition and finally the user input) and this 8 times in total

If all the measuremenst have been made, the data has to be processed.

The subVI's for the motor, DAQ and user input are already made and work.

The problem is that I have problems making the loop.

At first I recieved an endless loop with the user input
I have managed to let the first cycles execute (motor, daq and user input) and the following cycles only the user input was executed.

I hope this gives a better image about the situation

0 Kudos
Message 4 of 5
(2,851 Views)

Thanks falkpl

I think that it will work with the standard state machine.

0 Kudos
Message 5 of 5
(2,826 Views)