ESP Line Following Buggy
2nd Year Embedded System Project (Group 48 - 2023/24)
|
Represents a motor with integrated quadrature encoder for the buggy. More...
#include <motor.h>
Public Member Functions | |
Motor (PinName pwm, PinName dir, PinName bip, PinName CH_A, PinName CH_B, int pulsePerRev, int pwmFreq, int updateRate, float LowPass_a0, float LowPass_b0, float LowPass_b1, float wheelRadius) | |
Construct a new Motor object. | |
void | set_direction (bool DirState) |
Set the direction of the motor. | |
void | set_bipolar_mode (bool BipState) |
Set the bipolar mode of the motor. | |
void | set_duty_cycle (float DutyCycle) |
Set the duty cycle of the motor. | |
bool | get_direction () |
Get the direction of the motor. | |
bool | get_bipolar_mode () |
Get the bipolar mode of the motor. | |
float | get_duty_cycle () |
Get the duty cycle of the motor. | |
void | update (void) |
Calculate and update all the speed variables. | |
void | reset (void) |
Reset the encoder tick count. | |
int | get_tick_count (void) |
Get the cumulative tick count. | |
float | get_rotational_freq (void) |
Get the rotational frequency of the motor in revolutions per second (rev/s). | |
float | get_rpm (void) |
Get the revolutions per minute (RPM) of the motor. | |
float | get_speed (void) |
Get the tangential speed of the wheel. | |
float | get_filtered_speed (void) |
Get the low-pass filtered speed of the wheel. | |
Represents a motor with integrated quadrature encoder for the buggy.
This class provides functionality to control the speed and direction of the motor, read encoder tick counts, and calculate various parameters such as rotational frequency, speed, and revolutions per minute (RPM). It also includes a low-pass filter for noise reduction in speed measurements.
Motor::Motor | ( | PinName | pwm, |
PinName | dir, | ||
PinName | bip, | ||
PinName | CH_A, | ||
PinName | CH_B, | ||
int | pulsePerRev, | ||
int | pwmFreq, | ||
int | updateRate, | ||
float | LowPass_a0, | ||
float | LowPass_b0, | ||
float | LowPass_b1, | ||
float | wheelRadius ) |
Construct a new Motor object.
pwm | The PWM pin. |
dir | The direction pin. |
bip | The bipolar/unipolar mode pin. |
CH_A | The encoder channel A pin. |
CH_B | The encoder channel B pin. |
pulsePerRev | The number of pulses per revolution of the motor. |
pwmFreq | The PWM frequency. |
updateRate | The update rate. |
LowPass_a0 | Coefficient a0 for the low-pass filter. |
LowPass_b0 | Coefficient b0 for the low-pass filter. |
LowPass_b1 | Coefficient b1 for the low-pass filter. |
wheelRadius | The radius of the wheel in meters. |
Definition at line 7 of file motor.cpp.
bool Motor::get_bipolar_mode | ( | void | ) |
bool Motor::get_direction | ( | void | ) |
float Motor::get_duty_cycle | ( | void | ) |
float Motor::get_filtered_speed | ( | void | ) |
float Motor::get_rotational_freq | ( | void | ) |
float Motor::get_rpm | ( | void | ) |
float Motor::get_speed | ( | void | ) |
int Motor::get_tick_count | ( | void | ) |
void Motor::reset | ( | void | ) |
void Motor::set_bipolar_mode | ( | bool | BipState | ) |
void Motor::set_direction | ( | bool | DirState | ) |
void Motor::set_duty_cycle | ( | float | DutyCycle | ) |
void Motor::update | ( | void | ) |