This is for ICRS\' second generation Quadcopter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers motors.h Source File

motors.h

00001 
00002 void initmotor() {
00003     PWMleft.period_ms(20);
00004     PWMleft = NOPOWER;
00005     PWMright.period_ms(20);
00006     PWMright = NOPOWER;
00007 
00008     PWMfront.period_ms(20);
00009     PWMfront = NOPOWER;
00010     PWMrear.period_ms(20);
00011     PWMrear = NOPOWER;
00012 }
00013 
00014 void leftM(float thrust) {
00015     float output = (542 + 0.462 * thrust) / 10000;
00016     if (output > 0.0950) {
00017         PWMleft = 0.0950;
00018         motormaxled = 1;
00019     } else {
00020         PWMleft = output;
00021     }
00022 }
00023 
00024 void rightM(float thrust) {
00025     float output = (542 + 0.462 * thrust) / 10000;
00026     if (output > 0.0950) {
00027         PWMright = 0.0950;
00028         motormaxled = 1;
00029     } else {
00030         PWMright = output;
00031     }
00032 }
00033 
00034 void frontM(float thrust) {
00035     float output = (542 + 0.462 * thrust) / 10000;
00036     if (output > 0.950) {
00037         PWMfront = 0.0950;
00038         motormaxled = 1;
00039     } else {
00040         PWMfront = output;
00041     }
00042 }
00043 
00044 void rearM(float thrust) {
00045     float output = (542 + 0.462 * thrust) / 10000;
00046     if (output > 0.0950) {
00047         PWMrear = 0.0950;
00048         motormaxled = 1;
00049     } else {
00050         PWMrear = output;
00051     }
00052 }