Skip to content

Commit 412c47a

Browse files
committed
use default dir only if sensor not connected
1 parent 5dffc7b commit 412c47a

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/BLDCMotor.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ int BLDCMotor::init() {
9393
P_angle.limit = velocity_limit;
9494

9595
// if using open loop control, set a CW as the default direction if not already set
96-
if ((controller==MotionControlType::angle_openloop
97-
||controller==MotionControlType::velocity_openloop)
98-
&& (sensor_direction == Direction::UNKNOWN)) {
99-
sensor_direction = Direction::CW;
96+
// only if no sensor is used
97+
if(!sensor){
98+
if ((controller==MotionControlType::angle_openloop
99+
||controller==MotionControlType::velocity_openloop)
100+
&& (sensor_direction == Direction::UNKNOWN)) {
101+
sensor_direction = Direction::CW;
102+
}
100103
}
101104

102105
_delay(500);

src/HybridStepperMotor.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ HybridStepperMotor::HybridStepperMotor(int pp, float _R, float _KV, float _induc
3030
void HybridStepperMotor::linkDriver(BLDCDriver *_driver)
3131
{
3232
driver = _driver;
33+
SIMPLEFOC_DEBUG("MOT: BLDCDriver linked, using pin C as the mid-phase");
3334
}
3435

3536
// init hardware pins
@@ -64,10 +65,13 @@ int HybridStepperMotor::init()
6465
P_angle.limit = velocity_limit;
6566

6667
// if using open loop control, set a CW as the default direction if not already set
67-
if ((controller==MotionControlType::angle_openloop
68-
||controller==MotionControlType::velocity_openloop)
69-
&& (sensor_direction == Direction::UNKNOWN)) {
70-
sensor_direction = Direction::CW;
68+
// only if no sensor is used
69+
if(!sensor){
70+
if ((controller==MotionControlType::angle_openloop
71+
||controller==MotionControlType::velocity_openloop)
72+
&& (sensor_direction == Direction::UNKNOWN)) {
73+
sensor_direction = Direction::CW;
74+
}
7175
}
7276

7377
_delay(500);

src/StepperMotor.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ int StepperMotor::init() {
5757
P_angle.limit = velocity_limit;
5858

5959
// if using open loop control, set a CW as the default direction if not already set
60-
if ((controller==MotionControlType::angle_openloop
61-
||controller==MotionControlType::velocity_openloop)
62-
&& (sensor_direction == Direction::UNKNOWN)) {
63-
sensor_direction = Direction::CW;
60+
// only if no sensor is used
61+
if(!sensor){
62+
if ((controller==MotionControlType::angle_openloop
63+
||controller==MotionControlType::velocity_openloop)
64+
&& (sensor_direction == Direction::UNKNOWN)) {
65+
sensor_direction = Direction::CW;
66+
}
6467
}
6568

6669
_delay(500);

0 commit comments

Comments
 (0)