LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vi not stopping

 

Hi

 

I am currently aquiring a TTL pulse once every revolution from my encoder through a counter input on my PCI -6229 DAQ board.

 

The attached program performs this and measures the frequency between pulses to give me the desired roational velocity.

 

However I cannot get the program to stop when clicking the stop button.

 

Running in highlighted execution mode, I can see where the program is effectively hanging, but I am unable to think of a method of allowing the program to stop when pressed.

 

Any help would be appreciated

 

Skyman

 

0 Kudos
Message 1 of 7
(4,196 Views)

Dear Skyman,

 

thank you so much for your post on our webforum. I could not review the complete code; tacho working.vi was not included. I created my own task, and then your VI was running without any problem.

If your VI runs highlighted; where does it 'hang'? I can imagine (just a wild guess) it stays in the DAQmx read.VI when something is wrong with triggering. You did wire -1 to timeout; the VI waits infinite in the DAQmx read VI until the number of samples are read by the counter.

 

Best regards,

Martijn S
Applications Engineer
NI Netherlands
0 Kudos
Message 2 of 7
(4,186 Views)

Hi Skyman 

 

Have you tried running it with highlight execution, because i've noticed you've got -1 wired into your daqmx read. It could just be sitting there waiting... hence not exiting the loop

 

Jevon

0 Kudos
Message 3 of 7
(4,185 Views)

Thanks to both of you for your quick replies.

 

The -1 timeout was to allow the program to remain running when the encoder shaft stopped spinning for a period of time.

 

I do realise that this has effectivley stopped us from physically stopping the program. I cannot however personally think of a workaround for this problem.

 

Skyman

 

0 Kudos
Message 4 of 7
(4,159 Views)

You can give it a timeout time, but then you will get an error at timeout which will stop the loop.

Simply check the error cluster for the particular error code when there's a timeout and then clear the errors if that particular error occurs... then the loop will not exit.

 

Jevon

Message 5 of 7
(4,149 Views)

Hi,

 

I have used the General Error Handler VI to clear the timeout erro and so an error message now does not pop up. However, pressing the STOP button whilst running the VI still does not do anything. After a timeout of say 10 seconds, the VI then stops.

 

I feel I haven't defined my problem as well as I could. The TTL input is not of constant frequency as it will measure the rotational speed from 0rpm to a value and then back down to 0. This will mean that when the shaft has stopped, no more pulses will be measured. At this point I want to stop the VI and this is the moment when the error occurs because the loop is waiting for another input for the loop to iterate.

 

I think applying a timeout time tells the loop to wait x seconds until the the next input and so when one does not occur, the stop button will also not work. This problem also occurs when the VI is first run but the shaft is not rotated. Pressing the stop button during this time does not stop the VI, but the timeout error overrides and stops the VI.

 

I appreciate your help with my problem.

 

Skyman

 

0 Kudos
Message 6 of 7
(4,109 Views)

The DAQmx Read function is what is called a "blocking function".  This means that once your program reaches the DAQmx read call, it will not proceed until either data is available or the timeout is reached.  The program will continue past the DAQmx Read VI either when the requested amount of data is available or the timeout is reached, whichever comes first  There is not a way to exit the DAQmx read VI before the timeout is reached unless you abort the VI, which is not a stable way of stopping the VI.  If you need your VI to respond faster, you'll need to set a shorter timeout.  For instance, if you want your VI to stop within 1 second of pressing the stop button, the longest timeout you can set will be 1 second.  The tradeoff is that your VI will loop faster and use more CPU resources.

 

Regards,

 

 

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 7 of 7
(4,087 Views)