 |
SimpleFOClibrary
2.1
|
Go to the documentation of this file.
89 if(
_isset(zero_electric_offset)){
99 if(
sensor) exit_flag = alignSensor();
113 int StepperMotor::alignSensor() {
122 if(!exit_flag)
return exit_flag;
126 for (
int i = 0; i <=500; i++ ) {
134 for (
int i = 500; i >=0; i-- ) {
140 setPhaseVoltage(0, 0, 0);
143 if (mid_angle == end_angle) {
146 }
else if (mid_angle < end_angle) {
155 float moved = fabs(mid_angle - end_angle);
176 setPhaseVoltage(0, 0, 0);
184 int StepperMotor::absoluteZeroSearch() {
194 angleOpenloop(1.5*
_2PI);
200 setPhaseVoltage(0, 0, 0);
298 void StepperMotor::setPhaseVoltage(
float Uq,
float Ud,
float angle_el) {
305 float _ca =
_cos(angle_el);
306 float _sa =
_sin(angle_el);
308 Ualpha = _ca * Ud - _sa * Uq;
309 Ubeta = _sa * Ud + _ca * Uq;
318 float StepperMotor::velocityOpenloop(
float target_velocity){
320 unsigned long now_us =
_micros();
322 float Ts = (now_us - open_loop_timestamp) * 1e-6;
324 if(Ts <= 0 || Ts > 0.5) Ts = 1e-3;
339 open_loop_timestamp = now_us;
347 float StepperMotor::angleOpenloop(
float target_angle){
349 unsigned long now_us =
_micros();
351 float Ts = (now_us - open_loop_timestamp) * 1e-6;
353 if(Ts <= 0 || Ts > 0.5) Ts = 1e-3;
372 open_loop_timestamp = now_us;
StepperMotor(int pp, float R=NOT_SET)
float current_sp
target current ( q current )
int initFOC(float zero_electric_offset=NOT_SET, Direction sensor_direction=Direction::CW) override
float zero_electric_angle
absolute zero electric angle - if available
float voltage_limit
limiting voltage set to the motor
virtual int needsSearch()
@ voltage
Torque control using voltage.
float voltage_limit
Voltage limitting variable - global limit.
@ angle
Position/angle motion control.
void _delay(unsigned long ms)
float Ubeta
Phase voltages U alpha and U beta used for inverse Park and Clarke transform.
float electrical_angle
current electrical angle
float shaft_velocity_sp
current target velocity
@ velocity
Velocity motion control.
virtual void setPwm(float Ua, float Ub)=0
void linkDriver(StepperDriver *driver)
float shaft_velocity
current motor velocity
int8_t enabled
enabled or disabled motor flag
float shaft_angle
current motor angle
float target
current target value - depends of the controller
float phase_resistance
motor phase resistance
TorqueControlType torque_controller
parameter determining the torque control type
float _normalizeAngle(float angle)
int sensor_direction
if sensor_direction == Direction::CCW then direction will be flipped to CW
float limit
Maximum output value.
float _electricalAngle(float shaft_angle, int pole_pairs)
float current_limit
Current limitting variable - global limit.
void move(float target=NOT_SET) override
unsigned int motion_cnt
counting variable for downsampling for move commad
PIDController P_angle
parameter determining the position PID configuration
DQVoltage_s voltage
current d and q voltage set to the motor
MotionControlType controller
parameter determining the control loop to be used
int pole_pairs
motor pole pairs number
Print * monitor_port
Serial terminal variable if provided.
float voltage_sensor_align
sensor and motor align voltage parameter
PIDController PID_velocity
parameter determining the velocity PID configuration
float velocity_limit
Velocity limitting variable - global limit.
unsigned int motion_downsample
parameter defining the ratio of downsampling for move commad
float velocity_index_search
target velocity for index search
virtual float getAngle()=0
float shaft_angle_sp
current target angle