UAVX Multicopter Flight Controller.

Dependencies:   mbed

Committer:
gke
Date:
Tue Apr 26 12:12:29 2011 +0000
Revision:
2:90292f8bd179
Parent:
1:1e3318a30ddd
Not flightworthy. Posted for others to make use of the I2C SW code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gke 0:62a1c91a859a 1 // ===============================================================================================
gke 0:62a1c91a859a 2 // = UAVXArm Quadrocopter Controller =
gke 0:62a1c91a859a 3 // = Copyright (c) 2008 by Prof. Greg Egan =
gke 0:62a1c91a859a 4 // = Original V3.15 Copyright (c) 2007 Ing. Wolfgang Mahringer =
gke 2:90292f8bd179 5 // = http://code.google.com/p/uavp-mods/ =
gke 0:62a1c91a859a 6 // ===============================================================================================
gke 0:62a1c91a859a 7
gke 0:62a1c91a859a 8 // This is part of UAVXArm.
gke 0:62a1c91a859a 9
gke 0:62a1c91a859a 10 // UAVXArm is free software: you can redistribute it and/or modify it under the terms of the GNU
gke 0:62a1c91a859a 11 // General Public License as published by the Free Software Foundation, either version 3 of the
gke 0:62a1c91a859a 12 // License, or (at your option) any later version.
gke 0:62a1c91a859a 13
gke 0:62a1c91a859a 14 // UAVXArm is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without
gke 0:62a1c91a859a 15 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gke 0:62a1c91a859a 16 // See the GNU General Public License for more details.
gke 0:62a1c91a859a 17
gke 0:62a1c91a859a 18 // You should have received a copy of the GNU General Public License along with this program.
gke 0:62a1c91a859a 19 // If not, see http://www.gnu.org/licenses/
gke 0:62a1c91a859a 20
gke 0:62a1c91a859a 21
gke 0:62a1c91a859a 22 void OutSignals(void) { // The PWM pulses are in two parts these being a 1mS preamble followed by a 0-1mS part.
gke 0:62a1c91a859a 23 // Interrupts are enabled during the first part which uses TMR0. TMR0 is monitored until
gke 0:62a1c91a859a 24 // there is just sufficient time for one remaining interrupt latency before disabling
gke 0:62a1c91a859a 25 // interrupts. We do this because there appears to be no atomic method of detecting the
gke 0:62a1c91a859a 26 // remaining time AND conditionally disabling the interupt.
gke 0:62a1c91a859a 27 static int8 m;
gke 0:62a1c91a859a 28 static uint8 r, s;
gke 0:62a1c91a859a 29 static i16u SaveTimer0;
gke 0:62a1c91a859a 30 static uint24 SaveClockmS;
gke 0:62a1c91a859a 31
gke 0:62a1c91a859a 32 PWM[FrontTC] = TC(PWM[FrontTC]);
gke 0:62a1c91a859a 33 PWM[LeftTC] = TC(PWM[LeftTC]);
gke 0:62a1c91a859a 34 PWM[RightTC] = TC(PWM[RightTC]);
gke 0:62a1c91a859a 35 PWM[FrontBC] = TC(PWM[FrontBC]);
gke 0:62a1c91a859a 36 PWM[LeftBC] = TC(PWM[LeftBC]);
gke 0:62a1c91a859a 37 PWM[RightBC] = TC(PWM[RightBC]);
gke 0:62a1c91a859a 38
gke 0:62a1c91a859a 39 #if !( defined SIMULATE | defined TESTING )
gke 0:62a1c91a859a 40
gke 0:62a1c91a859a 41 if ( !F.MotorsArmed )
gke 0:62a1c91a859a 42 StopMotors();
gke 0:62a1c91a859a 43
gke 0:62a1c91a859a 44 Out0.pulsewidth_us(1000 + (int16)( PWM[FrontTC] * PWMScale ) );
gke 1:1e3318a30ddd 45 Out1.pulsewidth_us(1000 + (int16)( PWM[RightTC] * PWMScale ) );
gke 1:1e3318a30ddd 46 Out2.pulsewidth_us(1000 + (int16)( PWM[LeftTC] * PWMScale ) );
gke 0:62a1c91a859a 47 Out3.pulsewidth_us(1000 + (int16)( PWM[FrontBC] * PWMScale ) );
gke 0:62a1c91a859a 48
gke 1:1e3318a30ddd 49 xxx #ifdef USING_PWM4AND5
gke 1:1e3318a30ddd 50 Out4.pulsewidth_us(1000 + (int16)( PWM[RightBC] * PWMScale ) );
gke 1:1e3318a30ddd 51 Out5.pulsewidth_us(1000 + (int16)( PWM[LeftBC] * PWMScale ) );
gke 0:62a1c91a859a 52 #endif // USING_PWM4AND5
gke 0:62a1c91a859a 53
gke 0:62a1c91a859a 54 #endif // !(SIMULATE | TESTING)
gke 0:62a1c91a859a 55
gke 0:62a1c91a859a 56 } // OutSignals
gke 0:62a1c91a859a 57
gke 0:62a1c91a859a 58
gke 0:62a1c91a859a 59
gke 0:62a1c91a859a 60