It would seem I’m not the only one using ArduPilot1 code so I fiddled with the code and took some extracts from
Ardupilot 2.1 and used it to save the home alt in the EEPROM.
When the autopilot resets it self during flight or is reset by the user (quick 5 times toggle of AP switch) the home position (WP 0) would reset and for that given position during the flight the alt. will be “0”.
If you descend the alt would read something silly like 65000 subsequently with AP armed then your plane start a immediate dive, but with home alt saved to EEPROM it still reads the correct height you are flying at and then only adjust for WP1 alt.
The only problem when a reset happens is the nav routine starts from scratch with WP1 again, it doesn’t matter if you are on your way to the last waypoint or midway to WP3. My next attempt would be to write the current waypoint to the EEPROM and WP0 lat & long.
To save home alt. add a jumper between pins 6 & 7 power-up and wait for a valid GPS fix on Ardupilot give it a nother couple of seconds (just to be sure) now home alt is saved to EEPROM. Maybe a led flashing at the end of EEPROM write would be a good idea?
You can remove the jumper and reset the board either with the reset button or by cycling the power source.
I have not flown this code yet but it works fine on the simulator and will give it a go this coming weekend. --- hopefully!
and I'm not a programming guru so the changes might not be completely "sound", maybe Jordi can give the code his blessing.