LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to end a while loop to transition a camera from viewing images to taking photos

Hi Everyone,

 

I am controlling a motor and a camera at the same time. In the first frame, I wanted the camera to view what is going on until the motor finishes executing its last command in the visa write "S G". In the second frame, the camera will save the images. 

 

If there is a better way, I am open to changing my code. Sorry this is a simplified version of my code so it is not very usable especially since the visa write is calling my specific hardware.

 

1. How do I make the camera stop viewing in the first frame? I am not sure how to make a stopping condition.

Kwan90_0-1580243709627.png

0 Kudos
Message 1 of 4
(2,835 Views)

Use a state machine.

0 Kudos
Message 2 of 4
(2,817 Views)

As altenbach suggested, you should read about (and then probably use) a State Machine. Another possibility might be a Queued Message Handler (QMH) or similar (you can find many posts with Google etc).

 

Since it appears that you know the duration of your "Motor Run Time", you might want to use a flow somewhat like the following:

  1. Setup camera and motor devices
  2. Start the motor, take the current time value
  3. Take an image
  4. Check the current time. If less than start+run time, then go to 3. If not, go to 5.
  5. Stop the motor + camera (you could split this to two steps if the order is important and they are not at the same time).
  6. Go to viewing of images
  7. Optionally restart the process and repeat, or shutdown the camera and motor connections (could swap this and 6 if you wanted, and know you won't repeat the process without restarting the VI).

That's just a quick suggestion, but it might give you some ideas.


GCentral
0 Kudos
Message 3 of 4
(2,771 Views)

This is fairly simple to do with a State-Machine-like architecture (I use a variant of the QMH that uses Messenger Channels).  You only need to know if you are starting a new Video, continuing an existing Video, transitioning out of saving a Video (such as closing the AVI file), or "doing nothing but displaying".  I actually have two such CMH's (Channel message Handler) running in parallel -- one handles acquiring images and displaying them, the other handles creating the Video, including all of the file handling.

 

Bob Schor  

0 Kudos
Message 4 of 4
(2,319 Views)