# RC Airplane/RCAP
## Description

The RCAP v.3 is a Remote Control Autopilot for model airplanes and cars. The autopilot function can be switched off or on during flight with the flick of a switch. It requires a GPS antenna, and a computer to upload the waypoint coordinates to the WPS (Waypoint Sequencer. The navigation board, connects directly to the waypoint sequencer and to the GPS antenna/module (OEM GPS).
Please come back for an updated project an information on the RCAP v.3

## Description

The RCAP2 is a Remote Control AutoPilot for model airplanes, cars and boats. The autopilot function can be switched off or on during flight with the flick of a switch. For it to function, a NMEA capable GPS (with either an OEM GPS for new firmware being developed rcgroups thread, or with programmable goto/waypoints functions) must be connected to the serial input port of the RCAP2.
This Wikipedia article describes what the RCAP2 is, what you can do with it, how it works and how to install it. The article is not meant to be a how-to for the RCAP2. For that information you should visit the manufacturer website of the RCAP2.
The original RCAP was conceived by Mike Pawlowski. Mike wrote the firmware v1.1 for the RCAP, which this RCAP2 is based on. He also designed the original RCAP board, which this RCAP2 is based on. Many thanks to Mike for publishing his work as open source. His website and source code can be found on sourceforge. The RCAP2 is pin for pin compatible to the original RCAP. Some additional headers and servo ports have been added for future use. You will find them described below.
The RCAP2 is available from Scale Robotics in 2 flavours:
* 1. Pre-built and soldered RCAP2 GPS waypoint tracking (some items need to be added by customer, see below)
* 2. RCAP2 PCB kit & parts for gps waypoint tracking
Software/Firmware can be found here, and servo.inc and other original firmware for can be found here. The source code for this project was programmed using PicBasic Pro. This software is available from MELabs. PicBasic Pro is only necessary if you wish to customize the program of the RCAP2.
The version that is currently being sold (Nov 2007) contains bootloader functionality which makes it possible to upload new firmware to your RCAP2 by connecting the it to the serial port of your computer through a null-modem cable.

## How does it work

Very soon I will be adding more information on how the RCAP works.

## Before buying

Before you jump into buying the RCAP2, you have to realize that to make your UAV system complete, there are a few other items that you need to have/buy to get started. Also there are things that need to be considered before taking the plunge into RCAP2:
* Airplane / boat / car) in which you are going to use the RCAP2
* a GPS device that is can store waypoints/routes
* Read Use and Limited Liability paragraph

## Installation

Before you can actually use the RCAP2 there is some minor work to do. This includes soldering to the board. If you don't feel comfortable with soldering, then find someone that can help you with this.
Power
To power the board, I suggest you to choose a connector that mates with the connector on your powersupply (ie. batterypack). The connector can be attached to the board through wires. Soldering has to be done for powering the board and in some cases for connecting the RCAP2 to your receiver.
Solder the red wire (positive lead) coming from the connector to the pad marked with a + sign and the black wire (negative lead) to the pad marked with the '-' sign. These pads are a little hard to find. If you look at the image above, you will see 2 blue capacitors, just next to the DB9 connector. The pads can be found below the capacitor nearest to the edge of the board. You probably have to bend away the capacitor to have access to the pads. Be careful not to bend the legs of the capacitors to often or it will break and cause your board not to work anymore.
Receiver connection
In the image above you see jumper J3 (enable channel) and J4 (RCAP2 to Rudder on receiver). To save weight -crucial for airborne models- some boards are sold without the jumper. If you received your board without thes jumpers you have to solder servo extension wires to the board. The servo extension cord should have a female connector on 1 side (for connecting it to, in most cases, the landing gear/flaps channel and rudder channel of your receiver). The pads that you connect ground to is the pad closest to the edge of the board. Slide the servo wire into the board from the upside and solder it on the backside of the board.
Rudder
In most cases you want to use your rudder for steering from one waypoint to another. Connect your rudder servo to jumper J2 on the RCAP2 board.
Also connect the servo wire coming from J4 to the rudder channel of your receiver

## First use

