SBB Micro
Source code for the self-balancing-bike microcontroller unit (Teensy 4.1-based). 🚀️
Loading...
Searching...
No Matches
User paramters

User-defined parameters. More...

Macros

#define CPU_FREQ   600e6
 CPU clock speed (Hz). /warning Maximum value is 816e6 without cooling.
 
#define MTR_CTRL_MODE   1
 Control mode of steer motor (0=PWM or 1=DAC).
 
#define EN_LONG_CTRL   1
 Enable the longitudinal control.
 
#define EN_REMOTE_CTRL   0
 Enable the remote controller.
 
#define EN_BRAKE_CTRL   0
 Enable the brake control.
 
#define TEST_THROTTLE   0
 Test the throttle using the remote controller.
 
#define CW   LOW
 Digital pin state for clockwise torque.
 
#define NUM_ZERO_SAMPLES   500
 Samples used to perform the zero of sensors.
 
#define STEERVEL_RATIO   (-36.0*1.25)
 Speed ratio of steer velocity.
 
#define FULLEXT_FORKDISP   0
 Fork displacement at full extended suspension (in mm).
 
#define NAN_VAL   0xFFC00000
 NaN value used for invalid data.
 
#define YINCL_MCUBOX   1.3426
 Pitch iinclination of MCU box (in rad).
 
#define SBB_SPEED   2.5F
 Cruise speed (m/s)
 
#define SBB_ROLL   0.1F
 Turn roll angle (rad)
 
#define SBB_T_CRUISE   2.0F
 Cruise time (s)
 
#define SBB_T_TURN   6.0F
 Cornering time (s)
 

Variables

const float imu_rotMat [3][3]
 Rotation matrix from IMU frame to SAE body-fixed frame.
 
const float mag_rotMat [3][3]
 Rotation matrix from MAG frame to SAE body-fixed frame.
 

Detailed Description

User-defined parameters.

Definition of the user-defined paramters and other miscellanous constants.

Macro Definition Documentation

◆ CPU_FREQ

#define CPU_FREQ   600e6

CPU clock speed (Hz). /warning Maximum value is 816e6 without cooling.

See also
https://www.pjrc.com/store/teensy40.html

◆ CW

#define CW   LOW

Digital pin state for clockwise torque.

◆ EN_BRAKE_CTRL

#define EN_BRAKE_CTRL   0

Enable the brake control.

◆ EN_LONG_CTRL

#define EN_LONG_CTRL   1

Enable the longitudinal control.

◆ EN_REMOTE_CTRL

#define EN_REMOTE_CTRL   0

Enable the remote controller.

◆ FULLEXT_FORKDISP

#define FULLEXT_FORKDISP   0

Fork displacement at full extended suspension (in mm).

◆ MTR_CTRL_MODE

#define MTR_CTRL_MODE   1

Control mode of steer motor (0=PWM or 1=DAC).

Warning
This setting must be consistent with ESCON Studio.

◆ NAN_VAL

#define NAN_VAL   0xFFC00000

NaN value used for invalid data.

◆ NUM_ZERO_SAMPLES

#define NUM_ZERO_SAMPLES   500

Samples used to perform the zero of sensors.

◆ SBB_ROLL

#define SBB_ROLL   0.1F

Turn roll angle (rad)

◆ SBB_SPEED

#define SBB_SPEED   2.5F

Cruise speed (m/s)

◆ SBB_T_CRUISE

#define SBB_T_CRUISE   2.0F

Cruise time (s)

◆ SBB_T_TURN

#define SBB_T_TURN   6.0F

Cornering time (s)

◆ STEERVEL_RATIO

#define STEERVEL_RATIO   (-36.0*1.25)

Speed ratio of steer velocity.

Values from Simulink model.

◆ TEST_THROTTLE

#define TEST_THROTTLE   0

Test the throttle using the remote controller.

◆ YINCL_MCUBOX

#define YINCL_MCUBOX   1.3426

Pitch iinclination of MCU box (in rad).

Value of 76.928deg, found from a static calibration with the IMU.

Variable Documentation

◆ imu_rotMat

const float imu_rotMat[3][3]
Initial value:
= { {0, -cosf(YINCL_MCUBOX), -sinf(YINCL_MCUBOX)},
{-1, 0, 0},
{0, sinf(YINCL_MCUBOX), -cosf(YINCL_MCUBOX)} }
#define YINCL_MCUBOX
Pitch iinclination of MCU box (in rad).
Definition config.h:348

Rotation matrix from IMU frame to SAE body-fixed frame.

This is the result of Rz(90deg)*Rx(180deg)*Ry(YINCL_MCUBOX).

See also
YINCL_MCUBOX

◆ mag_rotMat

const float mag_rotMat[3][3]
Initial value:
= { {cosf(YINCL_MCUBOX), 0, sinf(YINCL_MCUBOX)},
{0, -1, 0},
{-sinf(YINCL_MCUBOX), 0, cosf(YINCL_MCUBOX)} }

Rotation matrix from MAG frame to SAE body-fixed frame.

This is the result of Ry(180deg)*Ry(YINCL_MCUBOX).

See also
YINCL_MCUBOX