Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 764 → Rev 765

/branches/V0.68d Code Redesign killagreg/cmps03.c
1,6 → 1,7
#include <avr/io.h>
#include "fc.h"
#include "timer0.h"
 
 
int32_t PWMHeading = -1;
uint8_t PWMTimeout = 0;
 
67,12 → 68,25
/*********************************************/
int16_t CMPS03_Heading(void)
{
int16_t heading;
int16_t heading, w, v;
if(PWMTimeout)
{ // range from 0 to 359
heading = (int16_t)PWMHeading;
if (heading < 0) heading += 360;
heading = heading%360;
{
w = abs(IntegralPitch / 512);
v = abs(IntegralRoll / 512);
if(v > w) w = v; // get maximum declination
// if declination is small enough do have valid compass heading
if(w < 35)
{
// range from 0 to 359
heading = (int16_t)PWMHeading;
if (heading < 0) heading += 360;
heading = heading%360;
}
else // no date available from compass
{
if(!BeepTime) BeepTime = 100; // make noise to signal the compass problem
heading = -1;
}
}
else // no data from compass
{
/branches/V0.68d Code Redesign killagreg/fc.c
1053,7 → 1053,6
if (CompassHeading < 0) // no compass data available
{
CompassOffCourse = 0;
if(!BeepTime) BeepTime = 100; // make noise at 10 Hz to signal the compass problem
}
else // calculate OffCourse (angular deviation from heading to course)
CompassOffCourse = ((540 + CompassHeading - CompassCourse) % 360) - 180;
1064,7 → 1063,7
v = abs(IntegralRoll / 512);
if(v > w) w = v; // get maximum declination
// if declination is small enough update compass course if neccessary
if(w < 35 && StoreNewCompassCourse)
if((w < 35) && StoreNewCompassCourse && (CompassHeading>=0) )
{
CompassCourse = CompassHeading;
StoreNewCompassCourse = 0;
/branches/V0.68d Code Redesign killagreg/mm3.c
373,6 → 373,7
}
else // MM3_Timeout = 0 i.e now new data from external board
{
if(!BeepTime) BeepTime = 100; // make noise to signal the compass problem
heading = -1;
}
return heading;
/branches/V0.68d Code Redesign killagreg/version.txt
113,36 → 113,67
- Stickauswertung verbessert -> träger und präziser
- Alle Settings angepasst
V0.68d G.Stobrawa 28.2.2008
V0.68d Ausgangsversion.
 
G.Stobrawa 06.03.2008:
 
- Code stärker modularisiert und restrukturiert
- viele Kommentare zur Erklärug eingefügt
- konsequent englische Variablennamen
- 2. Uart wird nun unterstützt
- Ausertung des UBX-Pprotocols an 2. Uart
- Integration des MM3-Kompasses inkl. Lagekorrekturbugfix
(Userparameter3 zur Skalierung der Lageintegrale zu Winkeln - Richtwert 170)
(Userparameter4 zur Angabe des Winkels vom MM3-Borad bzgl. der Nase des MK)
- einige unbedeutende kleine Bugfixes
- PPM24 Support für bis zu 12 RC-Kanäle.
- Support für Kompass CMPS01 oder MM3 (mit verbesserte Neigungskompensation, stabilere Kommunikation) (Option im Makefile)
- 2. Uart wird nun unterstützt (MCU = atmega644p im Makefile)
- Ausertung des UBX-Pprotocols an 1. oder 2. Uart
- einige kleinere Bugfixes
- GPS-Hold-Funktion hinzugefügt
- GPS-Home-Funktion hinzugefügt (wird beim Motorstart gelernt)
- Poti2 is used for Enabling the GPS Hold Feature (Value > 70)
- Poti3 steuert die GPS Funktionen (Poti3 < 70:GPS inaktiv, 70<=Poti3<160: GPS Hold, 160<=Poti3: GPS Home)
- LED Steuerung an J16, parametrierbar durch die User Parameter 7 & 8. UserParam7 legt die LEDOnTime in Vielfachen von 2ms fest
und UserParam 8 die LEDOffTime.
- Zusätzliche Punkte im Menü des KopterTool zur Anzeige des GPS-Status und der MM3-Kalibierparameter
 
- User Parameters:
Parameter 3 --> Calibration factor for transforming Gyro Integrals to angular degrees
Parameter 4 --> Angle between the MM3 Board (Arrow) and the MK head
Parameter 5 --> P-Factor for GPS PD controller
Parameter 6 --> D-Factor for GPS PD controller
Parameter 3 --> Calibration factor for transforming Gyro Integrals to angular degrees (~170)
Parameter 4 --> Angle between the MM3 Board (Arrow) and the MK head (typical ~180)
Parameter 5 --> P-Factor for GPS PD controller (~100)
Parameter 6 --> D-Factor for GPS PD controller (~80)
Parameter 7 --> LEDOnTime for J16
Parameter 8 --> LEDOfftime for J16
 
- Additional Beep Codes:
- Zusätzliche Akustische Signale:
Dauerton: Eine GPS-Funktion is aktiviert und es werden keine oder
unvollständige GPS-Daten via UART empfangen.
Hier ist zu berücksichtigen, dass die folgenden UBX Messages am UBLOX
aktiviert wurden: NAV - POSLLH, NAV-SOL, NAV-POSUTM, NAV-VELNED.
Fehlt eine dieser Messages wird breits der Dauerton gesetzt.
4Hz Piepen: Ist eine der GPS Funktion aktiviert, zeigt dass den Empfang valider UBX-Daten,
jedoch liegt noch kein 3D-Satfix vor. Die Pausen zwischen den 4Hz Pieps werden
immer länger je mehr Satelitten das GPS empfängt.
Liegt ein 3D Fix vor verstummt der Pieper dann endgültig egal wie viele Satelitten
beteiligt sind (es müssen dafür aber mindesten 4 sein).
10Hz Piepen: Die Kommunikation zum Kompassmodul ist gestört. (Funktioniert bei beiden Kompassmodulen)
Der CompassValue in den Debugs vom Koptertool zeigt dann -1 an.
1s Piepen: Ertönt dieses Signal nach dem Einschalten der Motoren wird die erfolgreiche
Übernahme der Home Position bestätigt.
- Zum Makefile:
Der Code so gestrickt, dass man für den Atemga644p oder den Atmega644 kompilieren kann.
(im Makefile MCU=atmega644 / MCU=atmega644p)
 
If Compass is activatied in the configuration and a communication problem occurs to the
MM3 board then a 10Hz beep is send out to signal this problem and a possible running GPS
function is deactivated to avoid a malfunction.
If GPS is activated in the configuration and the GPS position hold feature is activated
(Poti2 > 70) a permanent beep signals that no data from GPS-Module are received and
a 4Hz beep signals that no 3D-Fix is present.
If the position home feature is activated (Poti2 > 160) a 4Hz beep signal indicates that
no 3D-Fix is set or the stored home position is invalid.
Falls der 644p verwendet wird, wird immer der Code für die 2. Uart mit compiliert. Diese wird aber nur initialisiert,
wenn die FC 1.1/1.2 erkannt wurde. In diesem Fall werden die GPS-Daten auch dort erwartet.
Bei der FC 1.0 wird die 2. Uart nicht initialisiert und die GPS-Daten an der 1. UART erwartet.
Wird der Code für den 644 erzeugt entfällt der gesamte Code für die 2. Uart.
Die GPS-Daten werden immer über die 1. Uart gelesen.
 
Damit sollte jede Kombination von FC-Version und Prozessorbestückung funktionieren.
 
Unabhängig von diesen Harwarevoraussetzungen kann man den Code für den MM3 oder CMPS03 Kompass einbinden.
(im Makefile: COMAPSS=MM3 / COMPASS = CMPS03)