nuttx-apps/examples/foc
Xiang Xiao 8083b094c3 Kconfig: Simplify the conditional default statement
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-25 09:51:09 +08:00
..
CMakeLists.txt cmake: port nxscope and foc and add missing directories 2023-07-14 22:04:35 +08:00
foc_adc.h include: fix double include pre-processor guards 2022-01-16 17:36:21 +08:00
foc_cfg.h examples/foc: control motor identification parameters from cmd line 2022-11-04 02:07:15 +08:00
foc_debug.h include: fix double include pre-processor guards 2022-01-16 17:36:21 +08:00
foc_device.c Replace all sprintf with snprintf 2023-05-08 21:35:16 +03:00
foc_device.h include: fix double include pre-processor guards 2022-01-16 17:36:21 +08:00
foc_fixed16_thr.c examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
foc_float_thr.c examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
foc_intf.c fsutils/examples: Include unistd.h explicitly 2023-02-05 08:46:59 +02:00
foc_intf.h include: fix double include pre-processor guards 2022-01-16 17:36:21 +08:00
foc_main.c examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
foc_motor_b16.c examples/foc: add missing deinit calls 2023-05-15 13:19:34 -03:00
foc_motor_b16.h examples/foc: improve the readability of the motor structures 2023-05-17 13:45:24 +08:00
foc_motor_f32.c examples/foc: add missing deinit calls 2023-05-15 13:19:34 -03:00
foc_motor_f32.h examples/foc: improve the readability of the motor structures 2023-05-17 13:45:24 +08:00
foc_mq.c examples/foc: make sure that the queue is empty before start the control thread 2022-08-27 23:50:58 +08:00
foc_mq.h include: fix double include pre-processor guards 2022-01-16 17:36:21 +08:00
foc_nxscope.c examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
foc_nxscope.h examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
foc_parseargs.c examples/foc: add controller IDLE mode 2023-05-15 13:19:34 -03:00
foc_parseargs.h examples/foc: move validate_args to parseargs file 2022-11-04 02:07:15 +08:00
foc_thr.c examples/foc/foc_thr: get controller type from controller ID 2023-05-19 20:18:38 +08:00
foc_thr.h examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
Kconfig Kconfig: Simplify the conditional default statement 2023-07-25 09:51:09 +08:00
Make.defs Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
Makefile examples/foc: add real time data capture with the NxScope library 2023-05-19 20:18:38 +08:00
README.md Remove the tail space char from all files 2023-03-03 00:18:36 +02:00

FOC example

The main purpose of this example is to provide a universal template to implement the motor controller based on the kernel-side FOC device and the application-side FOC library.

At the moment, this example implements a simple open-loop velocity controller.

Hardware setup

This example has not yet implemented any mechanism to protect the powered device. This means that there is no overtemeprature protection, no overcurrent protection and no overvoltage protection.

Make sure that you power the device properly and provide current limits on your own so as not to break your hardware.

Configuration

The FOC PI current controller parameters can be obtained from the given equations:

Kp = ccb * Ls;
pp = Rs / Ls;
Ki = pp * Kp * T;

where: Kp - PI proportional coefficient Ki - PI integral coefficient Rs - average phase serial resistance Ls - average phase serial inductance pp - pole plant ccb - current control bandwidth T - sampling period

Sample parameters for some commercially available motors

  • Odrive D6374 150KV p = 7 Rs = 0.0254 Ohm Ls = 8.73 uH i_max = ? v_max = ?

    Example configuration for f_PWM = 20kHz, f_notifier = 10kHz, ccb=1000: Kp = 0.0087 Ki = 0.0025

  • Linix 45ZWN24-40 (PMSM motor dedicated for NXP FRDM-MC-LVMTR kit) p = 2 Rs = 0.5 Ohm Ls = 0.400 mH i_max = 2.34 A v_max = 24 V

    Example configuration for f_PWM = 10kHz, f_notifier = 5kHz, ccb=1000: Kp = 0.4 Ki = 0.1

  • Bull-Running BR2804-1700 kV (motor provided with the ST P-NUCLEO-IHM07 kit) p = 7 Rs = 0.11 Ohm Ls = 0.018 mH i_max = 1.2A v_max = 12V

    Example configuration for f_PWM = 20kHz, f_notifier = 10kHz, ccb=200: Kp = 0.036 Ki = 0.022

  • iPower GBM2804H-100T (gimbal motor provided with the ST P-NUCLEO-IHM03 kit) p = 7 Rs = 5.29 Ohm Ls = 1.05 mH i_max = 0.15A v_max = 12V

    Example configuration for f_PWM = 10kHz, f_notifier = 5kHz, ccb=TODO: Kp = TODO Ki = TODO