3-Phase-Controller
3-Phase-Controller copied to clipboard
Firmware for 3 Phase BLDC controller
Firmware for 3 Phase Motor Driver
3 Phase motor controller driver firmware.
Current Implementation
This is very much a work in progress. The following list is of currently implemented and planned features.
- [ ] Sensors
- [x] Magnetometer
- [ ] Back EMF Sensing
- [ ] External Sensor
- [x] Motor movement
- [ ] Full Torque
- [x] Commands
- [x] Stepping function
- [x] Amplitude
- [x] Velocity
- [x] Position
- [ ] I2C Communication
- [x] USB Communication
- [x] Serial Communication
Getting Started
Board
This code is meant to run on the ATmega32U4 on 3 Phase Driver Board.
Initial Programming and Calibration Procedure
- Program the Bootloader
- Open a terminal in this project
- cd into
bootloaderdirectory - Connect programmer to motor
- Power the device (either option)
- Set switch on programmer to "5v"
- Provide 12V power to the board
- Run
make - Verify that the red LED flashes at 1 Hz
- Program with the main program
- Plug in a USB (internal or external plug)
cd ..up to main project folder- Plug in DC power (generally 12v)
- Verify that the red LED flashes at 1 Hz
- If not flashing or if it is not visible, do a reset
- If still does not work, reload the bootloader
- requires the motor to be opened to use the programing board
- Run
make - Verify that the red LED on solid
- Run Calibration procedure
cd Calibration-Tool- ensure yarn dependencies are up to date:
yarn yarn mlxto set the gain to a constant. (26 seems appropriate. Max raw is about 4000.)- reset device
- cycle USB connection
- return
- set LowGain and HighGain to 26
- enter to accept hex value
- Run Calibration Procedure:
yarn start- Power cycle the motor
Data file? [data.csv]: <enter> Capture fresh? [No]: y<enter> Fresh: true Cycles per Rev: 15 Revolutions: 3 Amplitude: 65 Smooth Control - info: Started watching for USB devices Device attached: 4:38:25 PM None Serial Number [None]: <enter> New serial number [1c28c9e0-b57f-11e9-b138-9de272fac789]: (Must be clamped into test fixture at this point) <enter> - Look at data.html to verify that the curves are right. Max X and Y should be under 3800.
- Run
yarn mlxagain to reset the gain to a better value iff there is a problem.
- Load calibration data onto device
- Reset device
dfu-programmer.exe ATmega32u4 flash --force <SerialNumber>.hex
- Test the motor
- power cycle the supply or USB
yarn test- Check for devices present and present the serial number
<enter>starts a sine testcX <enter>to to constant X force.
Motor
Currently Testing with Quanum MT5206. Also playing with Hoverboard motors.
Git Submodules
Don't forget about the submodules we're using. Modern git checks out submodules correctly but older git requires some extra commands:
git submodule init
git submodule update
Build Requirements
Only real requirement is running the main Makefile.
All build steps are configurable on a per machine hostname basis.
Create a file named local.<hostname>.mk in the project root, next to the main Makefile.
This file will be automatically loaded and can be used to override any make variables.
The primary use for this is to enable the ability to not have all the needed binaries in the PATH.
Compiler
While we endeavour to be standards compliant, the reality is that it is difficult to ensure all possible compilers work.
Known working compilers:
- AVR 8-bit Toolchain v3.6.2
Common local.<hostname>.mk options
GCC_RootDir = C:/Program Files (x86)/avr8-gnu-toolchain
mkdirCommand = mkdir
Windows
All paths in uMaker use / as a directory separator.
Windows's mkdir/md does not support / directory separator.
Installing Cygwin is the easiest way to get building on Windows working.
Make sure make is "selected for installation".
Troubleshooting
Try make clean first.
Bootloader
The current Makefile is setup to program an AVR via USB DFU. It is possible to switch to using an ISP or other bootloader/programmer easily as well.
VSCode
To get VSCode IntelliSense to work, local.avr-gcc.compilerDir must be set in your User Settings.
Likely something like "/path/to/avr8-gnu-toolchain" or "C:/Program Files/avr8-win64" is needed.
This directory should have a bin and include directory inside of it, among others.
Associated documentation
- Technical Docs
- 3 Phase sine generation
- Triple Buffer