Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contributor Covenant Code of Conduct
# 贡献者公约行为准则

We adhere to the Contributor Covenant Code of Conduct (version 2.0). Key points:
我们遵守《贡献者公约行为准则》(2.0 版)。要点如下:
- Respect others, avoid personal attacks, harassment, or discrimination.
- 尊重他人,避免人身攻击、骚扰或歧视。
- Encourage constructive discussions, respect contributors from diverse backgrounds.
- 鼓励建设性讨论,尊重来自不同背景的贡献者。
- If you encounter issues, please contact the maintainers: tkung.lqk@foxmail.com (or tag the security contact in an issue)
- 如遇到问题,请联系维护者:tkung.lqk@foxmail.com(或在 issue 中 @ 安全联系人)

For the full code of conduct, please refer to: https://www.contributor-covenant.org/
完整行为准则请参阅:https://www.contributor-covenant.org/
51 changes: 51 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contributing to AMBD-MC / 为 AMBD-MC 贡献

Thank you for your interest and contributions! To ensure high-quality collaboration, please follow the process below.

感谢你的关注与贡献!为确保高质量协作,请遵循以下流程。

## Submission Process / 提交流程
EN:
- Fork the repository and develop on a feature branch: `git checkout -b feat/your-feature`
- Submissions follow the standards (see Commit Style below)
- Run and pass project tests.
- Submit a PR to `main` (or the repo's default main branch), including reproduction steps, key changes, and related issues in the PR description.

中文:
- Fork 仓库并在功能分支上开发:`git checkout -b feat/your-feature`
- 提交需遵循规范(见下方“提交风格”)
- 运行并通过项目测试
- 向 `main`(或仓库默认主分支)提交 PR,在描述中包含复现步骤、关键改动和相关 issue。

## PR Checklist / PR 检查清单
- [ ] Link to issue (if any) / 关联 issue(如有)
- [ ] New/modified code includes unit tests/ 新增/修改的代码包含单元测试
- [ ] Pass CI (lint + tests) / 通过 CI(lint + tests)
- [ ] Update or supplement necessary documentation (README / docs) / 更新或补充必要文档(README / docs)
- [ ] Changes described clearly/ 清晰描述改动

## Code Style / 代码风格
EN:
- Add LICENSE to all copies or substantial portions of the Software.

中文:
- 在软件的所有副本或主要部分中添加许可证信息。

## Commit Messages / 提交信息
We recommend using concise type prefixes, such as:
建议使用简洁的类型前缀,例如:
```
feat: new feature / 新功能
fix: fix bug / 修复缺陷
docs: documentation changes / 文档变更
chore: build/tool/dependency changes / 构建/工具/依赖变更
refactor: refactor without changing functionality / 在不改变功能的情况下重构
test: test-related changes / 测试相关变更
```

## Development Roadmap and Tasks / 开发路线图与任务
We will list medium- to long-term plans in the repository's Projects / Roadmap. If you want to become a long-term maintainer, please express your interest in a PR or issue.
我们会在仓库的 Projects / Roadmap 中列出中长期计划。如果你想成为长期维护者,请在 PR 或 issue 中表达你的意愿。

Thank you!
谢谢!
42 changes: 14 additions & 28 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
title: "[bug] short description"
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
**Describe the issue you encountered**
Briefly describe what the problem is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Reproduction Steps**
1. Step one
2. Step two
3. Expected result vs actual result

**Expected behavior**
A clear and concise description of what you expected to happen.
**Environment**
- Operating System:
- Version/Commit:
- Other information (logs/stack trace)

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
**Additional Information**
Logs/screenshots/minimal reproducible example
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Pull Request
about: Submit changes and request merge
---

## Change Type
- [ ] feat: new feature
- [ ] fix: fix
- [ ] docs: documentation
- [ ] chore: maintenance
- [ ] test: test

## Change Description
Please briefly describe what this change does and why it is needed.

## Related Issue
Fixes # (issue number)

## Testing
- [ ] Unit tests added/updated
- [ ] CI passes

## Other Notes
48 changes: 48 additions & 0 deletions .github/workflows/github_workflows_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Basic CI (no MATLAB required)

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
basic-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: SPDX / license header check (.m files)
run: |
python3 tools/test_check_spdx.py || exit $?

- name: Detect large files (>10MB)
run: |
echo "Searching for files larger than 10MB..."
big=$(git ls-files -z | xargs -0 -I{} bash -c 'f="{}"; s=$(stat -c%s "$f" 2>/dev/null || echo 0); if [ "$s" -gt $((10*1024*1024)) ]; then echo "$f|$s"; fi' || true)
if [ -n "$big" ]; then
echo "Found large files (name|size):"
echo "$big"
echo "Please avoid committing large binaries. Consider using git-lfs or remove them."
exit 1
else
echo "No large files found."
fi

- name: Run Python tests if present
run: |
if [ -d "tests" ]; then
if [ -f "requirements-dev.txt" ]; then
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
fi
pytest -q || { echo "pytest failed"; exit 1; }
else
echo "No tests/ directory found, skipping pytest."
fi
75 changes: 75 additions & 0 deletions .github/workflows/github_workflows_deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build and deploy docs

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs-material

- name: Build docs
run: |
mkdocs build --verbose

- name: Check site directory
run: |
ls -la
test -d site || (echo "site directory not found" && exit 1)

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Check links (optional)
run: |
npm install -g markdown-link-check
# 检查docs目录下的所有markdown文件,忽略错误
find ./docs -name "*.md" -exec markdown-link-check {} \; || true

- name: Upload site artifact
uses: actions/upload-artifact@v4
with:
name: site
path: site
retention-days: 1

deploy:
needs: build
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: site
path: site
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: site
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The MIT License
MIT许可证
<https://opensource.org/license/mit>

SPDX short identifier / SPDX 短标识符:MIT

Copyright (c) 2026 autoMBD
版权所有 (c) 2026 autoMBD

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
特此向获得本软件及相关文档(合称“本软件”)副本的任何人免费授予不受限制地利用本软件的许可,包括而不限于:使用、复制、修改、合并、发布、分发、分许可和/或销售本软件副本,并允许本软件的接收者也获得前述许可,但须遵守以下条件:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
以上版权声明及本许可声明应包含在本软件的所有副本或主要部分中。

THE SOFTWAREISPROVIDED“ASIS”,WITHOUT WARRANTYOFANYKIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITEDTO THEWARRANTIESOF MERCHANTABILITY, FITNESS FOR APARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENTSHALLTHEAUTHORSORCOPYRIGHT HOLDERSBELIABLE FORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHER IN ANACTIONOFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORIN CONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHE SOFTWARE.
本软件系“按原样”提供,不包含任何形式的明示或默示保证,包括但不限于适销性、特定目的适用性及不侵权的保证。在任何情况下,无论是在合同、侵权或其他案件中,作者或版权持有人均不对因本软件、或因本软件的使用或其他利用而引起的、引发的或与之相关的任何权利主张、损害赔偿或其他责任承担责任。
75 changes: 21 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,22 @@
# AMBD-MC / autoMBD Motor Control

TODO

NOTICE

This project follows the MIT License, except for the following files:

- **All files under the `legacy` directory do not follow the MIT License**
- **All files under the `legacy` directory are owned by the autoMBD author <email: tkung.lqk@foxmail.com>**
- **All files under the `legacy` directory are not allowed to be modified, merged, published, distributed, sublicensed, and/or sold; for learning purposes only**
- **All files under the `legacy` directory are historical development artifacts, kept to maintain project continuity, but will be removed in the future**

特别提示

本项目遵循MIT许可,但以下文件除外:

- **`legacy`目录下所有文件不遵循MIT许可**
- **`legacy`目录下所有文件所有权利归autoMBD作者<邮箱tkung.lqk@foxmail.com>所有**
- **`legacy`目录下所有文件不允许任何修改、合并、发布、分发、分许可和/或销售本软件副本,仅供学习使用**
- **`legacy`目录下所有文件为历史开发遗留,保留的目的是维持项目的延续性,但将会在未来被移除**

# autoMBD: Motor Control

## 项目描述
AMBD-MC(autoMBD Motor Control project)是autoMBD的第一个开源项目,该项目基于MBD(Model-Based Design,基于模型的设计)实现电机控制框架。

仓库中包含BLDC/PMSM控制算法的MBD模型,分别实现了六步换相算法和矢量控制(FOC)算法。模型在NXP的电机开发套件平台上,实现了PIL(处理器在环)验证、HIL(硬件在环)验证。

## 仓库结构
* FreeMASTER_Prjct/
* BLDC_Ctrl_MBD.pmpx
* FOC_Cctrl_MBD_Integration.pmpx
* FOC_Ctrl_MBD.pmpx
* MBD_Models/
* BLDC_Ctrl_MBD/
* BLDC_Ctrl_MBD.slx
* struct_BLDC_Crtl.mat
* FOC_basic/
* FOC_basic.m
* FOC_basic1_OrientedCtrl.slx
* FOC_basic2_VoltageCtrl.slx
* FOC_basic3_CurrentCtrl.slx
* FOC_basic4_CurrentCtrl_SVPWM.slx
* FOC_basic5_SpeedCtrl.slx
* FOC_Ctrl_MBD/
* FOC_Config.m
* FOC_Ctrl_CodeModel.slx
* FOC_Ctrl_MBD.slx
* FOC_PIL_Algth_model.slx
* FOC_PIL_Algth_top.slx
* FOC_PIL_StateMch_model.slx
* FOC_PIL_StateMch_top.slx
* FOC_Sub_CoreAlgoithm.slx
* FOC_Sub_StateMch.slx
* struct_FOC_Crtl.mat
* Record_Pictures/
* S32DS_Prjct/
* BLDC_Ctrl_MBD_DS/
* FOC_Ctrl_MBD_Integration/

## BLDC模型
基于MBD电机控制框架,实现了BLDC六步换相算法。
* BLDC完整模型预览
![MBD-BLDC](Record_Pictures/BLDCctrl-Model-overview.png)
* BLDC运行结果预览
![MBD-BLDC](Record_Pictures/BLDCctrl-FreeMstr-DutyWave.png)

## PMSM模型
基于MBD电机控制框架,实现了FOC无感算法。
* FOC算法模型预览
![MBD-BLDC](Record_Pictures/FOC-Algorithm-Overview.png)
* PIL测试模型预览
![MBD-BLDC](Record_Pictures/FOC-PIL-Overview.png)
* 运行结果预览
![MBD-BLDC](Record_Pictures/三相电流-带载.png)
Loading