Matlab-Simulink device driver Blockset for Microchip dsPIC / PIC24 / PIC32 Microcontrollers.

# DsPIC Block/PWM Motor Output

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Block PWM Motor Output

The PWM Motor block allows to generate either simple PWM pulse like OC block or PWM pulse with two channel in opposit phase for motor control. This block do not use a timer like the OC or IC blocks.

# Main Dialog Box Parameters

PWM Motor Output main Dialog

## General Input Enable

Add the enable input to the block. Allow to Start and Stop the PWM pulses.

## Input Periode

Add the Periode Input. When the PWM periode is not constant, this input allow to control the PWM periode dynamically. Only one Input Periode appears as this periode is common for PWM channels of the PWM peripheral. If your application require different input period, you may either

## Output Channel

Choose the PWM motor Channels to be used.

## Periode

• When Input Periode is disable, Fixed the Periode value.
• When Input Periode is enable, This define the max Periode that will be used.

All temporal value provided to the bock input must be uint16 variable. The integer variable PWMmax created automatically in the workspace code for the time defined in Periode. Thus, any temporal value at block input must be multiplied by $\frac{PWMmax}{Periode}$. integer value at block input = $T_{set} * \frac{PWMmax}{Periode}$

With

• Tset = the requested time in second (should be inferior to Periode)
• Periode = The literal value (in second) you defined in the Periode dialog box
• PWMmax = a constant automatically evaluated in the matlab workspace

for example, a 1ms is coded with (Periode is set to 20ms : $20*10^{-3}$):

$1*10^{-3}*\frac{PWMmax}{20*10^{-3}}$

## ValMax Periode Calcule

This Variable will be evaluated in the workspace and allow you to scale the data.The ValMax is the max value that correspond to the duration defined in Periode.

## Centered

Edge-Aligned PWM vs Center-Aligned PWM. Center-Aligned PWM multiply by two the max Period and Duty Cycle achievable

This parameter center-aligned PWM duty cycle (see figure on the right). A side effect is to add a factor 2 to the internal PWM prescaler. Thus, This option multiply by 2 the MAX Period and the MAX duty Cycle time that can be achieved. However, for fast PWM (with prescalar set to 1), this option divide by two the resolution.

## Activate H Complementary Output

Activate the Complementary output (PWM low) of each channel.

## Info

Gives information :

• NbrBits is the resolution for the full scale defined by Periode.
• PWM max value corresponing to the time defined in Periode. PWM is evaluated in the workspace to allow you to scale the data.
• Prescaler is the Prescaler internally used in the microcontroller..

## Status

Information if error encountred.

PWM Motor Output Dead Time Dialog. some dsPIC has only one Dead Time Prescaler. This Dialog may be different, depending on the dsPIC being used

This tab may change. Some PIC / dsPIC has only one Dead Time, others have two.

## Dead Time A - B

Value in second for Dead Time A or B. When only one Dead time is available on the chip, only one value is requested and this value affect all PWM channels.

Get the real Dead Time value achievable