11#include "stm32f4xx_hal.h"
31 Motor(TIM_HandleTypeDef* htim,
32 uint32_t chA, uint32_t chB, uint32_t chC,
56 void applyPWM(
float Va,
float Vb,
float Vc);
63 static const float commTable[16384];
65 TIM_HandleTypeDef* htim;
66 uint32_t chA, chB, chC;
74 static constexpr float V_max = 12;
75 static constexpr uint16_t polePairs = 11;
76 static constexpr uint16_t resolution = 16384;
Class to interface with a 14-bit SPI-based rotary encoder.
Definition encoder.h:20
Wrapper class for STM32 GPIO pin control.
Definition gpio.h:17
void commutate()
Applies 3-phase commutation based on current encoder angle and effort.
Definition motor.cpp:29
void applyPWM(float Va, float Vb, float Vc)
Sets PWM outputs based on given phase voltages.
Definition motor.cpp:89
void setEffort(int effort)
Sets the motor effort as a percentage (-100 to 100).
Definition motor.cpp:22
void testCommutation(int32_t theta, float Vq)
Applies open-loop commutation at specified angle and voltage.
Definition motor.cpp:69
void enable()
Enables all motor phases.
Definition motor.cpp:55
void disable()
Disables all motor phases.
Definition motor.cpp:62
Motor(TIM_HandleTypeDef *htim, uint32_t chA, uint32_t chB, uint32_t chC, GPIO &enA, GPIO &enB, GPIO &enC, Encoder &encoder)
Constructs a Motor object.
Definition motor.cpp:11