Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do my 6602 encoder measurement counters stop without the stop command?

Hi,
 
I am working with the 6602 counter card and am having trouble with the counters stoping without the stop command.  I set up the counters I am using to trigger off of a PWM signal, and then read the encoder positon x4, the pulse width, and the period.  I have verified that the PWM signal is there and clean during the entire move that I am trying to collect data for, however, during about 70% of the attempts the counters will just stop on their own.  Does anyone have any idea why the counters would/could stop?  I am using VB and have attached my setup code for the counters.  While the motion is occuring, the VB code is in a DO loop that uses DoEvents, a call to read the encoder position from custom hardware (without using the NI card), and a check of the timer to see if a timeout condition has occured.  No stop command is sent unless the encoder position has passed the end of travel.  This cannot happen as it is placed in the aquired_data event for the position counter which only fired once NMEASUREMENTS has been reached (here set to 100).  The counter stops mid-motion so the aquired_data event stops being called.
 
-Thanks for any help!
Amehl
0 Kudos
Message 1 of 2
(3,423 Views)

Amehl,

Unfortunately, I do not know of any reasons why the counter task would simply stop some of the time.  I have a couple recommendations that you can try to troubleshoot the issue. 

First, it would be good to know if the event (acquired_data) is not being called, or if the counter actually stops counting.  To do this you might try calling the readcounter method after you see that events are no longer being called.  If you call this method several times, and you know pulses are still going to the counter you should see it increment.

Secondly, you might want to try minimizing the amount of code you have executing inside the callback function to decrease its execution time. Finally, if neither the above help, you might try increasing the number of samples before the acquired_data event is called.  This will help prevent the event stack from getting bogged down and possibly causing problems.

If none of this helps, can you find any similarities between when it works and when it does not?  Do you create/start any other tasks/acquisitions when this problem seems to occur?

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
Message 2 of 2
(3,399 Views)