152 Ua = (_ca * Ud) - (_sa * Uq);
153 Ub = (_sa * Ud) + (_ca * Uq);
164 Ua = (_ca * Ud) - (_sa * Uq);
165 Ub = (_sa * Ud) + (_ca * Uq);
167 float Umin = fmin(fmin(
Ua,
Ub), 0);
168 float Umax = fmax(fmax(
Ua,
Ub), 0);
#define SIMPLEFOC_MOTOR_DEBUG(msg,...)
@ SpaceVectorPWM
Space vector modulation method.
@ SinePWM
Sinusoidal PWM modulation.
@ motor_uncalibrated
Motor is initialized, but not calibrated (open loop possible)
@ motor_initializing
Motor intiialization is in progress.
@ motor_init_failed
Motor initialization failed (not recoverable)
#define SIMPLEFOC_MOTOR_ERROR(msg,...)
@ voltage
Torque control using voltage.
virtual void setPwm(float Ua, float Ub, float Uc)=0
DriverType driver_type
driver type (BLDC or Stepper)
bool initialized
true if driver was successfully initialized
float voltage_limit
limiting voltage set to the motor
int8_t enabled
enabled or disabled motor flag
void updateCurrentLimit(float new_current_limit)
DQ_s axis_inductance
motor direct axis phase inductance
PIDController PID_current_q
parameter determining the q current PID config
void updateVoltageLimit(float new_voltage_limit)
MotionControlType controller
parameter determining the control loop to be used
float phase_resistance
motor phase resistance
PIDController PID_current_d
parameter determining the d current PID config
Sensor * sensor
CurrentSense link.
CurrentSense * current_sense
void linkCurrentSense(CurrentSense *current_sense)
float voltage_limit
Voltage limiting variable - global limit.
float velocity_limit
Velocity limiting variable - global limit.
PIDController P_angle
parameter determining the position PID configuration
FOCMotorStatus motor_status
motor status
float KV_rating
motor KV rating
float voltage_sensor_align
sensor and motor align voltage parameter
Direction sensor_direction
default is CW. if sensor_direction == Direction::CCW then direction will be flipped compared to CW....
float current_limit
Current limiting variable - global limit.
TorqueControlType torque_controller
parameter determining the torque control type
PIDController PID_velocity
parameter determining the velocity PID configuration
float phase_inductance
motor phase inductance q axis - FOR BACKWARDS COMPATIBILITY
int pole_pairs
motor pole pairs number
void updateVelocityLimit(float new_velocity_limit)
FOCModulationType foc_modulation
parameter determining modulation algorithm
void setPhaseVoltage(float Uq, float Ud, float angle_el) override
void linkDriver(BLDCDriver *driver)
float estimateBEMF(float velocity) override
BLDCDriver * driver
BLDCDriver instance.
float Uc
Phase voltages used for inverse Park and Clarke transform.
void linkCurrentSense(CurrentSense *current_sense)
HybridStepperMotor(int pp, float R=NOT_SET, float KV=NOT_SET, float L_q=NOT_SET, float L_d=NOT_SET)
void _sincos(float a, float *s, float *c)
void _delay(unsigned long ms)