![]() |
SimpleFOClibrary 2.4.0
|
#include <CurrentSense.h>
Public Member Functions | |
| virtual int | init ()=0 |
| void | linkDriver (FOCDriver *driver) |
| virtual int | driverAlign (float align_voltage, bool modulation_centered=false) |
| virtual PhaseCurrent_s | getPhaseCurrents ()=0 |
| virtual float | getDCCurrent (float angle_el=0) |
| DQCurrent_s | getFOCCurrents (float angle_el) |
| ABCurrent_s | getABCurrents (PhaseCurrent_s current) |
| DQCurrent_s | getDQCurrents (ABCurrent_s current, float angle_el) |
| virtual void | enable () |
| virtual void | disable () |
| int | alignBLDCDriver (float align_voltage, BLDCDriver *driver, bool modulation_centered) |
| int | alignStepperDriver (float align_voltage, StepperDriver *driver, bool modulation_centered) |
| int | alignHybridDriver (float align_voltage, BLDCDriver *driver, bool modulation_centered) |
| PhaseCurrent_s | readAverageCurrents (int N=100) |
Public Attributes | |
| bool | skip_align = false |
| variable signaling that the phase current direction should be verified during initFOC() | |
| FOCDriver * | driver = nullptr |
| driver link | |
| bool | initialized = false |
| void * | params = 0 |
| pointer to hardware specific parameters of current sensing | |
| DriverType | driver_type = DriverType::UnknownDriver |
| driver type (BLDC or Stepper) | |
| float | gain_a |
| phase A gain | |
| float | gain_b |
| phase B gain | |
| float | gain_c |
| phase C gain | |
| float | offset_ia |
| zero current A voltage value (center of the adc reading) | |
| float | offset_ib |
| zero current B voltage value (center of the adc reading) | |
| float | offset_ic |
| zero current C voltage value (center of the adc reading) | |
| int | pinA |
| pin A analog pin for current measurement | |
| int | pinB |
| pin B analog pin for current measurement | |
| int | pinC |
| pin C analog pin for current measurement | |
Current sensing abstract class defintion Each current sensing implementation needs to extend this interface
Definition at line 14 of file CurrentSense.h.
| int CurrentSense::alignBLDCDriver | ( | float | align_voltage, |
| BLDCDriver * | driver, | ||
| bool | modulation_centered | ||
| ) |
Function used to align the current sense with the BLDC motor driver
Definition at line 199 of file CurrentSense.cpp.
| int CurrentSense::alignHybridDriver | ( | float | align_voltage, |
| BLDCDriver * | driver, | ||
| bool | modulation_centered | ||
| ) |
Function used to align the current sense with the Hybrid motor driver
Definition at line 503 of file CurrentSense.cpp.
| int CurrentSense::alignStepperDriver | ( | float | align_voltage, |
| StepperDriver * | driver, | ||
| bool | modulation_centered | ||
| ) |
Function used to align the current sense with the Stepper motor driver
Definition at line 418 of file CurrentSense.cpp.
|
virtual |
disable the current sense. default implementation does nothing, but you can override it to do something useful.
Definition at line 138 of file CurrentSense.cpp.
|
virtual |
Function intended to verify if:
This function corrects the alignment errors if possible ans if no such thing is needed it can be left empty (return 1)
IMPORTANT: Default implementation provided in the CurrentSense class, but can be overriden in the child classes
Reimplemented in GenericCurrentSense.
Definition at line 152 of file CurrentSense.cpp.
|
virtual |
enable the current sense. default implementation does nothing, but you can override it to do something useful.
Definition at line 134 of file CurrentSense.cpp.
| ABCurrent_s CurrentSense::getABCurrents | ( | PhaseCurrent_s | current | ) |
Function used for Clarke transform in FOC control It reads the phase currents of the motor It returns the alpha and beta currents
| current | - phase current |
Definition at line 51 of file CurrentSense.cpp.
|
virtual |
Function reading the magnitude of the current set to the motor It returns the absolute or signed magnitude if possible It can receive the motor electrical angle to help with calculation This function is used with the current control (not foc)
| angle_el | - electrical angle of the motor (optional) |
Definition at line 8 of file CurrentSense.cpp.
| DQCurrent_s CurrentSense::getDQCurrents | ( | ABCurrent_s | current, |
| float | angle_el | ||
| ) |
Function used for Park transform in FOC control It reads the Alpha Beta currents and electrical angle of the motor It returns the D and Q currents
| current | - phase current |
Definition at line 113 of file CurrentSense.cpp.
| DQCurrent_s CurrentSense::getFOCCurrents | ( | float | angle_el | ) |
Function used for FOC control, it reads the DQ currents of the motor It uses the function getPhaseCurrents internally
| angle_el | - motor electrical angle |
Definition at line 35 of file CurrentSense.cpp.
|
pure virtual |
Function rading the phase currents a, b and c This function will be used with the foc control throught the function CurrentSense::getFOCCurrents(electrical_angle)
Implemented in GenericCurrentSense, InlineCurrentSense, and LowsideCurrentSense.
|
pure virtual |
Function intialising the CurrentSense class
Implemented in GenericCurrentSense, InlineCurrentSense, and LowsideCurrentSense.
| void CurrentSense::linkDriver | ( | FOCDriver * | _driver | ) |
Linking the current sense with the motor driver Only necessary if synchronisation in between the two is required
Driver linking to the current sense
Definition at line 127 of file CurrentSense.cpp.
| PhaseCurrent_s CurrentSense::readAverageCurrents | ( | int | N = 100 | ) |
Function used to read the average current values over N samples
Definition at line 177 of file CurrentSense.cpp.
| FOCDriver* CurrentSense::driver = nullptr |
driver link
Definition at line 34 of file CurrentSense.h.
| DriverType CurrentSense::driver_type = DriverType::UnknownDriver |
driver type (BLDC or Stepper)
Definition at line 37 of file CurrentSense.h.
| float CurrentSense::gain_a |
phase A gain
Definition at line 43 of file CurrentSense.h.
| float CurrentSense::gain_b |
phase B gain
Definition at line 44 of file CurrentSense.h.
| float CurrentSense::gain_c |
phase C gain
Definition at line 45 of file CurrentSense.h.
| bool CurrentSense::initialized = false |
Definition at line 35 of file CurrentSense.h.
| float CurrentSense::offset_ia |
zero current A voltage value (center of the adc reading)
Definition at line 47 of file CurrentSense.h.
| float CurrentSense::offset_ib |
zero current B voltage value (center of the adc reading)
Definition at line 48 of file CurrentSense.h.
| float CurrentSense::offset_ic |
zero current C voltage value (center of the adc reading)
Definition at line 49 of file CurrentSense.h.
| void* CurrentSense::params = 0 |
pointer to hardware specific parameters of current sensing
Definition at line 36 of file CurrentSense.h.
| int CurrentSense::pinA |
pin A analog pin for current measurement
Definition at line 52 of file CurrentSense.h.
| int CurrentSense::pinB |
pin B analog pin for current measurement
Definition at line 53 of file CurrentSense.h.
| int CurrentSense::pinC |
pin C analog pin for current measurement
Definition at line 54 of file CurrentSense.h.
| bool CurrentSense::skip_align = false |
variable signaling that the phase current direction should be verified during initFOC()
Definition at line 32 of file CurrentSense.h.