This code is DEPRICATED. It is incomplete and its only purpose is for future development.
When using the software provided by STM which supports their MCUs a lot of functions and libraries are generated. We have not been able to exclude the libraries generated that isn't necessary for the code to run. In this repo, the team have elected to only upload the main.c file which is the only file that has been changed by the developers. Later in this README there is a step-by-step instruction on what the team did in respective software so that those could generate the files. However, there is no way the team could ensure that even though a future user follows the steps provided in the README will generate the same files due to the fact that STM might not support the version the team have used in the future, or if STM elects to generate another code using a different library.
This repository contains the code running on the ESC for controlling the wheel motors using FOC.
The following tools were used to generate and modify the code for FOC:
- STM32CubeIDE 1.16.1
- STM32CubeMX 6.12.1
- MC Workbench 6 (Only available for Windows.)
To retrace the steps the students made during the autumn semester of 2024 the hardware componentes below you will need in addtion to the software listed above. Also, you will need a power source and cables which you can solder onto the inverter and motor.
- Nanotec DF45L024048-A
- Electronic Speed Controller Discovery kit for drones with STM32G431CB B-G431B-ESC1
- Clone the repository:
git clone https://github.com/DVA490-474-Project-Course/foc_code.git
- Download and install STM32CubeIDE 1.16.1, STM32CubeMX 6.12, STM32 Motor Control Software Development Kit (please see ## Built with)
- In the MC Workbench, create a new project.
-
Under 'General Info' select
-
Under Motors select a motor that is similar to the Nanotec DF45L024048-A
-
Under the Inverter tab select B-G431B-ESC1
-
Once you've completed all the steps above click ok
-
- In the next window called Project Steps select the Application Configuration tab, check the box for 'Motor Profiler' and click ok
- Click Generate the project - you will be asked to save the project as well.
- A pop-up window will emerge, make sure that all the settings are the same as in the image below (in the extent that it is possible).
- Once STM32CubeMX has launched go to the 'Pinout & Configuration' tab and select connectivity. Make sure that the settings for USART2 are the same as in the picture below.
- Go to 'Project Manager' and in the first tab 'Project' make sure that the option 'Toolchain / IDE' is set to STM32CubeIDE, as seen in the picture (and highlighted with a red arrow).
- Establish a connection using UART
- Develop FOC
Design diagrams/files can be found in the docs directory. Additionally they are available on:
A majority of the code is generated by the STM32CubeIDE and thus distributed under their License (see liscense).
- Carl Larsson: cln20001@student.mdu.se
- Fredrik Westerbom