Berkeley Humanoid Lite Docs
  • Home
  • Releases
  • Getting Started with Hardware
    • Materials and Parts (BOM)
    • Preparing the Tools
    • 3D Printing Instructions
    • Building the Actuator
    • Flashing the Motor Controllers
    • Building the Robot
  • Getting Started with Software
    • Software Development Environment Overview
    • Training Environment
    • Sim2sim Validation
    • The On-board Computer
    • Motion Capture System
  • lerobot Integration
  • In-depth Contents
    • Field Oriented Control (FOC) Operation
    • Motor Controller Firmware Execution Timing Information
    • Motor Characterization
    • Actuator Characterization
    • CAN Communication
    • Joint ID Mapping
    • Exporting Robot Description Files from Onshape
    • Domain Randomizations for Training Locomotion
  • Contribute
Powered by GitBook
On this page
  • Initial flash configuration
  • Configuring actuator parameters
  • Calibrate the actuator
  1. Getting Started with Hardware

Flashing the Motor Controllers

PreviousBuilding the ActuatorNextBuilding the Robot

Last updated 27 days ago

We are going to use to flash the motor controllers.

After setting up STM32CubeIDE, download the firmware codebase from the .

git clone git@github.com:T-K-233/Recoil-Motor-Controller-BESC.git

Initial flash configuration

Because we are using the internal Flash of STM32 to store our motor configuration parameters, we need to configure the Flash protection to allow us to read and write to the pages.

Go to Core/Inc/motor_controller_conf.h and set the FIRST_TIME_BOOTUP flag to be 1.

/**
 * First Time Bootup Flag:
 * If this is the first time the device is programmed, set this flag to 1 to configure Flash option byte.
 */
- #define FIRST_TIME_BOOTUP               0             // Set to 1 for the first-time bootup routine, 0 for normal operation
+ #define FIRST_TIME_BOOTUP               1             // Set to 1 for the first-time bootup routine, 0 for normal operation

Connect the motor controller to the computer via the Micro USB port on the controller board. STM32CubeIDE should automatically detect the new device. Then, click the Run button.

In case where it prompts a debugger firmware update, click accept and perform firmware upgrade according to its instructions.

After flashing with the initial configuration program, power-cycle the board by unplug and plug in again the USB cable. Then, change the FIRST_TIME_BOOTUP flag back to 0 and flash the program again.

Configuring actuator parameters

Now we need to load the correct actuator parameters into the Flash. Set LOAD_ID_FROM_FLASH and LOAD_CONFIG_FROM_FLASH flags to 0 so that our program can override the default random values in the Flash. Also configure the CAN ID according to the Joint ID Mapping.

/**
 * Device CAN ID:
 * This macro defines the CAN (Controller Area Network) ID of the device.
 * The CAN ID is a unique identifier for the device on the CAN bus.
 * The value should be set in range [1, 63].
 */
- #define DEVICE_CAN_ID                   1
+ #define DEVICE_CAN_ID                   <correct-can-id>

/**
 * First Time Bootup Flag:
 * If this is the first time the device is programmed, set this flag to 1 to configure Flash option byte.
 */
#define FIRST_TIME_BOOTUP               0             // Set to 1 for the first-time bootup routine, 0 for normal operation


/**
 * Load ID from Flash Flag:
 * This flag specifies whether the device should load the ID configuration from Flash memory.
 */
- #define LOAD_ID_FROM_FLASH              1             // Set to 1 to load ID config from Flash, 0 to load default values
+ #define LOAD_ID_FROM_FLASH              0             // Set to 1 to load ID config from Flash, 0 to load default values

/**
 * Load Config from Flash Flag:
 * This flag specifies whether the device should load the configuration settings from Flash memory.
 * It excludes loading motor flux offset and CAN ID.
 */
- #define LOAD_CONFIG_FROM_FLASH          1             // Set to 1 to load config settings (everything except
+ #define LOAD_CONFIG_FROM_FLASH          0             // Set to 1 to load config settings (everything except
                                                      // motor flux offset and can id) from Flash, 0 to load default values
/**
 * Load Calibration from Flash Flag:
 * This flag indicates whether the device should load the encoder flux offset settings from Flash memory.
 */
#define LOAD_CALIBRATION_FROM_FLASH     1             // Set to 1 to load calibration settings, 0 to load default values

Load the program into the motor controller by clicking Run button. Then, change the flags back to 0 and flash again.

At this point, the Run button should be clicked four times.

Calibrate the actuator

The easiest way to do this is to directly use the on-board computer on the robot after finishing The On-board Computer section.

Run this program to calibrate the electrical position offset. Make sure nothing is attached to the actuator and it is free to spin.

python3 ./berkeley_humanoid_lite_lowlevel/motor/calibrate_electrical_offset.py

WARNING

The motor will spin and draw quite amount of current (~ 1 A from power supply). Make sure the power cables are connected properly and the actuator is free to spin.

STM32CubeIDE
repository
STM32CubeIDE - STMicroelectronicsSTMicroelectronics
Logo