Before using the RCAP2 for the first time, be assured that you have the latest firmware version.
Your RCAP2 board contains a PIC Microcontroller (type 16F876A) that contains the software that takes care of sending your model to pre-programmed waypoints. On the microcontroller you will find a label with the firmware version that is in the chip. New firmwares can be downloaded from the RCAP2 RCAP2 website, follow the link to firmware and download the latest HEX file. You also need the software to upload the HEX file to the RCAP2 board that you find on the same page.
After downloading the firmware, use the null-modem cable to connect the RCAP2 to your computer (note: Notebooks don't work in most cases since the power they can supply through the serial ports is too low). Follow the instructions on the firmware page on how to upload the firmware to the RCAP2.
Be sure to set your GPS data transfer settings to NMEA/NMEA at 4800 baud. A new firmware has come available (2006-05-03) which makes it possible to work on 9600 baud, go to the firmware website to download this new version
Now follow the procedure below for first use.
* 1. Connect the wire coming from J3 to your receiver's landing gear or flaps channel (please take note of correct polarity) and J4 to the rudder channel on your receiver.
* 2. Connect the rudder servo to jumper J2 (check polarity)
* 3. Switch off landing gear (or flaps) channel of your transmitter
* 4. Program a route into your GPS device by adding waypoints, when finished, switch of the GPS device
* 5. Connect your GPS device through a cable to the RCAP2
* 6. Switch on your transmitter
* 7. Switch on your GPS device
* 8. Select the goto function of your GPS device and select a waypoint.
* 8. Power up your receiver (by connecting the battery to your Electronic Speed Control)
* 9. Connect the RCAP2 to the powersupply
No smoke? great! You did well. Now, when the RCAP is first powered, it samples the transmitters rudder stick for neutral position. In versions previous to 1.6, it also samples the rudder position (and assumes it to be neutral) each time the autopilot is enabled. This means that you must be in neutral rudder position each time you flip to autopilot if you are using versions previous to 1.6. This is important for the autopilot to function properly. During power up, you will see the LED light for the first 6 or so seconds after you apply power to the RCAP.
Now verify if all controls on your model work as they are supposed to do. If something doesn't work as it is supposed to do, then check your connections and see if you followed all steps of the procedure above. Maybe you forgot something.
If everything works correctly, you are ready to flip the landing gear (or flaps) switch on your transmitter to switch on the RCAP2 autopilot function. The LED should start to blink every 2 seconds or so. This indicates that your RCAP2 has autopilot enabled, and valid GPS data is being received through the serial port. If the LED is not blinking, then check if all the following conditions are met:
* The GPS device is receiving good data and plugged in correctly to the RCAP2
* The GPS is set to output NMEA in/out at 4800 baud (or 9600 baud with latest firmware - see above)
* A waypoint selected and in goto mode
* All connections between receiver, and RCAP made properly
* Autopilot enabled with transmitter

## Testing your RCAP2

Comming soon...

## Recommendations

It is suggested that the RCAP2 be used only on high wing trainer type aircraft. The original RCAP website suggests that it only be used with a FMA Co-pilot type device, in order to keep your plane stable. It is unknown whether an inherently stable aircraft could be flown successfully with the RCAP2 without a flight stabilization system. The original RCAP site shows a FMA Copilot being connected to the elevator and ailerons, while the RCAP is connected to the rudder.

## Configuring the RCAP2

There are 3 variables to set to the RCAP2 and have it work the way you want, those are Travel, Gain and Servo direction.
Travel
Max Servo Travel (Variable resistor R2) allows you to set a maximum end point that you will allow a servo to travel. This is especially important when installing the RCAP into an aircraft. I recommend starting with a minimal setting and increasing it slowly. For your information a max setting of travel is attained when the pot is set fully counter clockwise.The position of this pot will be looked at each time autopilot is selected.
Gain
Course Correction Gain (Variable resistor R3) allows you to adjust how aggressively you want to RCAP to remain on course. A low setting means that the RCAP will slowly turn toward the current course. A high setting will have the turns perform much quicker. The amount of correction used is also proportional to the amount off course the vehicle is, the greater the amount off course, the greater the correction is. I would recommend starting with a minimal setting and increasing it slowly. For your information, a max setting of gain is attained when the pot is set fully counter-clockwise.
Servo direction
Servo direction simply allows you to reverse the direction a servo turns while the RCAP autopilot mode is selected. While in radio controlled flight (autopilot off), your transmitter takes care of servo direction. The transmitter uses the settings you have done in the radio. When autopilot is on, you give control to the RCAP2 and it is not aware of any transiter settings. Before actually putting the RCAP into your vehicle your have to make sure it matches the expected response. You must test this with the GPS attached, waypoint selected, passing a waypoint position one side or the other while looking at the rudder to ensure that it is turning the proper direction to turn toward the waypoint. This switch position is looked at every time the autopilot mode is selected.

## Custom programming

Programming or modifying your own code is possible as the PIC16F876A chip can be reprogrammed about 100,000 times. The RCAP2 currently comes with version 1.6B programmed in. This version includes a small bootloader code in the firmware that allows the chip to be programed easily through the serial port. With version 1.6B no programmer will be required. If you are interested in a programmer, there are many programmers out there. Many will need a separate adapter to program a 28 pin chip. PicBasicPro was the software tool used to create Main.bas (ver 1.1 RCAP code), as well as each successive version. This program makes it relatively easy to program a PIC chip using code similar to the Parallax Basic Stamp code. PicBasic Pro is made by MELabs, and can be found on their website.
If you think you have designed a useful piece of code, then we would love to hear from you about it. Please contact Scale Robotics and let us know what you have made. We might consider to use your code in feature releases of our firmware.
Debugging
Debug is a tool you can use to get information out of your PIC chip. You can use the provided code debug-main.hex to help you understand what is going on inside the RCAP2. This is not going to be available, unless you program the chip that way. it is easiest to work with the debugging port, J7. This gives you the following status while you have turned on autopilot mode.
_____________________________________________________________________ !$GPRMB,V,0.00,L,,001,3700.356,N,12134.960,W,0.643,180.5,-20.0,A,S*76 !===DoCS: !cs=118 gpscs=118 !$GPRMC,045034,V,3701.0202,N,12134.9525,W,20.0,0.4,230206,14.8,E,S*0F !===DoCS: !cs=15 gpscs=15 !===Correct: !Center : 1525 !Position : 805 !Pos in ms : 1705 !Gain : 3 !TrvlMax : 2100 !TrvlMin : 925 !GPS Valid : 1 !Offcourse : 180 !Dir : 0 !Servo Dir : 0 !TrackErr : 000 !Steer : L !Bearing to dest: 1805 !CMG : 0004

## Use and Limited Liability

You should always fly your model within visual range. Also it's very important to stay keep your model within your transmitter's range. Never fly near the limits of your range. You may not be able to switch it out of autopilot mode, should it become necessary. The RCAP2 may generate extra electronic noise that reduces the range of your transmitter. You should fully bench test and range test your setup with a friend thoroughly before your first flights are attempted. Be sure to meet all regulations that are made by the local authorities/model assocations in your country (id. AMA, FAA and/or others). Scale Robotics Inc. shall not be held responsible for any incidental, consequential or direct damages or expenses associated with the use or misuse of its products.

## Technical information

A glance at the board. Specifications and a description of the connectors, jumpers, etc... you will find on the board. Some jumpers are for future use, for example, altitude-hold through a pressure sensor is being worked on. Furthermore a list of all components on the RACP2 board.
| Specifications | |
| Weight | 23 grams or 0.8 ounces without DB9 serial connector |
| Size | 3-3/8” long 1-5/8” wide |
| Power | Supply 6 volts dc or higher, at about 20 to 25mA. Do not exceed 25 volts! |
| Jumper/ Connector | Description |
| DB9 | This connector allows a standard type GPS serial to PC cable to be plugged directly into the RCAP. This also allows serial port flashing of the firmware without the need for a programmer (see version 1.6B description) You can leave this connector off, and solder a home made cable to the RCAP if you would like to save the space and weight. However, a compatible GPS must be connected for it to function in AutoPilot mode. |
| J2 | Rudder servo - Plug your rudder servo onto this jumper. Pay attention to ground side. |
| J3 | Enable Channel - This plugs into receiver, normally on a spare Gear channel that you can switch on or off. |
| J4 | Rudder-receiver - Plug this jumper into your receiver on the Rudder channel. |
| J5 | Analog in port (for future use) PortA,0 |
| J6 | This jumper allows you to power the unit from the DB9 connector. This is better left to the + and - pads, so we suggest you to leave the jumper out. |
| J7 | Debug port as documented in RCAP PicBasic Pro code. (Not used) PortA,5 |
| J8 | Servo/receiver Port C,5(for future use). |
| A1 | Aux servo - PortB,1 (for future use). |
| A5 | Aux servo - PortB,0 (for future use). |
Unlabeled 6 pin header above J5: This header is made up of spare pins from the board that are currently unused by the RCAP. Pins from left to right: PortC,4 PortA,1 PortA,2 PortC,0 PortC,2 PortC,3
| Component | Description |
| PCB | The circuit board |
| C3 | 50v .1 uf capacitor (black) short lead goes to ground |
| C2 | 16v 10uf capacitor (blue) short lead goes to ground |
| C1 | .1 uf capacitor (small blue) |
| U2 | 5v regulator. A heatsink was removed for weight, and the fact that with a max regulator load of 150 mA, I dont think you will get much heat. |
| C4, C5, C6, C7, C8, C9, C10 | .1uf monolithic capacitor (tan) |
| D1 | LED (flat edge toward outside of board) |
| Gain-/Travel Pots | 5k single turn potentiometers |
| SW1 | three pin header with jumper |
| A1, J2, J3, J4, A5 | 15 pin header (Optional, you may want to solder your wires directly to the board to save weight) |
| R1 | Yellow Purple Red resistor |
| R4 | Brown Black Orange resistor |
| R5 | Brown Blue Brown resistor |
| U1 | socket 28 pin |
| U1 | PIC16F876a chip preprogrammed with latest firmware |
| U3 | Socket 16 pin |
| U3 | MAX232ACPE chip |
| DB9 connector | Serial port connector (optional, many will probably like to build their own gps cable soldered directly to the RCAP2 board to save on weight). |
| CR1 | 20 mhz resonator |

## User tests/stories/testimonials

In this paragraph you will find stories or links to stories from RCAP2 customers. You will see how they have come to their setup, what obstacles they have run into, etc...
After some start up troubles, kd7ost reported about his first successful flights:
    RCAP unit test flown
    Well, we didn't get much of a break but it was enough. The winds settled down to 15 mph. Jeff had the Telemaster 40 ready to go with the RCAP on its own power source. He managed to fit the Garmin geko 201 above the fuel tank so we gave it a go late in the day.
    Jeff had also worked his FS8 receiver into the project so would have a failsafe unit to further test with. Set location as a waypoint and performed a “goto”. Fueled up and into the air, climb out to a safe altitude and first got the roll and pitch control working to satisfaction. Next, flew down wind and back towards us to engage the RCAP while observing results. We were standing at the waypoint. The plane got overhead and as soon as it passed the waypoint it started a gentle right hand turn. We watch as it slowly came around, went back down wind a fair ways and finished the turn heading right back at us. Over head again and it repeated. It was loitering at the waypoint. Jeff had the gain set to about 50 percent and that was a little light for the Telemaster. We brought it in and tweaked the gain up to about 100 percent deflection.
    Back up and set it again. It kept in a little tighter this time. We continued to fly and were so happy watching and evaluating it that we let the fuel run out. Dead sticked in, re-fueled and back up for more. Jeff flew it off in the distance till it was a spec in the distance and shut of the transmitter to fully test the failsafe and return. Within a few minutes it was obediently overhead back into the loiter pattern. As a long time PDC-10¹ user I can say this performs just like the now retired PDC-10. Several more test’s were done trying various directions, down wind, (still up at 15 mph) up wind, cross wind etc and it came back over head every time.
    Due to not having the time to plot a course we didn’t send it out on an autonomous flight. But that’s a function of the GPS and I know this RCAP would have flown the route and returned to loiter overhead.
    Congratulations to Scale Robotics. You got a winner. We're still waiting for decent weather but I know there will be many flights to come with the unit.
¹) The PDC-10 is an obsolete UAV product from Unav.
The story above originates from this thread on the RC Groups forums. In that thread the initial problems with getting the RCAP2 working correctly with a GPS device were discussed.

## Further reading

* If you want to customize the firmware on the RCAP, you may find Embedded Systems/PIC Programming helpful.