Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine actual number of pulses generated

I want to use digital I/O lines to control a stepper motor driver. I have a vi that 1) starts a counter to use at the clock for the timed digital I/O, 2) generates a digital waveform of alternating 1s and 0s and writes that to the Digital Output task that is clocked by the counter, 3) looks at digital inputs connected to the limit switches and stops the DO task if a limit is reached even if the task is not complete.

 

If the limit switch is not reached then everything works fine. The problem I have is trying to figure out how many steps were completed if the task is stopped before completion. The "number of samples generated" just gives the number written into the buffer and not the number that actually got clocked to the output. I could use a counter to count the number of pulses generated, but  I eventually need to have 8 outputs and I don't have 8 counters. I tried to estimate the number of steps from the time elapsed, but that was very inaccurate due to startup delays.

 

If I can't figure this out I will lose track of my position if I hit a limit switch, which I really want to avoid. I considered dividing the motion into smaller chunks so that the maximum loss of accuracy would be limited to the size of one of those chunks, but that adds a lot of overhead and slows things down quite a bit.

0 Kudos
Message 1 of 3
(3,117 Views)

Hi Richard,

 

Can you elaborate more on how you are generating your digital waveform?  Does the waveform vary or is it always the same?  

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,100 Views)

The waveform is a simple toggle waveform: alternating 1s and 0s.

 

I have basically given up on this. I have read that other people have asked similar questions and there seems to be no way to tell how many pulses were actually clocked out the output port. I think I can just do the output slowly, one pulse at a time, and count them myself. It sacrifices speed but should be good enough for now.

0 Kudos
Message 3 of 3
(3,097 Views)