In an earlier post
, I discussed some of the options for connecting your autopilot to your PC for GPS simulation. I've now tried several of the options on our Basic Stamp autopilot, and I have some recommendations on what to do (and not to do).
Rather than try to re-use your dev board's serial connection to the PC for GPS simulation (an option I discussed in the earlier post), I recommend that you get a USB-to-serial board like this one
($20), and run two serial connections simultaneously. This is because one of the serial connections is going to be used by the Basic Stamp as a terminal monitoring the autopilot and incoming data. The second one is going to be used by the GPS simulation software. You really need both, especially if you're doing any debugging.
With the above USB-to-serial card, it's a little unclear what pin does what (the boards don't come with instructions). The picture below shows which wires you need. Basically, with the USB connector at the bottom, you want the first three pins from the top on the right side. They are, in order, ground, V+ and "Rx". (confusingly, the terms Rx and Tx depend on your perspective of what side of the serial connections you consider the "sending" side. In this case, this is the same pin that we call "Tx" on our GPS module.
We're going to plug this board in the exact same rows on the breadboard as we used for the real GPS module, so it's simply a matter of unplugging one and plugging in the other to do a simulation. This is what it looks like on my board (click to get a larger picture if you can't read the text)
When you plug in that USB to serial adapter, Windows should recognize it immediately and load the right driver. Windows will assign the board a serial port, but odds are it will be pretty high one (I usually get 10 and above). To find out which one it got, go to the Windows Control Panel, System, Hardware, Device Manager, Ports. It should show that you've got a new "USB Serial Port (COM X)" where X is whatever port it's been assigned.
Now you need the simulation software. I found a good free one from FlyWithCE here
. Fire it up, and see if you can select the port that your USB to serial card has been assigned to. If that port isn't listed, you need to remap the card to a lower port. The easiest way to do that is back in Windows Device Manager. Select the port, and click Properties, then Port Settings, then Advanced. Select the lowest port you can. Click Okay, unplug the cable and plug it back in again. Now when you check Windows Device Manager, it should be listed at the new port numbers.
Now go to the Basic Stamp IDE and run the GPS test code from this post
. The Debug terminal should show that the code can't find a GPS signal. Now go to the GPS Simulator. Enter a starting lat/lon and press start. If you set everything up right, you should start to see NEMA sentences. Click on the Move and/or Circle buttons and enter some speeds, and those GPS readings should start to change.
Now you've got GPS simulation working! If you fire up your autopilot, it should start to navigate according to these [fake] readings. But it's more fun to see what you're doing, so we'll replace the FlyWithCE simulator with Flight Gear in the next post.