ZhuYanzhen1 / miniFOC

你还在为有刷电机的高噪声、低响应速度和低寿命而烦恼吗?这个项目是一个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/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]

liaozhelin opened this issue · comments

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

再次感谢大佬!

@liaozhelin 手动旋转电机出现的值突然归零是因为旋转电机超过360度之后会自动回到零度,这属于正常现象。另外如果想要使用上位机进行调试,必须要用串口接收中断绑定mdtp回调函数并且在main函数中进行状态机切换,这一部分你可以参考我的源码。

@liaozhelin 手动旋转电机出现的值突然归零是因为旋转电机超过360度之后会自动回到零度,这属于正常现象。另外如果想要使用上位机进行调试,必须要用串口接收中断绑定mdtp回调函数并且在main函数中进行状态机切换,这一部分你可以参考我的源码。

好的,感谢大佬😎
我刚才重新修改测试了一下,现在上位机角度模式可以动了,PID参数也可以调整。
后续仔细研究下您的源码学习下,十分感谢。

好的