Skip to content
Back to skills

Esp32 Mcpwm Power Stage

ASecurity

Use when driving a motor, inverter, half bridge, complementary PWM output or other power stage with ESP32 MCPWM; especially when dead time, synchronization, fault braking or safe startup matters.

  • 16 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
ai-agentsapi

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 7, 2026

npx -y skills add Esmail-sarhadi/esp32-agent-skills --skill esp32-mcpwm-power-stage --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Esp32 Mcpwm Power Stage?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Esp32 Mcpwm Power Stage
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/esmail-sarhadi-esp32-mcpwm-power-stage/badge)](https://www.skillsdirectory.com/skills/esmail-sarhadi-esp32-mcpwm-power-stage)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: esp32-mcpwm-power-stage
description: Use when driving a motor, inverter, half bridge, complementary PWM output or other power stage with ESP32 MCPWM; especially when dead time, synchronization, fault braking or safe startup matters.
license: MIT
---

# MCPWM power-stage control

MCPWM generates coordinated motor-control waveforms. It does not make a power stage safe by itself.
The external gate driver, current sensing, protection and hardware shutdown path remain part of the design.

## Establish hardware capability

- Identify exact SoC and ESP-IDF version; MCPWM features and operator/timer counts vary by target.
- Read the SoC technical reference manual and the selected gate-driver datasheet before assigning pins.
- Confirm GPIO matrix routing, output polarity, complementary-output support and fault input availability.
- Keep the build example pinned to one driver API generation; legacy MCPWM and the newer handle-based driver are not source-compatible.
- Do not infer that a peripheral exists because another ESP32 family exposes it.

## Define the safe electrical state first

- Draw the power-stage truth table for reset, bootloader, firmware startup, normal run, fault and brownout.
- Use external pull resistors so gate-driver inputs remain OFF while ESP32 pins are high impedance.
- Prefer a hardware enable/fault path that disables switching independently of the application task.
- Configure fault actions to force the documented safe output state; verify active-high/active-low polarity.
- Never rely on a software task watchdog as the only overcurrent or shoot-through protection.

## PWM timing

- Derive timer period from the selected clock source and prescaler; document resolution and frequency error.
- Set compare values with explicit bounds and define what 0% and 100% mean electrically.
- Use complementary outputs and dead-time insertion only after validating gate-driver requirements and propagation delays.
- Check that dead time is represented in timer ticks and remains valid across clock changes.
- Use synchronization for multi-phase outputs; do not start independent timers and assume phase alignment.
- Keep updates at a defined boundary (for example, timer-zero event) to avoid mid-cycle glitches.

## Fault handling

- Wire overcurrent, gate-driver fault and emergency-stop signals to hardware-capable fault inputs where supported.
- Define one-shot versus cycle-by-cycle behavior from the power-stage protection requirements.
- Latch faults in firmware for diagnosis, but do not let firmware clear a fault while the physical cause remains.
- Require an explicit re-arm sequence after fault removal; default to outputs disabled after reset.
- Record fault source, timestamp, operating point and recovery action without blocking the ISR.

## Current and speed feedback

- Sample current with a documented trigger point relative to PWM switching edges.
- Account for amplifier settling, ADC acquisition time, offset and gain calibration.
- Use hardware comparators or external protection when software ADC latency cannot meet the shutdown requirement.
- Filter encoder/speed feedback without hiding a real stall or overspeed condition.
- Separate control-loop execution time from telemetry and logging.

## Verification

- Unit-test duty conversion, saturation, phase calculations and fault-state transitions on the host.
- On hardware, first test with the gate driver disabled or a current-limited low-voltage supply.
- Observe all complementary outputs with a scope and verify dead time at voltage and temperature corners.
- Inject each fault input and prove the gate-driver enable drops without waiting for a task.
- Test reset, brownout and firmware crash while outputs are active.
- Do not connect a motor or mains-powered stage until the independent protection path has been reviewed.

## Acceptance criteria

- The build targets a named SoC and pinned driver API.
- A state-machine test proves every fault transitions to outputs-disabled.
- Scope captures show polarity, frequency, duty limits and dead time.
- The document states that software validation is not a substitute for power-electronics safety review.

## References

- ESP-IDF MCPWM: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/mcpwm.html
- ESP-IDF GPIO: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/gpio.html
- Espressif technical documents: https://www.espressif.com/en/support/documents/technical-documents

Files in this skill

  • LICENSE.txt1 KB
  • SKILL.md4.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.