From bcf3656e958df8814713ba16bfd77ff6de8d9397 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Tue, 8 Mar 2022 19:54:52 +0100 Subject: [PATCH 01/36] Changed configuration --- Inc/config.h | 4 ++-- platformio.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index 65bb8f8..a49fccd 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -143,7 +143,7 @@ // Enable/Disable Motor #define MOTOR_LEFT_ENA // [-] Enable LEFT motor. Comment-out if this motor is not needed to be operational -#define MOTOR_RIGHT_ENA // [-] Enable RIGHT motor. Comment-out if this motor is not needed to be operational +//#define MOTOR_RIGHT_ENA // [-] Enable RIGHT motor. Comment-out if this motor is not needed to be operational // Control selections #define CTRL_TYP_SEL FOC_CTRL // [-] Control type selection: COM_CTRL, SIN_CTRL, FOC_CTRL (default) @@ -156,7 +156,7 @@ #define N_MOT_MAX 1000 // [rpm] Maximum motor speed limit // Field Weakening / Phase Advance -#define FIELD_WEAK_ENA 0 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled +#define FIELD_WEAK_ENA 1 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled #define FIELD_WEAK_MAX 5 // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed. Up to 10A has been tested using 10" wheels. #define PHASE_ADV_MAX 25 // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed. #define FIELD_WEAK_HI 1000 // (1000, 1500] Input target High threshold for reaching maximum Field Weakening / Phase Advance. Do NOT set this higher than 1500. diff --git a/platformio.ini b/platformio.ini index d7612db..e83ee5d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ src_dir = Src ;default_envs = VARIANT_PPM ; Variant for RC-Remotes with PPM-Sum signal ;default_envs = VARIANT_PWM ; Variant for RC-Remotes with PWM signal ;default_envs = VARIANT_IBUS ; Variant for RC-Remotes with FLYSKY IBUS -;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build +default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build ;default_envs = VARIANT_HOVERBOARD ; Variant for HOVERBOARD ;default_envs = VARIANT_TRANSPOTTER ; Variant for TRANSPOTTER build https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter https://hackaday.io/project/161891-transpotter-ng ;default_envs = VARIANT_SKATEBOARD ; Variant for SKATEBOARD build controlled via RC-Remotes with PWM signal From eb784bcf3bf2def75a60992312f24dec6b482674 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:36:01 +0100 Subject: [PATCH 02/36] Create wiki.md --- .github/ISSUE_TEMPLATE/wiki.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/ISSUE_TEMPLATE/wiki.md diff --git a/.github/ISSUE_TEMPLATE/wiki.md b/.github/ISSUE_TEMPLATE/wiki.md new file mode 100644 index 0000000..c783d8a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/wiki.md @@ -0,0 +1 @@ +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) From 33eae7e24b85c0bd389485d2d1fd954defe8262c Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:52:33 +0100 Subject: [PATCH 03/36] Update and rename wiki.md to bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 54 ++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/wiki.md | 1 - 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yaml delete mode 100644 .github/ISSUE_TEMPLATE/wiki.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..d52e97c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,54 @@ +name: 🐞 Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' +body: +- type: dropdown + attributes: + label: Variant + description: What variant of the firmware are you using? + multiple: false + options: + - label: ADC + - label: USART + - label: NUNCHUK + - label: PPM + - label: PWM + - label: IBUS + - label: HOVERCAR + - label: TRANSPOTTER + - label: SKATEBOARD + - label: HOVERBOARD + validations: + required: true +- type: dropdown + attributes: + label: Control type + description: What Control type are you using? + multiple: false + options: + - label: Commutation + - label: Sinusoidale + - label: FOC + validations: + required: true +- type: dropdown + attributes: + label: Control mode + description: What Control mode are you using? + multiple: false + options: + - label: Voltage + - label: Speed + - label: Torque + validations: + required: true + +- type: textarea + attributes: + label: Desciption + description: Describe the bug and how we can reproduce it. + placeholder: Example: bla bla bla + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/wiki.md b/.github/ISSUE_TEMPLATE/wiki.md deleted file mode 100644 index c783d8a..0000000 --- a/.github/ISSUE_TEMPLATE/wiki.md +++ /dev/null @@ -1 +0,0 @@ -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) From e9eb7fa720f41719e0f96397719499a27d69f9ba Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:53:27 +0100 Subject: [PATCH 04/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index d52e97c..9890732 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -49,6 +49,6 @@ body: attributes: label: Desciption description: Describe the bug and how we can reproduce it. - placeholder: Example: bla bla bla + placeholder: bla bla bla validations: required: true From ac33240d202414678c4e34882f700636a90ad4e1 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:54:14 +0100 Subject: [PATCH 05/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 9890732..0f446fd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,8 +1,6 @@ name: 🐞 Bug report -about: Create a report to help us improve -title: '' +title: Create a report to help us improve labels: bug -assignees: '' body: - type: dropdown attributes: From 837fd029908cc139f2ab4c8cbaaef3fd26370eeb Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:55:58 +0100 Subject: [PATCH 06/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 0f446fd..2b7f73e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,6 +1,7 @@ name: 🐞 Bug report -title: Create a report to help us improve -labels: bug +description: Create a report to help us improve +title : "[Bug]: " +labels: "bug" body: - type: dropdown attributes: From 124f3d046a27ccd524e3960ab2d1265ff8e1260d Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:57:53 +0100 Subject: [PATCH 07/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 2b7f73e..a07e736 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -9,16 +9,16 @@ body: description: What variant of the firmware are you using? multiple: false options: - - label: ADC - - label: USART - - label: NUNCHUK - - label: PPM - - label: PWM - - label: IBUS - - label: HOVERCAR - - label: TRANSPOTTER - - label: SKATEBOARD - - label: HOVERBOARD + - ADC + - USART + - NUNCHUK + - PPM + - PWM + - IBUS + - HOVERCAR + - TRANSPOTTER + - SKATEBOARD + - HOVERBOARD validations: required: true - type: dropdown @@ -27,9 +27,9 @@ body: description: What Control type are you using? multiple: false options: - - label: Commutation - - label: Sinusoidale - - label: FOC + - Commutation + - Sinusoidale + - FOC validations: required: true - type: dropdown @@ -38,9 +38,9 @@ body: description: What Control mode are you using? multiple: false options: - - label: Voltage - - label: Speed - - label: Torque + - Voltage + - Speed + - Torque validations: required: true From 785f64778a20e229973db4a594f2b2b011c97f43 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 10:58:41 +0100 Subject: [PATCH 08/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index a07e736..b83ad27 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -46,8 +46,7 @@ body: - type: textarea attributes: - label: Desciption - description: Describe the bug and how we can reproduce it. - placeholder: bla bla bla + label: Description + placeholder: Describe the bug and how we can reproduce it validations: required: true From dfb95cd522e7139d196f98a8a6d562963e1400a4 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 11:06:22 +0100 Subject: [PATCH 09/36] Create question-about-the-firmware.yaml --- .../question-about-the-firmware.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/question-about-the-firmware.yaml diff --git a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml new file mode 100644 index 0000000..d01d446 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml @@ -0,0 +1,52 @@ +name: ❓ Question about the firmware +description: How to use the firmware to... +title : "[Bug]: " +labels: "bug" +body: +- type: dropdown + attributes: + label: Variant + description: What variant of the firmware are you using? + multiple: false + options: + - ADC + - USART + - NUNCHUK + - PPM + - PWM + - IBUS + - HOVERCAR + - TRANSPOTTER + - SKATEBOARD + - HOVERBOARD + validations: + required: true +- type: dropdown + attributes: + label: Control type + description: What Control type are you using? + multiple: false + options: + - Commutation + - Sinusoidale + - FOC + validations: + required: true +- type: dropdown + attributes: + label: Control mode + description: What Control mode are you using? + multiple: false + options: + - Voltage + - Speed + - Torque + validations: + required: true + +- type: textarea + attributes: + label: Description + placeholder: If applicable, indicate what you tried that doesn't work + validations: + required: true From 81c5a0dd443b3b376f45503693944633a2a8bc19 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 11:14:35 +0100 Subject: [PATCH 10/36] Create idea---feature-request.yaml --- .../idea---feature-request.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/idea---feature-request.yaml diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml new file mode 100644 index 0000000..abdd044 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -0,0 +1,58 @@ +name: 🚀 Idea / Feature request +description: Suggest an idea for this project +title : "[Enhancement]: " +labels: "Enhancement" +body: +- type: dropdown + attributes: + label: Variant + description: What variant of the firmware are you using? + multiple: false + options: + - ADC + - USART + - NUNCHUK + - PPM + - PWM + - IBUS + - HOVERCAR + - TRANSPOTTER + - SKATEBOARD + - HOVERBOARD + validations: + required: true +- type: dropdown + attributes: + label: Control type + description: What Control type are you using? + multiple: false + options: + - Commutation + - Sinusoidale + - FOC + validations: + required: true +- type: dropdown + attributes: + label: Control mode + description: What Control mode are you using? + multiple: false + options: + - Voltage + - Speed + - Torque + validations: + required: true + +- type: textarea + attributes: + label: What can we do to make the firmware better? + placeholder: Consider if code examples or images would help communicate your request + validations: + required: true +- type: textarea + attributes: + label: Describe suggestions or alternatives you have considered + placeholder: A clear and concise description of any alternative solutions or features you've considered + validations: + required: true From 9522c4b32544a0bec903a28efe62300c61bee8c1 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 11:15:22 +0100 Subject: [PATCH 11/36] Update question-about-the-firmware.yaml --- .github/ISSUE_TEMPLATE/question-about-the-firmware.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml index d01d446..641b1bb 100644 --- a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml +++ b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml @@ -1,7 +1,7 @@ name: ❓ Question about the firmware description: How to use the firmware to... -title : "[Bug]: " -labels: "bug" +title : "[Question]: " +labels: "question" body: - type: dropdown attributes: From 77bf95771b8bfc85f2896c81e46dcfb498b6dba6 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:12:56 +0100 Subject: [PATCH 12/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index b83ad27..e097c8b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,6 +1,5 @@ name: 🐞 Bug report description: Create a report to help us improve -title : "[Bug]: " labels: "bug" body: - type: dropdown From 4cd8421fa44bcf2e96523731403f87d6c50d9df4 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:13:45 +0100 Subject: [PATCH 13/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index abdd044..571dfa3 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -1,7 +1,6 @@ name: 🚀 Idea / Feature request description: Suggest an idea for this project -title : "[Enhancement]: " -labels: "Enhancement" +labels: "enhancement" body: - type: dropdown attributes: From 453b048382595d97348dd67e7a9b86287fd69c8c Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:14:02 +0100 Subject: [PATCH 14/36] Update question-about-the-firmware.yaml --- .github/ISSUE_TEMPLATE/question-about-the-firmware.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml index 641b1bb..84c00fe 100644 --- a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml +++ b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml @@ -1,6 +1,5 @@ name: ❓ Question about the firmware description: How to use the firmware to... -title : "[Question]: " labels: "question" body: - type: dropdown From 4bd75c59ec67997d523c8e5959c1eff94ae8a32e Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:35:42 +0100 Subject: [PATCH 15/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index e097c8b..df217b2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -2,6 +2,12 @@ name: 🐞 Bug report description: Create a report to help us improve labels: "bug" body: +- type: checkboxes + id: Wiki + attributes: + label: Wiki + options: + - I have already checked the [wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) - type: dropdown attributes: label: Variant From 5001ed556310d65a30775e3cae05bda07c3ea9ad Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:36:16 +0100 Subject: [PATCH 16/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index df217b2..ddc164f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -5,9 +5,9 @@ body: - type: checkboxes id: Wiki attributes: - label: Wiki + label: I have already checked the [wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) options: - - I have already checked the [wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) + - Yes - type: dropdown attributes: label: Variant From 99f36738ce0e7129ea80c84a7c47e6fe15c9628d Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:38:52 +0100 Subject: [PATCH 17/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index ddc164f..56ebfee 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -2,12 +2,9 @@ name: 🐞 Bug report description: Create a report to help us improve labels: "bug" body: -- type: checkboxes - id: Wiki +- type: markdown attributes: - label: I have already checked the [wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) - options: - - Yes + value: Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki), it contains tips for troubleshooting - type: dropdown attributes: label: Variant From ae492d1e096cc98dfddc0dfb2273b6864c6a25dc Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:39:59 +0100 Subject: [PATCH 18/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index 571dfa3..369c34b 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -2,6 +2,9 @@ name: 🚀 Idea / Feature request description: Suggest an idea for this project labels: "enhancement" body: +- type: markdown + attributes: + value: ## Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features - type: dropdown attributes: label: Variant From 8cadd430c56e29757242d9b4f27f56b2cb68defb Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:40:16 +0100 Subject: [PATCH 19/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index 369c34b..d01e97f 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -4,7 +4,7 @@ labels: "enhancement" body: - type: markdown attributes: - value: ## Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features + value: "## Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features" - type: dropdown attributes: label: Variant From 2b0a4ea7ded91f2118035efc2aa3e0c43d6fcce0 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:41:41 +0100 Subject: [PATCH 20/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index d01e97f..0d60804 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -4,7 +4,7 @@ labels: "enhancement" body: - type: markdown attributes: - value: "## Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features" + value: "** Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features **" - type: dropdown attributes: label: Variant From 22b1c76c97c63a9c4af248643d4fee3cc06481c7 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:42:21 +0100 Subject: [PATCH 21/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index 0d60804..a91c0b7 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -4,7 +4,7 @@ labels: "enhancement" body: - type: markdown attributes: - value: "** Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features **" + value: "**Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki) for existing features**" - type: dropdown attributes: label: Variant From 7c247cee4cf913adab51bcd896691076c79e0bf3 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:43:58 +0100 Subject: [PATCH 22/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 56ebfee..46e92d8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -4,7 +4,7 @@ labels: "bug" body: - type: markdown attributes: - value: Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki), it contains tips for troubleshooting + value: "**Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki), it contains tips for troubleshooting**" - type: dropdown attributes: label: Variant From 6a72b03c41954239fa44fc2fe13a371ece32c1ba Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:45:01 +0100 Subject: [PATCH 23/36] Update question-about-the-firmware.yaml --- .github/ISSUE_TEMPLATE/question-about-the-firmware.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml index 84c00fe..03a7a88 100644 --- a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml +++ b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml @@ -2,6 +2,9 @@ name: ❓ Question about the firmware description: How to use the firmware to... labels: "question" body: +- type: markdown + attributes: + value: "**Please check the [Wiki](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki), it might already contain an answer to your question**" - type: dropdown attributes: label: Variant From faae9f9033bee9442467f8a19171e814465f7c63 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 12:59:49 +0100 Subject: [PATCH 24/36] Update bug_report.yaml --- .github/ISSUE_TEMPLATE/bug_report.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 46e92d8..038b635 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -48,7 +48,7 @@ body: - type: textarea attributes: - label: Description - placeholder: Describe the bug and how we can reproduce it + label: What is the bug and how to reproduce it ? + placeholder: Describe the bug and how to reproduce it validations: required: true From baf4a1e69145cd5b4a694f32d518daba9aa4bece Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 13:02:39 +0100 Subject: [PATCH 25/36] Create config.yml --- .github/ISSUE_TEMPLATE/config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false From be6ac57c768224a859d3ccde8bd2a3ae16229492 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 13:06:12 +0100 Subject: [PATCH 26/36] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0..51a6fbe 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,6 @@ blank_issues_enabled: false + +contact_links: + - name: Telegram Community + url: https://t.me/joinchat/BHWO_RKu2LT5ZxEkvUB8uw + about: Connect with the Telegram Community From 3a5cd3331c80c653ef6351313c6c078806a22870 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 13:12:45 +0100 Subject: [PATCH 27/36] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 51a6fbe..b630546 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,6 +1,6 @@ blank_issues_enabled: false contact_links: - - name: Telegram Community + - name: đŸ’Ŧ Telegram Community url: https://t.me/joinchat/BHWO_RKu2LT5ZxEkvUB8uw about: Connect with the Telegram Community From 0057cff9a11b08abcf852cbbbd6a89ffb2ae7e49 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Wed, 23 Mar 2022 13:18:34 +0100 Subject: [PATCH 28/36] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index b630546..7acde52 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,6 +1,9 @@ blank_issues_enabled: false contact_links: + - name: â„šī¸ Wiki Pages + url: https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki + about: Please check the Wiki first - name: đŸ’Ŧ Telegram Community url: https://t.me/joinchat/BHWO_RKu2LT5ZxEkvUB8uw about: Connect with the Telegram Community From b5c6fa0a670177f5896f314cbb973349fe07ca45 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Thu, 24 Mar 2022 10:12:25 +0100 Subject: [PATCH 29/36] Revert "Changed configuration" This reverts commit bcf3656e958df8814713ba16bfd77ff6de8d9397. --- Inc/config.h | 4 ++-- platformio.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index a49fccd..65bb8f8 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -143,7 +143,7 @@ // Enable/Disable Motor #define MOTOR_LEFT_ENA // [-] Enable LEFT motor. Comment-out if this motor is not needed to be operational -//#define MOTOR_RIGHT_ENA // [-] Enable RIGHT motor. Comment-out if this motor is not needed to be operational +#define MOTOR_RIGHT_ENA // [-] Enable RIGHT motor. Comment-out if this motor is not needed to be operational // Control selections #define CTRL_TYP_SEL FOC_CTRL // [-] Control type selection: COM_CTRL, SIN_CTRL, FOC_CTRL (default) @@ -156,7 +156,7 @@ #define N_MOT_MAX 1000 // [rpm] Maximum motor speed limit // Field Weakening / Phase Advance -#define FIELD_WEAK_ENA 1 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled +#define FIELD_WEAK_ENA 0 // [-] Field Weakening / Phase Advance enable flag: 0 = Disabled (default), 1 = Enabled #define FIELD_WEAK_MAX 5 // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed. Up to 10A has been tested using 10" wheels. #define PHASE_ADV_MAX 25 // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed. #define FIELD_WEAK_HI 1000 // (1000, 1500] Input target High threshold for reaching maximum Field Weakening / Phase Advance. Do NOT set this higher than 1500. diff --git a/platformio.ini b/platformio.ini index e83ee5d..d7612db 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ src_dir = Src ;default_envs = VARIANT_PPM ; Variant for RC-Remotes with PPM-Sum signal ;default_envs = VARIANT_PWM ; Variant for RC-Remotes with PWM signal ;default_envs = VARIANT_IBUS ; Variant for RC-Remotes with FLYSKY IBUS -default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build +;default_envs = VARIANT_HOVERCAR ; Variant for HOVERCAR build ;default_envs = VARIANT_HOVERBOARD ; Variant for HOVERBOARD ;default_envs = VARIANT_TRANSPOTTER ; Variant for TRANSPOTTER build https://github.com/NiklasFauth/hoverboard-firmware-hack/wiki/Build-Instruction:-TranspOtter https://hackaday.io/project/161891-transpotter-ng ;default_envs = VARIANT_SKATEBOARD ; Variant for SKATEBOARD build controlled via RC-Remotes with PWM signal From bb119d7a38bae8b5de88d150a37554ea203eb182 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Tue, 29 Mar 2022 21:43:07 +0200 Subject: [PATCH 30/36] Fixes and improvements --- Inc/config.h | 7 +++ Src/comms.c | 2 + Src/main.c | 54 ++++++++++++---- Src/util.c | 169 +++++++++++++++++++++++++++++++-------------------- 4 files changed, 155 insertions(+), 77 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index 65bb8f8..483fcb7 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -78,6 +78,7 @@ #define BAT_CELLS 10 // battery number of cells. Normal Hoverboard battery: 10s #define BAT_LVL2_ENABLE 0 // to beep or not to beep, 1 or 0 #define BAT_LVL1_ENABLE 1 // to beep or not to beep, 1 or 0 +#define BAT_DEAD_ENABLE 1 // to poweroff or not to poweroff, 1 or 0 #define BAT_BLINK_INTERVAL 80 // battery led blink interval (80 loops * 5ms ~= 400ms) #define BAT_LVL5 (390 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // Green blink: no beep #define BAT_LVL4 (380 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // Yellow: no beep @@ -299,6 +300,7 @@ #define DEBUG_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used! #endif + // #define TANK_STEERING // use for tank steering, each input controls each wheel // #define ADC_ALTERNATE_CONNECT // use to swap ADC inputs // #define SUPPORT_BUTTONS_LEFT // use left sensor board cable for button inputs. Disable DEBUG_SERIAL_USART2! // #define SUPPORT_BUTTONS_RIGHT // use right sensor board cable for button inputs. Disable DEBUG_SERIAL_USART3! @@ -330,6 +332,7 @@ #define FLASH_WRITE_KEY 0x1002 // Flash memory writing key. Change this key to ignore the input calibrations from the flash memory and use the ones in config.h #endif + // #define TANK_STEERING // use for tank steering, each input controls each wheel // #define SUPPORT_BUTTONS_LEFT // use left sensor board cable for button inputs. Disable DEBUG_SERIAL_USART2! // #define SUPPORT_BUTTONS_RIGHT // use right sensor board cable for button inputs. Disable DEBUG_SERIAL_USART3! #endif @@ -396,6 +399,7 @@ #endif #define PPM_NUM_CHANNELS 6 // total number of PPM channels to receive, even if they are not used. + // #define TANK_STEERING // use for tank steering, each input controls each wheel // #define SUPPORT_BUTTONS // Define for PPM buttons support // #define SUPPORT_BUTTONS_LEFT // use left sensor board cable for button inputs. Disable DEBUG_SERIAL_USART2! // #define SUPPORT_BUTTONS_RIGHT // use right sensor board cable for button inputs. Disable DEBUG_SERIAL_USART3! @@ -435,6 +439,7 @@ #define FILTER 6553 // 0.1f [-] fixdt(0,16,16) lower value == softer filter [0, 65535] = [0.0 - 1.0]. #define SPEED_COEFFICIENT 16384 // 1.0f [-] fixdt(1,16,14) higher value == stronger. [0, 65535] = [-2.0 - 2.0]. In this case 16384 = 1.0 * 2^14 #define STEER_COEFFICIENT 16384 // 1.0f [-] fixdt(1,16,14) higher value == stronger. [0, 65535] = [-2.0 - 2.0]. In this case 16384 = 1.0 * 2^14. If you do not want any steering, set it to 0. + // #define TANK_STEERING // use for tank steering, each input controls each wheel // #define INVERT_R_DIRECTION // #define INVERT_L_DIRECTION // #define SUPPORT_BUTTONS_LEFT // use left sensor board cable for button inputs. Disable DEBUG_SERIAL_USART2! @@ -479,6 +484,8 @@ #define PRI_INPUT2 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section #endif + // #define TANK_STEERING // use for tank steering, each input controls each wheel + #if defined(CONTROL_SERIAL_USART3) && !defined(DUAL_INPUTS) #define DEBUG_SERIAL_USART2 // left sensor cable debug #elif defined(DEBUG_SERIAL_USART2) && !defined(DUAL_INPUTS) diff --git a/Src/comms.c b/Src/comms.c index 835aded..90219bb 100644 --- a/Src/comms.c +++ b/Src/comms.c @@ -488,6 +488,8 @@ void handle_input(uint8_t *userCommand, uint32_t len) // If there is already an unprocessed command, exit if (command.semaphore == 1) return; + if (*userCommand > 127) return; // reject if first character is not ascii + // Check end of line userCommand+=len-1; // Go to last char if (*userCommand != '\n' && *userCommand != '\r'){ diff --git a/Src/main.c b/Src/main.c index 2f665da..62b551d 100644 --- a/Src/main.c +++ b/Src/main.c @@ -216,7 +216,8 @@ int main(void) { #ifndef VARIANT_TRANSPOTTER // ####### MOTOR ENABLING: Only if the initial input is very small (for SAFETY) ####### - if (enable == 0 && (!rtY_Left.z_errCode && !rtY_Right.z_errCode) && (input1[inIdx].cmd > -50 && input1[inIdx].cmd < 50) && (input2[inIdx].cmd > -50 && input2[inIdx].cmd < 50)){ + if (enable == 0 && !rtY_Left.z_errCode && !rtY_Right.z_errCode && + ABS(input1[inIdx].cmd) < 50 && ABS(input2[inIdx].cmd) < 50){ beepShort(6); // make 2 beeps indicating the motor enable beepShort(4); HAL_Delay(100); steerFixdt = speedFixdt = 0; // reset filters @@ -293,10 +294,15 @@ int main(void) { } #endif - // ####### MIXER ####### - // cmdR = CLAMP((int)(speed * SPEED_COEFFICIENT - steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX); - // cmdL = CLAMP((int)(speed * SPEED_COEFFICIENT + steer * STEER_COEFFICIENT), INPUT_MIN, INPUT_MAX); - mixerFcn(speed << 4, steer << 4, &cmdR, &cmdL); // This function implements the equations above + #if defined(TANK_STEERING) && !defined(VARIANT_HOVERCAR) && !defined(VARIANT_SKATEBOARD) + // Tank steering (no mixing) + cmdL = steer; + cmdR = speed; + #else + // ####### MIXER ####### + mixerFcn(speed << 4, steer << 4, &cmdR, &cmdL); // This function implements the equations above + #endif + // ####### SET OUTPUTS (if the target change is less than +/- 100) ####### #ifdef INVERT_R_DIRECTION @@ -407,14 +413,19 @@ int main(void) { #endif // ####### SIDEBOARDS HANDLING ####### - #if defined(SIDEBOARD_SERIAL_USART2) && defined(FEEDBACK_SERIAL_USART2) - sideboardLeds(&sideboard_leds_L); + #if defined(SIDEBOARD_SERIAL_USART2) sideboardSensors((uint8_t)Sideboard_L.sensors); #endif - #if defined(SIDEBOARD_SERIAL_USART3) && defined(FEEDBACK_SERIAL_USART3) - sideboardLeds(&sideboard_leds_R); + #if defined(FEEDBACK_SERIAL_USART2) + sideboardLeds(&sideboard_leds_L); + #endif + #if defined(SIDEBOARD_SERIAL_USART3) sideboardSensors((uint8_t)Sideboard_R.sensors); #endif + #if defined(FEEDBACK_SERIAL_USART3) + sideboardLeds(&sideboard_leds_R); + #endif + // ####### CALC BOARD TEMPERATURE ####### filtLowPass32(adc_buffer.temp, TEMP_FILT_COEF, &board_temp_adcFixdt); @@ -484,7 +495,15 @@ int main(void) { poweroffPressCheck(); // ####### BEEP AND EMERGENCY POWEROFF ####### - if ((TEMP_POWEROFF_ENABLE && board_temp_deg_c >= TEMP_POWEROFF && speedAvgAbs < 20) || (batVoltage < BAT_DEAD && speedAvgAbs < 20)) { // poweroff before mainboard burns OR low bat 3 + if (TEMP_POWEROFF_ENABLE && board_temp_deg_c >= TEMP_POWEROFF && speedAvgAbs < 20){ // poweroff before mainboard burns OR low bat 3 + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Powering off, temperature is too high\r\n"); + #endif + poweroff(); + } else if ( BAT_DEAD_ENABLE && batVoltage < BAT_DEAD && speedAvgAbs < 20){ + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Powering off, battery voltage is too low\r\n"); + #endif poweroff(); } else if (rtY_Left.z_errCode || rtY_Right.z_errCode) { // 1 beep (low pitch): Motor error, disable motors enable = 0; @@ -510,13 +529,24 @@ int main(void) { } + inactivity_timeout_counter++; + // ####### INACTIVITY TIMEOUT ####### if (abs(cmdL) > 50 || abs(cmdR) > 50) { inactivity_timeout_counter = 0; - } else { - inactivity_timeout_counter++; } + + #if defined(CRUISE_CONTROL_SUPPORT) + if ((abs(rtP_Left.n_cruiseMotTgt) > 50 && rtP_Left.b_cruiseCtrlEna) || + (abs(rtP_Right.n_cruiseMotTgt) > 50 && rtP_Right.b_cruiseCtrlEna)) { + inactivity_timeout_counter = 0; + } + #endif + if (inactivity_timeout_counter > (INACTIVITY_TIMEOUT * 60 * 1000) / (DELAY_IN_MAIN_LOOP + 1)) { // rest of main loop needs maybe 1ms + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Powering off, wheels were inactive for too long\r\n"); + #endif poweroff(); } diff --git a/Src/util.c b/Src/util.c index 7403cd4..4ee899f 100644 --- a/Src/util.c +++ b/Src/util.c @@ -303,6 +303,10 @@ void Input_Init(void) { EE_Init(); /* EEPROM Init */ EE_ReadVariable(VirtAddVarTab[0], &writeCheck); if (writeCheck == FLASH_WRITE_KEY) { + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Using the configuration from EEprom\r\n"); + #endif + EE_ReadVariable(VirtAddVarTab[1] , &readVal); rtP_Left.i_max = rtP_Right.i_max = (int16_t)readVal; EE_ReadVariable(VirtAddVarTab[2] , &readVal); rtP_Left.n_max = rtP_Right.n_max = (int16_t)readVal; for (uint8_t i=0; i old_pos) { // "Linear" buffer mode: check if current position is over previous one usart_process_debug(&rx_buffer_L[old_pos], pos - old_pos); // Process data } else { // "Overflow" buffer mode - memcpy(&ptr[0], &rx_buffer_L[old_pos], rx_buffer_L_len - old_pos); // First copy data from the end of buffer + memcpy(&ptr_debug[0], &rx_buffer_L[old_pos], rx_buffer_L_len - old_pos); // First copy data from the end of buffer if (pos > 0) { // Check and continue with beginning of buffer - memcpy(&ptr[rx_buffer_L_len - old_pos], &rx_buffer_L[0], pos); // Copy remaining data + memcpy(&ptr_debug[rx_buffer_L_len - old_pos], &rx_buffer_L[0], pos); // Copy remaining data } - usart_process_debug(ptr, rx_buffer_L_len - old_pos + pos); // Process data + usart_process_debug(ptr_debug, rx_buffer_L_len - old_pos + pos); // Process data } } #endif // DEBUG_SERIAL_USART2 @@ -1130,17 +1158,17 @@ void usart3_rx_check(void) #endif #if defined(DEBUG_SERIAL_USART3) - uint8_t ptr[SERIAL_BUFFER_SIZE]; + uint8_t ptr_debug[SERIAL_BUFFER_SIZE]; if (pos != old_pos) { // Check change in received data if (pos > old_pos) { // "Linear" buffer mode: check if current position is over previous one usart_process_debug(&rx_buffer_R[old_pos], pos - old_pos); // Process data } else { // "Overflow" buffer mode - memcpy(&ptr[0], &rx_buffer_R[old_pos], rx_buffer_R_len - old_pos); // First copy data from the end of buffer + memcpy(&ptr_debug[0], &rx_buffer_R[old_pos], rx_buffer_R_len - old_pos); // First copy data from the end of buffer if (pos > 0) { // Check and continue with beginning of buffer - memcpy(&ptr[rx_buffer_R_len - old_pos], &rx_buffer_R[0], pos); // Copy remaining data + memcpy(&ptr_debug[rx_buffer_R_len - old_pos], &rx_buffer_R[0], pos); // Copy remaining data } - usart_process_debug(ptr, rx_buffer_R_len - old_pos + pos); // Process data + usart_process_debug(ptr_debug, rx_buffer_R_len - old_pos + pos); // Process data } } #endif // DEBUG_SERIAL_USART3 @@ -1387,9 +1415,7 @@ void sideboardSensors(uint8_t sensors) { sensor1_prev = sensor1_index; } else { // Use Optical switches sensor1_trig = (sensors & SENSOR1_SET) && !sensor1_prev; // rising edge detection - sensor2_trig = (sensors & SENSOR2_SET) && !sensor2_prev; // rising edge detection sensor1_prev = sensors & SENSOR1_SET; - sensor2_prev = sensors & SENSOR2_SET; } // Control MODE and Control Type Handling @@ -1418,11 +1444,7 @@ void sideboardSensors(uint8_t sensors) { if (++sensor1_index > 4) { sensor1_index = 0; } } - #ifdef CRUISE_CONTROL_SUPPORT // Cruise Control Activation/Deactivation - if (sensor2_trig) { - cruiseControl(sensor2_trig); - } - #else // Field Weakening Activation/Deactivation + // Field Weakening Activation/Deactivation static uint8_t sensor2_index = 1; // holds the press index number for sensor2, when used as a button // Override in case the Sideboard control is Active @@ -1433,25 +1455,33 @@ void sideboardSensors(uint8_t sensors) { sensor2_trig = 1; } sensor2_prev = sensor2_index; + }else{ + sensor2_trig = (sensors & SENSOR2_SET) && !sensor2_prev; // rising edge detection + sensor2_prev = sensors & SENSOR2_SET; } - if (sensor2_trig) { - switch (sensor2_index) { - case 0: // FW Disabled - rtP_Left.b_fieldWeakEna = 0; - rtP_Right.b_fieldWeakEna = 0; - Input_Lim_Init(); - break; - case 1: // FW Enabled - rtP_Left.b_fieldWeakEna = 1; - rtP_Right.b_fieldWeakEna = 1; - Input_Lim_Init(); - break; + #ifdef CRUISE_CONTROL_SUPPORT // Cruise Control Activation/Deactivation + if (sensor2_trig) { + cruiseControl(sensor2_trig); } - if (inIdx == inIdx_prev) { beepShortMany(sensor2_index + 1, 1); } - if (++sensor2_index > 1) { sensor2_index = 0; } - } - #endif // CRUISE_CONTROL_SUPPORT + #else + if (sensor2_trig) { + switch (sensor2_index) { + case 0: // FW Disabled + rtP_Left.b_fieldWeakEna = 0; + rtP_Right.b_fieldWeakEna = 0; + Input_Lim_Init(); + break; + case 1: // FW Enabled + rtP_Left.b_fieldWeakEna = 1; + rtP_Right.b_fieldWeakEna = 1; + Input_Lim_Init(); + break; + } + if (inIdx == inIdx_prev) { beepShortMany(sensor2_index + 1, 1); } + if (++sensor2_index > 1) { sensor2_index = 0; } + } + #endif // CRUISE_CONTROL_SUPPORT #endif } @@ -1473,6 +1503,10 @@ void saveConfig() { #endif #if !defined(VARIANT_HOVERBOARD) && !defined(VARIANT_TRANSPOTTER) if (inp_cal_valid || cur_spd_valid) { + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Saving configuration to EEprom\r\n"); + #endif + HAL_FLASH_Unlock(); EE_WriteVariable(VirtAddVarTab[0] , (uint16_t)FLASH_WRITE_KEY); EE_WriteVariable(VirtAddVarTab[1] , (uint16_t)rtP_Left.i_max); @@ -1513,12 +1547,14 @@ void poweroff(void) { void poweroffPressCheck(void) { #if !defined(VARIANT_HOVERBOARD) && !defined(VARIANT_TRANSPOTTER) if(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { - enable = 0; uint16_t cnt_press = 0; while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { HAL_Delay(10); if (cnt_press++ == 5 * 100) { beepShort(5); } } + + if (cnt_press > 8) enable = 0; + if (cnt_press >= 5 * 100) { // Check if press is more than 5 sec HAL_Delay(1000); if (HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { // Double press: Adjust Max Current, Max Speed @@ -1534,7 +1570,10 @@ void poweroffPressCheck(void) { #endif } } else if (cnt_press > 8) { // Short press: power off (80 ms debounce) - poweroff(); + #if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3) + printf("Powering off, button has been pressed\r\n"); + #endif + poweroff(); } } #elif defined(VARIANT_TRANSPOTTER) @@ -1634,22 +1673,22 @@ void rateLimiter16(int16_t u, int16_t rate, int16_t *y) { * Parameters: SPEED_COEFFICIENT, STEER_COEFFICIENT = fixdt(0,16,14) */ void mixerFcn(int16_t rtu_speed, int16_t rtu_steer, int16_t *rty_speedR, int16_t *rty_speedL) { - int16_t prodSpeed; - int16_t prodSteer; - int32_t tmp; + int16_t prodSpeed; + int16_t prodSteer; + int32_t tmp; - prodSpeed = (int16_t)((rtu_speed * (int16_t)SPEED_COEFFICIENT) >> 14); - prodSteer = (int16_t)((rtu_steer * (int16_t)STEER_COEFFICIENT) >> 14); + prodSpeed = (int16_t)((rtu_speed * (int16_t)SPEED_COEFFICIENT) >> 14); + prodSteer = (int16_t)((rtu_steer * (int16_t)STEER_COEFFICIENT) >> 14); - tmp = prodSpeed - prodSteer; - tmp = CLAMP(tmp, -32768, 32767); // Overflow protection - *rty_speedR = (int16_t)(tmp >> 4); // Convert from fixed-point to int - *rty_speedR = CLAMP(*rty_speedR, INPUT_MIN, INPUT_MAX); + tmp = prodSpeed - prodSteer; + tmp = CLAMP(tmp, -32768, 32767); // Overflow protection + *rty_speedR = (int16_t)(tmp >> 4); // Convert from fixed-point to int + *rty_speedR = CLAMP(*rty_speedR, INPUT_MIN, INPUT_MAX); - tmp = prodSpeed + prodSteer; - tmp = CLAMP(tmp, -32768, 32767); // Overflow protection - *rty_speedL = (int16_t)(tmp >> 4); // Convert from fixed-point to int - *rty_speedL = CLAMP(*rty_speedL, INPUT_MIN, INPUT_MAX); + tmp = prodSpeed + prodSteer; + tmp = CLAMP(tmp, -32768, 32767); // Overflow protection + *rty_speedL = (int16_t)(tmp >> 4); // Convert from fixed-point to int + *rty_speedL = CLAMP(*rty_speedL, INPUT_MIN, INPUT_MAX); } From 5612af0a90531012d3404353fb0fc9e1b16eb987 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Mon, 25 Apr 2022 21:11:55 +0200 Subject: [PATCH 31/36] Fix average speed --- Inc/config.h | 2 +- Src/comms.c | 6 +++--- Src/util.c | 29 +++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index 483fcb7..f78bd19 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -318,7 +318,7 @@ // #define SIDEBOARD_SERIAL_USART3 0 // #define CONTROL_SERIAL_USART3 0 // right sensor board cable. Number indicates priority for dual-input. Disable if I2C (nunchuk or lcd) is used! For Arduino control check the hoverSerial.ino // #define FEEDBACK_SERIAL_USART3 // right sensor board cable, disable if I2C (nunchuk or lcd) is used! - + // #define DUAL_INPUTS // UART*(Primary) + SIDEBOARD(Auxiliary). Uncomment this to use Dual-inputs #define PRI_INPUT1 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section #define PRI_INPUT2 3, -1000, 0, 1000, 0 // TYPE, MIN, MID, MAX, DEADBAND. See INPUT FORMAT section diff --git a/Src/comms.c b/Src/comms.c index 90219bb..73eb93d 100644 --- a/Src/comms.c +++ b/Src/comms.c @@ -487,9 +487,8 @@ void handle_input(uint8_t *userCommand, uint32_t len) // If there is already an unprocessed command, exit if (command.semaphore == 1) return; - - if (*userCommand > 127) return; // reject if first character is not ascii - + if (*userCommand != '$') return; // reject if first character is not # + // Check end of line userCommand+=len-1; // Go to last char if (*userCommand != '\n' && *userCommand != '\r'){ @@ -497,6 +496,7 @@ void handle_input(uint8_t *userCommand, uint32_t len) return; } userCommand-=len-1; // Come back + userCommand++; // Skip # int8_t cindex = -1; int8_t pindex = -1; diff --git a/Src/util.c b/Src/util.c index 4ee899f..419acfc 100644 --- a/Src/util.c +++ b/Src/util.c @@ -460,13 +460,34 @@ void beepShortMany(uint8_t cnt, int8_t dir) { void calcAvgSpeed(void) { // Calculate measured average speed. The minus sign (-) is because motors spin in opposite directions #if !defined(INVERT_L_DIRECTION) && !defined(INVERT_R_DIRECTION) - speedAvg = ( rtY_Left.n_mot - rtY_Right.n_mot) / 2; + speedAvg = ( rtY_Left.n_mot - rtY_Right.n_mot); #elif !defined(INVERT_L_DIRECTION) && defined(INVERT_R_DIRECTION) - speedAvg = ( rtY_Left.n_mot + rtY_Right.n_mot) / 2; + speedAvg = ( rtY_Left.n_mot + rtY_Right.n_mot); #elif defined(INVERT_L_DIRECTION) && !defined(INVERT_R_DIRECTION) - speedAvg = (-rtY_Left.n_mot - rtY_Right.n_mot) / 2; + speedAvg = (-rtY_Left.n_mot - rtY_Right.n_mot); #elif defined(INVERT_L_DIRECTION) && defined(INVERT_R_DIRECTION) - speedAvg = (-rtY_Left.n_mot + rtY_Right.n_mot) / 2; + speedAvg = (-rtY_Left.n_mot + rtY_Right.n_mot); + #endif + + speedAvg = 0; + #if defined(MOTOR_LEFT_ENA) + #if defined(INVERT_L_DIRECTION) + speedAvg -= rtY_Left.n_mot; + #else + speedAvg += rtY_Left.n_mot; + #endif + #endif + #if defined(MOTOR_RIGHT_ENA) + #if defined(INVERT_R_DIRECTION) + speedAvg += rtY_Right.n_mot; + #else + speedAvg -= rtY_Right.n_mot; + #endif + + // Average only if both motors are enabled + #if defined(MOTOR_LEFT_ENA) + speedAvg /= 2; + #endif #endif // Handle the case when SPEED_COEFFICIENT sign is negative (which is when most significant bit is 1) From 2fbeb1fca4c410cf2c5bf2b7d6930dc9d87d21e2 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Mon, 25 Apr 2022 21:16:55 +0200 Subject: [PATCH 32/36] Update idea---feature-request.yaml --- .github/ISSUE_TEMPLATE/idea---feature-request.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml index a91c0b7..fa24909 100644 --- a/.github/ISSUE_TEMPLATE/idea---feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/idea---feature-request.yaml @@ -22,7 +22,7 @@ body: - SKATEBOARD - HOVERBOARD validations: - required: true + required: false - type: dropdown attributes: label: Control type @@ -33,7 +33,7 @@ body: - Sinusoidale - FOC validations: - required: true + required: false - type: dropdown attributes: label: Control mode @@ -44,7 +44,7 @@ body: - Speed - Torque validations: - required: true + required: false - type: textarea attributes: From ac489d51e64b5fb766817a141092233345d7996a Mon Sep 17 00:00:00 2001 From: Candas1 Date: Mon, 25 Apr 2022 21:17:41 +0200 Subject: [PATCH 33/36] Update question-about-the-firmware.yaml --- .github/ISSUE_TEMPLATE/question-about-the-firmware.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml index 03a7a88..0aa55cd 100644 --- a/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml +++ b/.github/ISSUE_TEMPLATE/question-about-the-firmware.yaml @@ -22,7 +22,7 @@ body: - SKATEBOARD - HOVERBOARD validations: - required: true + required: false - type: dropdown attributes: label: Control type @@ -33,7 +33,7 @@ body: - Sinusoidale - FOC validations: - required: true + required: false - type: dropdown attributes: label: Control mode @@ -44,7 +44,7 @@ body: - Speed - Torque validations: - required: true + required: false - type: textarea attributes: From 31326ad15897f4f323c3c079dc5350a81fdc11d7 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Mon, 25 Apr 2022 21:21:52 +0200 Subject: [PATCH 34/36] Update comms.c --- Src/comms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/comms.c b/Src/comms.c index 73eb93d..71aa770 100644 --- a/Src/comms.c +++ b/Src/comms.c @@ -487,7 +487,7 @@ void handle_input(uint8_t *userCommand, uint32_t len) // If there is already an unprocessed command, exit if (command.semaphore == 1) return; - if (*userCommand != '$') return; // reject if first character is not # + if (*userCommand != '$') return; // reject if first character is not $ // Check end of line userCommand+=len-1; // Go to last char @@ -496,7 +496,7 @@ void handle_input(uint8_t *userCommand, uint32_t len) return; } userCommand-=len-1; // Come back - userCommand++; // Skip # + userCommand++; // Skip $ int8_t cindex = -1; int8_t pindex = -1; From 29535a26e67bac30b05edd1244414c8d01f78524 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Mon, 25 Apr 2022 21:31:14 +0200 Subject: [PATCH 35/36] Update util.c --- Src/util.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Src/util.c b/Src/util.c index 419acfc..cf46bff 100644 --- a/Src/util.c +++ b/Src/util.c @@ -459,16 +459,6 @@ void beepShortMany(uint8_t cnt, int8_t dir) { void calcAvgSpeed(void) { // Calculate measured average speed. The minus sign (-) is because motors spin in opposite directions - #if !defined(INVERT_L_DIRECTION) && !defined(INVERT_R_DIRECTION) - speedAvg = ( rtY_Left.n_mot - rtY_Right.n_mot); - #elif !defined(INVERT_L_DIRECTION) && defined(INVERT_R_DIRECTION) - speedAvg = ( rtY_Left.n_mot + rtY_Right.n_mot); - #elif defined(INVERT_L_DIRECTION) && !defined(INVERT_R_DIRECTION) - speedAvg = (-rtY_Left.n_mot - rtY_Right.n_mot); - #elif defined(INVERT_L_DIRECTION) && defined(INVERT_R_DIRECTION) - speedAvg = (-rtY_Left.n_mot + rtY_Right.n_mot); - #endif - speedAvg = 0; #if defined(MOTOR_LEFT_ENA) #if defined(INVERT_L_DIRECTION) From 12cc722cef056a4eeca641eba3fe5569031736a7 Mon Sep 17 00:00:00 2001 From: Candas1 Date: Sat, 30 Apr 2022 13:53:49 +0200 Subject: [PATCH 36/36] Fixes --- Src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/main.c b/Src/main.c index 62b551d..ce2b142 100644 --- a/Src/main.c +++ b/Src/main.c @@ -520,7 +520,7 @@ int main(void) { beepCount(0, 10, 6); } else if (BAT_LVL2_ENABLE && batVoltage < BAT_LVL2) { // 1 beep slow (medium pitch): Low bat 2 beepCount(0, 10, 30); - } else if (BEEPS_BACKWARD && ((speed < -50 && speedAvg < 0) || MultipleTapBrake.b_multipleTap)) { // 1 beep fast (high pitch): Backward spinning motors + } else if (BEEPS_BACKWARD && (((cmdR < -50 || cmdL < -50) && speedAvg < 0) || MultipleTapBrake.b_multipleTap)) { // 1 beep fast (high pitch): Backward spinning motors beepCount(0, 5, 1); backwardDrive = 1; } else { // do not beep @@ -536,7 +536,7 @@ int main(void) { inactivity_timeout_counter = 0; } - #if defined(CRUISE_CONTROL_SUPPORT) + #if defined(CRUISE_CONTROL_SUPPORT) || defined(STANDSTILL_HOLD_ENABLE) if ((abs(rtP_Left.n_cruiseMotTgt) > 50 && rtP_Left.b_cruiseCtrlEna) || (abs(rtP_Right.n_cruiseMotTgt) > 50 && rtP_Right.b_cruiseCtrlEna)) { inactivity_timeout_counter = 0;