Basebot modules
From Rsewiki
Back to Basebot
Module description
Main code
Support modules
Motor
Motor voltage is translated to a PWM at 65kHz where the average value corresponds to the set motor voltage. Current battery voltage is taken into consideration.
PWM = motorVoltage * MAX_PWM/(battery_voltage - voltageLoss)
The motor controller has a minimum pulse width. If the motor voltage is not zero, a minimum PWM is added to compensate. The minimum corresponds to 0.4V motor voltage.
The motor current uses a HAL sensor, and the zero is about 3.3V/2.
(implemented in umotor.cpp in function motorSetAnchorVoltage())
Gyro and accelerometer
The sensor chip is an MPU9250. Sensor values are extracted from the chip at every sample time, but if the sample time is faster than 1ms, values may be repeated.
The values are available as
imu2.gyro[0..2] for rotation velocity around axis x,y,z in degrees per second. imu2.acc[0..2] for acceleration along x,y,z. X is forward, Y is left, and Z is up.
(implemented in uimu2.cpp)