diff --git a/.travis.yml b/.travis.yml index c0f71b0..412ed1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,9 +44,7 @@ jobs: before_script: arm-none-eabi-gcc --version - name: platformio - script: platformio run -e VARIANT_ADC -e VARIANT_USART3 -e VARIANT_HOVERCAR -e VARIANT_TRANSPOTTER -e VARIANT_NUNCHUCK -e VARIANT_PPM - env: - - PLATFORMIO_DEFAULT_ENVS=VARIANT_ADC + script: platformio run language: python python: - "2.7" @@ -54,4 +52,4 @@ jobs: - pip install -U platformio - platformio update cache: - - directories: "~/.platformio" + - directories: "~/.platformio" \ No newline at end of file diff --git a/Inc/config.h b/Inc/config.h index dbe955f..fb9e198 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -145,7 +145,7 @@ // ###### CONTROL VIA RC REMOTE ###### // left sensor board cable. Channel 1: steering, Channel 2: speed. #define CONTROL_PPM // use PPM-Sum as input. disable CONTROL_SERIAL_USART2! -//#define PPM_NUM_CHANNELS 6 // total number of PPM channels to receive, even if they are not used. +#define PPM_NUM_CHANNELS 6 // total number of PPM channels to receive, even if they are not used. #endif // ###### CONTROL VIA TWO POTENTIOMETERS ###### @@ -318,7 +318,7 @@ // ############################### VALIDATE SETTINGS ############################### #if !defined(VARIANT_ADC) && !defined(VARIANT_USART3) && !defined(VARIANT_HOVERCAR) && !defined(VARIANT_TRANSPOTTER) && !defined(VARIANT_NUNCHUCK) && !defined(VARIANT_PPM) - #error Variant not defined! Please check platformio.ini or inc/config.h for available variants. + #error Variant not defined! Please check platformio.ini or Inc/config.h for available variants. #endif #if defined(CONTROL_SERIAL_USART2) && defined(CONTROL_SERIAL_USART3) diff --git a/README.md b/README.md index 12d7f28..3f3b77f 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,17 @@ The main firmware architecture includes: - **FOC Algorithm**: implements the FOC strategy - **Control Type Manager**: Manages the transition between Commutation, Sinusoidal, and FOC control type -![Firmware architecture](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/docs/pictures/FW_architecture.png) +![Firmware architecture](/docs/pictures/FW_architecture.png) The FOC algorithm architecture is illustrated in the figure below: -![FOC algorithm](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/docs/pictures/FOC_algorithm.png) +![FOC algorithm](/docs/pictures/FOC_algorithm.png) In this firmware 3 control types are available: - Commutation - SIN (Sinusoidal) - FOC (Field Oriented Control) -![Schematic representation of the available control methods](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/01_Matlab/02_Figures/control_methods.png) +![Schematic representation of the available control methods](/01_Matlab/02_Figures/control_methods.png) Demo videos: @@ -48,13 +48,13 @@ Demo videos: [â–ºVideo: HOVERCAR demo](https://drive.google.com/open?id=18IvRJVdQSsjTg1I0Wedlg19e0FuDjfdS) -![Hoverboard wheel](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/docs/pictures/hoverboard_wheel.JPG) +![Hoverboard wheel](/docs/pictures/hoverboard_wheel.JPG) --- ## General Notes - - The C code for the controller was auto-code generated using [Matlab/Simulink](https://nl.mathworks.com/solutions/embedded-code-generation.html) from a model which I developed from scratch specifically for hoverboard control. For more details regarding the working principle of the controller please consult the [Matlab/Simulink model](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/tree/master/01_Matlab). - - A [webview](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/tree/master/01_Matlab/BLDC_controller_ert_rtw/html/webview) was created, so Matlab/Simulink installation is not needed, unless you want to regenerate the code. The webview is an html page that can be opened with browsers like: Microsoft Internet Explorer or Microsoft Edge. + - The C code for the controller was auto-code generated using [Matlab/Simulink](https://nl.mathworks.com/solutions/embedded-code-generation.html) from a model which I developed from scratch specifically for hoverboard control. For more details regarding the working principle of the controller please consult the [Matlab/Simulink model](/01_Matlab). + - A [webview](/01_Matlab/BLDC_controller_ert_rtw/html/webview) was created, so Matlab/Simulink installation is not needed, unless you want to regenerate the code. The webview is an html page that can be opened with browsers like: Microsoft Internet Explorer or Microsoft Edge. ### Field Weakening / Phase Advance @@ -62,7 +62,7 @@ Demo videos: - The Field Weakening is a linear interpolation from 0 to FIELD_WEAK_MAX or PHASE_ADV_MAX (depeding if FOC or SIN is selected, respectively) - The Field Weakening starts engaging at FIELD_WEAK_LO and reaches the maximum value at FIELD_WEAK_HI - The figure below shows different possible calibrations for Field Weakening / Phase Advance - ![Field Weakening](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/docs/pictures/FieldWeakening.png) + ![Field Weakening](/docs/pictures/FieldWeakening.png) - If you re-calibrate the Field Weakening please take all the safety measures! The motors can spin very fast! @@ -72,7 +72,7 @@ Demo videos: - For calibrating the fixed-point parameters use the [Fixed-Point Viewer](https://github.com/EmanuelFeru/FixedPointViewer) tool - The parameters data Fixed-point types are given in the following table: -![Parameters table](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/docs/pictures/paramTable.png) +![Parameters table](/docs/pictures/paramTable.png) ### Diagnostics @@ -153,9 +153,9 @@ Most robust way for input is to use the ADC and potis. It works well even on 1m --- ## Example variants -This firmware offers currently these variants (selectable in [platformio.ini](platformio.ini) and / or [config.h](/Inc/config.h)): +This firmware offers currently these variants (selectable in [platformio.ini](/platformio.ini) and / or [/Inc/config.h](/Inc/config.h)): - **VARIANT_ADC**: In this variant the motors are controlled by two potentiometers connected to the Left sensor cable (long wired) -- **VARIANT_USART3**: In this variant the motors are controlled via serial protocol on USART3 right sensor cable (short wired). The commands can be sent from an Arduino. Check out the [hoverserial.ino](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/tree/master/02_Arduino/hoverserial) as an example sketch. +- **VARIANT_USART3**: In this variant the motors are controlled via serial protocol on USART3 right sensor cable (short wired). The commands can be sent from an Arduino. Check out the [hoverserial.ino](/02_Arduino/hoverserial) as an example sketch. - **VARIANT_HOVERCAR**: In this variant the motors are controlled by two pedals brake and throttle. Reverse is engaged by double tapping on the brake pedal at standstill. - **VARIANT_TRANSPOTTER**: This build is for transpotter which is a hoverboard based transportation system. For more details on how to build it check [here](https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter) and [here](https://hackaday.io/project/161891-transpotter-ng). - **VARIANT_NUNCHUCK**: Wii Nunchuck offers one hand control for throttle, braking and steering. This was one of the first input device used for electric armchairs or bottle crates. diff --git a/platformio.ini b/platformio.ini index 0e017b7..fd04d77 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,7 +6,9 @@ include_dir = Inc src_dir = Src ;=================== VARIANT SELECTION ========================== -default_envs = UNDEFINED ; +; +; Choose one or all variants get built +; ;default_envs = VARIANT_ADC ; Variant for control via ADC input ;default_envs = VARIANT_USART3 ; Variant for Serial control via USART3 input ;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build