Skip to content

Commit

Permalink
Add conversion command for inline
Browse files Browse the repository at this point in the history
  • Loading branch information
mcells committed Feb 12, 2024
1 parent 9fcd4e5 commit b68fedf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/current_sense/InlineCurrentSense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void InlineCurrentSense::calibrateOffsets(){
offset_ic = 0;
// read the adc voltage 1000 times ( arbitrary number )
for (int i = 0; i < calibration_rounds; i++) {
_startADC3PinConversionInline();
if(_isset(pinA)) offset_ia += _readADCVoltageInline(pinA, params);
if(_isset(pinB)) offset_ib += _readADCVoltageInline(pinB, params);
if(_isset(pinC)) offset_ic += _readADCVoltageInline(pinC, params);
Expand All @@ -75,6 +76,7 @@ void InlineCurrentSense::calibrateOffsets(){
// read all three phase currents (if possible 2 or 3)
PhaseCurrent_s InlineCurrentSense::getPhaseCurrents(){
PhaseCurrent_s current;
_startADC3PinConversionInline();
current.a = (!_isset(pinA)) ? 0 : (_readADCVoltageInline(pinA, params) - offset_ia)*gain_a;// amps
current.b = (!_isset(pinB)) ? 0 : (_readADCVoltageInline(pinB, params) - offset_ib)*gain_b;// amps
current.c = (!_isset(pinC)) ? 0 : (_readADCVoltageInline(pinC, params) - offset_ic)*gain_c; // amps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ void IRAM_ATTR _startADC3PinConversionLowSide()
#endif
}

void IRAM_ATTR _startADC3PinConversionInline(){
_startADC3PinConversionLowSide();
}

// Takes the buffered adc counts and returns the coresponding float voltage for a pin.
float IRAM_ATTR _readADCVoltageI2S(const int pin, const void *cs_params)
{
Expand Down

0 comments on commit b68fedf

Please sign in to comment.