mirror of
https://github.com/EFeru/hoverboard-firmware-hack-FOC.git
synced 2025-08-05 02:24:26 +02:00
Updated Input Calibration (markdown)
@@ -4,18 +4,43 @@ Input Calibration is required to identify:
|
|||||||
* the middle value (e.g center of the joystick) for mid-resting pots
|
* the middle value (e.g center of the joystick) for mid-resting pots
|
||||||
|
|
||||||
At startup, for safety reasons, the firmware won't enable the motors if the input is not very small (between -50 and 50).<br>
|
At startup, for safety reasons, the firmware won't enable the motors if the input is not very small (between -50 and 50).<br>
|
||||||
If you don't hear beeps after the turn on melody, it means the motors are not enabled as they would start to spin otherwise.<br>
|
If you don't hear a single beep after the Power On melody, it means the motors are not enabled as they would start to spin otherwise.<br>
|
||||||
You need to calibrate your inputs either manually or with the auto-calibration.<br>
|
You need to calibrate your inputs either manually or with the auto-calibration.<br>
|
||||||
|
|
||||||
# Manual Calibration:
|
|
||||||
|
|
||||||
Setting the type of input:
|
# Type of inputs
|
||||||
|
### (0) Disabled input
|
||||||
|
This type of input has to be used if you don't need one of the inputs and want it to be ignored. The ouput will always be 0.<br>
|
||||||
|
The [skateboard](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Variant-SKATEBOARD) variant for example is only using one input.
|
||||||
|
|
||||||
|
### (1) Normal pot
|
||||||
|
This type of input will be mapped to a positive ouput(voltage/speed/torque) only.<br>
|
||||||
|
0----------> INPUT_MAX(1000)
|
||||||
|
|
||||||
|
The [hovercar](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Variant-HOVERCAR) variant for example is using such inputs (throttle/brake handles or pedals)
|
||||||
|
|
||||||
|
### (2) Mid-resting pot
|
||||||
|
This type of input will be mapped to a positive and negative ouput(voltage/speed/torque) on each side of the resting/middle position.<br>
|
||||||
|
INPUT_MIN(-1000) <----------0----------> INPUT_MAX(1000)
|
||||||
|
|
||||||
|
The [Nunchuk](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Variant-Nunchuk) variant is using such input types.
|
||||||
|
|
||||||
|
### (3) Automatic
|
||||||
|
This type of input will be automatically be identified when you proceed with the [auto-calibration](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Input-Calibration#auto-calibration).<br>
|
||||||
|
The [ADC](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Variant-ADC) variant is using such input types.
|
||||||
|
|
||||||
|
|
||||||
|
# Manual Calibration:
|
||||||
|
Manual Calibration has to be done in [config.h](https://github.com/EFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h) in the section related to the variant you have selected.<br>
|
||||||
|
Make sure you are updating the primary input. Auxiliary inputs are for [Dual input](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Dual-Inputs).
|
||||||
|
|
||||||
|
### Setting the type of input:
|
||||||
* If you don't need an input, disable it by setting INPUT1_TYPE or INPUT2_TYPE to 0, it will be ignored
|
* If you don't need an input, disable it by setting INPUT1_TYPE or INPUT2_TYPE to 0, it will be ignored
|
||||||
* For normal potis, set INPUT1_TYPE or INPUT2_TYPE to 1
|
* For normal potis, set INPUT1_TYPE or INPUT2_TYPE to 1
|
||||||
* For middle resting potis, set INPUT1_TYPE or INPUT2_TYPE to 2
|
* For middle resting potis(e.g. Joystick), set INPUT1_TYPE or INPUT2_TYPE to 2
|
||||||
* If INPUT1_TYPE or INPUT2_TYPE is set to 3, the right input type will be automatically identified during auto-calibration
|
* If INPUT1_TYPE or INPUT2_TYPE is set to 3, the right input type will be identified when you proceed with the auto-calibration
|
||||||
|
|
||||||
Setting Minimum, Middle and Maximum position:
|
### Setting Minimum, Middle and Maximum position:
|
||||||
* Connect FTDI RX to blue wire from right sensor board cable to read USART DEBUG values, baud rate should be 115200 bauds (38400 bauds in older versions of the firmware)
|
* Connect FTDI RX to blue wire from right sensor board cable to read USART DEBUG values, baud rate should be 115200 bauds (38400 bauds in older versions of the firmware)
|
||||||
* Turn the potis to minimum position, write value 1: to **INPUT1_MIN** and value 2: to **INPUT2_MIN** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h)
|
* Turn the potis to minimum position, write value 1: to **INPUT1_MIN** and value 2: to **INPUT2_MIN** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h)
|
||||||
* Turn the potis to maximum position, write value 1: to **INPUT1_MAX** and value 2: to **INPUT2_MAX** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h)
|
* Turn the potis to maximum position, write value 1: to **INPUT1_MAX** and value 2: to **INPUT2_MAX** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h)
|
||||||
@@ -23,15 +48,28 @@ Setting Minimum, Middle and Maximum position:
|
|||||||
|
|
||||||
[Config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h) values will be ignored if you have already used the auto-calibration procedure below.
|
[Config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h) values will be ignored if you have already used the auto-calibration procedure below.
|
||||||
|
|
||||||
|
### Deadband
|
||||||
|
DEADBAND parameter is used to set a dead area around the MIN or MID value that will still map to a zero input value.<br>
|
||||||
|
For Normal pots:
|
||||||
|
* Deadband>0----------> INPUT_MAX(1000)<br>
|
||||||
|
|
||||||
|
For Mid-resting pots:
|
||||||
|
* INPUT_MIN(-1000) <----------0< Deadband >0----------> INPUT_MAX(1000)<br>
|
||||||
|
|
||||||
|
This is for example used with [PWM](https://github.com/EFeru/hoverboard-firmware-hack-FOC/wiki/Variant-PWM) variant to prevent jitters at standstill due to signal noise.<br>
|
||||||
|
It can also help in addition to the auto-calibration if your joystick is not perfectly centered.<br>
|
||||||
|
|
||||||
# Auto-calibration:
|
# Auto-calibration:
|
||||||
Auto-calibration finds the minimum, middle and maximum values for the inputs.
|
Auto-calibration finds the minimum, middle and maximum values for the inputs.
|
||||||
It also identifies the type of input and checks if it can be protected (ADC only).
|
It also identifies the type of input and checks if it can be protected (ADC only).
|
||||||
|
|
||||||
|
### How to enter auto-calibration mode
|
||||||
* Turn the board on and press the power button for more than 5 sec and release after the beep sound
|
* Turn the board on and press the power button for more than 5 sec and release after the beep sound
|
||||||
* Move the potis freely to the min and max limits repeatedly
|
* Move the potis freely to the min and max limits repeatedly
|
||||||
* Release potis to the resting position
|
* Release potis to the resting position
|
||||||
* Press the power button to confirm or wait for the 20 sec timeout
|
* Press the power button to confirm or wait for the 20 sec timeout
|
||||||
|
|
||||||
|
### Input type identification
|
||||||
If you haven't moved one of the inputs, if it's floating or is grounded, it will be identified as inactive and ignored(type=0).<br />
|
If you haven't moved one of the inputs, if it's floating or is grounded, it will be identified as inactive and ignored(type=0).<br />
|
||||||
If min and mid values are close, the inputs will be identified as normal potis(type=1).<br />
|
If min and mid values are close, the inputs will be identified as normal potis(type=1).<br />
|
||||||
Otherwise the inputs will be identified as middle resting potis(type=2).<br />
|
Otherwise the inputs will be identified as middle resting potis(type=2).<br />
|
||||||
@@ -39,6 +77,7 @@ Otherwise the inputs will be identified as middle resting potis(type=2).<br />
|
|||||||
For inputs with type 3 (AUTO) in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h), auto-calibration will automatically identify the right input type.
|
For inputs with type 3 (AUTO) in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h), auto-calibration will automatically identify the right input type.
|
||||||
If input type 0,1,2 has been selected in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h), auto-calibration will fail if identified input type is not matching and disable the input.
|
If input type 0,1,2 has been selected in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h), auto-calibration will fail if identified input type is not matching and disable the input.
|
||||||
|
|
||||||
|
### Debug output
|
||||||
If you use [Debug Serial](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/wiki/Debug-Serial), you can see the results of auto-calibration procedure:
|
If you use [Debug Serial](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/wiki/Debug-Serial), you can see the results of auto-calibration procedure:
|
||||||
```
|
```
|
||||||
Input calibration started...
|
Input calibration started...
|
||||||
@@ -52,9 +91,11 @@ In this example:
|
|||||||
* Input1 was ignored as it was not connected or wasn't moved
|
* Input1 was ignored as it was not connected or wasn't moved
|
||||||
* Input2 was identified as a normal pot (pedal or throttle handle), and the minimum value is high enough to detect a floating input pulled to ground. If firmware reads a value below 915 ( MIN - ADC_PROTECT_THRESH ) for ADC_PROTECT_TIMEOUT time, it will trigger an ADC Timeout error.
|
* Input2 was identified as a normal pot (pedal or throttle handle), and the minimum value is high enough to detect a floating input pulled to ground. If firmware reads a value below 915 ( MIN - ADC_PROTECT_THRESH ) for ADC_PROTECT_TIMEOUT time, it will trigger an ADC Timeout error.
|
||||||
|
|
||||||
|
### Saving the calibration
|
||||||
The limits will be saved/overwritten in flash memory when you turn the board off by pressing the button.
|
The limits will be saved/overwritten in flash memory when you turn the board off by pressing the button.
|
||||||
|
|
||||||
⚠The input limits (and maximum current and speed settings) will be persisted in flash memory even if you flash the firmware again, the only way to delete it is to fully erase the chip in st-utility before flashing.<br />
|
⚠The input limits (and maximum current and speed settings) will be persisted in flash memory even if you flash the firmware again, the only way to delete it is to fully erase the chip in st-utility before flashing.<br />
|
||||||
An alternative to bypass those limits is to change **FLASH_WRITE_KEY** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h).
|
An alternative to bypass those limits is to change **FLASH_WRITE_KEY** in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h).
|
||||||
|
|
||||||
|
### Turning auto-calibration OFF
|
||||||
If you have no use of auto-calibration feature and want to turn it off not to accidentally start this mode, you can disable it in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h) by commenting parameter AUTO_CALIBRATION_ENA. Firmware will still use previously saved auto-calibration values.
|
If you have no use of auto-calibration feature and want to turn it off not to accidentally start this mode, you can disable it in [config.h](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/master/Inc/config.h) by commenting parameter AUTO_CALIBRATION_ENA. Firmware will still use previously saved auto-calibration values.
|
Reference in New Issue
Block a user