Skip to content

cinderblock/3-Phase-Controller

Repository files navigation

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
    • Magnetometer
    • Back EMF Sensing
    • External Sensor
  • Motor movement
    • Full Torque
  • Commands
    • Stepping function
    • Amplitude
    • Velocity
    • Position
  • I2C Communication
  • USB Communication
  • Serial Communication

Getting Started

Board

This code is meant to run on the ATmega32U4 on 3 Phase Driver Board.

Initial Programming and Calibration Procedure

  1. Program the Bootloader
    1. Open a terminal in this project
    2. cd into bootloader directory
    3. Connect programmer to motor
    4. Power the device (either option)
      • Set switch on programmer to "5v"
      • Provide 12V power to the board
    5. Run make
    6. Verify that the red LED flashes at 1 Hz
  2. Program with the main program
    1. Plug in a USB (internal or external plug)
    2. cd .. up to main project folder
    3. Plug in DC power (generally 12v)
    4. Verify that the red LED flashes at 1 Hz
      1. If not flashing or if it is not visible, do a reset
      2. If still does not work, reload the bootloader
        • requires the motor to be opened to use the programing board
    5. Run make
    6. Verify that the red LED on solid
  3. Run Calibration procedure
    1. cd Calibration-Tool
    2. ensure yarn dependencies are up to date: yarn
    3. yarn mlx to set the gain to a constant. (26 seems appropriate. Max raw is about 4000.)
      1. reset device
      2. cycle USB connection
      3. return
      4. set LowGain and HighGain to 26
      5. enter to accept hex value
    4. Run Calibration Procedure: yarn start
      1. 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>
    5. Look at data.html to verify that the curves are right. Max X and Y should be under 3800.
    6. Run yarn mlx again to reset the gain to a better value iff there is a problem.
  4. Load calibration data onto device
    1. Reset device
    2. dfu-programmer.exe ATmega32u4 flash --force <SerialNumber>.hex
  5. Test the motor
    1. power cycle the supply or USB
    2. yarn test
      1. Check for devices present and present the serial number
      2. <enter> starts a sine test
      3. cX <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:

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

Communication Diagram

Communication Diagram

About

Firmware for 3 Phase BLDC controller

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •