Skip to content

Method configure4PWM of esp8266_mcu.cpp bug fix #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/base_classes/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void Sensor::update() {
float Sensor::getVelocity() {
// calculate sample time
float Ts = (angle_prev_ts - vel_angle_prev_ts)*1e-6;
if (Ts<minDeltaT) return velocity; // don't update velocity if deltaT is too small
if (Ts < min_elapsed_time) return velocity; // don't update velocity if Ts is too small

velocity = ( (float)(full_rotations - vel_full_rotations)*_2PI + (angle_prev - vel_angle_prev) ) / Ts;
vel_angle_prev = angle_prev;
Expand Down
2 changes: 1 addition & 1 deletion src/common/base_classes/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Sensor{
/**
* Minimum time between updates to velocity. If time elapsed is lower than this, the velocity is not updated.
*/
float minDeltaT = 0.000100; // default is 100 microseconds, or 10kHz
float min_elapsed_time = 0.000100; // default is 100 microseconds, or 10kHz

protected:
/**
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/hardware_specific/esp8266_mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void* _configure4PWM(long pwm_frequency,const int pinA, const int pinB, const in
_setHighFrequency(pwm_frequency, pinC);
_setHighFrequency(pwm_frequency, pinD);
GenericDriverParams* params = new GenericDriverParams {
.pins = { pin1A, pin1B, pin2A, pin2B },
.pins = { pinA, pinB, pinC, pinD },
.pwm_frequency = pwm_frequency
};
return params;
Expand Down Expand Up @@ -112,4 +112,4 @@ void _writeDutyCycle4PWM(float dc_1a, float dc_1b, float dc_2a, float dc_2b, vo
analogWrite(((GenericDriverParams*)params)->pins[3], 255.0f*dc_2b);
}

#endif
#endif