National Instruments 321645c-01 Welding System User Manual


 
Chapter 2 Function Reference CTR_Rate
©
National Instruments Corporation 2-105 NI-DAQ FRM for PC Compatibles
3: 100 µs.
4: 1 ms.
5: 10 ms.
period1 and period2 represent the number of units of time (selected by timebase) that the
square wave is high and low, respectively. The roles of period1 and period2 are reversed if
the output polarity is negative.
Range: 1 through 65,535.
Note C Programmers—timebase, period1, and period2 are pass-by-reference
parameters.
Using This Function
CTR_Rate translates a definition of a square wave in terms of frequency and duty cycle into
terms of a timebase and two period values. You can then input the timebase and period values
directly into the
CTR_Square function to produce the selected square wave.
CTR_Rate emphasizes matching the frequency first and then the duty cycle. That is, if the
duty fraction is 0.5 but an odd-numbered total period is needed to produce the selected
frequency, the two periods returned by
CTR_Rate will not be equal and the duty cycle of the
square wave differs slightly from 50 percent. For example, if freq is 40,000 Hz and duty is
0.50,
CTR_Rate returns values of 1 for timebase, 13 for period1, and 12 for period2. The
resulting square wave has the frequency of 40,000 Hz but a duty fraction of 0.52.