As a summer project, I set out to use an STM32 microcontroller (particularly the STM32l476rg Nucleo Board) to control a turret, which is driven by 2 stepper motors for gun aiming and 1 servo motor for a trigger-pulling mechanism. I did this with the purpose of familiarizing myself with the STM32 family of microcontrollers and of having a cool project to apply my knowledge of them. The turret is controlled remotely by a PS3 controller which interfaces with an ESP32 board. In addition to remotely controlling the turret's steppers and servos, there was an independent part of the project, in which I streamed video from a small camera (fixed to the gun-mounting arm), to a STM32 MPU, which I booted with a custom Linux distribution; however, this component of the project is not the concern of this repo.
The focus of this repo is the C-programming and configuring of the STM32l476rg necessary to run the STM32 MCU component of the project. This repo contains the code and configuration files that I used to set up and program the board in STM32CubeIDE. Most of the configuration work consisted of configuring 3 timers to generate PWM signals at the correct frequencies for the motor drivers and for the servo motor, which also operated at PWM. I also had to configure a UART port to receive data from the ESP32 board that was receiving data via Bluetooth from the PS3 controller. In terms of programming, I had to receive data over UART from the ESP32 board, parse the data for commands (horizontal/vertical rotation & trigger pulling), and then update the frequency sent from the PWM pins according to the driver and motor specifications.