Curt Olson interview part 2: we pause for a hardware moment

(part one of the interview is here. A followup to the post below, with some more specific advice, is here.)

Before we drill down with Curt on the specifics on one way to use FlightGear for simulation (synthetic GPS generation), I should start with a little primer on the hardware side of simulation.

The first thing we'll need is a way to connect a PC's serial port (or, if you're like me and only have a laptop with no serial hardware, a virtual serial port via USB) to your autopilot. In the example in the next post, we're going just be doing GPS simulation, basically tricking your autopilot into thinking that it's flying around when in fact it's right on your desk.

There are two ways to do make this connection with your PC, where the simulator will be running: in software or in hardware. The first is the easiest but requires you to change your autopilot code every time you do a simulation. The second is a simple plug replacement for your GPS module, but requires some one-time wiring.

The hardware approach:

If you're using a desktop PC with a real serial port, just cut the end off of a 9-pin serial cable and do one of the following, depending on your setup:
  • If you're plugging in your GPS with a standard three-pin RC servo plug, just connect the serial cable's pin 3 to the white wire of the servo plug. (See DB9 in this schematic to know which is pin 3)
  • If you're using a standard GPS connector, such as the little white one in the EM406, the serial cable's pin 3 should go to the connector's pin 4 (Tx), as discussed in this post.
  • If you want to go straight to your breadboard, just cut the end off of a 9-pin serial cable and solder pins 2,3 and 4 to a header strip (break off three pins from a breakaway strip). We're actually going to use only one of those pins--the Tx signal on pin 3--but you may want the others for other simulations later. Stick that headers strip on some unused part of your breadboard and connect it with a wire to whatever Basic Stamp pin you're using for GPS in.
If you're connecting to your PC with a USB cable, as I do, you'll need to buy a USB-to-serial converter such as this one ($20), Plug it into your breadboard and connect V+ and ground as shown in this tutorial. Connect pin 2 to whatever CPU pin your GPS Tx pin is normally connected to. If you're working on a development board, this is probably the easiest approach. It's what I'm doing. [UPDATE: here's a How-To for my particular setup]

The software approach:

At this point you're probably probably saying "But my autopilot is already connected to my computer! Why do it again?" Well, yes, but it isn't connected to your PC on the same wires as your GPS. If you to want have a simple plug trade between your GPS and your simulator, you'll have to use the hardware approach above. But if you're willing to tweak your autopilot code when you're running simulations, you can skip all of that and edit a single line, changing the pin on which your autopilot looks for GPS data.

In our Basic Stamp examples, you'd go to the constant declaration part at the top of the code and edit "Sio PIN 15" (or whatever you've set as your GPS-in pin) to "Sio PIN 16". That's because "16" is the Basic Stamp code for the dedicated serial-input pin (SIN, physical pin 2), which is normally used by the Stamp Editor during the download process. That will be different on different processors and programming languages, so revise accordingly if you're using something else. Just make sure you're telling the autopilot to look for GPS on the same pin it normally uses to communicate with the PC.

And now to simulation...


Now you can use the same cable and hardware setup you normally use, but the autopilot will look to the PC for GPS NEMA sentences. And those will now be generated not by a real GPS module, but by a simulator.

So now we can turn to the next part of the Curt Olson interview, which will talk about how to get that simulator running.

Views: 1087

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service