Skip to content

Commit f2ae008

Browse files
committed
added an enable_active_high field (default true) to BLDCDriver6PWM
this is to use the enable pin on the DRV8316, which is actually a driver_off pin, and therefore active-low for enabled state
1 parent 273bcf8 commit f2ae008

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/drivers/BLDCDriver6PWM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BLDCDriver6PWM::BLDCDriver6PWM(int phA_h,int phA_l,int phB_h,int phB_l,int phC_h
2424
// enable motor driver
2525
void BLDCDriver6PWM::enable(){
2626
// enable_pin the driver - if enable_pin pin available
27-
if ( _isset(enable_pin) ) digitalWrite(enable_pin, HIGH);
27+
if ( _isset(enable_pin) ) digitalWrite(enable_pin, enable_active_high?HIGH:LOW);
2828
// set zero to PWM
2929
setPwm(0, 0, 0);
3030
}
@@ -35,7 +35,7 @@ void BLDCDriver6PWM::disable()
3535
// set zero to PWM
3636
setPwm(0, 0, 0);
3737
// disable the driver - if enable_pin pin available
38-
if ( _isset(enable_pin) ) digitalWrite(enable_pin, LOW);
38+
if ( _isset(enable_pin) ) digitalWrite(enable_pin, enable_active_high?LOW:HIGH);
3939

4040
}
4141

@@ -82,4 +82,4 @@ void BLDCDriver6PWM::setPwm(float Ua, float Ub, float Uc) {
8282
// Set voltage to the pwm pin
8383
void BLDCDriver6PWM::setPhaseState(int sa, int sb, int sc) {
8484
// TODO implement disabling
85-
}
85+
}

src/drivers/BLDCDriver6PWM.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class BLDCDriver6PWM: public BLDCDriver
3737
int pwmB_h,pwmB_l; //!< phase B pwm pin number
3838
int pwmC_h,pwmC_l; //!< phase C pwm pin number
3939
int enable_pin; //!< enable pin number
40+
bool enable_active_high = true;
4041

4142
float dead_zone; //!< a percentage of dead-time(zone) (both high and low side in low) for each pwm cycle [0,1]
4243

0 commit comments

Comments
 (0)