Skip to content

Commit 9251630

Browse files
committed
remove default params from checkbus, encoder added empty update, bug in FOCMotor::electricalAngle
1 parent b040f7d commit 9251630

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

src/BLDCMotor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ int BLDCMotor::alignSensor() {
209209
// get the current zero electric angle
210210
zero_electric_angle = 0;
211211
zero_electric_angle = electricalAngle();
212+
//zero_electric_angle = _normalizeAngle(_electricalAngle(sensor_direction*sensor->getAngle(), pole_pairs));
212213
_delay(20);
213214
if(monitor_port){
214215
monitor_port->print(F("MOT: Zero elec. angle: "));

src/common/base_classes/FOCMotor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ float FOCMotor::shaftVelocity() {
6868
float FOCMotor::electricalAngle(){
6969
// if no sensor linked return previous value ( for open loop )
7070
if(!sensor) return electrical_angle;
71-
return sensor_direction * _normalizeAngle(sensor->getMechanicalAngle() * pole_pairs - zero_electric_angle);
71+
return _normalizeAngle( (float)(sensor_direction * pole_pairs) * sensor->getMechanicalAngle() - zero_electric_angle );
7272
}
7373

7474
/**

src/sensors/Encoder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ void Encoder::handleIndex() {
9898
}
9999
}
100100

101+
102+
void Encoder::update() {
103+
// do nothing for Encoder
104+
}
105+
101106
/*
102107
Shaft angle calculation
103108
*/

src/sensors/Encoder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Encoder: public Sensor{
2727
Encoder(int encA, int encB , float ppr, int index = 0);
2828

2929
/** encoder initialise pins */
30-
void init();
30+
void init() override;
3131
/**
3232
* function enabling hardware interrupts for the encoder channels with provided callback functions
3333
* if callback is not provided then the interrupt is not enabled
@@ -67,6 +67,7 @@ class Encoder: public Sensor{
6767
float getAngle() override;
6868
double getPreciseAngle() override;
6969
int32_t getFullRotations() override;
70+
virtual void update() override;
7071

7172
/**
7273
* returns 0 if it does need search for absolute zero

src/sensors/MagneticSensorI2C.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MagneticSensorI2C: public Sensor{
4949
float getSensorAngle() override;
5050

5151
/** experimental function to check and fix SDA locked LOW issues */
52-
int checkBus(byte sda_pin = SDA, byte scl_pin = SCL);
52+
int checkBus(byte sda_pin , byte scl_pin );
5353

5454
private:
5555
float cpr; //!< Maximum range of the magnetic sensor

0 commit comments

Comments
 (0)