Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop loop after a number of pulses

I am syncing a camera with a light source. In the attached VI the counter /Dev/Ctr1 controls the syncronization.

 

I want to stop the while loop after the counter task generation, when Ctr1 task is complete. This counter generates a finite number of samples which corresponds to the number of frames I want to be stored in the camera memory.

 

Any suggestions will be appreciated.

0 Kudos
Message 1 of 6
(3,579 Views)

Hi kmargaris,

 

I hope you are well.

 

I have taken a look at your code and want to ask you a few questions:

 

- From what I can see you are sysnchronising two CO Pulse Time tasks with a third CO Pulse Time task.

 

Why are you not able to stop the CO generation currently?

 

If you could go into a little bit more detail on what you trying to do, I would appreciate it.

 

Kind Regards, 

Dom C
0 Kudos
Message 2 of 6
(3,561 Views)

Hi Dominic,

 

Yes that is correct. The CO pulse time named "delay_ctr" is the master task. It rising edge triggers the camera ("cam_trig"). Each delay_ctr trigger triggers 2 cam_trig pulses. The falling edge of delay_ctr triggers two pulses of a strobe light ("burst_ctr").

 

I know how many frames the camera can store, so I set the delay_ctr to generate a finite number of samples (Post trigger control). The delay_ctr does stop after that, so everyting stops, but the VI doesn't exit automatically. Inside the while loop there is a DAQ assistant that measures the strobe temperature and an analog voltage output that controls the intensity of the light.

 

I'd like to stop the white loop when I get the pre-defined number of frames. I plan to make my VI automatically download the frames, so it is necessary to be able to stop the loop automatically.

 

Probably the solution is dead simple. I tried to connect the is task done with the while loop stop button, but it didn't work. The other possible solution is to count the number of pulses of delay_ctr or cam_trig and exit when a certain number has been counted. But I haven't done pulse counting before.

 

Best regards,

Kostas

0 Kudos
Message 3 of 6
(3,557 Views)

Hi Kostas,

 

Thanks for explaining your problem in further detail for you. I appreciate it.

 

Yes I can see what you are trying to do.

 

So when you mentioned you tried the is task done with the stop button of the while loop. What do you mean exactly?

 

Did you mean the 'Is Task Done' boolean output going into an 'Or' function (along with the 'Stop' button) and then into the condition terminal of the while loop?

 

I have another idea. To use a 'Write' property node to monitor the number of samples generated and then use boolean logic to work out if the total number have been generated through comparison with a constant. You could then use an Or function to allow either the boolean output from the 'Stop' button or from the 'Equal?' function.

 

I have attached a VI snippet of what I mean, would you be able to test this for me?

 

I was not able to test it here with my PCI card as I ran into some errors relating to device routes. 

 

I hope this helps.

 

Kind Regards,

 

 

Dom C
0 Kudos
Message 4 of 6
(3,537 Views)

Hi Donimic,

 

I actually tried the 'Is Task Done' again with an or gate and it works! I must have done something wrong when I tried that initially.

 

However, the second solution you are proposing seems good; it provides some error checking. The snippet you sent confused me a bit. What are those icons (Task out 3) before the DAQmxWrite?

 

Best regards,

Kostas

0 Kudos
Message 5 of 6
(3,534 Views)

Hey Kostas,

 

I'm glad that has worked out for you!

 

Please don't worry about the VI Snippet. Because of the way I took the snippet (items selected), some inside and some outside of the while loop), it must have done something to the terminals. 

 

All that needs to be taken away from the VI snippet it the fact that the DAQmx Write Node has been used before the 'Is Task Done?' function. That is all.

 

I hope that helps.

 

Good luck with the rest of your application.

 

Thanks for your post to the forum.

 

Kind Regards,

Dom C
0 Kudos
Message 6 of 6
(3,532 Views)