A methodology and skill library for AI-augmented MATLAB/Simulink modeling of Permanent Magnet Synchronous Motor (PMSM) control, built for use with Claude Code.
The repository is itself a Claude Code workspace: clone it, install the
prerequisites, open Claude Code in the folder, and follow CLAUDE.md.
| Path | Contents |
|---|---|
CLAUDE.md |
Workspace entry point — setup steps and working rules a fresh Claude Code reads on open. |
.claude/skills/ |
Six PMSM modeling skills plus a general-purpose Simulink layout utility (Claude Code skill format), registered automatically when Claude Code opens this folder. |
workflow/ |
The 11-phase Reference Model Learning Workflow for distilling a reference model into a Claude Code skill under anti-contamination discipline. |
shared/ |
Domain assets the skills reuse: formulas/ (PMSM plant model + control-law derivations), building_blocks/ (atomic Simulink blocks + API notes). |
workspace/ |
Where you build your own models. |
extended/ |
An extra reference generated by Claude Code following the workflow — a FOC speed controller with a load-torque estimator (Luenberger + Kalman family) + feed-forward compensation. Builds on the skills but is not itself a formal skill. |
motor-pmsm-base— PMSM plant modeling, dq conventions, building-blocks SOP, broken-FOC diagnostics. The method skills layer on this.motor-fcs-mpc— single-vector Finite-Control-Set Model Predictive Control (inner current loop).motor-fcs-mpc-dualvector— dual-vector (two-vectors-per-period) FCS-MPC current loop: two voltage vectors with q-axis deadbeat time allocation cut switching-cycle ripple ~3-5× below single-vector. Layers onmotor-fcs-mpc.motor-fcs-mpc-trivector— three-vector (two adjacent active + one zero per period) FCS-MPC current loop: a 2×2 dual-axis deadbeat solve synthesizes an expected voltage vector that nulls bothi_dandi_qin one period. Layers onmotor-pmsm-base.motor-dtc-pmsm— Direct Torque Control (αβ frame, Sutikno 6-state switching table).motor-smc-pmsm— Sliding Mode Control speed loop (PD-type sliding surface + super-twisting) over a dq PI current loop.motor-mfpcc-eso— model-free deadbeat predictive current control (ultralocal model + Extended State Observer) modulated by SVPWM. The current law uses no machine parameters — only the input gainαand ESO bandwidthω0. Continuous control set (deadbeat + SVM), not FCS-MPC. Layers onmotor-pmsm-base.simulink-layout-tidy— general-purpose Simulink layout tidier: removes block overlaps, minimizes line crossings honestly (never promising a zero the graph's topology forbids), and exports a screenshot for human sign-off. Not motor-specific; supports the layout gate used in the build workflow.
- MATLAB R2024b or later, with Simulink, Simscape, Simscape Electrical, Control System Toolbox.
- Claude Code.
- matlab-mcp-core-server (MathWorks, MIT) — lets Claude Code run MATLAB directly. Install per its README.
- MathWorks' official MATLAB skills for Claude Code — install per MathWorks' instructions.
- Clone this repository.
- Install the prerequisites above.
- Open Claude Code in the repository folder. It loads
CLAUDE.mdand registers.claude/skills/. - Follow
CLAUDE.mdandworkflow/.
This repository ships skills (instructions) and shared assets (formulas/,
building_blocks/). It does not include end-to-end build scripts that generate
complete models, simulation results (.mat, waveforms, logs), or a CI harness —
those live in the author's private development repository. The only runnable
artifacts here are the pi_design.m scripts under .claude/skills/*/scripts/.
The case studies in workflow/
(Appendix C) are anonymized narrative descriptions of engineering experience
(problem / diagnosis / resolution), not artifact-backed reproducible benchmarks.
Phrases like "validated case" refer to the author's private testing — treat them as
documented experience, not published, data-backed benchmarks.
To reproduce: install the prerequisites, then drive the skills with your own build script and your own PMSM parameters.
This repository indexes — it does not redistribute — the following MathWorks open-source references, used by workflow phases that need official ecosystem reference models. Clone them separately if needed:
- mathworks/pmsm-drive-optimization — BSD-3-Clause
- mathworks/FOC-of-PMSM — BSD-3-Clause
This repository's original content (skills, workflow, scripts) is under Apache-2.0. BSD-3-Clause (the indexed references above) is compatible with Apache-2.0 for downstream use.
shared/building_blocks/pmsm_blocks.slx is a user-authored Simulink model that
references MathWorks Simscape Electrical library blocks (PMSM, Universal Bridge,
powergui, SVPWM, etc.) by reference — it does not embed or redistribute MathWorks
block implementations. Opening it requires your own licensed MATLAB + Simulink +
Simscape Electrical installation, the same way models are shared on MathWorks File
Exchange.
Trademark notice: MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. This is an independent project, not affiliated with, endorsed by, or sponsored by MathWorks.
The "skill" format follows the Claude Code skill specification.
See CITATION.cff.
Zong Chuhang — School of Electrical and Electronic Engineering, Nanyang Technological University, Singapore. ZONG0008@e.ntu.edu.sg