Basebot modules: Difference between revisions
(→Motor) |
|||
Line 19: | Line 19: | ||
The minimum corresponds to 0.4V motor voltage. | The minimum corresponds to 0.4V motor voltage. | ||
The motor current uses a HAL sensor | The motor current uses a HAL sensor ACS714; the zero is about 3.3V/2. Other nearby components may influence the values and should be used with caution. | ||
(implemented in ''umotor.cpp'' in function ''motorSetAnchorVoltage()'') | (implemented in ''umotor.cpp'' in function ''motorSetAnchorVoltage()'') |
Revision as of 10:26, 2 September 2024
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 ACS714; the zero is about 3.3V/2. Other nearby components may influence the values and should be used with caution.
(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)