Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
2 ratings:
 2 out of 5     Rate this Document

Generate a Pulse Using an External Clock as the Source



Primary Software: LabVIEW Development Systems>>LabVIEW Full Development System
Primary Software Version: 7.1
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Development Systems, Driver Software>>NI-DAQ
Hardware: Multifunction DAQ (MIO)

Problem:

Traditional DAQ:
If I want to generate a pulse train on a counter by dividing down the internal timebase of the counter (that is, the internal timebase is the source signal), I can use the Set Pulse Specs VI to determine the characteristics of that pulse.

However, if I want to use an external clock as the source signal to divide down and generate my pulse from, can I still use the Set Pulse Specs VI? If I specify the pulse in terms of the frequency and duty cycle or the delay and width, this VI calculates the appropriate internal timebase to use along with the raw pulse specs to set. If I set the raw pulse specs of the counter, the VI also expects a timebase to be specified. There is no way to explicitly set the counter to use an external source using this VI.


DAQmx:
Can I generate a pulse or pulse train using an external clock as the timebase for the pulse?

Solution:

Traditional DAQ
:
You can configure the NI-TIO and DAQ-STC counters for a variety of pulse generation tasks such as generating a single pulse or a pulse train. To create a pulse signal, load registers on the counter are used to divide down the source signal into another signal to be output.

A pulse is defined by two phases, the delay of the pulse and the width of the pulse. Therefore, the number stored in the first load register of the counter defines the number of active source edges that will occur during the delay phase of the pulse being generated. The second load register stores the number of active source edges that will occur during the width phase of the output pulse. The counter can use an internal timebase or an external signal for its source.

In LabVIEW, you can program these load registers using the Counter Set Attribute VI. To set the delay of the pulse (load register 1), use the Counter Set Attribute VI with the attribute ID set to pulse spec 1 and the attribute value number set to the delay value (load register 1). To set the width of the pulse (load register 2), use the Counter Set Attribute VI with the attribute ID set to pulse spec 2 and the attribute value number set to the pulse width (load register 2).

You also can use the Set Pulse Specs VI in the labview\vi.lib\daq\zadvdctr.llb. This VI is a convenient grouping of Set Attributes that you can use to specify the pulse to generate in terms of its frequency and duty cycle, its delay and width, or its raw pulse specs. The VI converts the input parameters into raw pulse and timebase specifications and makes the appropriate Advanced Counter VI calls to program the load registers correctly. Although it is not explicitly stated in the documentation, the Set Pulse Specs VI always sets the source to divide down to the internal timebase of the counter and, therefore, cannot be used with an external source. If you want to generate a pulse by dividing down an external source signal, you must call the Counter Set Attribute VI to set the external source and pulse spec 1 and 2 parameters.


DAQmx:
There is a shipping example with the DAQmx driver that allows for a pulse to be generated from an external clock.  The only action item in this example is to specify which PFI line on which you will bring in the external clock.

The example can be found by navigating to Help»Find Examples...»Hardware Input and Output»DAQmx»Generating Digital Pulses»Gen Dig Pulse Train-Buff- Ext Clk- Cont.vi

Related Links:
KnowledgeBase 31TELI6I. How Do I Scale the Frequency of My Pulse Train Using a Counter?

Developer Zone Tutorial: Generating a Pulse Train with a Counter
Developer Zone Example: Generating a Finite Pulse Train
Community Example: Generate a Continuous Digital Pulse Train With a Variable Frequency

Attachments:





Report Date: 03/26/2002
Last Updated: 04/16/2010
Document ID: 2JPC08B5

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit