![](/media/cache/profiles/652ea064e0352bd940d881f815c03175.50x50_q85.jpg)
This controls Quadrotor ESC
Quad Rotor control with mbed
Here is a video of it flying while being held down /media/uploads/Ryan/img_0735.mov
List of Parts
Q450 Glass Fiber Quadcopter Frame 450mm - Integrated PCB Version
HobbyKing ECO6 50W 5A Balancer/Charger w/ accessories
Turnigy dlux 20A SBEC Brushless Speed Controller w/Data Logging (2s4s)
Turnigy 3300mAh 3S 30C Lipo Pack "I changed this to a 2,200mAh 4S battery"
NTM Prop Drive Series 28-26A 1200kv / 250w
Specs
Stable flight is some where around 0.00139ms pulseWidth and it pulls 14.7amps so 2,200/1000/14.7*60= about 8.97 of flight time.
main.cpp@0:fe6280c7a52f, 2012-08-17 (annotated)
- Committer:
- Ryan
- Date:
- Fri Aug 17 14:18:42 2012 +0000
- Revision:
- 0:fe6280c7a52f
Finished
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ryan | 0:fe6280c7a52f | 1 | #include "mbed.h" |
Ryan | 0:fe6280c7a52f | 2 | #include "stdio.h" |
Ryan | 0:fe6280c7a52f | 3 | #include "stdlib.h" |
Ryan | 0:fe6280c7a52f | 4 | #include "string" |
Ryan | 0:fe6280c7a52f | 5 | AnalogIn Volts(p20); |
Ryan | 0:fe6280c7a52f | 6 | PwmOut BLDCM1(p21); |
Ryan | 0:fe6280c7a52f | 7 | PwmOut BLDCM2(p22); |
Ryan | 0:fe6280c7a52f | 8 | PwmOut BLDCM3(p23); |
Ryan | 0:fe6280c7a52f | 9 | PwmOut BLDCM4(p24); |
Ryan | 0:fe6280c7a52f | 10 | Serial pc(USBTX, USBRX); |
Ryan | 0:fe6280c7a52f | 11 | |
Ryan | 0:fe6280c7a52f | 12 | //red right p21 |
Ryan | 0:fe6280c7a52f | 13 | //blue right p22 |
Ryan | 0:fe6280c7a52f | 14 | //white left p23 |
Ryan | 0:fe6280c7a52f | 15 | //red left p24 |
Ryan | 0:fe6280c7a52f | 16 | |
Ryan | 0:fe6280c7a52f | 17 | // -----------> Make SURE!! each ESC is grounded on mbeds ground!!!!!!!!!! <------------ |
Ryan | 0:fe6280c7a52f | 18 | |
Ryan | 0:fe6280c7a52f | 19 | |
Ryan | 0:fe6280c7a52f | 20 | float val; |
Ryan | 0:fe6280c7a52f | 21 | |
Ryan | 0:fe6280c7a52f | 22 | int main() { |
Ryan | 0:fe6280c7a52f | 23 | val =0.001; |
Ryan | 0:fe6280c7a52f | 24 | // Most ESC take standard servo commands so that is a 50hz signal and listens between 1ms and 3ms pulsewidth |
Ryan | 0:fe6280c7a52f | 25 | BLDCM1.period_ms(20); |
Ryan | 0:fe6280c7a52f | 26 | BLDCM2.period_ms(20); |
Ryan | 0:fe6280c7a52f | 27 | BLDCM3.period_ms(20); |
Ryan | 0:fe6280c7a52f | 28 | BLDCM4.period_ms(20); |
Ryan | 0:fe6280c7a52f | 29 | //////////////////////////////// |
Ryan | 0:fe6280c7a52f | 30 | while (1) { |
Ryan | 0:fe6280c7a52f | 31 | |
Ryan | 0:fe6280c7a52f | 32 | |
Ryan | 0:fe6280c7a52f | 33 | //Initailize motors |
Ryan | 0:fe6280c7a52f | 34 | |
Ryan | 0:fe6280c7a52f | 35 | if(pc.readable()){ |
Ryan | 0:fe6280c7a52f | 36 | switch (pc.getc()) { |
Ryan | 0:fe6280c7a52f | 37 | case 'u': |
Ryan | 0:fe6280c7a52f | 38 | val += 0.00005; |
Ryan | 0:fe6280c7a52f | 39 | break; |
Ryan | 0:fe6280c7a52f | 40 | case 'd': |
Ryan | 0:fe6280c7a52f | 41 | val -= 0.00005; |
Ryan | 0:fe6280c7a52f | 42 | break; |
Ryan | 0:fe6280c7a52f | 43 | case 'w': |
Ryan | 0:fe6280c7a52f | 44 | val += 0.00001; |
Ryan | 0:fe6280c7a52f | 45 | break; |
Ryan | 0:fe6280c7a52f | 46 | case 'x': |
Ryan | 0:fe6280c7a52f | 47 | val -= 0.00001; |
Ryan | 0:fe6280c7a52f | 48 | break; |
Ryan | 0:fe6280c7a52f | 49 | case 's': |
Ryan | 0:fe6280c7a52f | 50 | val = 0.001; |
Ryan | 0:fe6280c7a52f | 51 | break; |
Ryan | 0:fe6280c7a52f | 52 | case 'm': |
Ryan | 0:fe6280c7a52f | 53 | val = 0.0018; |
Ryan | 0:fe6280c7a52f | 54 | break; |
Ryan | 0:fe6280c7a52f | 55 | } |
Ryan | 0:fe6280c7a52f | 56 | } |
Ryan | 0:fe6280c7a52f | 57 | |
Ryan | 0:fe6280c7a52f | 58 | BLDCM1.pulsewidth(val); |
Ryan | 0:fe6280c7a52f | 59 | BLDCM2.pulsewidth(val); |
Ryan | 0:fe6280c7a52f | 60 | BLDCM3.pulsewidth(val); |
Ryan | 0:fe6280c7a52f | 61 | BLDCM4.pulsewidth(val); |
Ryan | 0:fe6280c7a52f | 62 | wait(0.25); |
Ryan | 0:fe6280c7a52f | 63 | pc.printf("Volts (%f) Pulsewidth (%f) RPM (%f) \n",(((val*1000)*12)),(val),(((val*1000)*1200))); |
Ryan | 0:fe6280c7a52f | 64 | |
Ryan | 0:fe6280c7a52f | 65 | } |
Ryan | 0:fe6280c7a52f | 66 | } |