Board index FlightGear Support Interfacing

Building a Throttle Quadrant with Teensy

Connecting two computers, using generic protocol, connecting with Matlab?

Building a Throttle Quadrant with Teensy

Postby scarymovie » Mon Nov 30, 2020 9:14 am

Hi everyone,

I have been flying in FG with a Logitech Attack 3 joystick. It is really awkward to control everything on the same joystick and it is costly to get a separate throttle quadrant. Therefore I would like to build one (multi engines: 2 throttles and 2 mixtures without prop) with a Teensy 3.2 board (USB) which is supported on the Arduino IDE using Teensyduino and a couple of potentiometer. This has been tested working on X-Plane (not tested by me).

A couple of questions before I kick start the project:
1. Do Teensy boards work with Flightgear?
2. I believe that the DIY throttle quadrant will not work out of the box. Besides what have been described in Input Device, are there any additional steps to take?
3. I would prefer using rotary potentiometer over the slide ones, but will it the configuration be different?

Thank you.
scarymovie
 
Posts: 214
Joined: Wed Nov 21, 2007 3:34 pm
Location: Singapore

Re: Building a Throttle Quadrant with Teensy

Postby Isaak » Mon Nov 30, 2020 1:03 pm

I don't know the exact board, but if it is Arduino compatible, it should be trivial to connect it to FlightGear over serial. I've built an overhead panel with the Arduino Mega in the last month. It communicates over serial via USB. See this wiki for a guide.

Some hints from lessons I learned:
- don't update too frequently, as that brings FlightGear's framerate into single digits. 10 Hz is more than enough to get an instantaneous feeling. Use both the delay(); and the Serial.setTimeout(); functions. This reduces the fps hit FlightGear experiences. Experiment with different frequencies to get the best result.
- If you 're using Windows, FlightGear might have issues connecting to your serial port. Use this program to connect and disconnect (only a second is enough) to the serial port of your board if FlightGear hangs on 'finalizing position' during startup. This is most often the case after you 've used the Arduino IDE to upload some new code or to use the serial monitor.
- The config line to load your protocol file is case sensitive. I didn't get a connection to my Arduino board until I used \com4 instead of \COM4.

Rotary or slide potmeters don't matter. Just connect them in the correct way and they will provide the same result :)
Want to support medical research with your pc? Start Folding at Home and join team FlightGear!
Isaak
 
Posts: 768
Joined: Sat Jun 04, 2011 3:52 pm
Location: Hamme, Belgium
Pronouns: he, him
Callsign: OO-ISA
Version: next
OS: Windows 10

Re: Building a Throttle Quadrant with Teensy

Postby scarymovie » Mon Nov 30, 2020 3:20 pm

Hi Isaak, thank you for the tips. In that case, I'm going to get all the items and start working on it. Definitely will be posting questions along the way. Please stand by. :D
Last edited by Johan G on Mon Nov 30, 2020 3:58 pm, edited 1 time in total.
Reason: Please do not quote the entire preceding post.
scarymovie
 
Posts: 214
Joined: Wed Nov 21, 2007 3:34 pm
Location: Singapore

Re: Building a Throttle Quadrant with Teensy

Postby tom_nl » Mon Nov 30, 2020 5:09 pm

Sharing some of my experience. I built my own quadrant 3D printed from my own design, but using an arduino instead. I'll try to find and post the pictures if you're interested.

For the interfacing, there's two approaches you can follow:

1) use the generic protocol through serial, I've done this with the panel I built, and updating at 25Hz is no problem if you're clever with the code. I found that setting the serial rate to 38400 works best as it gives the arduino more time to do things between serial sends.
2) If the Teensy supports it, use the Nicohood USB HID library - the Teensy can then be programmed to appear as a joystick. In my experience it's easier to interface once you've got the code working as it appears as a USB game controller. If you do need a Pro Micro clones can be had for less than 3 Euro on Aliexpress if your'e prepared to wait.

My design worked fine, but In the end I bought a Saitek yoke and quadrant combo (mainly because I wanted a yoke - the quadrant was a bonus :-) ). The quadrant is certainly better than my own design (as you'd expect), but with hindsight and experience I could build something better than my first design now (as I proved to myself with my trim wheel design).

Tom

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Building a Throttle Quadrant with Teensy

Postby Andrew12345 » Mon Nov 30, 2020 5:44 pm

Hey! does the yoke automatically connect to FG?
Andrew12345
 
Posts: 5
Joined: Mon Nov 30, 2020 4:12 am

Re: Building a Throttle Quadrant with Teensy

Postby Andrew12345 » Mon Nov 30, 2020 6:06 pm

Also which arduino did you guys use? I used a Leanardo and potentiometers
Andrew12345
 
Posts: 5
Joined: Mon Nov 30, 2020 4:12 am

Re: Building a Throttle Quadrant with Teensy

Postby tom_nl » Mon Nov 30, 2020 6:33 pm

Andrew12345 wrote in Mon Nov 30, 2020 5:44 pm:Hey! does the yoke automatically connect to FG?


Yep, the yoke works out of the box and there's a default configuration in FG. I made my own configuration though tailored to the Cessna that remaps a load of the buttons (including using the right thumbwheel as a shift to expand the buttons), and one of the quadrant levers mapped to the flaps, posted here - viewtopic.php?f=24&t=12363&start=75#wrap

Andrew12345 wrote in Mon Nov 30, 2020 6:06 pm:Also which arduino did you guys use? I used a Leanardo and potentiometers


If you're using the nicohood HID library you'll need either a Leonardo or a Pro Mini - I've used a Pro Mini before successfully. For generic protocol via serial anything with a USB port should work (i've used an Uno, Pro Micro, and currently using a Mega 2560 because I need a lot of IO pins).

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Building a Throttle Quadrant with Teensy

