230 Ualpha = _ca * Ud - _sa * Uq;
231 Ubeta = _sa * Ud + _ca * Uq;
252 float Umin = min(
Ua, min(
Ub,
Uc));
253 float Umax = max(
Ua, max(
Ub,
Uc));
254 center -= (Umax+Umin) / 2;
260 float Umin = min(
Ua, min(
Ub,
Uc));
#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 setPhaseState(PhaseState sa, PhaseState sb, PhaseState sc)=0
virtual void setPwm(float Ua, float Ub, float Uc)=0
void setPhaseVoltage(float Uq, float Ud, float angle_el) override
BLDCDriver * driver
BLDCDriver instance.
virtual void linkDriver(BLDCDriver *driver)
BLDCMotor(int pp, float R=NOT_SET, float KV=NOT_SET, float L_q=NOT_SET, float L_d=NOT_SET)
float Uc
Current phase voltages Ua,Ub and Uc set to motor.
float estimateBEMF(float velocity) override
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)
int8_t modulation_centered
flag (1) centered modulation around driver limit /2 or (0) pulled to 0
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
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 Ubeta
Phase voltages U alpha and U beta used for inverse Park and Clarke transform.
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
float _normalizeAngle(float angle)
void _sincos(float a, float *s, float *c)
void _delay(unsigned long ms)