This is my quadcopter prototype software, still in development!
quadv3/pwmout.h@1:ac68f0368a77, 2013-07-23 (annotated)
- Committer:
- Anaesthetix
- Date:
- Tue Jul 23 14:01:42 2013 +0000
- Revision:
- 1:ac68f0368a77
- Parent:
- 0:978110f7f027
Other accelerometer added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anaesthetix | 0:978110f7f027 | 1 | #ifndef PWMOUT_H |
Anaesthetix | 0:978110f7f027 | 2 | #define PWMOUT_H |
Anaesthetix | 0:978110f7f027 | 3 | |
Anaesthetix | 0:978110f7f027 | 4 | #include "mbed.h" |
Anaesthetix | 0:978110f7f027 | 5 | |
Anaesthetix | 0:978110f7f027 | 6 | PwmOut motor1(p24); |
Anaesthetix | 0:978110f7f027 | 7 | PwmOut motor2(p23); |
Anaesthetix | 0:978110f7f027 | 8 | PwmOut motor3(p22); |
Anaesthetix | 0:978110f7f027 | 9 | PwmOut motor4(p21); |
Anaesthetix | 0:978110f7f027 | 10 | |
Anaesthetix | 0:978110f7f027 | 11 | void startpwm(void); |
Anaesthetix | 0:978110f7f027 | 12 | void setpwm(signed int, signed int, signed int, signed int); |
Anaesthetix | 0:978110f7f027 | 13 | |
Anaesthetix | 0:978110f7f027 | 14 | |
Anaesthetix | 0:978110f7f027 | 15 | void startpwm() { |
Anaesthetix | 0:978110f7f027 | 16 | motor1.period_ms(5); |
Anaesthetix | 0:978110f7f027 | 17 | // motor2.period_ms(15); |
Anaesthetix | 0:978110f7f027 | 18 | // motor3.period_ms(15); |
Anaesthetix | 0:978110f7f027 | 19 | // motor4.period_ms(15); |
Anaesthetix | 0:978110f7f027 | 20 | |
Anaesthetix | 0:978110f7f027 | 21 | motor1.pulsewidth_us(1200); |
Anaesthetix | 0:978110f7f027 | 22 | motor2.pulsewidth_us(1200); |
Anaesthetix | 0:978110f7f027 | 23 | motor3.pulsewidth_us(1200); |
Anaesthetix | 0:978110f7f027 | 24 | motor4.pulsewidth_us(1200); |
Anaesthetix | 0:978110f7f027 | 25 | } |
Anaesthetix | 0:978110f7f027 | 26 | |
Anaesthetix | 0:978110f7f027 | 27 | void setpwm(signed int pwm1, signed int pwm2, signed int pwm3, signed int pwm4) { |
Anaesthetix | 0:978110f7f027 | 28 | motor1.pulsewidth_us(pwm1); |
Anaesthetix | 0:978110f7f027 | 29 | motor2.pulsewidth_us(pwm2); |
Anaesthetix | 0:978110f7f027 | 30 | motor3.pulsewidth_us(pwm3); |
Anaesthetix | 0:978110f7f027 | 31 | motor4.pulsewidth_us(pwm4); |
Anaesthetix | 0:978110f7f027 | 32 | } |
Anaesthetix | 0:978110f7f027 | 33 | |
Anaesthetix | 0:978110f7f027 | 34 | #endif |