Postby Andrew12345 » Wed Dec 02, 2020 9:14 pm

Thank you! Also do you guys have a code? i'm new to this.
Andrew12345
 
Posts: 5
Joined: Mon Nov 30, 2020 4:12 am

Re: Building a Throttle Quadrant with Teensy

Postby Isaak » Wed Dec 02, 2020 11:10 pm

I programmed my Arduino Mega 2560 for my Boeing 777 Overhead panel with this code:
- Arduino: OHpanel.ino
- FG protocol file: ArduinoOHPanel.xml (put in your fgdata/protocol folder)
- FG nasal file that loads on startup: Arduino.nas (put in your fgdata/nasal folder)

Then I start FlightGear with this line in the settings tab: --generic=serial,in,10,\com4,9600,ArduinoOHPanel

The panel is still very basic: I used cheap push buttons with a locking mechanism for the push buttons and put a green led next to them. The output of the push buttons is tied to both an Arduino input and the base of a transistor. That transistor is tied with the collector to one of the ledpwm outputs (see code) and to an LED with the emitter. This makes the corresponding LED of a button light up if the Led output commands so.

The brightness of the LED's depends on the state of the IND LTS switch: DIM gives a PWM of 50, BRT sets them high and TEST lets them blink.
If none of the electrical power switches is on (battery, APU Gen en Ext Pwr 1 and 2 implemented), then all the leds go dark. The OHpanel is still one way: none of the FlightGear systems communicate to it.

For the rotary switches, I used three way toggle switches (ON-OFF-ON) for now. They are way cheaper than rotary switches. Both ON positions are tied with a 6k-8k resistor and to an analog input on the Arduino. In that way I can read the three positions with one analog input on the Arduino instead of using 2 digital inputs. I've thought of reading the state of two switches with one analog input, which should be feasible with different resistors, but as I had enough inputs and the voltage was fluctuating too much with all the LED's, I decided to do it this way. When I find affordable rotary switches, I can simply replace the toggle switches.

Hope this helps you a bit. Let me know if you find a better way of doing stuff ;)

edit: here is an image of my OHpanel.
image (too big for the forums)

edit 2:
I made a (not so) short video to demonstrate the OHpanel. Take a look here.
Want to support medical research with your pc? Start Folding at Home and join team FlightGear!
Isaak
 
Posts: 768
Joined: Sat Jun 04, 2011 3:52 pm
Location: Hamme, Belgium
Pronouns: he, him
Callsign: OO-ISA
Version: next
OS: Windows 10

Re: Building a Throttle Quadrant with Teensy

Postby tom_nl » Thu Dec 03, 2020 12:10 pm

My panel is a bit more portable, so I can get it out when needed. Designed for general aviation aircraft (in particular the Cessna 172) - pictures in this thread https://forum.flightgear.org/viewtopic.php?f=24&t=38181

I've used a very similar approach to Isaak - an Arduino Mega is driving the LCD character displays and buttons and encoders and switches (you need a LOT of I/O pins!). Arduino has code to receive values for display from FG and send button states to FG - both using generic via serial (bidirectional communication on serial does work on a mac at least). Then there's some nasal on FG for handling frequency swapping for the COM and NAV radios. The LCD instrument display is driven by a Raspberry Pi zero W running FGpanel (terminal version, the X version is too much for it) connected as a USB ethernet gadget.

I used a switch matrix for the toggle switches (with diodes) so that multiple switches can be active at once. 9 switches only need 6 pins (3 rows and 3 columns), with the more switches you add the fewer pins you need relatively - e.g. 100 switches will only need 20 pins (10 rows x 10 columns), and if you use shift registers too you need even fewer. I'm planning adding more button (for an autopilot panel) so will move these to a separate switch matrix rather than individual pins at present. Have ideas now about adding LED indicators - again probably as an LED matrix or through shift registers to save pins.

I'll see if I can get the code uploaded somewhere.

Tom
tom_nl
 
Posts: 84
Joined: Tue Aug 04, 2020 11:41 am
Location: Netherlands
OS: OS X Big Sur

Re: Building a Throttle Quadrant with Teensy

Postby Isaak » Thu Dec 03, 2020 1:33 pm

@Tom: that switch matrix is genius! I've only just started using Arduino and didn't read about that yet. This brief article explains it very well. I 'll definitely make use of it in the future!
Want to support medical research with your pc? Start Folding at Home and join team FlightGear!
Isaak
 
Posts: 768
Joined: Sat Jun 04, 2011 3:52 pm
Location: Hamme, Belgium
Pronouns: he, him
Callsign: OO-ISA
Version: next
OS: Windows 10

Re: Building a Throttle Quadrant with Teensy

Postby Johan G » Thu Dec 03, 2020 3:18 pm

Isaak wrote in Wed Dec 02, 2020 11:10 pm:I made a (not so) short video to demonstrate the OHpanel. Take a look here.

Nice. :)
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6634
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 5 guests