LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient way to count pulses?

Hello all,

 

I figure this is a fairly simple question, but I didn't know exactly what to search for so I couldn't find a good answer.

 

In my VI, I'm trying to figure out an efficient way to determine how far from the origin my stepper motor has move based on the pulses that are sent to the stepper motor.  As seen in the screenshot, the frequency at which the motor is set is based on the value of the desired initial fill rate.  How can I add in something to my code so that every time a pulse is sent, it can be recorded and that number can be used to determine the distance moved (based on the fact that the motor moves 0.0025 mm every pulse). 

 

Thanks,

James

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

Hi James,

 

A counter input DAQmx task should be able to measure pulses. You will need to specify a different counter than the one that is producing the pulses, although you may run in to hardware limitations here (not all cards have multiple counters). Alternatively, you could add a case to your structure that would increment a shift register with the number of times the pluse output has been called (you may also need to move around your counter output task and configure how it gets the needed frequency input.

 

Here are some more resources that might be useful:

 

Using Counters and Digital I/O

 

In the NI Example finder (in LabVIEW: Help>>Find Examples) go to  Hardware Input and Output>> DAQmx>> Counter Measurements>>  Count Digital Events>>  Count Digital Events.vi

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

 

 

0 Kudos
Message 2 of 3
(3,970 Views)

A solution I got from my boss (Archie Henderson):

 

1. Create a CI task and a channel node. In the channel node select CI.CountEdges.Term. Right click and Change All to Write.

2. Create a constant from the channel node.

3. Right click the constant, and select I/O Name Filtering...

4. Tick the "Include Advanced Terminals" box.

5. If you go back to the constant, you should be able to access the Internal Output of your output counter. This will give you access to the pulses generated by your output counter.

 

Capture1.PNG

Capture2.PNG

0 Kudos
Message 3 of 3
(2,640 Views)