Guojun Jiang
/
StewartPlatform
stewartplatform
Fork of PwmOut_HelloWorld by
src/motor.cpp@3:c5ea5b6a7460, 2016-08-20 (annotated)
- Committer:
- wheels
- Date:
- Sat Aug 20 12:06:14 2016 +0000
- Revision:
- 3:c5ea5b6a7460
- Parent:
- 2:50062ac8646d
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wheels | 2:50062ac8646d | 1 | #include "motor.h" |
wheels | 2:50062ac8646d | 2 | |
wheels | 3:c5ea5b6a7460 | 3 | PwmOut motor[6] = {PwmOut(PA_6), PwmOut(PA_0), PwmOut(PA_2), PwmOut(PB_0), PwmOut(PA_1), PwmOut(PB_9)}; |
wheels | 2:50062ac8646d | 4 | extern char position[6]; |
wheels | 2:50062ac8646d | 5 | |
wheels | 2:50062ac8646d | 6 | void motor_drive() { |
wheels | 2:50062ac8646d | 7 | for(int index = 0; index < 6; index++) { |
wheels | 2:50062ac8646d | 8 | float duty = (0.000417 * position[index] + 0.05); |
wheels | 2:50062ac8646d | 9 | motor[index] = duty; |
wheels | 2:50062ac8646d | 10 | } |
wheels | 2:50062ac8646d | 11 | } |
wheels | 2:50062ac8646d | 12 | |
wheels | 2:50062ac8646d | 13 | void motor_init() { |
wheels | 2:50062ac8646d | 14 | for (int index = 0; index < 6; index++) { |
wheels | 2:50062ac8646d | 15 | motor[index].period(0.020); //cycle period is 20ms |
wheels | 2:50062ac8646d | 16 | motor[index] = 0.075; //control pulse width is 1ms~2ms? should be confirmed!! |
wheels | 2:50062ac8646d | 17 | } |
wheels | 2:50062ac8646d | 18 | // motor[0].period(0.020); |
wheels | 2:50062ac8646d | 19 | // motor[0] = 0.05; |
wheels | 2:50062ac8646d | 20 | } |
wheels | 2:50062ac8646d | 21 |