SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
CurrentSense Class Referenceabstract

#include <CurrentSense.h>

Inheritance diagram for CurrentSense:
[legend]
Collaboration diagram for CurrentSense:
[legend]

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()
 
FOCDriverdriver = 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
 

Detailed Description

Current sensing abstract class defintion Each current sensing implementation needs to extend this interface

Definition at line 14 of file CurrentSense.h.

Member Function Documentation

◆ alignBLDCDriver()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignHybridDriver()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignStepperDriver()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disable()

void CurrentSense::disable ( )
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.

Here is the caller graph for this function:

◆ driverAlign()

int CurrentSense::driverAlign ( float  align_voltage,
bool  modulation_centered = false 
)
virtual

Function intended to verify if:

  • phase current are oriented properly
  • if their order is the same as driver phases

This function corrects the alignment errors if possible ans if no such thing is needed it can be left empty (return 1)

Returns
-
0 - failure 1 - success and nothing changed 2 - success but pins reconfigured 3 - success but gains inverted 4 - success but pins reconfigured and gains inverted

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable()

void CurrentSense::enable ( )
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.

Here is the caller graph for this function:

◆ getABCurrents()

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

Parameters
current- phase current

Definition at line 51 of file CurrentSense.cpp.

Here is the caller graph for this function:

◆ getDCCurrent()

float CurrentSense::getDCCurrent ( float  angle_el = 0)
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)

Parameters
angle_el- electrical angle of the motor (optional)

Definition at line 8 of file CurrentSense.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDQCurrents()

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

Parameters
current- phase current

Definition at line 113 of file CurrentSense.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFOCCurrents()

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

Parameters
angle_el- motor electrical angle

Definition at line 35 of file CurrentSense.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPhaseCurrents()

virtual PhaseCurrent_s CurrentSense::getPhaseCurrents ( )
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)

  • it returns current c equal to 0 if only two phase measurements available
Returns
PhaseCurrent_s current values

Implemented in GenericCurrentSense, InlineCurrentSense, and LowsideCurrentSense.

Here is the caller graph for this function:

◆ init()

virtual int CurrentSense::init ( )
pure virtual

Function intialising the CurrentSense class

  • All the necessary intialisations of adc and sync should be implemented here
Returns
- 0 - for failure & 1 - for success

Implemented in GenericCurrentSense, InlineCurrentSense, and LowsideCurrentSense.

◆ linkDriver()

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.

Here is the call graph for this function:

◆ readAverageCurrents()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ driver

FOCDriver* CurrentSense::driver = nullptr

driver link

Definition at line 34 of file CurrentSense.h.

◆ driver_type

DriverType CurrentSense::driver_type = DriverType::UnknownDriver

driver type (BLDC or Stepper)

Definition at line 37 of file CurrentSense.h.

◆ gain_a

float CurrentSense::gain_a

phase A gain

Definition at line 43 of file CurrentSense.h.

◆ gain_b

float CurrentSense::gain_b

phase B gain

Definition at line 44 of file CurrentSense.h.

◆ gain_c

float CurrentSense::gain_c

phase C gain

Definition at line 45 of file CurrentSense.h.

◆ initialized

bool CurrentSense::initialized = false

Definition at line 35 of file CurrentSense.h.

◆ offset_ia

float CurrentSense::offset_ia

zero current A voltage value (center of the adc reading)

Definition at line 47 of file CurrentSense.h.

◆ offset_ib

float CurrentSense::offset_ib

zero current B voltage value (center of the adc reading)

Definition at line 48 of file CurrentSense.h.

◆ offset_ic

float CurrentSense::offset_ic

zero current C voltage value (center of the adc reading)

Definition at line 49 of file CurrentSense.h.

◆ params

void* CurrentSense::params = 0

pointer to hardware specific parameters of current sensing

Definition at line 36 of file CurrentSense.h.

◆ pinA

int CurrentSense::pinA

pin A analog pin for current measurement

Definition at line 52 of file CurrentSense.h.

◆ pinB

int CurrentSense::pinB

pin B analog pin for current measurement

Definition at line 53 of file CurrentSense.h.

◆ pinC

int CurrentSense::pinC

pin C analog pin for current measurement

Definition at line 54 of file CurrentSense.h.

◆ skip_align

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.


The documentation for this class was generated from the following files: