![]() |
SimpleFOClibrary 2.4.0
|
#include <HybridStepperMotor.h>
Public Member Functions | |
| HybridStepperMotor (int pp, float R=NOT_SET, float KV=NOT_SET, float L_q=NOT_SET, float L_d=NOT_SET) | |
| void | linkDriver (BLDCDriver *driver) |
| int | init () override |
| void | disable () override |
| void | enable () override |
| void | setPhaseVoltage (float Uq, float Ud, float angle_el) override |
| float | estimateBEMF (float velocity) override |
| int | characteriseMotor (float voltage) |
| void | linkCurrentSense (CurrentSense *current_sense) |
Public Member Functions inherited from FOCMotor | |
| FOCMotor () | |
| virtual int | initFOC () |
| virtual void | loopFOC () |
| virtual void | move (float target=NOT_SET) |
| void | linkSensor (Sensor *sensor) |
| void | linkCurrentSense (CurrentSense *current_sense) |
| float | shaftAngle () |
| float | shaftVelocity () |
| float | electricalAngle () |
| int | characteriseMotor (float voltage, float correction_factor) |
| int | tuneCurrentController (float bandwidth) |
| void | useMonitoring (Print &serial) |
| void | monitor () |
| void | updateVelocityLimit (float new_velocity_limit) |
| void | updateCurrentLimit (float new_current_limit) |
| void | updateVoltageLimit (float new_voltage_limit) |
| void | updateTorqueControlType (TorqueControlType new_torque_controller) |
| void | updateMotionControlType (MotionControlType new_motion_controller) |
| float | velocityOpenloop (float target_velocity) |
| float | angleOpenloop (float target_angle) |
| void | linkCustomMotionControl (float(*controlMethod)(FOCMotor *motor)) |
Public Attributes | |
| BLDCDriver * | driver |
| BLDCDriver instance. | |
| float | Ua |
| float | Ub |
| float | Uc |
| Phase voltages used for inverse Park and Clarke transform. | |
Public Attributes inherited from FOCMotor | |
| float | target |
| current target value - depends of the controller | |
| float | feed_forward_velocity = 0.0f |
| current feed forward velocity | |
| float | shaft_angle |
| current motor angle | |
| float | electrical_angle |
| current electrical angle | |
| float | shaft_velocity |
| current motor velocity | |
| float | current_sp |
| target current ( q current ) | |
| float | shaft_velocity_sp |
| current target velocity | |
| float | shaft_angle_sp |
| current target angle | |
| DQVoltage_s | voltage |
| current d and q voltage set to the motor | |
| DQCurrent_s | current |
| current d and q current measured | |
| float | voltage_bemf |
| estimated backemf voltage (if provided KV constant) | |
| float | Ualpha |
| float | Ubeta |
| Phase voltages U alpha and U beta used for inverse Park and Clarke transform. | |
| DQCurrent_s | feed_forward_current |
| current d and q current measured | |
| DQVoltage_s | feed_forward_voltage |
| current d and q voltage set to the motor | |
| float | voltage_sensor_align |
| sensor and motor align voltage parameter | |
| float | velocity_index_search |
| target velocity for index search | |
| float | phase_resistance |
| motor phase resistance | |
| int | pole_pairs |
| motor pole pairs number | |
| float | KV_rating |
| motor KV rating | |
| float | phase_inductance |
| motor phase inductance q axis - FOR BACKWARDS COMPATIBILITY | |
| DQ_s | axis_inductance {NOT_SET, NOT_SET} |
| motor direct axis phase inductance | |
| float | voltage_limit |
| Voltage limiting variable - global limit. | |
| float | current_limit |
| Current limiting variable - global limit. | |
| float | velocity_limit |
| Velocity limiting variable - global limit. | |
| int8_t | enabled = 0 |
| enabled or disabled motor flag | |
| FOCMotorStatus | motor_status = FOCMotorStatus::motor_uninitialized |
| motor status | |
| FOCModulationType | foc_modulation |
| parameter determining modulation algorithm | |
| int8_t | modulation_centered = 1 |
| flag (1) centered modulation around driver limit /2 or (0) pulled to 0 | |
| TorqueControlType | torque_controller |
| parameter determining the torque control type | |
| MotionControlType | controller |
| parameter determining the control loop to be used | |
| PIDController | PID_current_q {DEF_PID_CURR_P,DEF_PID_CURR_I,DEF_PID_CURR_D,DEF_PID_CURR_RAMP, DEF_POWER_SUPPLY} |
| parameter determining the q current PID config | |
| PIDController | PID_current_d {DEF_PID_CURR_P,DEF_PID_CURR_I,DEF_PID_CURR_D,DEF_PID_CURR_RAMP, DEF_POWER_SUPPLY} |
| parameter determining the d current PID config | |
| LowPassFilter | LPF_current_q {DEF_CURR_FILTER_Tf} |
| parameter determining the current Low pass filter configuration | |
| LowPassFilter | LPF_current_d {DEF_CURR_FILTER_Tf} |
| parameter determining the current Low pass filter configuration | |
| PIDController | PID_velocity {DEF_PID_VEL_P,DEF_PID_VEL_I,DEF_PID_VEL_D,DEF_PID_VEL_RAMP,DEF_PID_VEL_LIMIT} |
| parameter determining the velocity PID configuration | |
| PIDController | P_angle {DEF_P_ANGLE_P,0,0,0,DEF_VEL_LIM} |
| parameter determining the position PID configuration | |
| LowPassFilter | LPF_velocity {DEF_VEL_FILTER_Tf} |
| parameter determining the velocity Low pass filter configuration | |
| LowPassFilter | LPF_angle {0.0} |
| parameter determining the angle low pass filter configuration | |
| unsigned int | motion_downsample = DEF_MOTION_DOWNSMAPLE |
| parameter defining the ratio of downsampling for move commad | |
| unsigned int | motion_cnt = 0 |
| counting variable for downsampling for move commad | |
| float | sensor_offset |
| user defined sensor zero offset | |
| float | zero_electric_angle = NOT_SET |
| absolute zero electric angle - if available | |
| Direction | sensor_direction = Direction::UNKNOWN |
| default is CW. if sensor_direction == Direction::CCW then direction will be flipped compared to CW. Set to UNKNOWN to set by calibration | |
| bool | pp_check_result = false |
| the result of the PP check, if run during loopFOC | |
| unsigned int | monitor_downsample = DEF_MON_DOWNSMAPLE |
| show monitor outputs each monitor_downsample calls | |
| char | monitor_start_char = '\0' |
| monitor starting character | |
| char | monitor_end_char = '\0' |
| monitor outputs ending character | |
| char | monitor_separator = '\t' |
| monitor outputs separation character | |
| unsigned int | monitor_decimals = 4 |
| monitor outputs decimal places | |
| uint8_t | monitor_variables = _MON_TARGET | _MON_VOLT_Q | _MON_VEL | _MON_ANGLE |
| Bit array holding the map of variables the user wants to monitor. | |
| Sensor * | sensor |
| CurrentSense link. | |
| CurrentSense * | current_sense |
| Print * | monitor_port |
| Serial terminal variable if provided. | |
| uint32_t | loopfoc_time_us = 0 |
| filtered loop times | |
| uint32_t | move_time_us = 0 |
Additional Inherited Members | |
Protected Member Functions inherited from FOCMotor | |
| void | updateLoopFOCTime () |
| void | updateMotionControlTime () |
| int | alignSensor () |
| int | alignCurrentSense () |
| int | absoluteZeroSearch () |
Protected Attributes inherited from FOCMotor | |
| uint32_t | last_loopfoc_timestamp_us = 0 |
| timestamp of the last loopFOC execution in microseconds | |
| uint32_t | last_loopfoc_time_us = 0 |
| last elapsed time of loopFOC in microseconds | |
| uint32_t | last_move_timestamp_us = 0 |
| timestamp of the last move execution in microseconds | |
| uint32_t | last_move_time_us = 0 |
| last elapsed time of move in microseconds | |
Stepper Motor class
Definition at line 20 of file HybridStepperMotor.h.
| HybridStepperMotor::HybridStepperMotor | ( | int | pp, |
| float | R = NOT_SET, |
||
| float | KV = NOT_SET, |
||
| float | L_q = NOT_SET, |
||
| float | L_d = NOT_SET |
||
| ) |
HybridStepperMotor class constructor
| pp | pole pair number |
| R | motor phase resistance - [Ohm] |
| KV | motor KV rating (1/K_bemf) - rpm/V |
| Lq | motor q-axis inductance - [H] |
| Ld | motor d-axis inductance - [H] |
Definition at line 10 of file HybridStepperMotor.cpp.
|
inline |
Measure resistance and inductance of a HybridStepperMotor and print results to debug. If a sensor is available, an estimate of zero electric angle will be reported too. TODO: determine the correction factor
| voltage | The voltage applied to the motor |
Definition at line 81 of file HybridStepperMotor.h.
|
overridevirtual |
Motor disable function
Implements FOCMotor.
Definition at line 95 of file HybridStepperMotor.cpp.
|
overridevirtual |
Motor enable function
Implements FOCMotor.
Definition at line 108 of file HybridStepperMotor.cpp.
|
overridevirtual |
Method estimating the Back EMF voltage based based on the current velocity and KV rating
| velocity | Current motor velocity |
Reimplemented from FOCMotor.
Definition at line 126 of file HybridStepperMotor.cpp.
|
overridevirtual |
Motor hardware init function
Implements FOCMotor.
Definition at line 47 of file HybridStepperMotor.cpp.
| void HybridStepperMotor::linkCurrentSense | ( | CurrentSense * | current_sense | ) |
Link the currentsense
Definition at line 41 of file HybridStepperMotor.cpp.
| void HybridStepperMotor::linkDriver | ( | BLDCDriver * | _driver | ) |
Function linking a motor and a foc driver
| driver | BLDCDriver handle for hardware peripheral control |
Link the driver which controls the motor
Definition at line 33 of file HybridStepperMotor.cpp.
|
overridevirtual |
Method using FOC to set Uq to the motor at the optimal angle Heart of the FOC algorithm
| Uq | Current voltage in q axis to set to the motor |
| Ud | Current voltage in d axis to set to the motor |
| angle_el | current electrical angle of the motor |
Implements FOCMotor.
Definition at line 135 of file HybridStepperMotor.cpp.
| BLDCDriver* HybridStepperMotor::driver |
BLDCDriver instance.
Definition at line 40 of file HybridStepperMotor.h.
| float HybridStepperMotor::Ua |
Definition at line 42 of file HybridStepperMotor.h.
| float HybridStepperMotor::Ub |
Definition at line 42 of file HybridStepperMotor.h.
| float HybridStepperMotor::Uc |
Phase voltages used for inverse Park and Clarke transform.
Definition at line 42 of file HybridStepperMotor.h.