Oskar Weigl
/
Quadcopter_copy
Very early flyable code.
motors.h@0:9fcb3bf5c231, 2011-10-01 (annotated)
- Committer:
- madcowswe
- Date:
- Sat Oct 01 12:57:23 2011 +0000
- Revision:
- 0:9fcb3bf5c231
This edit is for testing: not flyable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
madcowswe | 0:9fcb3bf5c231 | 1 | |
madcowswe | 0:9fcb3bf5c231 | 2 | void initmotor() { |
madcowswe | 0:9fcb3bf5c231 | 3 | PWMleft.period_ms(20); |
madcowswe | 0:9fcb3bf5c231 | 4 | PWMleft = 0.01; |
madcowswe | 0:9fcb3bf5c231 | 5 | PWMright.period_ms(20); |
madcowswe | 0:9fcb3bf5c231 | 6 | PWMright = 0.01; |
madcowswe | 0:9fcb3bf5c231 | 7 | |
madcowswe | 0:9fcb3bf5c231 | 8 | PWMfront.period_ms(20); |
madcowswe | 0:9fcb3bf5c231 | 9 | PWMfront = 0.01; |
madcowswe | 0:9fcb3bf5c231 | 10 | PWMrear.period_ms(20); |
madcowswe | 0:9fcb3bf5c231 | 11 | PWMrear = 0.01; |
madcowswe | 0:9fcb3bf5c231 | 12 | } |
madcowswe | 0:9fcb3bf5c231 | 13 | |
madcowswe | 0:9fcb3bf5c231 | 14 | bool leftM(float thrust) { |
madcowswe | 0:9fcb3bf5c231 | 15 | float output = (634 + 0.657 * thrust) / 10000; |
madcowswe | 0:9fcb3bf5c231 | 16 | if (output > 0.0910) { |
madcowswe | 0:9fcb3bf5c231 | 17 | PWMleft = 0.0910; |
madcowswe | 0:9fcb3bf5c231 | 18 | return true; |
madcowswe | 0:9fcb3bf5c231 | 19 | } else { |
madcowswe | 0:9fcb3bf5c231 | 20 | PWMleft = output; |
madcowswe | 0:9fcb3bf5c231 | 21 | return false; |
madcowswe | 0:9fcb3bf5c231 | 22 | } |
madcowswe | 0:9fcb3bf5c231 | 23 | } |
madcowswe | 0:9fcb3bf5c231 | 24 | |
madcowswe | 0:9fcb3bf5c231 | 25 | bool rightM(float thrust) { |
madcowswe | 0:9fcb3bf5c231 | 26 | float output = (617 + 0.474 * thrust) / 10000; |
madcowswe | 0:9fcb3bf5c231 | 27 | if (output > 0.0822) { |
madcowswe | 0:9fcb3bf5c231 | 28 | PWMright = 0.0822; |
madcowswe | 0:9fcb3bf5c231 | 29 | return true; |
madcowswe | 0:9fcb3bf5c231 | 30 | } else { |
madcowswe | 0:9fcb3bf5c231 | 31 | PWMright = output; |
madcowswe | 0:9fcb3bf5c231 | 32 | return false; |
madcowswe | 0:9fcb3bf5c231 | 33 | } |
madcowswe | 0:9fcb3bf5c231 | 34 | } |
madcowswe | 0:9fcb3bf5c231 | 35 | |
madcowswe | 0:9fcb3bf5c231 | 36 | bool frontM(float thrust) { |
madcowswe | 0:9fcb3bf5c231 | 37 | float output = (637 + 0.509 * thrust) / 10000; |
madcowswe | 0:9fcb3bf5c231 | 38 | if (output > 0.0880) { |
madcowswe | 0:9fcb3bf5c231 | 39 | PWMfront = 0.0800; |
madcowswe | 0:9fcb3bf5c231 | 40 | return true; |
madcowswe | 0:9fcb3bf5c231 | 41 | } else { |
madcowswe | 0:9fcb3bf5c231 | 42 | PWMfront = output; |
madcowswe | 0:9fcb3bf5c231 | 43 | return false; |
madcowswe | 0:9fcb3bf5c231 | 44 | } |
madcowswe | 0:9fcb3bf5c231 | 45 | } |
madcowswe | 0:9fcb3bf5c231 | 46 | |
madcowswe | 0:9fcb3bf5c231 | 47 | bool rearM(float thrust) { |
madcowswe | 0:9fcb3bf5c231 | 48 | float output = (644 + 0.470 * thrust) / 10000; |
madcowswe | 0:9fcb3bf5c231 | 49 | if (output > 0.0908) { |
madcowswe | 0:9fcb3bf5c231 | 50 | PWMrear = 0.0908; |
madcowswe | 0:9fcb3bf5c231 | 51 | return true; |
madcowswe | 0:9fcb3bf5c231 | 52 | } else { |
madcowswe | 0:9fcb3bf5c231 | 53 | PWMrear = output; |
madcowswe | 0:9fcb3bf5c231 | 54 | return false; |
madcowswe | 0:9fcb3bf5c231 | 55 | } |
madcowswe | 0:9fcb3bf5c231 | 56 | } |