8 motor test

Dependencies:   AX12 mbed

Fork of AX12-HelloWorld by Chris Styles

Committer:
tedparrott6
Date:
Thu Nov 16 14:53:46 2017 +0000
Revision:
2:9448381519ed
Parent:
1:b12b06e2fc2d
NA

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:f6f8cf11779f 1 #include "mbed.h"
chris 0:f6f8cf11779f 2 #include "AX12.h"
chris 0:f6f8cf11779f 3
chris 0:f6f8cf11779f 4 int main() {
chris 0:f6f8cf11779f 5
tedparrott6 2:9448381519ed 6 //Initiates all of the motors in the legs
tedparrott6 2:9448381519ed 7 AX12 m1 (p9, p10, 1);
tedparrott6 2:9448381519ed 8 AX12 m2 (p9, p10, 2);
tedparrott6 2:9448381519ed 9 AX12 m3 (p9, p10, 3);
tedparrott6 2:9448381519ed 10 AX12 m4 (p9, p10, 4);
tedparrott6 2:9448381519ed 11 AX12 m5 (p9, p10, 5);
tedparrott6 2:9448381519ed 12 AX12 m6 (p9, p10, 6);
tedparrott6 2:9448381519ed 13 AX12 m7 (p9, p10, 7);
tedparrott6 2:9448381519ed 14 AX12 m8 (p9, p10, 8);
tedparrott6 2:9448381519ed 15 Serial pc(USBTX, USBRX);
tedparrott6 2:9448381519ed 16
tedparrott6 2:9448381519ed 17 // Sets motors to initial positions, with waits in between to ensure positions are reached
tedparrott6 2:9448381519ed 18 m3.SetGoal(150);
tedparrott6 2:9448381519ed 19 pc.printf("\n\rMotor 3 Initiated");
tedparrott6 2:9448381519ed 20 wait(1);
tedparrott6 2:9448381519ed 21 m4.SetGoal(150);
tedparrott6 2:9448381519ed 22 pc.printf("\n\rMotor 4 Initiated");
tedparrott6 2:9448381519ed 23 wait(1);
tedparrott6 2:9448381519ed 24 m1.SetGoal(150);
tedparrott6 2:9448381519ed 25 pc.printf("\n\rMotor 1 Initiated");
tedparrott6 2:9448381519ed 26 wait(1);
tedparrott6 2:9448381519ed 27 m2.SetGoal(150);
tedparrott6 2:9448381519ed 28 pc.printf("\n\rMotor 2 Initiated");
tedparrott6 2:9448381519ed 29 wait(1);
tedparrott6 2:9448381519ed 30 m5.SetGoal(150);
tedparrott6 2:9448381519ed 31 pc.printf("\n\rMotor 5 Initiated");
tedparrott6 2:9448381519ed 32 wait(1);
tedparrott6 2:9448381519ed 33 m6.SetGoal(150);
tedparrott6 2:9448381519ed 34 pc.printf("\n\rMotor 6 Initiated");
tedparrott6 2:9448381519ed 35 wait(1);
tedparrott6 2:9448381519ed 36 m7.SetGoal(150);
tedparrott6 2:9448381519ed 37 pc.printf("\n\rMotor 7 Initiated");
tedparrott6 2:9448381519ed 38 wait(1);
tedparrott6 2:9448381519ed 39 m8.SetGoal(150);
tedparrott6 2:9448381519ed 40 pc.printf("\n\rMotor 8 Initiated");
tedparrott6 2:9448381519ed 41 wait(1);
chris 1:b12b06e2fc2d 42
chris 0:f6f8cf11779f 43 while (1) {
tedparrott6 2:9448381519ed 44
tedparrott6 2:9448381519ed 45 // Begins loop by sending each joint to key locations at appropriate speeds
tedparrott6 2:9448381519ed 46
tedparrott6 2:9448381519ed 47 //m4.SetCRSpeed(0.00489);
tedparrott6 2:9448381519ed 48 //m3.SetCRSpeed(0.05381);
tedparrott6 2:9448381519ed 49 //m2.SetCRSpeed(0.0349);
tedparrott6 2:9448381519ed 50 //m1.SetCRSpeed(0.0083);
tedparrott6 2:9448381519ed 51 m4.SetGoal(132);
tedparrott6 2:9448381519ed 52 m3.SetGoal(136);
tedparrott6 2:9448381519ed 53 m2.SetGoal(142.87);
tedparrott6 2:9448381519ed 54 m1.SetGoal(151.7);
tedparrott6 2:9448381519ed 55 pc.printf("\n\r1");
tedparrott6 2:9448381519ed 56 wait(0.1);
tedparrott6 2:9448381519ed 57
tedparrott6 2:9448381519ed 58 //m5.SetCRSpeed(0.0273);
tedparrott6 2:9448381519ed 59 //m6.SetCRSpeed(0.086);
tedparrott6 2:9448381519ed 60 //m7.SetCRSpeed(0.0671);
tedparrott6 2:9448381519ed 61 //m8.SetCRSpeed(0.0189);
tedparrott6 2:9448381519ed 62 m5.SetGoal(152);
tedparrott6 2:9448381519ed 63 m6.SetGoal(208);
tedparrott6 2:9448381519ed 64 m7.SetGoal(179);
tedparrott6 2:9448381519ed 65 m8.SetGoal(143);
tedparrott6 2:9448381519ed 66 pc.printf("\n\r2");
tedparrott6 2:9448381519ed 67 wait(0.2);
tedparrott6 2:9448381519ed 68
tedparrott6 2:9448381519ed 69 //m4.SetCRSpeed(0.01467);
tedparrott6 2:9448381519ed 70 //m3.SetCRSpeed(0.02933);
tedparrott6 2:9448381519ed 71 //m2.SetCRSpeed(0.0366);
tedparrott6 2:9448381519ed 72 //m1.SetCRSpeed(0.0087);
tedparrott6 2:9448381519ed 73 m4.SetGoal(136);
tedparrott6 2:9448381519ed 74 m3.SetGoal(128);
tedparrott6 2:9448381519ed 75 m2.SetGoal(152.85);
tedparrott6 2:9448381519ed 76 m1.SetGoal(149.32);
tedparrott6 2:9448381519ed 77 pc.printf("\n\r3");
tedparrott6 2:9448381519ed 78 wait(0.4);
tedparrott6 2:9448381519ed 79
tedparrott6 2:9448381519ed 80 //m4.SetCRSpeed(0.02569);
tedparrott6 2:9448381519ed 81 //m3.SetCRSpeed(0.01834);
tedparrott6 2:9448381519ed 82 //m2.SetCRSpeed(0.021);
tedparrott6 2:9448381519ed 83 //m1.SetCRSpeed(0.005);
tedparrott6 2:9448381519ed 84 m4.SetGoal(143);
tedparrott6 2:9448381519ed 85 m3.SetGoal(133);
tedparrott6 2:9448381519ed 86 m2.SetGoal(158.57);
tedparrott6 2:9448381519ed 87 m1.SetGoal(147.96);
tedparrott6 2:9448381519ed 88 pc.printf("\n\r4");
tedparrott6 2:9448381519ed 89 wait(0.1);
tedparrott6 2:9448381519ed 90
tedparrott6 2:9448381519ed 91 //m5.SetCRSpeed(0.0489);
tedparrott6 2:9448381519ed 92 //m6.SetCRSpeed(0.0342);
tedparrott6 2:9448381519ed 93 //m7.SetCRSpeed(0.0587);
tedparrott6 2:9448381519ed 94 //m8.SetCRSpeed(0.0147);
tedparrott6 2:9448381519ed 95 m5.SetGoal(162);
tedparrott6 2:9448381519ed 96 m6.SetGoal(215);
tedparrott6 2:9448381519ed 97 m7.SetGoal(167);
tedparrott6 2:9448381519ed 98 m8.SetGoal(146);
tedparrott6 2:9448381519ed 99 pc.printf("\n\r5");
tedparrott6 2:9448381519ed 100 wait(0.3);
tedparrott6 2:9448381519ed 101
tedparrott6 2:9448381519ed 102 //m4.SetCRSpeed(0.0212);
tedparrott6 2:9448381519ed 103 //m3.SetCRSpeed(0.01467);
tedparrott6 2:9448381519ed 104 //m2.SetCRSpeed(0.007);
tedparrott6 2:9448381519ed 105 //m1.SetCRSpeed(0.0017);
tedparrott6 2:9448381519ed 106 //m5.SetCRSpeed(0.022);
tedparrott6 2:9448381519ed 107 //m6.SetCRSpeed(0.0587);
tedparrott6 2:9448381519ed 108 //m7.SetCRSpeed(0.0416);
tedparrott6 2:9448381519ed 109 //m8.SetCRSpeed(0.0098);
tedparrott6 2:9448381519ed 110 m4.SetGoal(156);
tedparrott6 2:9448381519ed 111 m3.SetGoal(142);
tedparrott6 2:9448381519ed 112 m2.SetGoal(162.88);
tedparrott6 2:9448381519ed 113 m1.SetGoal(146.94);
tedparrott6 2:9448381519ed 114 m5.SetGoal(171);
tedparrott6 2:9448381519ed 115 m6.SetGoal(191);
tedparrott6 2:9448381519ed 116 m7.SetGoal(150);
tedparrott6 2:9448381519ed 117 m8.SetGoal(150);
tedparrott6 2:9448381519ed 118 pc.printf("\n\r6");
tedparrott6 2:9448381519ed 119 wait(0.6);
tedparrott6 2:9448381519ed 120
tedparrott6 2:9448381519ed 121 //m5.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 122 //m6.SetCRSpeed(0.1174);
tedparrott6 2:9448381519ed 123 //m7.SetCRSpeed(0);
tedparrott6 2:9448381519ed 124 //m8.SetCRSpeed(0);
tedparrott6 2:9448381519ed 125 m5.SetGoal(172);
tedparrott6 2:9448381519ed 126 m6.SetGoal(175);
tedparrott6 2:9448381519ed 127 m7.SetGoal(150);
tedparrott6 2:9448381519ed 128 m8.SetGoal(150);
tedparrott6 2:9448381519ed 129 pc.printf("\n\r7");
tedparrott6 2:9448381519ed 130 wait(0.2);
tedparrott6 2:9448381519ed 131
tedparrott6 2:9448381519ed 132 //m5.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 133 //m6.SetCRSpeed(0.0881);
tedparrott6 2:9448381519ed 134 //m7.SetCRSpeed(0.0037);
tedparrott6 2:9448381519ed 135 //m8.SetCRSpeed(0);
tedparrott6 2:9448381519ed 136 m5.SetGoal(170);
tedparrott6 2:9448381519ed 137 m6.SetGoal(151);
tedparrott6 2:9448381519ed 138 m7.SetGoal(149);
tedparrott6 2:9448381519ed 139 m8.SetGoal(150);
tedparrott6 2:9448381519ed 140 pc.printf("\n\r8");
tedparrott6 2:9448381519ed 141 wait(0.1);
tedparrott6 2:9448381519ed 142
tedparrott6 2:9448381519ed 143 //m4.SetCRSpeed(0.01467);
tedparrott6 2:9448381519ed 144 //m3.SetCRSpeed(0.00734);
tedparrott6 2:9448381519ed 145 //m2.SetCRSpeed(0.0106);
tedparrott6 2:9448381519ed 146 //m1.SetCRSpeed(0.0025);
tedparrott6 2:9448381519ed 147 m4.SetGoal(158);
tedparrott6 2:9448381519ed 148 m3.SetGoal(141);
tedparrott6 2:9448381519ed 149 m2.SetGoal(164.33);
tedparrott6 2:9448381519ed 150 m1.SetGoal(146.6);
tedparrott6 2:9448381519ed 151 pc.printf("\n\r9");
tedparrott6 2:9448381519ed 152 wait(0.2);
tedparrott6 2:9448381519ed 153
tedparrott6 2:9448381519ed 154 //m4.SetCRSpeed(0.011);
tedparrott6 2:9448381519ed 155 //m3.SetCRSpeed(0.02935);
tedparrott6 2:9448381519ed 156 //m2.SetCRSpeed(0.0264);
tedparrott6 2:9448381519ed 157 //m1.SetCRSpeed(0.0062);
tedparrott6 2:9448381519ed 158 m4.SetGoal(161);
tedparrott6 2:9448381519ed 159 m3.SetGoal(133);
tedparrott6 2:9448381519ed 160 m2.SetGoal(157.14);
tedparrott6 2:9448381519ed 161 m1.SetGoal(148.3);
tedparrott6 2:9448381519ed 162 pc.printf("\n\r10");
tedparrott6 2:9448381519ed 163 wait(0.1);
tedparrott6 2:9448381519ed 164
tedparrott6 2:9448381519ed 165 //m5.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 166 //m6.SetCRSpeed(0.0147);
tedparrott6 2:9448381519ed 167 //m7.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 168 //m8.SetCRSpeed(0);
tedparrott6 2:9448381519ed 169 m5.SetGoal(169);
tedparrott6 2:9448381519ed 170 m6.SetGoal(153);
tedparrott6 2:9448381519ed 171 m7.SetGoal(150);
tedparrott6 2:9448381519ed 172 m8.SetGoal(150);
tedparrott6 2:9448381519ed 173 pc.printf("\n\r11");
tedparrott6 2:9448381519ed 174 wait(0.2);
tedparrott6 2:9448381519ed 175
tedparrott6 2:9448381519ed 176 //m5.SetCRSpeed(0.0049);
tedparrott6 2:9448381519ed 177 //m6.SetCRSpeed(0.0538);
tedparrott6 2:9448381519ed 178 //m7.SetCRSpeed(0.0342);
tedparrott6 2:9448381519ed 179 //m8.SetCRSpeed(0.0098);
tedparrott6 2:9448381519ed 180 m5.SetGoal(168);
tedparrott6 2:9448381519ed 181 m6.SetGoal(164);
tedparrott6 2:9448381519ed 182 m7.SetGoal(157);
tedparrott6 2:9448381519ed 183 m8.SetGoal(148);
tedparrott6 2:9448381519ed 184 pc.printf("\n\r12");
tedparrott6 2:9448381519ed 185 wait(0.1);
tedparrott6 2:9448381519ed 186
tedparrott6 2:9448381519ed 187 //m4.SetCRSpeed(0.02726);
tedparrott6 2:9448381519ed 188 //m3.SetCRSpeed(0.08597);
tedparrott6 2:9448381519ed 189 //m2.SetCRSpeed(0.0761);
tedparrott6 2:9448381519ed 190 //m1.SetCRSpeed(0.0178);
tedparrott6 2:9448381519ed 191 m4.SetGoal(148);
tedparrott6 2:9448381519ed 192 m3.SetGoal(92);
tedparrott6 2:9448381519ed 193 m2.SetGoal(120.83);
tedparrott6 2:9448381519ed 194 m1.SetGoal(156.8);
tedparrott6 2:9448381519ed 195 pc.printf("\n\r13");
tedparrott6 2:9448381519ed 196 wait(0.2);
tedparrott6 2:9448381519ed 197
tedparrott6 2:9448381519ed 198 //m5.SetCRSpeed(0.022);
tedparrott6 2:9448381519ed 199 //m6.SetCRSpeed(0.0294);
tedparrott6 2:9448381519ed 200 //m7.SetCRSpeed(0.0367);
tedparrott6 2:9448381519ed 201 //m8.SetCRSpeed(0.011);
tedparrott6 2:9448381519ed 202 m5.SetGoal(174);
tedparrott6 2:9448381519ed 203 m6.SetGoal(172);
tedparrott6 2:9448381519ed 204 m7.SetGoal(147);
tedparrott6 2:9448381519ed 205 m8.SetGoal(151);
tedparrott6 2:9448381519ed 206 pc.printf("\n\r14");
tedparrott6 2:9448381519ed 207 wait(0.4);
tedparrott6 2:9448381519ed 208
tedparrott6 2:9448381519ed 209 //m5.SetCRSpeed(0.0624);
tedparrott6 2:9448381519ed 210 //m6.SetCRSpeed(0.0183);
tedparrott6 2:9448381519ed 211 //m7.SetCRSpeed(0.022);
tedparrott6 2:9448381519ed 212 //m8.SetCRSpeed(0.0037);
tedparrott6 2:9448381519ed 213 m5.SetGoal(157);
tedparrott6 2:9448381519ed 214 m6.SetGoal(167);
tedparrott6 2:9448381519ed 215 m7.SetGoal(141);
tedparrott6 2:9448381519ed 216 m8.SetGoal(152);
tedparrott6 2:9448381519ed 217 pc.printf("\n\r15");
tedparrott6 2:9448381519ed 218 wait(0.1);
tedparrott6 2:9448381519ed 219
tedparrott6 2:9448381519ed 220 //m4.SetCRSpeed(0.04892);
tedparrott6 2:9448381519ed 221 //m3.SetCRSpeed(0.03424);
tedparrott6 2:9448381519ed 222 //m2.SetCRSpeed(0.0584);
tedparrott6 2:9448381519ed 223 //m1.SetCRSpeed(0.0133);
tedparrott6 2:9448381519ed 224 m4.SetGoal(138);
tedparrott6 2:9448381519ed 225 m3.SetGoal(85);
tedparrott6 2:9448381519ed 226 m2.SetGoal(132.77);
tedparrott6 2:9448381519ed 227 m1.SetGoal(154.08);
tedparrott6 2:9448381519ed 228 pc.printf("\n\r16");
tedparrott6 2:9448381519ed 229 wait(0.3);
tedparrott6 2:9448381519ed 230
tedparrott6 2:9448381519ed 231 //m4.SetCRSpeed(0.02202);
tedparrott6 2:9448381519ed 232 //m3.SetCRSpeed(0.0587);
tedparrott6 2:9448381519ed 233 //m2.SetCRSpeed(0.0421);
tedparrott6 2:9448381519ed 234 //m1.SetCRSpeed(0.01);
tedparrott6 2:9448381519ed 235 //m5.SetCRSpeed(0.0212);
tedparrott6 2:9448381519ed 236 //m6.SetCRSpeed(0.0147);
tedparrott6 2:9448381519ed 237 //m7.SetCRSpeed(0.0065);
tedparrott6 2:9448381519ed 238 //m8.SetCRSpeed(0.0016);
tedparrott6 2:9448381519ed 239 m4.SetGoal(129);
tedparrott6 2:9448381519ed 240 m3.SetGoal(109);
tedparrott6 2:9448381519ed 241 m2.SetGoal(150);
tedparrott6 2:9448381519ed 242 m1.SetGoal(150);
tedparrott6 2:9448381519ed 243 m5.SetGoal(144);
tedparrott6 2:9448381519ed 244 m6.SetGoal(158);
tedparrott6 2:9448381519ed 245 m7.SetGoal(137);
tedparrott6 2:9448381519ed 246 m8.SetGoal(153);
tedparrott6 2:9448381519ed 247 pc.printf("\n\r17");
tedparrott6 2:9448381519ed 248 wait(0.6);
tedparrott6 2:9448381519ed 249
tedparrott6 2:9448381519ed 250 //m4.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 251 //m3.SetCRSpeed(0.11742);
tedparrott6 2:9448381519ed 252 //m2.SetCRSpeed(0);
tedparrott6 2:9448381519ed 253 //m1.SetCRSpeed(0);
tedparrott6 2:9448381519ed 254 m4.SetGoal(128);
tedparrott6 2:9448381519ed 255 m3.SetGoal(125);
tedparrott6 2:9448381519ed 256 m2.SetGoal(150);
tedparrott6 2:9448381519ed 257 m1.SetGoal(150);
tedparrott6 2:9448381519ed 258 pc.printf("\n\r18");
tedparrott6 2:9448381519ed 259 wait(0.2);
tedparrott6 2:9448381519ed 260
tedparrott6 2:9448381519ed 261 //m4.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 262 //m3.SetCRSpeed(0.0886);
tedparrott6 2:9448381519ed 263 //m2.SetCRSpeed(0.0052);
tedparrott6 2:9448381519ed 264 //m1.SetCRSpeed(0.0012);
tedparrott6 2:9448381519ed 265 m4.SetGoal(130);
tedparrott6 2:9448381519ed 266 m3.SetGoal(149);
tedparrott6 2:9448381519ed 267 m2.SetGoal(151.43);
tedparrott6 2:9448381519ed 268 m1.SetGoal(149.66);
tedparrott6 2:9448381519ed 269 pc.printf("\n\r19");
tedparrott6 2:9448381519ed 270 wait(0.1);
tedparrott6 2:9448381519ed 271
tedparrott6 2:9448381519ed 272 //m5.SetCRSpeed(0.0147);
tedparrott6 2:9448381519ed 273 //m6.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 274 //m7.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 275 //m8.SetCRSpeed(0.0);
tedparrott6 2:9448381519ed 276 m5.SetGoal(142);
tedparrott6 2:9448381519ed 277 m6.SetGoal(159);
tedparrott6 2:9448381519ed 278 m7.SetGoal(136);
tedparrott6 2:9448381519ed 279 m8.SetGoal(153);
tedparrott6 2:9448381519ed 280 pc.printf("\n\r20");
tedparrott6 2:9448381519ed 281 wait(0.2);
tedparrott6 2:9448381519ed 282
tedparrott6 2:9448381519ed 283 //m5.SetCRSpeed(0.011);
tedparrott6 2:9448381519ed 284 //m6.SetCRSpeed(0.0294);
tedparrott6 2:9448381519ed 285 //m7.SetCRSpeed(0.0257);
tedparrott6 2:9448381519ed 286 //m8.SetCRSpeed(0.0037);
tedparrott6 2:9448381519ed 287 m5.SetGoal(139);
tedparrott6 2:9448381519ed 288 m6.SetGoal(167);
tedparrott6 2:9448381519ed 289 m7.SetGoal(143);
tedparrott6 2:9448381519ed 290 m8.SetGoal(152);
tedparrott6 2:9448381519ed 291 pc.printf("\n\r21");
tedparrott6 2:9448381519ed 292 wait(0.1);
tedparrott6 2:9448381519ed 293
tedparrott6 2:9448381519ed 294 //m4.SetCRSpeed(0.0073);
tedparrott6 2:9448381519ed 295 //m3.SetCRSpeed(0.01467);
tedparrott6 2:9448381519ed 296 //m2.SetCRSpeed(0.0105);
tedparrott6 2:9448381519ed 297 //m1.SetCRSpeed(0.0025);
tedparrott6 2:9448381519ed 298 m4.SetGoal(131);
tedparrott6 2:9448381519ed 299 m3.SetGoal(147);
tedparrott6 2:9448381519ed 300 m2.SetGoal(150);
tedparrott6 2:9448381519ed 301 m1.SetGoal(150);
tedparrott6 2:9448381519ed 302 pc.printf("\n\r22");
tedparrott6 2:9448381519ed 303 wait(0.2);
tedparrott6 2:9448381519ed 304
chris 0:f6f8cf11779f 305 }
chris 0:f6f8cf11779f 306 }