Code Monkey home page Code Monkey logo

zhuyanzhen1 / minifoc Goto Github PK

View Code? Open in Web Editor NEW
749.0 40.0 220.0 13.32 MB

你还在为有刷电机的高噪声、低响应速度和低寿命而烦恼吗?这个项目是一个20块钱就能搞定的FOC无刷电机控制方案!This project is a FOC (Field Oriented Control) BLDC Motor control scheme that can be done for 3$!

Home Page: https://zhuyanzhen1.github.io/miniFOC/

License: GNU Affero General Public License v3.0

C 31.37% CMake 0.09% Assembly 0.36% Batchfile 0.01% C++ 68.16%
foc gd32 bldc controller

minifoc's Introduction

Hi there 👋

    I am a full-stack developer and capable of independently designing, building and controlling complex embedded systems. My skills include:
  • PCB design using KiCAD or Cadence SPB.
  • MCU program and port system using C language.
  • Programs for data visualization via Qt.
  • FPGA program using Verilog HDL.

You might want to check my personal website at https://zhuyanzhen1.github.io/ZhuYanzhen1/

minifoc's People

Contributors

frankxiaa avatar zhuyanzhen1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minifoc's Issues

挺期待的!

期待大佬更新!另外有几个问题:1.驱动电流是不是可以通过更换mos管获得更大的电流?2.Simplefoc好像支持了foc电流模式?

支持步进电机吗

Verify steps

Description

步进电机支持吗,有方案吗

Possible Solution

No response

[Bug]

Verify steps

  • 如果你可以自己 debug 并解决的话,提交 PR 吧。
    Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.
  • 我已经在 Issue Tracker 中找过我要提出的问题。
    I have searched on the issue tracker for a related issue.
  • 我已经仔细看过 Documentation 并无法自行解决问题。
    I have read the documentation and was unable to solve the issue.
  • 这是 miniFOC 核心的问题,并非我所使用的 miniFOC 衍生版本的特定问题。
    This is an issue of the miniFOC core, not to the derivatives of miniFOC.

miniFOC version

v1.1.2

What OS are you seeing the problem on?

No response

miniFOC config

/**************************************************************************//**
  \file     config.h
  \brief    used to place important parameter configurations for users
  \author   Lao·Zhu
  \version  V1.0.3
  \date     1. August 2023
 ******************************************************************************/

#ifndef MINIFOC__CONFIG_H_
#define MINIFOC__CONFIG_H_

/*! \brief bus voltage is 8.0V */
#define VBUS            8.0f
/*! \brief set BLDC polar pairs to 7 */
#define POLAR_PAIRS     7
/*! \brief SC60228 resolution is 2^8 = 4096 */
#define ENCODER_RESO    4096
/*! \brief set calibrate torque to 0.5 */
#define CALI_TORQUE     0.5f
/*! \brief Not using space vector pulse width modulator */
#define USE_SVPWM       1

/*! \brief set UART baud rate to 512000 */
#define UART_BAUDRATE   115200
/*! \brief set PWM frequency to 20kHz */
#define PWM_FREQUENCY   20
/*! \brief set FOC loop frequency to 8kHz */
#define TIM2_FREQUENCY  8
/*! \brief set speed/angle PID loop frequency to 100Hz */
#define TIM13_FREQUENCY 100
/*! \brief set speed update frequency to 200Hz */
#define SPEED_UP_FREQ   200
/*! \brief set SPI frequency to 72 / 16 = 4.5MHz */
#define SPI_PRESCALE    SPI_PSC_16

/*! \brief UART preemption priority set to 1 */
#define UART_PRIORITY   1
/*! \brief TIMER2 preemption priority set to 2 */
#define TIM2_PRIORITY   2
/*! \brief TIMER13 preemption priority set to 3 */
#define TIM13_PRIORITY  3

/*! \brief User flash space start address, 1KB user flash */
#define FMC_WRITE_START_ADDR    0x08007C00UL

#endif //MINIFOC__CONFIG_H_

miniFOC log

正常

Description

首先感谢大佬,提供了一个这么完善的项目,收获颇多
下面是我根据您的资料复刻的minifoc,我自己修改了芯片为GD32f130C6T6(QFN的涨价了些):1

IMG_5216

主要遇到下面这些问题,因为本人无法解决,所以来麻烦大佬看看,十分感谢!

  1. 手动在main函数中加入foc计算以及输出控制,电机可以旋转,但是使用原代码烧录后,打开上位机,设定好波特率后,可以看到图表内有编码器数据,但是手动旋转电机360度会出现数据突然间跳很大的情况:

    QQ截图20221020222608

  2. 使用上位机中三种控制模式,点击Start后,调整下方滑块电机均无反应:

    QQ截图20221020222644

再次感谢大佬!

[Feature] 是否可能移植到 esp32 的Arduino平台?

Verify steps

Description

能放出开源代码,已经很了不起了!非常感谢!

Possible Solution

如果可以支持ESP32的Arduino平台开发,相信更容易推荐开源软件的传播。
而且ESP32似乎在性能和功能上比GD32更有优势,更容易拓展。单价也很低。

催更Wiki😁

Verify steps

Description

催更Wiki😁

Possible Solution

No response

[Feature] 这么便宜的方案,不知道有没有成品? 另外,能扩展到多大功率?

Verify steps

Description

这么便宜的方案,不知道有没有成品? 另外,能扩展到多大功率?

Possible Solution

这么便宜的方案,不知道有没有成品? 另外,能扩展到多大功率?

[Feature] 无感FOC

Verify steps

Description

这个项目目前只是有感FOC的实现吧,有计划做无感的吗

Possible Solution

No response

[Feature] FOC调制算法似乎不是SVPWM?

Verify steps

Description

foc_calculate_dutycycle()这个函数计算的是FOC三相电压的输出,但是计算方法看着并非是SVPWM而是SinePWM。
在SimpleFOC给的描述中SinePWM的计算方法包括Inverse Park transformation和Inverse Clarke transformation,计算方式如下:

  • Inverse Park transformation

$$U_{\alpha}=U_dcos(\theta)-U_qsin(\theta)$$

$$U_{\beta}=U_dsin(\theta)+U_qsin(\theta)$$

一般只需要切向的$U_q$而不需要径向的$U_d$,故而$U_d=0$是期望值。

  • Inverse Clarke transformation

$$u_a=U_{\alpha}$$

$$u_b=\frac{-U_{\alpha}+\sqrt{3}U_{\beta}}{2}$$

$$u_b=\frac{-U_{\alpha}-\sqrt{3}U_{\beta}}{2}$$

在作者的设计代码中是这样处理的:

void foc_calculate_dutycycle(float elect_angle, float d, float q, float *u, float *v, float *w) {
    float alpha, beta;

    /* fast calculation of cosine and sine value of electric angle */
    float cf = fast_cos(elect_angle);
    float sf = fast_sin(elect_angle);

    /* firstly, the inverse Park transform is calculated */
    alpha = d * cf - q * sf;
    beta = q * cf + d * sf;

    /* secondly, the inverse Clarke transform is calculated */
    *u = 0.5f - alpha / VBUS;
    *v = 0.5f + (alpha * 0.5f - beta * 0.866025404f) / VBUS;
    *w = 1.5f - *u - *v;
}

0.5以及0.15这样奇怪的常量设置能否解释一下具体原因,以及整体计算方式应当归为SinePWM调制而不是SVPWM,与您的工程描述相悖。
@

Possible Solution

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.