-
Notifications
You must be signed in to change notification settings - Fork 0
/
Motor.h
45 lines (40 loc) · 1.04 KB
/
Motor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef MOTOR_H
#define MOTOR_H
class Motor {
double rpm;
long timeOld;
long count;
double speedWheel;
long positionOld;
long positionNew;
long countOld;
long timingOld;
int nummerMotor;
long timingMotor;
double voltage;
bool stopped;
long tSample;
double errorOld;
double voltageOld;
bool isIncreased;
Encoder motorEncoder;
double motorSpeed = 0;
int motorDirection = 0;
int mode = 1;
public:
Motor(int whichMotor, int encoderPin1, int encoderPin2, long T = 50);
void setSamplingTime(int T) { tSample = T; }
long readEncoder() { return motorEncoder.read(); }
bool countMotor();
double speedometer();
double getSpeed() { return speedWheel; }
void motorRun(int voltage, int desiredDirection = 1);
void motorStop();
void controllerPid(double desiredSpeed);
void setSpeed(double desiredSpeed);
void setVoltage(double v, int desiredDirection);
void setVoltage(double v);
void setMode(int desiredMode) { mode = desiredMode;}
void increase(bool value) { isIncreased = value; }
};
#endif