26 DigitalOut Direction, Bipolar;
32 volatile int curr_tick_count;
33 volatile int prev_tick_count;
34 volatile float rotational_freq;
36 volatile float filtered_speed;
37 volatile float prev_speed;
38 volatile float prev_filtered_speed;
42 const int update_rate;
43 const int pulse_per_rev;
44 const float wheel_radius;
52 const float pi = 3.14159265;
72 Motor(PinName pwm, PinName dir, PinName bip, PinName CH_A, PinName CH_B,
73 int pulsePerRev,
int pwmFreq,
int updateRate,
float LowPass_a0,
float LowPass_b0,
float LowPass_b1,
float wheelRadius);
Represents a motor with integrated quadrature encoder for the buggy.
float get_speed(void)
Get the tangential speed of the wheel.
void set_bipolar_mode(bool BipState)
Set the bipolar mode of the motor.
void set_direction(bool DirState)
Set the direction of the motor.
float get_filtered_speed(void)
Get the low-pass filtered speed of the wheel.
void set_duty_cycle(float DutyCycle)
Set the duty cycle of the motor.
void update(void)
Calculate and update all the speed variables.
float get_rpm(void)
Get the revolutions per minute (RPM) of the motor.
float get_rotational_freq(void)
Get the rotational frequency of the motor in revolutions per second (rev/s).
float get_duty_cycle()
Get the duty cycle of the motor.
void reset(void)
Reset the encoder tick count.
int get_tick_count(void)
Get the cumulative tick count.
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.
bool get_bipolar_mode()
Get the bipolar mode of the motor.
bool get_direction()
Get the direction of the motor.