mirror of
https://github.com/EFeru/hoverboard-firmware-hack-FOC.git
synced 2025-08-03 01:24:27 +02:00
Merge branch 'EFeru:master' into master
This commit is contained in:
41
.github/workflows/build_on_commit.yml
vendored
Normal file
41
.github/workflows/build_on_commit.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Get required packages
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: fiam/arm-none-eabi-gcc@v1
|
||||||
|
with:
|
||||||
|
release: '9-2019-q4'
|
||||||
|
|
||||||
|
# Build with make
|
||||||
|
- name: make
|
||||||
|
env:
|
||||||
|
VARIANT: VARIANT_ADC
|
||||||
|
run: make
|
||||||
|
|
||||||
|
# Build with Platformio
|
||||||
|
- name: PlatformIO Install
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install --upgrade platformio
|
||||||
|
- name: PlatformIO Run
|
||||||
|
run: pio run
|
||||||
|
|
||||||
|
- name: 'Upload Build Artifact'
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{github.workspace}}/.pio/build/**
|
||||||
|
name: ${{github.event.repository.name}}_build_${{github.run_number}}
|
||||||
|
retention-days: 5
|
||||||
|
|
55
.travis.yml
55
.travis.yml
@@ -1,55 +0,0 @@
|
|||||||
notifications:
|
|
||||||
email: true
|
|
||||||
|
|
||||||
os: linux
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
fast_finish: true
|
|
||||||
include:
|
|
||||||
|
|
||||||
- name: make (gcc-arm-none-eabi-7)
|
|
||||||
script: make
|
|
||||||
env: VARIANT=VARIANT_ADC
|
|
||||||
language: c
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libc6-i386
|
|
||||||
install:
|
|
||||||
- pushd .
|
|
||||||
- cd ~
|
|
||||||
- mkdir arm-gcc-toolchain
|
|
||||||
- wget -O $HOME/arm-gcc-toolchain/gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update
|
|
||||||
- cd arm-gcc-toolchain
|
|
||||||
- tar -jxf gcc.tar.bz2 --strip=1
|
|
||||||
- popd
|
|
||||||
- export PATH=$HOME/arm-gcc-toolchain/bin:$PATH
|
|
||||||
before_script: arm-none-eabi-gcc --version
|
|
||||||
|
|
||||||
- name: make (gcc-arm-none-eabi-5)
|
|
||||||
script: make
|
|
||||||
env: VARIANT=VARIANT_ADC
|
|
||||||
language: c
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libc6-i386
|
|
||||||
install:
|
|
||||||
- pushd .
|
|
||||||
- cd ~
|
|
||||||
- mkdir arm-gcc-toolchain
|
|
||||||
- wget -O $HOME/arm-gcc-toolchain/gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2?revision=111dee36-f88b-4672-8ac6-48cf41b4d375?product=GNU%20Arm%20Embedded%20Toolchain,32-bit,,Linux,5-2016-q3-update
|
|
||||||
- cd arm-gcc-toolchain
|
|
||||||
- tar -jxf gcc.tar.bz2 --strip=1
|
|
||||||
- popd
|
|
||||||
- export PATH=$HOME/arm-gcc-toolchain/bin:$PATH
|
|
||||||
before_script: arm-none-eabi-gcc --version
|
|
||||||
|
|
||||||
- name: platformio
|
|
||||||
script: platformio run
|
|
||||||
language: python
|
|
||||||
install:
|
|
||||||
- pip install -U platformio
|
|
||||||
- platformio update
|
|
||||||
cache:
|
|
||||||
- directories: "~/.platformio"
|
|
@@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Code generated for Simulink model 'BLDC_controller'.
|
* Code generated for Simulink model 'BLDC_controller'.
|
||||||
*
|
*
|
||||||
* Model version : 1.1296
|
* Model version : 1.1297
|
||||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||||
* C/C++ source code generated on : Tue Oct 20 17:29:57 2020
|
* C/C++ source code generated on : Sun Mar 6 11:02:11 2022
|
||||||
*
|
*
|
||||||
* Target selection: ert.tlc
|
* Target selection: ert.tlc
|
||||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Code generated for Simulink model 'BLDC_controller'.
|
* Code generated for Simulink model 'BLDC_controller'.
|
||||||
*
|
*
|
||||||
* Model version : 1.1296
|
* Model version : 1.1297
|
||||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||||
* C/C++ source code generated on : Tue Oct 20 17:29:57 2020
|
* C/C++ source code generated on : Sun Mar 6 11:02:11 2022
|
||||||
*
|
*
|
||||||
* Target selection: ert.tlc
|
* Target selection: ert.tlc
|
||||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||||
|
16
README.md
16
README.md
@@ -1,5 +1,5 @@
|
|||||||
# hoverboard-firmware-hack-FOC
|
# hoverboard-firmware-hack-FOC
|
||||||
[](https://app.travis-ci.com/EFeru/hoverboard-firmware-hack-FOC)
|
[](https://github.com/EFeru/hoverboard-firmware-hack-FOC/actions/workflows/build_on_commit.yml)
|
||||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=CU2SWN2XV9SCY¤cy_code=EUR&source=url)
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=CU2SWN2XV9SCY¤cy_code=EUR&source=url)
|
||||||
|
|
||||||
@@ -8,14 +8,13 @@ This repository implements Field Oriented Control (FOC) for stock hoverboards. C
|
|||||||
- smooth torque output and improved motor efficiency. Thus, lower energy consumption
|
- smooth torque output and improved motor efficiency. Thus, lower energy consumption
|
||||||
- field weakening to increase maximum speed range
|
- field weakening to increase maximum speed range
|
||||||
|
|
||||||
|
|
||||||
Table of Contents
|
Table of Contents
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
* **Wiki:** please check the wiki pages for [Getting Started](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki#getting-started) and for [Troubleshooting](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki#troubleshooting)
|
||||||
* [Hardware](#hardware)
|
* [Hardware](#hardware)
|
||||||
* [FOC Firmware](#foc-firmware)
|
* [FOC Firmware](#foc-firmware)
|
||||||
* [Example Variants](#example-variants)
|
* [Example Variants](#example-variants)
|
||||||
* [Wiki](#wiki)
|
|
||||||
* [Projects and Links](#projects-and-links)
|
* [Projects and Links](#projects-and-links)
|
||||||
* [Contributions](#contributions)
|
* [Contributions](#contributions)
|
||||||
|
|
||||||
@@ -97,6 +96,12 @@ In all FOC control modes, the controller features maximum motor speed and maximu
|
|||||||
- The controller parameters are given in [this table](https://github.com/EFeru/bldc-motor-control-FOC/blob/master/02_Figures/paramTable.png)
|
- The controller parameters are given in [this table](https://github.com/EFeru/bldc-motor-control-FOC/blob/master/02_Figures/paramTable.png)
|
||||||
|
|
||||||
|
|
||||||
|
### FOC Webview
|
||||||
|
|
||||||
|
To explore the controller without a Matlab/Simulink installation click on the link below:
|
||||||
|
|
||||||
|
[https://eferu.github.io/bldc-motor-control-FOC/](https://eferu.github.io/bldc-motor-control-FOC/)
|
||||||
|
|
||||||
---
|
---
|
||||||
## Example Variants
|
## Example Variants
|
||||||
|
|
||||||
@@ -114,11 +119,6 @@ In all FOC control modes, the controller features maximum motor speed and maximu
|
|||||||
Of course the firmware can be further customized for other needs or projects.
|
Of course the firmware can be further customized for other needs or projects.
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
## Wiki
|
|
||||||
Please check the wiki for [Getting Started](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki#getting-started) and for [Troubleshooting](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki#troubleshooting)
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
## Projects and Links
|
## Projects and Links
|
||||||
|
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Code generated for Simulink model 'BLDC_controller'.
|
* Code generated for Simulink model 'BLDC_controller'.
|
||||||
*
|
*
|
||||||
* Model version : 1.1296
|
* Model version : 1.1297
|
||||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||||
* C/C++ source code generated on : Tue Oct 20 17:29:57 2020
|
* C/C++ source code generated on : Sun Mar 6 11:02:11 2022
|
||||||
*
|
*
|
||||||
* Target selection: ert.tlc
|
* Target selection: ert.tlc
|
||||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||||
@@ -1019,6 +1019,8 @@ void BLDC_controller_step(RT_MODEL *const rtM)
|
|||||||
int32_T rtb_Sum1_jt;
|
int32_T rtb_Sum1_jt;
|
||||||
int16_T rtb_Merge_m;
|
int16_T rtb_Merge_m;
|
||||||
int16_T rtb_Merge1;
|
int16_T rtb_Merge1;
|
||||||
|
uint16_T rtb_Divide14_e;
|
||||||
|
uint16_T rtb_Divide1_f;
|
||||||
int16_T rtb_TmpSignalConversionAtLow_Pa[2];
|
int16_T rtb_TmpSignalConversionAtLow_Pa[2];
|
||||||
int32_T rtb_Switch1;
|
int32_T rtb_Switch1;
|
||||||
int32_T rtb_Sum1;
|
int32_T rtb_Sum1;
|
||||||
@@ -2116,20 +2118,15 @@ void BLDC_controller_step(RT_MODEL *const rtM)
|
|||||||
|
|
||||||
/* End of Switch: '<S44>/Switch2' */
|
/* End of Switch: '<S44>/Switch2' */
|
||||||
|
|
||||||
/* Switch: '<S42>/Switch2' incorporates:
|
/* Product: '<S42>/Divide14' incorporates:
|
||||||
* Constant: '<S1>/z_ctrlTypSel'
|
* Constant: '<S42>/r_fieldWeakHi'
|
||||||
* Constant: '<S42>/CTRL_COMM2'
|
* Constant: '<S42>/r_fieldWeakLo'
|
||||||
* Constant: '<S42>/a_phaAdvMax'
|
* Sum: '<S42>/Sum1'
|
||||||
* Constant: '<S42>/id_fieldWeakMax'
|
* Sum: '<S42>/Sum3'
|
||||||
* RelationalOperator: '<S42>/Relational Operator1'
|
|
||||||
*/
|
*/
|
||||||
if (rtP->z_ctrlTypSel == 2) {
|
rtb_Divide14_e = (uint16_T)(((int16_T)(DataTypeConversion2 -
|
||||||
rtb_Saturation1 = rtP->id_fieldWeakMax;
|
rtP->r_fieldWeakLo) << 15) / (int16_T)(rtP->r_fieldWeakHi -
|
||||||
} else {
|
rtP->r_fieldWeakLo));
|
||||||
rtb_Saturation1 = rtP->a_phaAdvMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of Switch: '<S42>/Switch2' */
|
|
||||||
|
|
||||||
/* Switch: '<S43>/Switch2' incorporates:
|
/* Switch: '<S43>/Switch2' incorporates:
|
||||||
* Constant: '<S42>/n_fieldWeakAuthHi'
|
* Constant: '<S42>/n_fieldWeakAuthHi'
|
||||||
@@ -2151,25 +2148,53 @@ void BLDC_controller_step(RT_MODEL *const rtM)
|
|||||||
|
|
||||||
/* End of Switch: '<S43>/Switch2' */
|
/* End of Switch: '<S43>/Switch2' */
|
||||||
|
|
||||||
/* Product: '<S42>/Divide3' incorporates:
|
/* Product: '<S42>/Divide1' incorporates:
|
||||||
* Constant: '<S42>/n_fieldWeakAuthHi'
|
* Constant: '<S42>/n_fieldWeakAuthHi'
|
||||||
* Constant: '<S42>/n_fieldWeakAuthLo'
|
* Constant: '<S42>/n_fieldWeakAuthLo'
|
||||||
* Constant: '<S42>/r_fieldWeakHi'
|
|
||||||
* Constant: '<S42>/r_fieldWeakLo'
|
|
||||||
* Product: '<S42>/Divide1'
|
|
||||||
* Product: '<S42>/Divide14'
|
|
||||||
* Product: '<S42>/Divide2'
|
|
||||||
* Sum: '<S42>/Sum1'
|
|
||||||
* Sum: '<S42>/Sum2'
|
* Sum: '<S42>/Sum2'
|
||||||
* Sum: '<S42>/Sum3'
|
|
||||||
* Sum: '<S42>/Sum4'
|
* Sum: '<S42>/Sum4'
|
||||||
*/
|
*/
|
||||||
rtDW->Divide3 = (int16_T)(((uint16_T)(((uint32_T)(uint16_T)(((int16_T)
|
rtb_Divide1_f = (uint16_T)(((int16_T)(rtb_Saturation -
|
||||||
(DataTypeConversion2 - rtP->r_fieldWeakLo) << 15) / (int16_T)
|
rtP->n_fieldWeakAuthLo) << 15) / (int16_T)(rtP->n_fieldWeakAuthHi -
|
||||||
(rtP->r_fieldWeakHi - rtP->r_fieldWeakLo)) * (uint16_T)(((int16_T)
|
rtP->n_fieldWeakAuthLo));
|
||||||
(rtb_Saturation - rtP->n_fieldWeakAuthLo) << 15) / (int16_T)
|
|
||||||
(rtP->n_fieldWeakAuthHi - rtP->n_fieldWeakAuthLo))) >> 15) *
|
/* Switch: '<S42>/Switch1' incorporates:
|
||||||
rtb_Saturation1) >> 15);
|
* MinMax: '<S42>/MinMax1'
|
||||||
|
* RelationalOperator: '<S42>/Relational Operator6'
|
||||||
|
*/
|
||||||
|
if (rtb_Divide14_e < rtb_Divide1_f) {
|
||||||
|
/* MinMax: '<S42>/MinMax' */
|
||||||
|
if (!(rtb_Divide14_e > rtb_Divide1_f)) {
|
||||||
|
rtb_Divide14_e = rtb_Divide1_f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of MinMax: '<S42>/MinMax' */
|
||||||
|
} else {
|
||||||
|
if (rtb_Divide1_f < rtb_Divide14_e) {
|
||||||
|
/* MinMax: '<S42>/MinMax1' */
|
||||||
|
rtb_Divide14_e = rtb_Divide1_f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of Switch: '<S42>/Switch1' */
|
||||||
|
|
||||||
|
/* Switch: '<S42>/Switch2' incorporates:
|
||||||
|
* Constant: '<S1>/z_ctrlTypSel'
|
||||||
|
* Constant: '<S42>/CTRL_COMM2'
|
||||||
|
* Constant: '<S42>/a_phaAdvMax'
|
||||||
|
* Constant: '<S42>/id_fieldWeakMax'
|
||||||
|
* RelationalOperator: '<S42>/Relational Operator1'
|
||||||
|
*/
|
||||||
|
if (rtP->z_ctrlTypSel == 2) {
|
||||||
|
rtb_Saturation1 = rtP->id_fieldWeakMax;
|
||||||
|
} else {
|
||||||
|
rtb_Saturation1 = rtP->a_phaAdvMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of Switch: '<S42>/Switch2' */
|
||||||
|
|
||||||
|
/* Product: '<S42>/Divide3' */
|
||||||
|
rtDW->Divide3 = (int16_T)((rtb_Saturation1 * rtb_Divide14_e) >> 15);
|
||||||
|
|
||||||
/* End of Outputs for SubSystem: '<S6>/Field_Weakening_Enabled' */
|
/* End of Outputs for SubSystem: '<S6>/Field_Weakening_Enabled' */
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Code generated for Simulink model 'BLDC_controller'.
|
* Code generated for Simulink model 'BLDC_controller'.
|
||||||
*
|
*
|
||||||
* Model version : 1.1296
|
* Model version : 1.1297
|
||||||
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
|
||||||
* C/C++ source code generated on : Tue Oct 20 17:29:57 2020
|
* C/C++ source code generated on : Sun Mar 6 11:02:11 2022
|
||||||
*
|
*
|
||||||
* Target selection: ert.tlc
|
* Target selection: ert.tlc
|
||||||
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
* Embedded hardware selection: ARM Compatible->ARM Cortex
|
||||||
|
BIN
docs/pictures/wiki_unlock/download_build.png
Normal file
BIN
docs/pictures/wiki_unlock/download_build.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Reference in New Issue
Block a user