Building the TPC C172 flightsim switch panel

TPC C172 switch panel

This build is a repeat of my first attempt at building a flightsim controller. My goals for this build were:

  1. Learn the basics of building a controller.

  2. Have it work in MSFS via the Controls Options without the need for any external program or key mapping.

  3. Use relatively inexpensive components.

  4. Utilize my laser cutter/engraver to make the enclosure and front panel.


I have included links to some of the items used in this build. None of them are affiliate links or intended to promote any particular source for these items. They are there to simply provide additional information on these components.


The Microcontroller

As part of my second and third goals, I settled on the Teensy 3.2 microprocessor for this build. This board is not an Arduino, yet by including a few additional libraries it can be programmed using the Arduino IDE interface. It supports up to 34 digital input/outputs, 21 analog inputs, and a lot more all in a very small package. Each of the digital inputs can be tied to an internal pull-up resistor eliminating the need to add extra resistors to the build.

While the 3.2 is an older board and is now becoming obsolete, the newer versions of the Teensy will all handle this same build and add even more options for future builds. At the time of writing, the Teensy 3.2 can still be found at some retail sources: Amazon.com: Teensy 3.2 (with Pins) : Electronics


The website for the Teensy boards: Teensy® 3.2 (pjrc.com) Includes information on downloading the free Arduino IDE and “Teensyduino” add-on, along with full documentation for the boards and help with getting started.

The Hardware

• Seven Miniature SPDT On-On Toggle Switches

  • Jameco Mini Toggle Switch

  • Any toggle switch will do for this, simple On-Off toggle switches would be more cost effective. I just had a bunch of these on hand.

• Four Rocker Switches

  • Rocker Switches

  • Again, any sort of switch will do here. These were the closest I found to the type of switches used in the C172 panel (I couldn’t find white at the time.)

• One 2 Pole 5 Position Rotary Switch

  • 5 Position Rotary Switch

  • In my first build I used one that was required too much torque to turn. It worked but made turning the magnetos switch awkward. This one worked out better.

• One Cabinet Lock

  • Cabinet Lock

  • There are lots of other options for implementing a key switch, but the price of this one is hard to beat.

• Five 220 Ohm Resistors

In addition, a Protoboard (or breadboard / printed circuit board) along with some printed circuit board standoffs are used in the project but are not required.


Holding It All Together

I used a laser cutter to create a structure to attach all the controls to. The front panel will sit up against this structure in the finished controller, but during development I used a clear piece of acrylic cut to the same shape.

You can just as easily (actually more easily) make or purchase a “project box”, drill holes in it, and mount the switches and teensy board in that.


The Magnetos Switch

The magnetos switch is created by drilling out the rear section of the cabinet lock to allow the rotary switch pole to fit snuggle inside. A small hole is then drilled in through the side of the cabinet lock and tapped to accept a small set screw. This can be tightened to keep the switch from slipping when the key is turned. The mounting board was sized to hold the rotary switch based on the measurements of the completed assembly.

It is possible to make the magnetos switch spring back from the “Start” to the “Both” position using a spring, but I opted not to go this route as I found it made the set up a little too fiddley. For more information on how to do this see: Cessna 172 Flight Simulator Panel (lots of inspiration here).

The Toggle and Rocker Switches

The remaining switches are mounted to the internal support.


Wiring Up the Switches

I mounted a protoboard to the internal support and connected the Teensy at one end. Everything will be powered by a USB cord connected to the Teensy. The Ground pin on the Teensy is connected to the (-) ground bus of the protoboard, and the 3.3V pin on the Teensy is connected to the (+) positive bus.


The center terminal for each of the toggle switches and the rocker switches are wired to the ground bus of the protoboard. These can all be daisy chained together instead of running separate wire for each switch.


The “On” terminal (with the switch “on” in the up position, this is the bottom terminal) are all wired individually to one of the Digital I/O pins of the Teensy. See the switch mapping document for the pin layout I used.


The Magneto Switch – Five Switches on One Wire

You could simply run a wire from each switch position terminals to another digital pin on the Teensy. While there are more than enough pins available in this build to do this, I wanted to try another approach that can be useful when you are running low on input pins.

The center terminal of the rotary switch is wired to the (+) positive bus of the protoboard. Then a 220-ohm resistor is connected between each of the switch position terminals and another 220-ohm resistor is connected between the “Off” position and the (-) ground bus of the protoboard. The “Off” position is also connected to an analog input pin on the Teensy. This creates a simple voltage divider. We can then check the input value of the analog input pin to tell what position the rotary switch is set to.



Someplace To Put It All

The outer box was once again cut using a laser cutter. Four posts were added to secure the front panel and support structure to the box. Blind T-nuts were used on the back of these posts to accept the hex socket cap head screws. The hole in the back of the box is for the USB cord.



The Pretty Part

The front panel was created using a piece of white acrylic with the front face painted black. Paint doesn’t like to stick to acrylic, so some sort of “Adhesion Promoter” should be applied first and then the paint.

Finally, the painted acrylic was cut and etched using a laser.


Programming The Teensy

By using the “Joystick Interface” provided for the Teensy, a computer will see this USB attached device as a joystick with 32 buttons (we are using 28) along with an eight position POV hat switch and X, Y, and Z joystick or slider controls (that we are not using in this build).


The program has the Teensy poll the switches repeatedly (once every 50 milliseconds) to see if anything has changed and only sends a button press, followed by a button release, to the flight simulator when this occurs. This keeps the load added to the computer/simulator to a bare minimum.


The program I used can be found in the link below. I tried to document what is going on in the various subroutines. I will not go further into the details of the program here, but if there is an interest, I could write a follow up blog post on this topic.


To use this program in the Arduino IDE, download the text file and then change the extension form “.txt” to “.ino”.



Teensy program file: FltSimButtonJoystick.txt

Switch/Pin/Button mapping: SwitchMapping.pdf

MSFS Control Options Settings: ControlOptions.pdf

 
 
 

More from the Blog

Previous
Previous

Partnership with Sky Blue Radio

Next
Next

Explorer Flight Missions