Skip to content

Commit 359ffc9

Browse files
committed
initial implementation
1 parent a8e5793 commit 359ffc9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/HybridStepperMotor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ void HybridStepperMotor::setPhaseVoltage(float Uq, float Ud, float angle_el)
172172
Ub = Ub + Vo;
173173
Uc = Vo;
174174
}
175+
176+
// compensate for voltage drop on the driver gate resistance
177+
if(_isset(driver->gate_resistance) && current_sense){
178+
// compensate for voltage drop on the driver gate resistance
179+
// this is especially important for hybrid steppers
180+
PhaseCurrent_s currents = current_sense->getPhaseCurrents();
181+
Ua += currents.a * driver->gate_resistance;
182+
Ub += currents.b * driver->gate_resistance;
183+
Uc += -(currents.a + currents.b) * driver->gate_resistance;
184+
}
185+
175186
driver->setPwm(Ua, Ub, Uc);
176187

177188
}

src/common/base_classes/FOCDriver.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define FOCDRIVER_H
33

44
#include "Arduino.h"
5-
5+
#include "../foc_utils.h"
66

77
enum PhaseState : uint8_t {
88
PHASE_OFF = 0, // both sides of the phase are off
@@ -36,6 +36,9 @@ class FOCDriver{
3636
float voltage_power_supply; //!< power supply voltage
3737
float voltage_limit; //!< limiting voltage set to the motor
3838

39+
// optional but very useful for hybrid stepper motor
40+
float gate_resistance = NOT_SET; //!< phase resistance of the driver
41+
3942
bool initialized = false; //!< true if driver was successfully initialized
4043
void* params = 0; //!< pointer to hardware specific parameters of driver
4144

0 commit comments

Comments
 (0)