LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop

Solved!
Go to solution

Hi,

 

I was trying to improve an old program. I have attached two VIs (A1 and A2) and their respective output file (a1 and a2).

A1: The program infinitely runs a while loop till it is stopped by the user, recording the energy of laser pulse every one-tenth of a second. The program runs as expected and creates an output file with xdata and ydata.

A2: Similar to A1 except that I used a linear stage motor. The motor was programmed to move from HOME position to eight centimeters while recording the laser pulse energy during stage movement. The movement itself takes sufficient time to record around 830 data points. But the while loop runs only twice providing only 2 data points. I could not find the error. Kindly help me sort out the error. Thank you.

Used: Labview 2020 community version; Energy ratio meter via GPIB, Linear stage motor via Serial port

Pradeep.

Download All
0 Kudos
Message 1 of 4
(182 Views)

The actual move may take some time but your middle while loop will execute much faster than the actual motion itself. In order to take all of your measurements you need to determine when the move is complete. Ideally, you should be reading the laser data in a separate loop/state machine. Your main control loop would send start/stop measuring commands to it. The control loop would send the move command to the motor and then have to continually check to see when the motion is complete. It would be great if the motor could simply send you a message saying the motion is complete or provide a digital output to indicate when the motor is in motion or not. Either way, you need to continue to read the laser while the motion is in progress.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 4
(156 Views)

Hello Mark Yedinak,

 

Thank you for your reply.

 

If I have to use two while loops in the center sequence stack, one for the laser reading and the other for the motor control, then I might need to stop the 'laser loop' when the 'control loop' exits. How can I achieve two while loops to start/stop simultaneously yet independently?

 

I was under the impression that I can fetch whatever the code that was last generated at the motor output. But the VISA read function wait for the next generated code. So the loop exceeds the loop wait time and therefore only two data points are recorded, one synchronizing with the successful reception of the write command and the other synchronizing with the successful execution of the write command.

 

Pradeep.

0 Kudos
Message 3 of 4
(112 Views)
Solution
Accepted by topic author pclab

Hi,

 

Things worked! I learnt about channel wiring among while loops.

 

Pradeep.

0 Kudos
Message 4 of 4
(70 Views)