-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBalanceBotTests.cpp
More file actions
75 lines (64 loc) · 2.48 KB
/
BalanceBotTests.cpp
File metadata and controls
75 lines (64 loc) · 2.48 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*!
* \file BalanceBotTests.cpp
* \author Michael Pillon
*
* Functions to run to test parts of the robot
* - MPU6050 runs debug messages in console when initialized
*/
#include "BalanceBot.hpp"
/*!
\fn runAllTests()
Runs all hardware tests
~~~ MAKE SURE TO ADD ALL TESTS TO THIS FUNCTION ~~~
*/
void BalanceBot::runAllTests() {
// Pick 1 motor test
testWheels();
}
/*!
\fn testWheels()
Runs both wheels in the same direction and opposite directions at all speeds.
- Based on A4988 stepper motor drivers
- It is recommended that tape or an identifier be put on each wheel to ensure full rotation at all microstepping modes.
Procedure:
1) Both wheels should do a full rotation in the forward direction for each of the 5 microstepping modes of the A4988 as well as with a 1 second delay between each rotation. (From fastest to slowest)
2) Both wheels should do a 6th rotation at the slowest speed.
3) Steps 1 and 2 then repeat in the reverse direction but going from slowest to fastest with the 6th rotation being at the fastest speed.
4) steps 1 and 2 are repeated with wheels going in opposite directions in both orientations
Troubleshooting:
- If wheels move in the same direction but do not move at 5 different speeds or do not make full rotations then the MSx pins are incorrectly set.
- Something else went wrong, figure it out and document here.
*/
void BalanceBot::testWheels(uint8_t scaleFactor) {
//!< Step 1 and 2
setDirection(FORWARD);
setStepMode(FULL_STEP);
for(int i = 0; i <= 5; i++) { // Do each of the 5 step modes
steps(STEPS_PER_REVOLUTION*scaleFactor);
incStepMode();
ThisThread::sleep_for(100);
}
//!< Step 3
setDirection(REVERSE);
for(int i = 0; i <= 5; i++) { // Do each of the 5 step modes
steps(STEPS_PER_REVOLUTION*scaleFactor);
decStepMode();
ThisThread::sleep_for(100);
}
//!< Step 4 part 1
setDirection(LEFT_TURN);
setStepMode(FULL_STEP);
for(int i = 0; i <= 5; i++) { // Do each of the 5 step modes
steps(STEPS_PER_REVOLUTION*scaleFactor);
incStepMode();
ThisThread::sleep_for(100);
}
//!< Step 4 part 2
setDirection(RIGHT_TURN);
setStepMode(SIXTEENTH_STEP*scaleFactor);
for(int i = 0; i <= 5; i++) { // Do each of the 5 step modes
steps(STEPS_PER_REVOLUTION*scaleFactor);
decStepMode();
ThisThread::sleep_for(100);
}
}