SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
GenericCurrentSense Class Reference

#include <GenericCurrentSense.h>

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

Public Member Functions

 GenericCurrentSense (PhaseCurrent_s(*readCallback)()=nullptr, void(*initCallback)()=nullptr)
 
int init () override
 
PhaseCurrent_s getPhaseCurrents () override
 
int driverAlign (float align_voltage, bool modulation_centered) override
 
- Public Member Functions inherited from CurrentSense
void linkDriver (FOCDriver *driver)
 
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

PhaseCurrent_s(* readCallback )() = nullptr
 function pointer to sensor reading
 
void(* initCallback )() = nullptr
 function pointer to sensor initialisation
 
- Public Attributes inherited from CurrentSense
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

Definition at line 13 of file GenericCurrentSense.h.

Constructor & Destructor Documentation

◆ GenericCurrentSense()

GenericCurrentSense::GenericCurrentSense ( PhaseCurrent_s(*)()  readCallback = nullptr,
void(*)()  initCallback = nullptr 
)

GenericCurrentSense class constructor

Definition at line 4 of file GenericCurrentSense.cpp.

Member Function Documentation

◆ driverAlign()

int GenericCurrentSense::driverAlign ( float  align_voltage,
bool  modulation_centered 
)
overridevirtual

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 from CurrentSense.

Definition at line 57 of file GenericCurrentSense.cpp.

◆ getPhaseCurrents()

PhaseCurrent_s GenericCurrentSense::getPhaseCurrents ( )
overridevirtual

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

Implements CurrentSense.

Definition at line 44 of file GenericCurrentSense.cpp.

◆ init()

int GenericCurrentSense::init ( )
overridevirtual

Function intialising the CurrentSense class

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

Implements CurrentSense.

Definition at line 11 of file GenericCurrentSense.cpp.

Member Data Documentation

◆ initCallback

void(* GenericCurrentSense::initCallback) () = nullptr

function pointer to sensor initialisation

Definition at line 27 of file GenericCurrentSense.h.

◆ readCallback

PhaseCurrent_s(* GenericCurrentSense::readCallback) () = nullptr

function pointer to sensor reading

Definition at line 26 of file GenericCurrentSense.h.


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