Skip to content

Commit bb7d29c

Browse files
committed
FEAT add _startADC3PinConversionLowSide() API
1 parent 0d54abe commit bb7d29c

File tree

8 files changed

+147
-264
lines changed

8 files changed

+147
-264
lines changed

src/SimpleFOC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void loop() {
109109
#include "drivers/StepperDriver4PWM.h"
110110
#include "drivers/StepperDriver2PWM.h"
111111
#include "current_sense/InlineCurrentSense.h"
112-
#include "current_sense/LowSideCurrentSense.h"
112+
#include "current_sense/LowsideCurrentSense.h"
113113
#include "communication/Commander.h"
114114
#include "communication/StepDirListener.h"
115115

src/current_sense/LowSideCurrentSense.cpp

Lines changed: 0 additions & 181 deletions
This file was deleted.

src/current_sense/LowSideCurrentSense.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/current_sense/LowsideCurrentSense.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void LowsideCurrentSense::calibrateOffsets(){
3434
offset_ic= 0;
3535
// read the adc voltage 1000 times ( arbitrary number )
3636
for (int i = 0; i < 1000; i++) {
37+
_startADC3PinConversionLowSide();
3738
offset_ia += _readADCVoltageLowSide(pinA);
3839
offset_ib += _readADCVoltageLowSide(pinB);
3940
if(_isset(pinC)) offset_ic += _readADCVoltageLowSide(pinC);
@@ -48,6 +49,7 @@ void LowsideCurrentSense::calibrateOffsets(){
4849
// read all three phase currents (if possible 2 or 3)
4950
PhaseCurrent_s LowsideCurrentSense::getPhaseCurrents(){
5051
PhaseCurrent_s current;
52+
_startADC3PinConversionLowSide();
5153
current.a = (_readADCVoltageLowSide(pinA) - offset_ia)*gain_a;// amps
5254
current.b = (_readADCVoltageLowSide(pinB) - offset_ib)*gain_b;// amps
5355
current.c = (!_isset(pinC)) ? 0 : (_readADCVoltageLowSide(pinC) - offset_ic)*gain_c; // amps

src/current_sense/hardware_api.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,26 @@ float _readADCVoltageInline(const int pinA);
2020
*/
2121
void _configureADCInline(const int pinA,const int pinB,const int pinC = NOT_SET);
2222

23-
void _start3PinsDMA();
24-
void _read3PinsDMA(const int pinA,const int pinB,const int pinC, float & a, float & b, float & c);
25-
void _configure3PinsDMA(const int pinA,const int pinB,const int pinC = NOT_SET);
23+
/**
24+
* function reading an ADC value and returning the read voltage
25+
*
26+
* @param pinA - adc pin A
27+
* @param pinB - adc pin B
28+
* @param pinC - adc pin C
29+
*/
30+
void _configureADCLowSide(const int pinA,const int pinB,const int pinC = NOT_SET);
2631

32+
void _startADC3PinConversionLowSide();
33+
34+
/**
35+
* function reading an ADC value and returning the read voltage
36+
*
37+
* @param pinA - the arduino pin to be read (it has to be ADC pin)
38+
*/
39+
float _readADCVoltageLowSide(const int pinA);
40+
41+
/**
42+
* function syncing the Driver with the ADC for the LowSide Sensing
43+
*/
44+
void _driverSyncLowSide();
2745
#endif

src/current_sense/hardware_specific/esp32_mcu.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ float _readADCVoltageLowSide(const int pin){
3030
return raw_adc * _ADC_CONV;
3131
}
3232

33+
void _startADC3PinConversionLowSide(){
34+
35+
}
3336

3437
// function reading an ADC value and returning the read voltage
3538
void _configureADCLowSide(const int pinA,const int pinB,const int pinC){

0 commit comments

Comments
 (0)