Zimbo
Oct 13, 2008, 04:50 AM
Hi guys,
I thought I would just show my electronics project I've been working on for a national high school Electronics and Technology competition here in New Zealand. It's certainly not a completed project as there is a lot of development and software fine tuning needed before it is at a stage I'm happy with but it's a start! Anyway, I've provided a short report on the project that I had to do for the competition entry. See what you think and any feedback is most welcome!
Cheers,
Paul
PICAXE 08M based GPS Autopilot for Model Cars, Boats and Aircraft
The system was conceived with the original intention of having a system that was capable of interfacing with a handheld GPS and directing a model airplane over a set route of waypoints. The system would have to be capable of controlling the aircraft’s heading whilst the stability of the aircraft in all other axis would be entrusted to widely available ‘co-pilots’ ; in particular the FMA CPD4 Flight Stabilization System.
Whilst these co-pilot systems are available readily and at affordable prices there exists few affordable and simple GPS based autopilots for the average flyer such as myself. For this reason I investigated the possibility of a system like this one that could be developed to suit my requirements.
Some of the essential system requirements that were decided on are as follows:
Ability to receive and interpret NMEA 0183 serial data from the handheld GPS
Be remotely controlled from the user and switched on/off in this way
Control a standard servo using pulse width modulation (PWM)
Additional or optional requirements were as follows:
Provide for optional telemetry to the ground
Enable software upgrades and development easily and quickly
Adjustable gain control
Research on the internet showed that model autopilots using PIC microcontrollers are nothing new and there are many published versions with similar specifications to those stated above.
However, in the interest of designing a system that used off the shelf components that are both affordable, easy to obtain and implement the PICAXE series of microcontrollers were chosen.
The first step in developing this system was the ability to receive and interpret NMEA serial data from the GPS. After research on the internet into this protocol and format this was proven to be viable using a handheld Garmin GPS unit. Virtually any data can be extracted from the GPS using this method but for the purposes of this project attention was focused on the current heading and bearing to destination information provided by the $GPRMB and $GPRMC sentences.
The second step was developing a program and unit to suit that would allow the user the ability to switch the autopilot on and off remotely from the transmitter. This was done by using a PICAXE 08M to measure the length of PWM pulses incoming from the radio receiver. Any change in these pulses was noted and if the change corresponded with the transmitter switching the device on and off this change was reflected in the state of the 08M. A fundamental feature of the ‘switch’ is its ability to pass control of the rudder servo to the user when in the off position but revert control to the autopilot when required.
Finally, in order to control a servo using the information gathered from the GPS the use of a servo command in the PICAXE had to be implemented. Whilst the PICAXE microcontrollers have this function by default it was found to be unsuitable for this project because it did not appear to position the servo with sufficient accuracy when the PICAXE was over clocked as required to communicate with the GPS. Instead, a custom sub routine which was created which in essence creates a PWM pulse to the servo over a short period of time that allows the servo to move to its required position. The process of moving the servo to its desired position is decided by comparing the current heading and bearing information provided by the GPS. From this the Autopilot decides in which direction a correction is required and depending on the extent to which the craft is off course, how far the servo is required to be moved in order to compensate.
These sub-components and processes were brought together to form a prototype system that was capable of providing simple control of a servo depending on the information received from an attached GPS unit. To test this system it was driven around a series of routes in town all the while directing it to steer a course as it saw fit towards its destination. It was found that it was perfectly capable of steering in the right direction and moving to compensate a change in course even when the change was deliberately created to oppose its preferred route.
The system was then developed to the point where three networked PICAXE 08Ms were networked to provide the basic functions of control, serial data interpretation and finally servo control. The microcontrollers responsible for serial data interpretation and servo control are controlled by the master control 08M which is in turn controlled by the transmitter.
Both the serial data interpreter and servo controller are synchronized in way that only allows the relevant serial data from extracted from the GPS stream to be passed to the servo controller when it is ready and has completed the previous command. This was found to be the key to ensuring a reliable chain of communication and reducing the lag between updates reaching the final 08M in the ‘chain of command’ as it were. Using this method reduces the time between heading and bearing updates from the GPS being translated to the servo controller to approximately two seconds. This appears to be limit of what can be extracted from the GPS. NMEA data is transmitted at 4800 baud from the GPS which results in the relevant data sentences being transmitted once every 1 to 1.5 seconds. This coupled with the maximum clock speed of the 08Ms of 8 MHz seems to be appreciable.
In this way the essential system requirements for the Autopilot were fulfilled. Optional requirements were tackled during the build of the first prototype model.
Facilities for optional telemetry were installed on the prototype PCB even though they have not yet been fully developed. By default the current system facilitates the use of short range 433 MHz RF models although in the interests of reliability and better range it should be noted that 2.4gHz modules are recommended if this device were to be fitted to a model aircraft.
The development and testing process dictates the requirement of easy software upgrades without the hassle of dismantling the Autopilot simply to upload a new program. This was easily overcome by simply placing programming circuits and connectors on all the chips on the PCB, allowing easy access to all of them for in-field development.
Adjustable gain was foreseen as a requirement that would make it easier to calibrate the Autopilot to the requirements of the user or the craft it is installed on. This was put in place by means of an adjustable trim pot on the upper PCB that forms part of a voltage divider which provides a reference voltage to the Autopilot. This voltage is measured and instituted into a process to calculate the gain. Thus, any adjustment to the trim pot results in a change to the Autopilot gain. This effectively changes the nature of the Autopilot by increasing or decreasing the amount of control it has over the steering servo and the margin of difference between the heading and bearing that the system will tolerate.
Development:
I believe that the Autopilot is not ready at this point to be fitted to a model aircraft as initially designed and should not be considered complete. Much development in the software and calibration is needed before this goal is to be reached. However, I feel that the present configuration fulfills the specifications I decided on during its initial conception. It is only with time and testing that it can be fine tuned to the required point of completion.
Already many lessons and processes have been learnt and engineering challenges overcome along the way. Undoubtedly, more challenges lie between the project’s current point and the eventual goal. However, with development and patience I am confident these can be overcome and the full potential of this system realised.
I thought I would just show my electronics project I've been working on for a national high school Electronics and Technology competition here in New Zealand. It's certainly not a completed project as there is a lot of development and software fine tuning needed before it is at a stage I'm happy with but it's a start! Anyway, I've provided a short report on the project that I had to do for the competition entry. See what you think and any feedback is most welcome!
Cheers,
Paul
PICAXE 08M based GPS Autopilot for Model Cars, Boats and Aircraft
The system was conceived with the original intention of having a system that was capable of interfacing with a handheld GPS and directing a model airplane over a set route of waypoints. The system would have to be capable of controlling the aircraft’s heading whilst the stability of the aircraft in all other axis would be entrusted to widely available ‘co-pilots’ ; in particular the FMA CPD4 Flight Stabilization System.
Whilst these co-pilot systems are available readily and at affordable prices there exists few affordable and simple GPS based autopilots for the average flyer such as myself. For this reason I investigated the possibility of a system like this one that could be developed to suit my requirements.
Some of the essential system requirements that were decided on are as follows:
Ability to receive and interpret NMEA 0183 serial data from the handheld GPS
Be remotely controlled from the user and switched on/off in this way
Control a standard servo using pulse width modulation (PWM)
Additional or optional requirements were as follows:
Provide for optional telemetry to the ground
Enable software upgrades and development easily and quickly
Adjustable gain control
Research on the internet showed that model autopilots using PIC microcontrollers are nothing new and there are many published versions with similar specifications to those stated above.
However, in the interest of designing a system that used off the shelf components that are both affordable, easy to obtain and implement the PICAXE series of microcontrollers were chosen.
The first step in developing this system was the ability to receive and interpret NMEA serial data from the GPS. After research on the internet into this protocol and format this was proven to be viable using a handheld Garmin GPS unit. Virtually any data can be extracted from the GPS using this method but for the purposes of this project attention was focused on the current heading and bearing to destination information provided by the $GPRMB and $GPRMC sentences.
The second step was developing a program and unit to suit that would allow the user the ability to switch the autopilot on and off remotely from the transmitter. This was done by using a PICAXE 08M to measure the length of PWM pulses incoming from the radio receiver. Any change in these pulses was noted and if the change corresponded with the transmitter switching the device on and off this change was reflected in the state of the 08M. A fundamental feature of the ‘switch’ is its ability to pass control of the rudder servo to the user when in the off position but revert control to the autopilot when required.
Finally, in order to control a servo using the information gathered from the GPS the use of a servo command in the PICAXE had to be implemented. Whilst the PICAXE microcontrollers have this function by default it was found to be unsuitable for this project because it did not appear to position the servo with sufficient accuracy when the PICAXE was over clocked as required to communicate with the GPS. Instead, a custom sub routine which was created which in essence creates a PWM pulse to the servo over a short period of time that allows the servo to move to its required position. The process of moving the servo to its desired position is decided by comparing the current heading and bearing information provided by the GPS. From this the Autopilot decides in which direction a correction is required and depending on the extent to which the craft is off course, how far the servo is required to be moved in order to compensate.
These sub-components and processes were brought together to form a prototype system that was capable of providing simple control of a servo depending on the information received from an attached GPS unit. To test this system it was driven around a series of routes in town all the while directing it to steer a course as it saw fit towards its destination. It was found that it was perfectly capable of steering in the right direction and moving to compensate a change in course even when the change was deliberately created to oppose its preferred route.
The system was then developed to the point where three networked PICAXE 08Ms were networked to provide the basic functions of control, serial data interpretation and finally servo control. The microcontrollers responsible for serial data interpretation and servo control are controlled by the master control 08M which is in turn controlled by the transmitter.
Both the serial data interpreter and servo controller are synchronized in way that only allows the relevant serial data from extracted from the GPS stream to be passed to the servo controller when it is ready and has completed the previous command. This was found to be the key to ensuring a reliable chain of communication and reducing the lag between updates reaching the final 08M in the ‘chain of command’ as it were. Using this method reduces the time between heading and bearing updates from the GPS being translated to the servo controller to approximately two seconds. This appears to be limit of what can be extracted from the GPS. NMEA data is transmitted at 4800 baud from the GPS which results in the relevant data sentences being transmitted once every 1 to 1.5 seconds. This coupled with the maximum clock speed of the 08Ms of 8 MHz seems to be appreciable.
In this way the essential system requirements for the Autopilot were fulfilled. Optional requirements were tackled during the build of the first prototype model.
Facilities for optional telemetry were installed on the prototype PCB even though they have not yet been fully developed. By default the current system facilitates the use of short range 433 MHz RF models although in the interests of reliability and better range it should be noted that 2.4gHz modules are recommended if this device were to be fitted to a model aircraft.
The development and testing process dictates the requirement of easy software upgrades without the hassle of dismantling the Autopilot simply to upload a new program. This was easily overcome by simply placing programming circuits and connectors on all the chips on the PCB, allowing easy access to all of them for in-field development.
Adjustable gain was foreseen as a requirement that would make it easier to calibrate the Autopilot to the requirements of the user or the craft it is installed on. This was put in place by means of an adjustable trim pot on the upper PCB that forms part of a voltage divider which provides a reference voltage to the Autopilot. This voltage is measured and instituted into a process to calculate the gain. Thus, any adjustment to the trim pot results in a change to the Autopilot gain. This effectively changes the nature of the Autopilot by increasing or decreasing the amount of control it has over the steering servo and the margin of difference between the heading and bearing that the system will tolerate.
Development:
I believe that the Autopilot is not ready at this point to be fitted to a model aircraft as initially designed and should not be considered complete. Much development in the software and calibration is needed before this goal is to be reached. However, I feel that the present configuration fulfills the specifications I decided on during its initial conception. It is only with time and testing that it can be fine tuned to the required point of completion.
Already many lessons and processes have been learnt and engineering challenges overcome along the way. Undoubtedly, more challenges lie between the project’s current point and the eventual goal. However, with development and patience I am confident these can be overcome and the full potential of this system realised.