Ivobot
Robotics in der BU2 der Kantonsschule am Burggraben
motors.h
1 #ifndef MOTORS_INCLUDED
2 #define MOTORS_INCLUDED
3 
4 // 800 for 20kHz = 16MHz/800 PWM
5 #define PWM_MAX 800
6 
11 class Motors {
12 
13  public:
17  void begin();
23  void setPower(int lr, int power);
24 
30  void setPowers(int leftPower, int rightPower);
31 
32 
37  long getTicks(int lr);
38 
45  long getDt(int lr);
51  long getLastTicks(int lr);
52 
67  long* getTicksArray();
68 
75  long* getDtArray();
76 
77 
84  long* getLastTicksArray();
85 
89  void resetCounters();
90 
91 
92  private:
93  // Left fwd, Left bkwd, Right fwd, Right bkwd
94  int mpins[4] = {5,6,7,8}; // PWM-pins on timers 3 (2,3,5) and 4 (6,7,8)
95  // sensor pins: left, right
96  int spins[2]={2,3};
97 };
98 
99 #endif
void setPower(int lr, int power)
Definition: motors.cpp:120
long * getTicksArray()
Definition: motors.cpp:50
void begin()
Definition: motors.cpp:87
void resetCounters()
Definition: motors.cpp:28
long getTicks(int lr)
Definition: motors.cpp:35
Definition: motors.h:11
long * getLastTicksArray()
Definition: motors.cpp:56
long getDt(int lr)
Definition: motors.cpp:40
long * getDtArray()
Definition: motors.cpp:53
void setPowers(int leftPower, int rightPower)
Definition: motors.cpp:127
long getLastTicks(int lr)
Definition: motors.cpp:45