PicoLowLevel
Loading...
Searching...
No Matches
SmartMotor.h
Go to the documentation of this file.
1#ifndef SMART_MOTOR_H
2#define SMART_MOTOR_H
3
4#include <Arduino.h>
5#include "Debug.h"
6#include "Motor.h"
7#include "TractionEncoder.h"
8#include "PID.h"
9#include "MovingAvgFilter.h"
10
16 public:
17 SmartMotor(byte pwm, byte dir, byte enc_a, byte enc_b, bool invert = false, PIO pio = pio0);
18 void begin();
19 void update();
20
21 void setSpeed(float value);
22 float getSpeed();
23 void stop();
24
25 void calibrate(float target = 45.f);
26
27 private:
28 int speedToPower(float speed);
29
30 Motor motor;
31 TractionEncoder encoder;
32 PID pid;
33
34 bool invert;
35 float speed;
36 unsigned long enc_last;
37 unsigned long pid_last;
38};
39
40#endif
Motor class used to control simple DC motors.
Definition Motor.h:10
PID controller library.
Definition PID.h:9
Class used to control DC motors at a constant speed.
Definition SmartMotor.h:15
void stop()
Stop the motor.
Definition SmartMotor.cpp:67
void update()
Update routine, updating the PID and the motor speed.
Definition SmartMotor.cpp:31
float getSpeed()
Get the current speed of the motor.
Definition SmartMotor.cpp:54
void setSpeed(float value)
Set the desired speed of the motor.
Definition SmartMotor.cpp:45
void begin()
Initialize SmartMotor and necessary components.
Definition SmartMotor.cpp:22
void calibrate(float target=45.f)
Calibrate the PID controller.
Definition SmartMotor.cpp:80
Class used to read data from traction rotary encoders.
Definition TractionEncoder.h:13