Smart Knob Controller

Class for 3-phase BLDC motor control using PWM and encoder feedback. More...

#include <motor.h>

Public Member Functions

 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.
void setEffort (int effort)
 Sets the motor effort as a percentage (-100 to 100).
void commutate ()
 Applies 3-phase commutation based on current encoder angle and effort.
void enable ()
 Enables all motor phases.
void disable ()
 Disables all motor phases.
void testCommutation (int32_t theta, float Vq)
 Applies open-loop commutation at specified angle and voltage.
void applyPWM (float Va, float Vb, float Vc)
 Sets PWM outputs based on given phase voltages.

Detailed Description

Class for 3-phase BLDC motor control using PWM and encoder feedback.

Constructor & Destructor Documentation

◆ Motor()

Motor::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.

Parameters
htimTimer used for PWM.
chAPWM channel A.
chBPWM channel B.
chCPWM channel C.
enAGPIO enable pin A.
enBGPIO enable pin B.
enCGPIO enable pin C.
encoderReference to Encoder object.

Member Function Documentation

◆ applyPWM()

void Motor::applyPWM ( float Va,
float Vb,
float Vc )

Sets PWM outputs based on given phase voltages.

Parameters
VaPhase A voltage.
VbPhase B voltage.
VcPhase C voltage.

◆ testCommutation()

void Motor::testCommutation ( int32_t theta,
float Vq )

Applies open-loop commutation at specified angle and voltage.

Parameters
thetaElectrical angle in encoder ticks.
VqVoltage magnitude.

The documentation for this class was generated from the following files:
  • C:/Users/nickl/OneDrive - Cal Poly/POLY4TH/SPRING'25/507/LAB WORKSPACE/SmartKnobController_REV2/Core/DoxCommd/motor.h
  • C:/Users/nickl/OneDrive - Cal Poly/POLY4TH/SPRING'25/507/LAB WORKSPACE/SmartKnobController_REV2/Core/DoxCommd/motor.cpp