flex_load_pwm_duty

NI-Motion Functions

flex_load_pwm_duty

Device Compatibility

Device Compatibility
7330
Y
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Xenus
N
NI SoftMotion Controller for CANopen—Accelnet
N

Load PWM Duty Cycle

Usage

status = flex_load_pwm_duty(u8 boardID, u8 PWMOutput, u16 dutyCycle, u8 inputVector);

Purpose

Sets the duty cycle for a PWM output.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
PWMOutput u8 PWM Output
dutyCycle u16 duty cycle for PWM Output
inputVector u8 source of the data for this function

Parameter Discussion

PWMOutput selects the PWM Output to control (1 or 2).

dutyCycle is a value between 0 and 255 that specifies the amount of time the PWM output is high.

inputVector indicates the source of the data for this function. Available input vectors include immediate (0xFF), variable (0x01 through 0x78), or indirect variable (0x81 through 0xF8). Refer to Input and Return Vectors for more detailed information.

Using This Function

The dutyCycle determines the amount of time the PWM output is high. A dutyCycle of 0 corresponds to a 0 V output, and a dutyCycle of 255 corresponds to a pulse train that is high for 255/256 = 99.6% of the time. Use the Configure PWM Output function to set the frequency of the PWM output signal.

You can set the duty cycle before or after configuring a PWM output. By default, dutyCycle is 0, so if you call the Configure PWM Output function to configure a PWM output, the output is low until you set dutyCycle differently. If you set the dutyCycle first, the PWM output reflects this dutyCycle immediately after calling the Configure PWM Output function.