home / skills / omer-metin / skills-for-antigravity / motor-control

motor-control skill

/skills/motor-control

This skill helps you implement efficient motor control patterns such as FOC and encoder interfaces with robust diagnostics.

npx playbooks add skill omer-metin/skills-for-antigravity --skill motor-control

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.1 KB
---
name: motor-control
description: Patterns for electric motor control including Field Oriented Control (FOC), stepper motor control, encoder interfaces, current sensing, and power electronics. Covers BLDC, PMSM, DC brushed, and stepper motor applications. Use when ", " mentioned. 
---

# Motor Control

## Identity



## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill provides patterns and practical guidance for electric motor control in Python, covering Field Oriented Control (FOC), stepper motor control, encoder interfaces, current sensing, and power electronics. It supports BLDC, PMSM, DC brushed, and stepper applications with reproducible patterns for design, diagnosis, and validation. The content focuses on safe, testable implementations and clear failure modes to reduce risk during development and commissioning.

How this skill works

The skill codifies proven patterns for control loops, sensor fusion, and power management, showing how to structure FOC, commutation, and stepper routines in Python. It inspects hardware interfaces (encoders, current sense, gate drivers) and highlights critical failure modes and their root causes. It also provides objective validation checks for parameter ranges, control stability, and safety interlocks.

When to use it

  • Designing or prototyping FOC for BLDC or PMSM motors in Python
  • Implementing stepper motor drivers with closed-loop position control
  • Integrating quadrature encoders, absolute encoders, or resolver interfaces
  • Building or verifying current sensing and overcurrent protection
  • Reviewing power electronics switching, dead-time, and gate drive safety

Best practices

  • Follow the provided control patterns for loop separation: inner current loop, outer speed/position loop, and trajectory planning
  • Validate sensor calibration and noise characteristics before tuning control gains
  • Use conservative current and voltage limits during initial commissioning
  • Implement watchdogs, fault latching, and clear diagnostics for safety-critical failures
  • Run objective validation checks on parameter ranges and timing constraints before deployment

Example use cases

  • Implementing FOC for a PMSM motor on a real-time controller with current sensing and encoder feedback
  • Converting an open-loop stepper system to closed-loop with encoder correction and missed-step detection
  • Diagnosing torque ripple and instability by tracing current loop performance and encoder resolution
  • Verifying safe start-up and shutdown sequences for a DC brushed motor with overcurrent protection
  • Auditing gate driver dead-time and switching transitions to prevent shoot-through failures

FAQ

Can I use these patterns on non-real-time Python platforms?

Patterns are portable, but closed-loop motor control requires deterministic timing; use a real-time capable runtime or offload fast loops to dedicated firmware where strict timing is needed.

How do I approach tuning for a new motor?

Start with measured inertia and resistance values, use conservative gains, validate inner current loop stability first, then tune speed/position loops while monitoring temperature and current limits.