Rev 155 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 155 | Rev 156 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
50 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
51 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
51 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
52 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
52 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
53 | // + POSSIBILITY OF SUCH DAMAGE. |
53 | // + POSSIBILITY OF SUCH DAMAGE. |
54 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
54 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 55 | // Aenderungen von Peter Muehlenbrock ("Salvo") Stand 13.9.2007 |
|
- | 56 | /* |
|
- | 57 | Driftkompensation fuer Gyros verbessert |
|
- | 58 | Linearsensor mit fixem neutralwert |
|
- | 59 | Ersatzkompass abgeleitet aus magnetkompass und Giergyro fuer nahezu neigungsubhaengige Kompassfunktion |
|
- | 60 | */ |
|
Line 55... | Line 61... | ||
55 | 61 | ||
Line 56... | Line 62... | ||
56 | #include "main.h" |
62 | #include "main.h" |
57 | 63 | ||
Line 73... | Line 79... | ||
73 | volatile int KompassStartwert = 0; |
79 | volatile int KompassStartwert = 0; |
74 | volatile int KompassRichtung = 0; |
80 | volatile int KompassRichtung = 0; |
75 | unsigned char MAX_GAS,MIN_GAS; |
81 | unsigned char MAX_GAS,MIN_GAS; |
76 | unsigned char Notlandung = 0; |
82 | unsigned char Notlandung = 0; |
77 | unsigned char HoehenReglerAktiv = 0; |
83 | unsigned char HoehenReglerAktiv = 0; |
78 | static int SignalSchlecht = 0; |
- | |
79 | uint8_t magkompass_ok=0; |
84 | uint8_t magkompass_ok=0; |
Line 80... | Line 85... | ||
80 | 85 | ||
81 | //Salvo 2.9.2007 Ersatzkompass |
86 | //Salvo 2.9.2007 Ersatzkompass |
82 | volatile long GyroKomp_Int,GyroKomp_Int2; |
87 | volatile long GyroKomp_Int,GyroKomp_Int2; |
Line 135... | Line 140... | ||
135 | NeutralAccY = 0; |
140 | NeutralAccY = 0; |
136 | NeutralAccZ = 0; |
141 | NeutralAccZ = 0; |
137 | AdNeutralNick = 0; |
142 | AdNeutralNick = 0; |
138 | AdNeutralRoll = 0; |
143 | AdNeutralRoll = 0; |
139 | AdNeutralGier = 0; |
144 | AdNeutralGier = 0; |
- | 145 | GPS_Neutral(); |
|
140 | CalibrierMittelwert(); |
146 | CalibrierMittelwert(); |
141 | timer = SetDelay(5); |
147 | timer = SetDelay(5); |
142 | while (!CheckDelay(timer)); |
148 | while (!CheckDelay(timer)); |
143 | CalibrierMittelwert(); |
149 | CalibrierMittelwert(); |
144 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
150 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
Line 171... | Line 177... | ||
171 | MesswertGier = 0; |
177 | MesswertGier = 0; |
172 | StartLuftdruck = Luftdruck; |
178 | StartLuftdruck = Luftdruck; |
173 | HoeheD = 0; |
179 | HoeheD = 0; |
174 | Mess_Integral_Hoch = 0; |
180 | Mess_Integral_Hoch = 0; |
175 | KompassStartwert = KompassValue; |
181 | KompassStartwert = KompassValue; |
176 | GPS_Neutral(); |
- | |
177 | beeptime = 50; |
182 | beeptime = 50; |
178 | //Salvo 2.9.2007 Ersatzkompass |
183 | //Salvo 2.9.2007 Ersatzkompass |
179 | GyroKomp_Int = 0; |
184 | GyroKomp_Int = 0; |
180 | GyroKomp_Int2 = 0; |
185 | GyroKomp_Int2 = 0; |
181 | // Salvo End |
186 | // Salvo End |
Line 199... | Line 204... | ||
199 | AccumulateGier = 0; MessanzahlGier = 0; |
204 | AccumulateGier = 0; MessanzahlGier = 0; |
200 | accumulate_AccRoll = 0;messanzahl_AccRoll = 0; |
205 | accumulate_AccRoll = 0;messanzahl_AccRoll = 0; |
201 | accumulate_AccNick = 0;messanzahl_AccNick = 0; |
206 | accumulate_AccNick = 0;messanzahl_AccNick = 0; |
202 | accumulate_AccHoch = 0;messanzahl_AccHoch = 0; |
207 | accumulate_AccHoch = 0;messanzahl_AccHoch = 0; |
203 | Integral_Gier = Mess_Integral_Gier; |
208 | Integral_Gier = Mess_Integral_Gier; |
204 | // Integral_Gier2 = Mess_Integral_Gier2; |
- | |
205 | IntegralNick = Mess_IntegralNick; |
209 | IntegralNick = Mess_IntegralNick; |
206 | IntegralRoll = Mess_IntegralRoll; |
210 | IntegralRoll = Mess_IntegralRoll; |
207 | IntegralNick2 = Mess_IntegralNick2; |
211 | IntegralNick2 = Mess_IntegralNick2; |
208 | IntegralRoll2 = Mess_IntegralRoll2; |
212 | IntegralRoll2 = Mess_IntegralRoll2; |
209 | // ADC einschalten |
213 | // ADC einschalten |
Line 417... | Line 421... | ||
417 | Ki = (float) Parameter_I_Faktor * 0.0001; |
421 | Ki = (float) Parameter_I_Faktor * 0.0001; |
418 | MAX_GAS = EE_Parameter.Gas_Max; |
422 | MAX_GAS = EE_Parameter.Gas_Max; |
419 | MIN_GAS = EE_Parameter.Gas_Min; |
423 | MIN_GAS = EE_Parameter.Gas_Min; |
420 | } |
424 | } |
Line 421... | Line -... | ||
421 | - | ||
422 | 425 | ||
423 | //############################################################################ |
426 | //############################################################################ |
424 | // |
427 | // |
425 | void MotorRegler(void) |
428 | void MotorRegler(void) |
426 | //############################################################################ |
429 | //############################################################################ |
Line 438... | Line 441... | ||
438 | static int hoehenregler = 0; |
441 | static int hoehenregler = 0; |
439 | static char TimerWerteausgabe = 0; |
442 | static char TimerWerteausgabe = 0; |
440 | static char NeueKompassRichtungMerken = 0; |
443 | static char NeueKompassRichtungMerken = 0; |
441 | Mittelwert(); |
444 | Mittelwert(); |
442 | //******PROVISORISCH*************** |
445 | //******PROVISORISCH*************** |
443 | Get_GPS_data(); |
446 | short int n; |
444 | if (gps_act_position.status > 0) |
447 | n = Get_Rel_Position(); |
- | 448 | if (n == 0) |
|
445 | { |
449 | { |
446 | ROT_ON; |
450 | ROT_ON; |
447 | gps_act_position.status = 0; |
451 | // gps_act_position.status = 0; |
448 | } |
452 | } |
Line 449... | Line 453... | ||
449 | 453 | ||
450 | //******PROVISORISCH*************** |
454 | //******PROVISORISCH*************** |
Line 530... | Line 534... | ||
530 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
534 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
531 | { |
535 | { |
532 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
536 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
533 | } |
537 | } |
534 | } |
538 | } |
- | 539 | GPS_Save_Home(); |
|
535 | } |
540 | } |
536 | else delay_neutral = 0; |
541 | else delay_neutral = 0; |
537 | } |
542 | } |
538 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
543 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
539 | // Gas ist unten |
544 | // Gas ist unten |
Line 637... | Line 642... | ||
637 | if(IntegralFehlerNick > 500/DRIFT_FAKTOR) AdNeutralNick++; |
642 | if(IntegralFehlerNick > 500/DRIFT_FAKTOR) AdNeutralNick++; |
638 | if(IntegralFehlerNick < -500/DRIFT_FAKTOR) AdNeutralNick--; |
643 | if(IntegralFehlerNick < -500/DRIFT_FAKTOR) AdNeutralNick--; |
639 | if(IntegralFehlerRoll > 500/DRIFT_FAKTOR) AdNeutralRoll++; |
644 | if(IntegralFehlerRoll > 500/DRIFT_FAKTOR) AdNeutralRoll++; |
640 | if(IntegralFehlerRoll < -500/DRIFT_FAKTOR) AdNeutralRoll--; |
645 | if(IntegralFehlerRoll < -500/DRIFT_FAKTOR) AdNeutralRoll--; |
641 | } |
646 | } |
642 | else if ((w < 2*ACC_WAAGRECHT_LIMIT) && (v < 2*ACC_WAAGRECHT_LIMIT)) // langsamer kompensieren, weil ACC Werte unsicherer sind, was die Neigung angeht |
647 | else if ((w < 2*ACC_WAAGRECHT_LIMIT) && (v < 2*ACC_WAAGRECHT_LIMIT)) // langsamer kompensieren, weil ACC Werte unsicherer sind, was die Neigung angeht |
643 | { |
648 | { |
644 | if(IntegralFehlerNick > 500*2/DRIFT_FAKTOR) AdNeutralNick++; |
649 | if(IntegralFehlerNick > 500*2/DRIFT_FAKTOR) AdNeutralNick++; |
645 | if(IntegralFehlerNick < -500*2/DRIFT_FAKTOR) AdNeutralNick--; |
650 | if(IntegralFehlerNick < -500*2/DRIFT_FAKTOR) AdNeutralNick--; |
646 | if(IntegralFehlerRoll > 500*2/DRIFT_FAKTOR) AdNeutralRoll++; |
651 | if(IntegralFehlerRoll > 500*2/DRIFT_FAKTOR) AdNeutralRoll++; |
647 | if(IntegralFehlerRoll < -500*2/DRIFT_FAKTOR) AdNeutralRoll--; |
652 | if(IntegralFehlerRoll < -500*2/DRIFT_FAKTOR) AdNeutralRoll--; |
Line 653... | Line 658... | ||
653 | if(IntegralFehlerRoll > 500*4/DRIFT_FAKTOR) AdNeutralRoll++; |
658 | if(IntegralFehlerRoll > 500*4/DRIFT_FAKTOR) AdNeutralRoll++; |
654 | if(IntegralFehlerRoll < -500*4/DRIFT_FAKTOR) AdNeutralRoll--; |
659 | if(IntegralFehlerRoll < -500*4/DRIFT_FAKTOR) AdNeutralRoll--; |
655 | } |
660 | } |
656 | // Salvo End |
661 | // Salvo End |
Line 657... | Line -... | ||
657 | - | ||
658 | // Salvo 31.8.2007 Abgleich Giergyro nur wenn Kompass aktiv und ok ist *********************** |
- | |
659 | // Ohne Kompass wird die Pseudo-Gyrodrift durch die Driftkompensation nur verschlimmert |
- | |
660 | // Ohne Driftkompensation ist die Gierachse wesentlich stabiler |
- | |
661 | // if ((EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) && (!SignalSchlecht)) |
- | |
662 | // Salvo 13.9.2007 |
- | |
663 | // if ((EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) && (magkompass_ok >0)) |
- | |
664 | // { |
- | |
665 | // if(Mess_Integral_Gier2 > 500/DRIFT_FAKTOR) AdNeutralGier--; |
- | |
666 | // if(Mess_Integral_Gier2 <-500/DRIFT_FAKTOR) AdNeutralGier++; |
- | |
667 | // } |
- | |
668 | // else Mess_Integral_Gier2 = 0; |
- | |
669 | - | ||
670 | // Salvo End *********************** |
662 | |
671 | ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern |
663 | ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern |
672 | Mess_IntegralNick2 = IntegralNick; |
664 | Mess_IntegralNick2 = IntegralNick; |
673 | Mess_IntegralRoll2 = IntegralRoll; |
665 | Mess_IntegralRoll2 = IntegralRoll; |
674 | Mess_Integral_Gier2 = Integral_Gier; |
666 | Mess_Integral_Gier2 = Integral_Gier; |
Line 763... | Line 755... | ||
763 | ANALOG_ON; // ADC einschalten |
755 | ANALOG_ON; // ADC einschalten |
764 | } |
756 | } |
765 | } |
757 | } |
766 | else magkompass_ok = 0; |
758 | else magkompass_ok = 0; |
767 | } |
759 | } |
768 | - | ||
769 | // Salvo End ************************* |
760 | // Salvo End ************************* |
Line 770... | Line 761... | ||
770 | 761 | ||
771 | 762 | ||
Line 775... | Line 766... | ||
775 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
766 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
776 | { |
767 | { |
777 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
768 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
778 | v = abs(IntegralRoll /512); |
769 | v = abs(IntegralRoll /512); |
779 | if(v > w) w = v; // grösste Neigung ermitteln |
770 | if(v > w) w = v; // grösste Neigung ermitteln |
780 | // Salvo 12.9.2007 Kompassdaempfung abschalten weil Ersatzkompass verwendet wird |
- | |
781 | // w=0, v=0; |
- | |
782 | //Salvo End |
771 | |
783 | // if(w < 20 && NeueKompassRichtungMerken && !SignalSchlecht) |
772 | // Salvo 13.9.2007 Nur wenn Magnetkompass ordentliche Werte liefert |
784 | if ((magkompass_ok > 0) && NeueKompassRichtungMerken) |
773 | if ((magkompass_ok > 0) && NeueKompassRichtungMerken) |
785 | { |
774 | { |
786 | // Salvo 12.9.2007 Ersatzkompass nehmen statt Magnetkompass |
- | |
787 | // KompassStartwert = KompassValue; |
- | |
788 | // KompassStartwert = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT; |
- | |
789 | // Salvo End ************************* |
- | |
790 | // Salvo 13.9.2007 |
- | |
791 | KompassStartwert = KompassValue; |
775 | KompassStartwert = KompassValue; |
792 | // Salvo End |
- | |
793 | NeueKompassRichtungMerken = 0; |
776 | NeueKompassRichtungMerken = 0; |
794 | } |
777 | } |
795 | // Salvo 13.9.2007 |
778 | // Salvo 13.9.2007 |
796 | w=0; |
779 | w=0; |
797 | // Salvo End |
780 | // Salvo End |
Line 802... | Line 785... | ||
802 | ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern |
785 | ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern |
Line 803... | Line 786... | ||
803 | 786 | ||
804 | // Salvo Kompasssteuerung ********************** |
787 | // Salvo Kompasssteuerung ********************** |
805 | if (magkompass_ok > 0) Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
788 | if (magkompass_ok > 0) Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
806 | // Salvo End |
- | |
807 | // Salvo 30.8.2007 Winkelbegrenzung ********************** |
- | |
808 | /* |
- | |
809 | if ((!SignalSchlecht) ) |
- | |
810 | { |
- | |
811 | if (abs(KompassRichtung) < 135 ) |
- | |
812 | { |
- | |
813 | Mess_Integral_Gier += (KompassRichtung * w) / 32; // nach Kompass ausrichten |
- | |
814 | } |
- | |
815 | } |
- | |
816 | */ |
- | |
817 | // Salvo End ************************* |
- | |
818 | 789 | // Salvo End |
|
819 | ANALOG_ON; // ADC einschalten |
- | |
820 | if(SignalSchlecht) SignalSchlecht--; |
790 | ANALOG_ON; // ADC einschalten |
821 | } |
- | |
822 | else SignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek |
791 | } |
823 | } |
792 | } |
824 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
793 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 825... | Line 794... | ||
825 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
794 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 841... | Line 810... | ||
841 | DebugOut.Analog[4] = MesswertGier; |
810 | DebugOut.Analog[4] = MesswertGier; |
842 | DebugOut.Analog[5] = HoehenWert; |
811 | DebugOut.Analog[5] = HoehenWert; |
843 | DebugOut.Analog[6] = (Mess_Integral_Hoch / 512); |
812 | DebugOut.Analog[6] = (Mess_Integral_Hoch / 512); |
844 | DebugOut.Analog[7] = GasMischanteil; |
813 | DebugOut.Analog[7] = GasMischanteil; |
845 | DebugOut.Analog[8] = KompassValue; |
814 | DebugOut.Analog[8] = KompassValue; |
- | 815 | ||
- | 816 | DebugOut.Analog[9] = gps_rel_act_position.utm_east; |
|
- | 817 | DebugOut.Analog[10] = gps_rel_act_position.utm_north; |
|
- | 818 | DebugOut.Analog[11] = gps_rel_act_position.status; |
|
- | 819 | ||
846 | // ******provisorisch |
820 | // ******provisorisch |
847 | // DebugOut.Analog[9] = cnt1; |
821 | // DebugOut.Analog[9] = cnt1; |
848 | // DebugOut.Analog[10] = cnt1; |
822 | // DebugOut.Analog[10] = cnt1; |
849 | // DebugOut.Analog[11] = cnt2; |
823 | // DebugOut.Analog[11] = cnt2; |
850 | // DebugOut.Analog[10] = (gps_act_position.utm_east/10) % 10000; |
824 | // DebugOut.Analog[10] = (gps_act_position.utm_east/10) % 10000; |
851 | // DebugOut.Analog[11] = (gps_act_position.utm_north/10) % 10000; |
825 | // DebugOut.Analog[11] = (gps_act_position.utm_north/10) % 10000; |
852 | // ******provisorisch |
826 | // ******provisorisch |
Line 853... | Line 827... | ||
853 | 827 | ||
854 | 828 | /* |
|
855 | DebugOut.Analog[9] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT; |
829 | DebugOut.Analog[9] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT; |
856 | DebugOut.Analog[10] = magkompass_ok; |
830 | DebugOut.Analog[10] = magkompass_ok; |
- | 831 | DebugOut.Analog[11] = Mess_Integral_Gier2; |
|
857 | DebugOut.Analog[11] = Mess_Integral_Gier2; |
832 | */ |
858 | /* |
833 | /* |
859 | DebugOut.Analog[11] = GyroKomp_Inc_Grad; |
834 | DebugOut.Analog[11] = GyroKomp_Inc_Grad; |
860 | DebugOut.Analog[12] = GyroKomp_Value; |
835 | DebugOut.Analog[12] = GyroKomp_Value; |
861 | */ |
836 | */ |