Overview
Watchdog Timer
My main concern was the aircraft falling out of the sky. I'd say that that was a reasonable concern to have for a system you were writing from scratch. Through ground testing, I found that when the servos pulled too much current, the microcontroller would freeze. This happened only when the system was being powered off of the computer and not off of the battery. That behavior makes sense since the batteries are designed for large current output, the computer's USB port is not. However, if it were to happen in flight, the plane would simply freeze up and glide/fall whichever direction it was pointing.
In order to avoid this, I added a watchdog timer. The main loop of the program that read the receiver values and wrote to the servos operated at 20Hz. Therefore, I set the watchdog timer to 60ms. This meant that if the main loop took 10ms longer than it was supposed to, the entire system would be reset. There was very little setup code in this file so upon a reset, control was maintained almost immediately.
No comments:
Post a Comment