Skip to content
Candas1 edited this page May 31, 2023 · 21 revisions

Parameters are used in config.h to configure the behavior of the firmware, by enabling/disabling features, or adjusting value.

🔋 Battery Management

For parameters related to Battery Management, please visit following wiki section.

🎛️ Motor Control

Motor Control Type, Control Mode and Field Weakening/Phase Advance are described in the readme.

Current and Speed limits

For Current and Speed limits, please visit following wiki section

Variant specific parameters

Variant specific parameters are covered in the wiki section of for each variant.

🕹️ Input Calibration

For Parameters related to Input Calibration, please visit following wiki section.

Further Input processing

After the inputs have been mapped to the MIN, MID and MAX value that have been calibrated, following parameters can help adjust the behavior of the firmware.

📈 Rate limiting

DEFAULT_RATE parameter is used to limit the rate of change of the inputs in the main loop between 2 loop iterations.
This helps smooth out the final ouput to the motor control model.
The default value is 480 in fixed-point, which corresponds to 30 value in single precision.

This means if the input goes from 0 to 300, the firmware will limit the increment to 30 for each loop iteration (5ms)

Iteration Time Input
Value
Limited
Value
0 0ms 0 0
1 5ms 300 30
2 10ms 300 60
3 15ms 300 90
4 20ms 300 120
5 25ms 300 150
6 30ms 300 180
7 35ms 300 210
8 40ms 300 240
9 45ms 300 270
10 50ms 300 300

A rate of 32767 in fixed-point means the value can increase/decrease by an increment of 2047, so basically there is no limiting.
Please don't change this parameter if you don't know what you are doing, this can lead to issues.
⚠ Don't set the RATE parameter higher than 32767, this corresponds to a Negative Rate in single precision value.

📈 Filtering

DEFAULT_FILTER parameter is used to smooth out (low-pass filter) the output value to the motor control.
The default value is 6553 in fixed-point, which corresponds to a filter of 0.1 in single precision.
This means if the input goes from 0 to 300, the output value will be 90% of the previous value + 10% of the new value

Iteration Time Input
Value
Filtered
Value
0 0ms 0 0
1 5ms 300 90% of 0 + 10% of 300 = 30
2 10ms 300 90% of 30 + 10% of 300 = 57
3 15ms 300 90% of 57 + 10% of 300 = 81

A filter of 65535 in fixed-point, which corresponds to 1 in single precision, means no filter will be applied.
You can also define parameter FILTER for a specific variant, it will overwrite DEFAULT_FILTER parameter (e.g. NUNCHUK Variant is using a smoother filter of 3276->0.05 ).

✖️ Coefficients

DEFAULT_STEER_COEFFICIENT and DEFAULT_SPEED_COEFFICIENT parameters can be used to scale INPUT1 and INPUT2 respectively.
The default value for the speed coefficient is 16384 in fixed-point, which corresponds to 1.0 in single precision, it means INPUT2 is not scaled.

  • A value of 8192 in fixed-point means the input value is multiplied by 0.5
  • A value of 32767 in fixed-point means the input value is multiplied by 2
  • A value higher than 32767 in fixed-point means the coefficient is negative(e.g. NUNCHUK variant has a negative STEER_COEFFICIENT)

After the coefficients have been applied, Steer and Speed value are mixed to control left and right motor.
If you don't need steering, you can define STEER_COEFFICIENT parameter as 0, it will overwrite DEFAULT_STEER_COEFFICIENT.

↕↕ Tank Steering

TANK_STEERING parameter can be used to disable the differential steering, each input will drive each motor/wheel individually.
STEER_COEFFICIENT and SPEED_COEFFICIENT parameters will be ignored, but RATE and FILTER are still used.
This parameter is valid for all variant except Hovercar, Skateboard, Transpoter and Hoverboard.

⏪ Invert wheel direction

By default, the firmware assumes the wheels are side by side.
You can use INVERT_R_DIRECTION or INVERT_L_DIRECTION parameter to invert the direction of one wheel. (e.g. on a scooter, both wheels are facing the same direction).

💿 Single wheel use

If you only want to use a single wheel/motor, the firmware will go into error mode because it will detect a motor is missing.
Comment out parameter MOTOR_LEFT_ENA or MOTOR_RIGHT_ENA to disable the wheel you don't need.