[UPDATE: We no longer recommend this GPS module, since it's incomptible with GPS simulators. The module we do recommend, the EM406, is described here.]
Now you've got the hang of connecting components to the development board, you'll be pleased by how easy it is to include GPS. Parallax sells a pretty inexpensive ($70) GPS module that has a simplified "smart" mode that only sends the data fields requested. It's not the best GPS chip (only 12 sats), so you'll need a pretty clear view of the sky and it probably won't work indoors (but a little balsa or foam in your plane shouldn't be a problem). This is the easiest GPS module to use with the Basic Stamp board, but if you think you're going to want a more advanced module with better reception, skip to the next tutorial
I had a little trouble when I first tried to get the Parallax GPS working, so this tutorial will help you avoid my mistakes.
First, DON'T place the GPS board right on your development board's breadboard. For some reason the GPS reception is terrible there, due to noise from other components. Instead, use another female-to-female servo connector cable (at least ten inches long; one of these is fine) and with it connect the three GPS pins other than /RAW to one of the dev board's servo ports that you're not using, as I've show in the picture.
Second, you're going to have to modify the demo code for the particular BASIC Stamp chip you're using. This took me forever to discover and it's definitely a shame that neither the manual or demo code mention this. You'll see in the code that there is this line:
T4800 CON 188
It tuns out that that 188 is just for the BS2, BS2e, and BS2pe chip. If you've got one of the other chips (I've got the BS2p) you need to change it. For the BS2sx and BS2p the number should be 500. For the BS2px it should be 813. (This info is buried in the BASIC Stamp Editor's help file in the SEROUT entry)
Also, change this line:
Sio PIN 15
To reflect whichever pin you've actually connected the GPS's SIO pin to.
Once you've made those modification the demo should run and you'll be able to copy the relevant code from that to your autopilot program.
If you're finding that this GPS just doesn't give you reliable enough performance, you may want to upgrade to a more advanced GPS module based on the 20-sat SIRFIII chipset. A good choice is this one from SparkFun, which is $10 cheaper than the Parallax module but offers much better reception. It's a bit trickier to interface with the Basic Stamp chip, so that's what we'll look at in the next tutorial.
Previous posts in this series:
Tutorial 1 -- Servos
Tutorial 2 -- Reading the Rx
Comments
FindPSC:
' DEBUG "Finding PSC", CR
' SEROUT Sdat, Baud+$8000, ["!SCVER?", CR]
' SERIN Sdat, Baud+$8000, 500, FindPSC, [STR buff\3]
' DEBUG "PSC Ver:", buff(0), buff(1), buff(2), CR
SetBaud:
' DEBUG "Setting Baudrate", CR
' SEROUT sdat, Baud+$8000, ["!SCSBR",0,CR]
' SERIN sdat,Baud+$8000,500, SetBaud, [STR buff\3]
' DEBUG "Baud reply: ", buff(0), buff(1), DEC1 buff(2), CR
SetBaud2:
'DEBUG "Setting Baudrate", CR
'SEROUT sdat, Baud+$8000, ["!SCSBR",1,CR]
'SERIN sdat,Baud,500, SetBaud2, [STR buff\3]
'DEBUG "Baud reply: ", buff(0), buff(1), DEC1 buff(2), CR
'DEBUG CLS 'clear debug screen
I certainly hope the propeller chip can offer servo control by its own accord with the need for a servo controller of some sort. Can the proto board for the propeller suppor the required volt and current draw for 5 servos?
The SIRF III modules lock on within 15 seconds and stay locked on.