Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

generate a pulse train using pci dio 32HS card

I have a NI PCI DIO 32 HS card. I need to generate a continuous pulse train at the one of the port outputs which will be given to the stepper motor drive. Can someone suggest how to design the counter so that i get the desired no. of pulses as output. 
0 Kudos
Message 1 of 4
(4,394 Views)
Hello tej,

There are two LabVIEW shipping examples that ship with DAQmx that demonstrate how to program the 6533.  One is called Cont Write Dig Port-Ext Clk and the other is called Write Dig Chan-Ext Clk.  Both of these examples can be found in the NI Example finder under Hardware Input and Output >> DAQmx >> Digital Generation.  If you want to use the built in clock of the 6533 (DIO 32 HS) you will want to set the clock source to OnboardClock.  The Cont Write Dig Port-Ext Clk example is continuous, while the other outputs a finite number of pulses.

There are similar examples for .NET & C.  The C Examples are typically located here:  C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values

and the .NET examples are typically found here:  C:\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples

To generate a clock output, simple specify a series of 1 and 0 samples.  If you have a waveform of 64 samples where you toggle between 1 and 0 every sample the output clock rate will be half your sample clock.  For example with a sample clock of 10k, the output clock frequency is 5k.

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 4
(4,373 Views)
i have a quadrature encoder for the purpose of feedback. how do i acquire the output of the encoder while using the same pci dio 32hs card??
0 Kudos
Message 3 of 4
(4,360 Views)
Hi Tej,

Typically encoders are connected and read by counters which have built-in functionality to determine the direction of movement based upon the state of the 2 or 3 quadrature encoder signals (Channels A, B and Z).

First of all, a little background on quadrature encoders:
Quadrature encoders generally have 2 or 3 signals, A&B which are square waves +/-90 degrees out of phase and optionally Z which pulses to zero the position. When the encoder moves, a pulse is created on both A&B.  Depending on the direction of movement, pulse A will either lead or lag pulse B by 90 degrees.

I see you are working with a digital board which does not have onboard counters, however with a little extra work you may still be able to use your 6533 for encoder measurement.  To be able to perform counter measurments on your digital lines you will want to sample the lines as fast as possible to make sure that you do not miss any high or low transitions. You will then need to create a software algorithm to determine which way the encoder is turning. 

I have not tried this before, but I would suggest using a state machine type of architecture. For example, monitor both lines until a change occurs  - this would be the initial state.  You would then transition to a "prepare to increment" or "prepare to decrement count" state (depending on whether the A or B signal was the one that changed).  In this state you would wait for the opposite line to pulse and then increment or decrement the count accordingly.  Next you would want to wait for both lines to return to idle. This process would then repeat. You will need to know some information about your encoder to verify that the pulse width will be wide enough to ensure you are able to accurately detect which line (A or B) pulses first.  If you are using a Z signal you would want to add code to reset the count back to zero when this line pulses.

Hope this helps,

Jennifer O.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,345 Views)