Configure PWM Output

NI-Motion VI

Configure PWM Output

Enables and disables PWM outputs, and sets the PWM clock frequency.

Details

Device Compatibility

DeviceCompatibility
7330
Y
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Accelnet
N
NI SoftMotion Controller for CANopen—Xenus
N
Clock Frequency specifies the clock frequency for the PWM output.

The base clock frequency for the PWM outputs is 24.81 MHz on the 7340 and 7330 controllers, 24.58 MHz on the 7350 controller, and 20.48 on 7334/42/44 controllers. This base clock frequency is divided down depending on the clock value selected.

The following table describes the PWM clock frequency settings:

Clock Divider
Value
Clock
Value*
7334/42/44
Clock Frequency
7330/40
Clock Frequency
7350
Clock Frequency
512 0 40.00 kHz 48.46 kHz 48.01 kHz
1K 1 20.00 kHz 24.23 kHz 24.00 kHz
2K 2 10.00 kHz 12.11 kHz 12.00 kHz
4K 3 5.00 kHz 6.06 kHz 6.00 kHz
8K 4 2.50 kHz 3.03 kHz 3.00 kHz
16K 5 1.25 kHz 1.51 kHz 1.50 kHz
33K 6 625.00 Hz 757.14 Hz 750.09 Hz
External Clock/256 Hz 7 External Clock/256 Hz External Clock/256 Hz External Clock/256 Hz
65K 8 312.50 Hz 378.57 Hz 375.05 Hz
131K 9 156.25 Hz 189.29 Hz 187.52 Hz
262K 10 78.13 Hz 94.64 Hz 93.76 Hz
524K 11 39.06 Hz 47.32 Hz 46.88 Hz
1048K 12 19.53 Hz 23.66 Hz 23.44 Hz
2097K 13 9.77 Hz 11.83 Hz 11.72 Hz
4194K 14 4.88 Hz 5.92 Hz 5.86 Hz
External Clock/ 32,768 Hz 15 External Clock/ 32,768 Hz External Clock/ 32,768 Hz External Clock/ 32,768 Hz
*  These clock value numbers are used for purposes of discussion only.
PWM Enable (Disable) enables or disables the specified PWM Output. When enabled, the clock parameter determines the clock frequency used for the PWM output.

1 = enabled
0 = disabled

Board ID is a unique number assigned by Measurement & Automation Explorer (MAX) used to send and receive commands and data to or from a specific NI motion controller.
PWM Output selects the PWM Output to configure (1 or 2).
error in (no error) describes error conditions that occur before this VI runs. The default input of this cluster is no error. If an error already occurred, this VI returns the value of error in in error out. The VI runs normally only if no incoming error exists. Otherwise, the VI passes the error in value to error out. The error in cluster contains the following parameters:
status is TRUE if an error occurred before this VI was called, or FALSE if not. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code.
code is a number identifying an error or warning. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code. Use the error handler VIs to look up the meaning of this code and display the corresponding error message.
source is a string that indicates the origin of the error, if any. Typically, source is the name of the VI in which the error occurred.
Bd ID Out is provided for flow control. You can string together NI-Motion VIs by wiring the Bd ID Out terminal of one VI to the Board ID terminal of the next VI.
Resource Out is the Axis, Vector Space, ADC, or Encoder you wired into the VI. Use Resource Output to pass the resource to another VI and/or to display information about the device.
error out contains error information. If error in indicates an error, error out contains the same error information. Otherwise, it describes the error status that this VI produces.
status is TRUE if an error occurred, or FALSE if not. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code.
code is a number identifying an error or warning. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code. Use the error handler VIs to look up the meaning of this code and display the corresponding error message.
source is a string that indicates the origin of the error, if any. Typically, source is the name of the VI in which the error occurred.

Using This VI

The PWM outputs on the NI motion controller are digital pulse-train outputs that have a frequency specified by the clock parameter of this VI and a duty cycle specified by the Load PWM Duty Cycle VI. These outputs can be used to control devices that require a PWM input, such as a laser whose intensity is controlled by a PWM signal, or can be used to generate isolated analog outputs by passing the PWM output through an optocoupler, and then filtering the digital pulse train to produce an analog output voltage.

When you configure a PWM output, the clock frequency applies to both PWM outputs. If you configure one PWM output for a clock value of 3, and then the second PWM output for a clock value of 4, the value of 4 applies to both PWM outputs.

The only exception is when the clock settings for the two PWM outputs are 0 and 8, 1 and 9, 2 and 10, and so on, in which case each output has a different frequency. This is because clock values 0–7 and 8–15 are paired. Clock values 0 and 8 use the common time base of 10.24 MHz (12.8 MHz on the 7350). The frequency of clock value 0 is found by dividing the time base by 256, while clock value 8 is found by dividing the time base by 32768. If you have an NI 7344 controller and you switch channel B to clock value 10, the time base changes to 2.56 MHz. This change also switches channel A to 2.56/256 = 10 kHz. Therefore, if the value in one set changes, it switches the other channel to the pairing clock value. If the two values are in the same group, the two channels have the same frequency.

To use an external clock (clock values of 7 or 15), connect the external clock signal to the PCLK input on the Digital I/O connector.