This project contains the MCAD and source files for a BLDC motor test stand, designed to enable running various experiments in openloop control, closed loop control, and user interface / haptics using a small BLDC motor that's commonly used in camera gimbals.
The code supports running on the custom BLDC Test Stand (TinyS3 Test Stand
),
as well as on the MotorGo-Mini
. You can select which hardware you want to run
on via menuconfig
.
Either:
- TinyS3 Test Stand:
- TinyS3
- BLDC Motor (I used these A and B motors from aliexpress)
- MT6701 Magnetic Encoder Breakout (I used this purple one (color B) from aliexpress)
- TMC6300 BOB
- Mini solderless breadboard
- 3d printed test stand enclosure (.stl and source files in the mcad directory)
- Benchtop power supply (currently running at 5V 1A so many things should work) or:
- MotorGo-Mini
idf.py menuconfig
Select which hardware you are building and deploying to.
Build the project and flash it to the board, then run monitor tool to view serial output:
idf.py -p PORT flash monitor
(Replace PORT with the name of the serial port to use.)
(To exit the serial monitor, type Ctrl-]
.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
The haptics (detent configuration, click/buzz) can be configured dynamically at run-time using the provided CLI, see screenshot below:
bldc_test_stand-compressed.mp4
As you can see, the cli also allows you to start and stop the haptic engine (default is off when the program starts) and allows you to query the position of the motor based on the current detent config. The default detent config is the unbounded_no_detents configuration.
For more information, see the documentation or the original PR: esp-cpp/espp#60
Some examples:
coarse_values_strong_detents.mp4
magnetic_detents.mp4
on_off_strong.mp4
multi_rev_no_detents.mp4
Make sure to run the code once with zero_electrical_offset
set to 0 so that
the motor will go through a calibration / zero offset routine. At the end of
this startup routine it will print the measured zero electrical offset that you
can then provide within the code, at which point it will not need to run the
calibration routine.
You must run this calibration any time you change your hardware configuration (such as by remounting your motor, magnet, encoder chip).
This example encapsulates the board support packages into one of two components:
espp::TinyS3TestStand
(in this repo)espp::MotorGoMini
(in espp)
These components build complex haptic behavior using the following components:
espp::Mt6701
espp::BldcDriver
espp::BldcMotor
espp::BldcHaptics
espp::I2c
You combine the Mt6701
and BldcDriver
together when creating the BldcMotor
and then simply pass the BldcMotor
to the BldcHaptics
component. At that
point, you only have to interface to the BldcHaptics
to read the input
position or reconfigure the haptics.