{"id":21969642,"url":"https://github.com/cinderblock/3-phase-controller","last_synced_at":"2025-04-28T10:24:53.274Z","repository":{"id":143531347,"uuid":"52562035","full_name":"cinderblock/3-Phase-Controller","owner":"cinderblock","description":"Firmware for 3 Phase BLDC controller","archived":false,"fork":false,"pushed_at":"2020-04-29T11:05:12.000Z","size":6430,"stargazers_count":41,"open_issues_count":1,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-28T10:24:45.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinderblock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-25T22:41:01.000Z","updated_at":"2024-04-19T08:35:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"92952541-acc3-41c3-9683-ac5325effbc1","html_url":"https://github.com/cinderblock/3-Phase-Controller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2F3-Phase-Controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2F3-Phase-Controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2F3-Phase-Controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2F3-Phase-Controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinderblock","download_url":"https://codeload.github.com/cinderblock/3-Phase-Controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251293289,"owners_count":21566075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T14:23:03.641Z","updated_at":"2025-04-28T10:24:53.264Z","avatar_url":"https://github.com/cinderblock.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firmware for 3 Phase Motor Driver\n\n3 Phase motor controller driver firmware.\n\n## Current Implementation\n\nThis is very much a work in progress. The following list is of currently implemented and planned features.\n\n- [ ] Sensors\n  - [x] Magnetometer\n  - [ ] Back EMF Sensing\n  - [ ] External Sensor\n- [x] Motor movement\n  - [ ] Full Torque\n- [x] Commands\n  - [x] Stepping function\n  - [x] Amplitude\n  - [x] Velocity\n  - [x] Position\n- [ ] I2C Communication\n- [x] USB Communication\n- [x] Serial Communication\n\n## Getting Started\n\n### Board\n\nThis code is meant to run on the [ATmega32U4](http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf) on [3 Phase Driver Board](https://github.com/cinderblock/3-Phase-Driver).\n\n## Initial Programming and Calibration Procedure\n\n1. Program the Bootloader\n   1. Open a terminal in this project\n   1. cd into `bootloader` directory\n   1. Connect programmer to motor\n   1. Power the device (either option)\n      - Set switch on programmer to \"5v\"\n      - Provide 12V power to the board\n   1. Run `make`\n   1. Verify that the red LED flashes at 1 Hz\n1. Program with the main program\n   1. Plug in a USB (internal or external plug)\n   1. `cd ..` up to main project folder\n   1. Plug in DC power (generally 12v)\n   1. Verify that the red LED flashes at 1 Hz\n      1. If not flashing or if it is not visible, do a reset\n      1. If still does not work, reload the bootloader\n         - requires the motor to be opened to use the programing board\n   1. Run `make`\n   1. Verify that the red LED on solid\n1. Run Calibration procedure\n   1. `cd Calibration-Tool`\n   1. ensure yarn dependencies are up to date: `yarn`\n   1. `yarn mlx` to set the gain to a constant. (26 seems appropriate. Max raw is about 4000.)\n      1. reset device\n      1. cycle USB connection\n      1. return\n      1. set LowGain and HighGain to 26\n      1. enter to accept hex value\n   1. Run Calibration Procedure: `yarn start`\n      1. Power cycle the motor\n      ```txt\n      Data file? [data.csv]: \u003center\u003e\n      Capture fresh? [No]: y\u003center\u003e\n      Fresh: true\n      Cycles per Rev: 15\n      Revolutions: 3\n      Amplitude: 65\n      Smooth Control - info: Started watching for USB devices\n      Device attached: 4:38:25 PM None\n      Serial Number [None]: \u003center\u003e\n      New serial number [1c28c9e0-b57f-11e9-b138-9de272fac789]: (Must be clamped into test fixture at this point) \u003center\u003e\n      ```\n   1. Look at data.html to verify that the curves are right. Max X and Y should be under 3800.\n   1. Run `yarn mlx` again to reset the gain to a better value iff there is a problem.\n1. Load calibration data onto device\n   1. Reset device\n   1. `dfu-programmer.exe ATmega32u4 flash --force \u003cSerialNumber\u003e.hex`\n1. Test the motor\n   1. power cycle the supply or USB\n   1. `yarn test`\n      1. Check for devices present and present the serial number\n      1. `\u003center\u003e` starts a sine test\n      1. `cX \u003center\u003e` to to constant X force.\n\n## Motor\n\nCurrently Testing with [Quanum MT5206](https://hobbyking.com/en_us/quanum-mt-series-5206-320kv-brushless-multirotor-motor-built-by-dys.html).\nAlso playing with Hoverboard motors.\n\n## Git Submodules\n\nDon't forget about the submodules we're using.\nModern git checks out submodules correctly but older git requires some extra commands:\n\n```bash\ngit submodule init\ngit submodule update\n```\n\n## Build Requirements\n\nOnly real requirement is running the main `Makefile`.\nAll build steps are configurable on a per machine hostname basis.\nCreate a file named `local.\u003chostname\u003e.mk` in the project root, next to the main `Makefile`.\nThis file will be automatically loaded and can be used to override any make variables.\nThe primary use for this is to enable the ability to not have all the needed binaries in the PATH.\n\n#### Compiler\n\nWhile we endeavour to be standards compliant, the reality is that it is difficult to ensure all possible compilers work.\n\nKnown working compilers:\n\n- [AVR 8-bit Toolchain](https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers) v3.6.2\n\n#### Common `local.\u003chostname\u003e.mk` options\n\n```make\nGCC_RootDir = C:/Program Files (x86)/avr8-gnu-toolchain\nmkdirCommand = mkdir\n```\n\n#### Windows\n\nAll paths in uMaker use `/` as a directory separator.\n\nWindows's `mkdir`/`md` does not support `/` directory separator.\n\nInstalling Cygwin is the easiest way to get building on Windows working.\nMake sure `make` is \"selected for installation\".\n\n#### Troubleshooting\n\nTry `make clean` first.\n\n### Bootloader\n\nThe 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.\n\n### VSCode\n\nTo get VSCode IntelliSense to work, `local.avr-gcc.compilerDir` must be set in your User Settings.\nLikely something like `\"/path/to/avr8-gnu-toolchain\"` or `\"C:/Program Files/avr8-win64\"` is needed.\nThis directory should have a `bin` and `include` directory inside of it, among others.\n\n## Associated documentation\n\n- [Technical Docs](docs/README.md)\n- [3 Phase sine generation](docs/3%20Phase%20Sine%20Wave%20Generation.md)\n- [Triple Buffer](libCameron/Triple%20Buffer.png)\n\n### Communication Diagram\n\n[![Communication Diagram](docs/Control%20Sequence.svg)](docs/Control%20Sequence.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2F3-phase-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinderblock%2F3-phase-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2F3-phase-controller/lists"}