mercredi 8 juillet 2015

Home made cockpit for xplane

Introduction


Xplane user for over three years now, I thought it was time for me to tinker with a few switches, glue and nails, a dashboard allowing me to add additional commands to the joystick that is already being used and all for less than 130 dollars.

A real cockpit here would be pretty good !

Technical choice:

obviously, only the nails are not sufficient, we also need some electronics and computer science. But nothing really difficult after a bit of thinking. Indeed, a little Web lap I discovered that the Teensy micro-controller makes it easy to be programmed as a USB device.
For my application, I choose de Teensy++2.0 because it has forty Inputs/outputs. The factory website is https://www.pjrc.com/teensy/.

To better understand what can be done, an overview on existing projects shows us that we should be able to do many things :
This excellent blog : https://simelectronics.wordpress.com/

And of course the forums are a great source of information:
Carpentry :
In short, after being reassured about the feasibility of the project, we can begin to saw some boards. But first, a little plan:
the sticky joystick shows us the remaining space for the dashboard
Joinery, 13x38 of wood battens will do the edges and an aglo plate 'medium' 3 mm thick will be perfect for panels.
Wooden angles also serve as pins for feet (see back panel)
Back panel, Pins used for add stabilizer feet

After some brainstorming, here are the chosen commands which will be installed into the cockpit.

Electronics and wiring :

Now, let's do a bit of wiring. Heat the soldering iron...

Changing the radio frequencies :

Let's start with the part of rotary encoders (those used to change the frequency of the radio)For this, I opted for this type of encoders: 3054-encoder-bright-a-rotation-infinite whose plans are there.
 

These encoders are backlit by two red and green internal LEDs. I chose to take the green for the radio part and the color red for the navigation part. For coding, there are two possible ways: either using D flip-flops (component CMOS 40xx) for decoding the direction, either it is the the Teensy micro-controller which handles this though a computer program. For now, we will choose the second approach.

The wiring diagram for the 4 encoders consist of 4 resistors to power the integrated LEDs. Note that the resistance values are higher for green LEDs to reduce their brightness compared to red.



And here is the result :


So we can check it by powering it with 5volts DC :

Support plate for the micro-controller Teensy:

We will add 2 connection strips to the Teensy:



Then prepare on a 'prototyping' printed circuit for receiving wires and connector.




 Wiring:

Rummaging through my boxes, I found an old ribbon wire and another with an 8 point connector which can be used to connect the inner pins of Teensy. This cable was used to connect two USB ports on a motherboard to the front of a PC.

notice the 8 soldered pins for receive the connector and 2 more soldered pins for deport the teensy reset button.

Initially I had not planned to deport the Reset button. However, this offset will be helpful for that button should be used to dump the program to the Teensy.
I had not ordered enough Pin on my last purchase, I went to the dump and I was able to get an old computer mother board from which I got these connectors.


From side of the support plate, here is the result :



And finally, the links to the other switches and components :

The ribbon wires perfectly play their role in so far as they provide a clean wiring. Which is far from being the case for the big switches. Still, a layout is needed to see things more clearly... :



And now, plug in the teensy :


Programming the Tennsy:

requisite :

  1. set up TeensyLoader : https://www.pjrc.com/teensy/loader.html
  2. set up "Arduino" soft and "Teensyduino" : https://www.pjrc.com/teensy/td_download.html
  3. set up X-plane plug-in : http://www.pjrc.com/teensy/td_flightsim.html

a first test:

First, let's make a program just to identify the connections of each switch. Indeed, when wiring I did not follow the exact order and now I'd better check what is connected with what. You'll also notice that sometimes I skipped some Pins Teensy in order to keep the specialized pins (PWM -> Pulse Wave Modulation, AC / DC, etc ...). These pins can be used later as a dimmer dashboard (exit PWD), joysticks potentiometers (AD converter) for the propeller pitch, richness carburettor, etc ...

So, before fantasizing, let's find our connections.
The program is available at the following address : https://github.com/Nicolou/cockpit/blob/master/testButtons/testButtons.ino. To upload program into Teensy, instructions are on the manufacturer website : https://www.pjrc.com/teensy/loader.html
AS mentioned in the prerequisites, do  not forget to install and set up Arduino programming software and the plugin to be able to use the Teensy  : https://www.pjrc.com/teensy/tutorial.html 



Here's what happens with me:




And  the deducted summary table :

Pin number
Button namearduino styleC style
BATTERY20B0
ALTERNATOR21B1
MAGENTO_STOP7D7
MAGENTO_LEFT8E0
MAGENTO_RIGHT9E1
MAGNETO_BOTH10C0
MAGNETO_START11C1
AVIONIC23B3
PUMP22B2
CARB HEAT19E7
NC15D5
NC24D4
LAND_LIGHT3D3
TAXY_LIGHT2D2
NAV_LIGHT1D1
STROB_LIGHT0D0
BEACON_LIGHT27B7
RADIO_SWITCH17C7
NAV_SWTICH14C4
RADIO_MHZ28,29PA0,PA1
RADIO_KHZ32,33PA4,PA5
NAV_MHZ30,31PA2,PA3
NAV_KHZ34,35PA6,PA7
LANDING_GEAR12C2



A second test, the rotary encoders :

For this, we will use the library "Encoder .h" as shown in the example of the site : https://www.pjrc.com/teensy/td_libs_Encoder.html
By adapting the exemplary program with our matching pin numbers we get the following code : https://github.com/Nicolou/cockpit/blob/master/testEncoders/TwoKnobs/TwoKnobs.ino

An upload of this program in the Teensy and ... The test proves successful.

Now, we can really start to have fun.


 Xplane program :

We  will use the specifications provided by dataref file for communication between the cockpit and the Teensy Xplane software.
Do not forget to install the X-Plane plug-in by decompressing it in the following folder ./Resources/plugins.


But first, some explanation of the elements used in the program will allow a better understanding of its operation.
  • To use the FlightSim specific library Xplaneit is necessary in the Arduino program editor to set up USB type. Hence, go to the menu tool '->' USB type 'and select' Flight sim controls'.
  • To identify the pine Teensy numbers, we will use constants to define these numbers for once and in one place in the program.
  • In addition to the library 'Encoder.h'; we will use the library 'bounce.h'. This library allows to manage the switches states (anti-rebound, change of state detection, etc) See   https://www.pjrc.com/teensy/td_libs_Bounce.html
  • Read the documentation https://www.pjrc.com/teensy/td_flightsim.html
  • A program Arduino '(or teensyalways consists of a setup ()  and loop() functions...
Now, after those few instructions, (and a few hours later ...)here is the program to open in arduino editor (teensy version) : https://github.com/Nicolou/cockpit/blob/master/xplaneDR400v1/xplaneDR400v1.ino

 Then compile and upload it in your Teensy.
That's it, the box is almost finished. I just need an USB socket and a push button (reset) that will allow me to close the set.

Just one last picture, (but not the most beautiful) to show you how I have fixed the cockpit on my desk.

Well, that is finished regarding the prototyping stage. Hopefully this article will be useful.

Nicolas Montarnal




Aucun commentaire:

Enregistrer un commentaire