![]() |
SimpleFOClibrary
2.1
|
#include <BLDCMotor.h>
Public Member Functions | |
| BLDCMotor (int pp, float R=NOT_SET) | |
| void | linkDriver (BLDCDriver *driver) |
| void | init () override |
| void | disable () override |
| void | enable () override |
| int | initFOC (float zero_electric_offset=NOT_SET, Direction sensor_direction=Direction::CW) override |
| void | loopFOC () override |
| void | move (float target=NOT_SET) override |
Public Member Functions inherited from FOCMotor | |
| FOCMotor () | |
| void | linkSensor (Sensor *sensor) |
| void | linkCurrentSense (CurrentSense *current_sense) |
| float | shaftAngle () |
| float | shaftVelocity () |
| float | electricalAngle () |
| void | useMonitoring (Print &serial) |
| void | monitor () |
Public Attributes | |
| BLDCDriver * | driver |
| float | Ua |
| float | Ub |
| float | Uc |
| Current phase voltages Ua,Ub and Uc set to motor. More... | |
| float | Ualpha |
| float | Ubeta |
| Phase voltages U alpha and U beta used for inverse Park and Clarke transform. More... | |
Public Attributes inherited from FOCMotor | |
| float | target |
| current target value - depends of the controller More... | |
| float | shaft_angle |
| current motor angle More... | |
| float | electrical_angle |
| current electrical angle More... | |
| float | shaft_velocity |
| current motor velocity More... | |
| float | current_sp |
| target current ( q current ) More... | |
| float | shaft_velocity_sp |
| current target velocity More... | |
| float | shaft_angle_sp |
| current target angle More... | |
| DQVoltage_s | voltage |
| current d and q voltage set to the motor More... | |
| DQCurrent_s | current |
| current d and q current measured More... | |
| float | voltage_sensor_align |
| sensor and motor align voltage parameter More... | |
| float | velocity_index_search |
| target velocity for index search More... | |
| float | phase_resistance |
| motor phase resistance More... | |
| int | pole_pairs |
| motor pole pairs number More... | |
| float | voltage_limit |
| Voltage limitting variable - global limit. More... | |
| float | current_limit |
| Current limitting variable - global limit. More... | |
| float | velocity_limit |
| Velocity limitting variable - global limit. More... | |
| int8_t | enabled = 0 |
| enabled or disabled motor flag More... | |
| FOCModulationType | foc_modulation |
| parameter derterniming modulation algorithm More... | |
| int8_t | modulation_centered = 1 |
| flag (1) centered modulation around driver limit /2 or (0) pulled to 0 More... | |
| TorqueControlType | torque_controller |
| parameter determining the torque control type More... | |
| MotionControlType | controller |
| parameter determining the control loop to be used More... | |
| 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 More... | |
| 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 More... | |
| LowPassFilter | LPF_current_q {DEF_CURR_FILTER_Tf} |
| parameter determining the current Low pass filter configuration More... | |
| LowPassFilter | LPF_current_d {DEF_CURR_FILTER_Tf} |
| parameter determining the current Low pass filter configuration More... | |
| 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 More... | |
| PIDController | P_angle {DEF_P_ANGLE_P,0,0,1e10,DEF_VEL_LIM} |
| parameter determining the position PID configuration More... | |
| LowPassFilter | LPF_velocity {DEF_VEL_FILTER_Tf} |
| parameter determining the velocity Low pass filter configuration More... | |
| LowPassFilter | LPF_angle {0.0} |
| parameter determining the angle low pass filter configuration More... | |
| unsigned int | motion_downsample = DEF_MOTION_DOWNSMAPLE |
| parameter defining the ratio of downsampling for move commad More... | |
| unsigned int | motion_cnt = 0 |
| counting variable for downsampling for move commad More... | |
| float | sensor_offset |
| user defined sensor zero offset More... | |
| float | zero_electric_angle = NOT_SET |
| absolute zero electric angle - if available More... | |
| int | sensor_direction = NOT_SET |
| if sensor_direction == Direction::CCW then direction will be flipped to CW More... | |
| unsigned int | monitor_downsample = DEF_MON_DOWNSMAPLE |
| show monitor outputs each monitor_downsample calls More... | |
| 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. More... | |
| Sensor * | sensor |
| CurrentSense * | current_sense |
| Print * | monitor_port |
| Serial terminal variable if provided. More... | |
BLDC motor class
Definition at line 15 of file BLDCMotor.h.
| BLDCMotor::BLDCMotor | ( | int | pp, |
| float | R = NOT_SET |
||
| ) |
BLDCMotor class constructor
| pp | pole pairs number |
| R | motor phase resistance |
Definition at line 6 of file BLDCMotor.cpp.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Function initializing FOC algorithm and aligning sensor's and motors' zero position
FOC functions
Implements FOCMotor.
Definition at line 85 of file BLDCMotor.cpp.
| void BLDCMotor::linkDriver | ( | BLDCDriver * | _driver | ) |
Function linking a motor and a foc driver
| driver | BLDCDriver class implementing all the hardware specific functions necessary PWM setting |
Link the driver which controls the motor
Definition at line 21 of file BLDCMotor.cpp.
|
overridevirtual |
Function running FOC algorithm in real-time it calculates the gets motor angle and sets the appropriate voltages to the phase pwm signals
Implements FOCMotor.
Definition at line 244 of file BLDCMotor.cpp.
|
overridevirtual |
Function executing the control loops set by the controller parameter of the BLDCMotor.
| target | Either voltage, angle or velocity based on the motor.controller If it is not set the motor will use the target set in its variable motor.target |
This function doesn't need to be run upon each loop execution - depends of the use case
Implements FOCMotor.
Definition at line 295 of file BLDCMotor.cpp.
| BLDCDriver* BLDCMotor::driver |
| float BLDCMotor::Ua |
Definition at line 69 of file BLDCMotor.h.
| float BLDCMotor::Ualpha |
Definition at line 70 of file BLDCMotor.h.
| float BLDCMotor::Ub |
Definition at line 69 of file BLDCMotor.h.
| float BLDCMotor::Ubeta |
Phase voltages U alpha and U beta used for inverse Park and Clarke transform.
Definition at line 70 of file BLDCMotor.h.
| float BLDCMotor::Uc |
Current phase voltages Ua,Ub and Uc set to motor.
Definition at line 69 of file BLDCMotor.h.