When to use:
When NOT to use:


| Input | Type | Condition | Description |
|---|---|---|---|
| Period | uint16 or uint16[] | Period input enabled | Period value(s). Label varies by mode: Period[1 2...] for master time base, Period Hx/Period Lx for independent mode |
| DutyCycle 1..N | uint16 or uint16[2] | Duty cycle enabled | Duty cycle values. Single value or up down for double update |
| Phase 1..N | uint16 | Phase input enabled | Phase shift values for interleaved operation |
| Trigger 1..N | uint16 | Dynamic trigger enabled | Dynamic ADC trigger point values |
| Output | Type | Description |
|---|---|---|
| Fault State 1..N | boolean | Fault status output per PWM (if enabled) |
This block uses a custom 5-tab GUI dialog. All parameters shown below are visible to users.
| Parameter | Description |
|---|---|
| PWM-H and PWM-L mode | Complementary (PWM-L is complement of PWM-H), Redundant (identical signals), Push-Pull (alternating on H/L), or Independent (separate control) |
| Independent Period | Enable independent period per PWM channel (required for Center Aligned mode) |
| Independent Duty Cycle | Enable independent duty cycle per PWM channel |
| Enable Channels | Per-channel enable checkboxes for PWM 1..N (H and L separately) |
| Max Period (s) | Maximum period in seconds per channel. Defines PWMxmax workspace variables |
| Center Aligned Mode | Align PWMs to middle of up/down time. Resolution is divided by two |
| Immediate Update | Update duty-cycle, phase, and period immediately (vs. at period boundary) |
| Double Update | In Center Aligned mode, update twice per PWM cycle. Input becomes val1 val2 vector |
| Block Sampling Time (s) | Sample time for block outputs |
| Parameter | Description |
|---|---|
| Initial Period (s) | Starting period value per channel (H and L separately for Independent mode) |
| Period is a block Input | Enable period block input per channel |
| Initial Duty Cycle (%) | Starting duty cycle percentage per channel |
| Duty Cycle is a block Input | Enable duty cycle block input per channel |
| Initial Phase (s) | Starting phase shift in seconds per channel |
| Phase is a block Input | Enable phase shift block input per channel |
| Initial ADC Trigger (s) | Starting ADC trigger timing per channel |
| Trigger is a block input | Enable dynamic trigger adjustment per channel |
| Parameter | Description |
|---|---|
| Fault | Fault source selection per PWM: Disabled, FLTx pin, Comparator, or combinations |
| Fault pin | Select fault input pin per PWM channel |
| Fault Pin Active | High or Low - polarity of fault input |
| Fault PWMxH state | Output state during fault: Low, High, or High-Z |
| Fault PWMxL state | Output state during fault: Low, High, or High-Z |
| Fault State is a block output | Enable fault status output port per channel |
| Fault Mode | Normal (Override Active/Inactive set to 0/1) or Independent (keeps PWM enabled/disabled) |
| Current-Limit Source | Current limit trigger source selection |
| Current Limit PWMxH/L state | Output state during current limit |
| Parameter | Description |
|---|---|
| Leading Edge Blanking | Enable blanking after PWM transitions to ignore switching noise on fault inputs |
| LEB Duration | Blanking time period in timer counts |
| LEB Source | Trigger source: Rising edge PWMxH, Falling edge PWMxH, or PWMxL edges |
| Parameter | Description |
|---|---|
| Dead Time | Mode selection: Disabled, Positive, Negative (edge-aligned only), or Compensation |
| Dead Time (s) | Dead-time duration for PWMxH transitions (seconds) per channel |
| Alternate Dead Time (s) | Dead-time duration for PWMxL transitions (seconds) per channel |
This block uses uint16 raw values for all inputs (period, duty cycle, phase, trigger). User scaling is required.
| Input Type | Range | Scaling | Description |
|---|---|---|---|
| Uint16 raw | 0 to PWMxmax | User handles scaling | Direct register value |
⚠️ Important: The block performs no range checking on inputs. Users must clamp values before the block input (e.g., using a Saturation block) to prevent overflow.
The block creates workspace variables for user scaling:
| Variable | Description |
|---|---|
PWMmax | Global maximum period value (when using master time base) |
PWM1max…PWMNmax | Maximum period per channel (based on Max Period in GUI) |
PWMxmax_H, PWMxmax_L | For Independent mode with separate H/L periods |
Fixed Period (period input disabled):
$$\text{DutyCycle}_\text{raw} = \text{DutyCycle}_\text{normalized} \times \text{PWMxmax}$$
DutyCycle_raw = DutyCycle_normalized × PWMxmax
Where DutyCycle_normalized is in the range [0, 1] relative to the fixed Max Period.
Variable Period (period input enabled):
When the period is dynamically controlled via block input, both period and duty cycle use the same scaling:
$$\text{Period}_\text{raw} = \text{Period}_\text{normalized} \times \text{PWMxmax}$$
Period_raw = Period_normalized × PWMxmax
$$\text{DutyCycle}_\text{raw} = \text{DutyCycle}_\text{normalized} \times \text{Period}_\text{raw}$$
DutyCycle_raw = DutyCycle_normalized × Period_raw
⚠️ Constraints:
Center-Aligned Mode: The @@PROT_20@@ workspace variable is halved at configuration time because the timer counts both up and down. This applies to all input types (Uint raw, Float).
No runtime division: Since @@PROT_21@@ is already halved, the block passes integer inputs directly to registers without any runtime shift operation. Users simply scale their values to the halved @@PROT_22@@.
Edge-Aligned Mode: The timer counts up only. @@PROT_23@@ represents the full period count. Duty cycle updates take effect at the next period boundary (unless Immediate Update is enabled).
When Double Update is enabled (requires Center-Aligned Mode + Independent Period):
Workspace variables for double update:
GUI configuration: Specify in seconds (e.g., @@PROT_27@@ for 1 µs)
Integer block input: Dead time uses a different scaling base (full period, not halved).
⚠️ In center-aligned mode, multiply @@PROT_28@@ by 2 for dead time scaling:
$$\text{DeadTime}_\text{raw} = \frac{\text{DeadTime}_s \times 2 \times \text{PWMxmax}}{\text{MaxPeriod}_s}$$
DeadTime_raw = (DeadTime_s × 2 × PWMxmax) / MaxPeriod_s
PWMxmax| Mode | Description | Use Case |
|---|---|---|
| Complementary | PWM-L is complement of PWM-H with dead-time insertion | Standard motor drive, half-bridge converters |
| Redundant | PWM-L is identical to PWM-H | Parallel drive, increased current capability |
| Push-Pull | PWM pulses alternate on PWM-H and PWM-L outputs | Push-pull converters, full-bridge DC-DC |
| Independent | PWM-H and PWM-L have separate period and duty cycle | Dual independent loads, asymmetric control |
| Family | Masksets | Key Features |
|---|---|---|
| dsPIC33F (selected) | High-speed PWM module | High-speed PWM, Auxiliary clock support |
| dsPIC33EP (GS) | High-speed PWM module | Enhanced features, APLL clock, up to 12 channels |
| dsPIC33C/CH/CK | Various (WAC, WBH masksets) | Full-featured high-speed PWM, independent time bases |
Synchronizing ADC sampling with PWM switching is essential for accurate current measurement in motor control and power conversion.
Configuration using Initial ADC Trigger:
% In PWM HighSpeed GUI, Block Input and Initialisation tab:
Initial_ADC_Trigger = 0; % Trigger at valley (center-aligned)
% Or for edge-aligned:
Initial_ADC_Trigger = Max_Period / 2; % Trigger at mid-period
% In ADC block:
Trigger_Source = 'PWM Trigger 1';
Sample_Time = 'Inherited';
Benefits:
| PWM Mode | Recommended Trigger Timing | Configuration |
|---|---|---|
| Center-Aligned | At valley (maximum current flow) | Initial ADC Trigger = 0 |
| Edge-Aligned | Mid-period (stable PWM state) | Initial ADC Trigger = Max_Period / 2 |
| Interleaved Phases | Staggered triggers per phase | Different trigger values per PWM |
% Main tab:
PWM_HL_mode = 'Complementary';
Independent_Period = false; % Master time base
Independent_Duty_Cycle = true; % Per-channel control
Center_Aligned_Mode = true;
Immediate_Update = false; % Synchronized updates
Double_Update = false;
% Max Period for 20 kHz PWM:
Max_Period = 1/20000; % 50 µs
% Dead Time tab:
Dead_Time = 1e-6; % 1 µs
Alt_Dead_Time = 1e-6; % 1 µs
% Main tab:
Independent_Period = true; % Required for Double Update
Center_Aligned_Mode = true; % Required for Double Update
Double_Update = true; % Enable asymmetric PWM
% Duty cycle input becomes [val1 val2] for up/down count
% Use case: Harmonic reduction, EMI optimization
% Add block to model
add_block('MCHP_Blockset/PWM IO/PWM High Speed', [mdl '/PWM_HS']);
% Configure key parameters
set_param([mdl '/PWM_HS'], 'MaxPeriod_s', '50e-6');
set_param([mdl '/PWM_HS'], 'InitPeriode_s', '50e-6');
set_param([mdl '/PWM_HS'], 'InitDutyCycleP_s', '20e-6');
set_param([mdl '/PWM_HS'], 'PWM1_HL', 'PWMxH & PWMxL output enabled');
Double Update requires:
If conditions not met, double update is automatically disabled.