A little pandemic project to build a DHC-2 Beaver cockpit in the basement.
This repo contains the software used for the integration, with miscellaneous other notes.
The panel instruments are displayed with [g3py]hhttps://github.com/patricksurry/g3py) running on a Raspberry Pi 4. The Pi also monitors various physical inputs via an Arduino Mega connected by USB.
The Arduino Mega runs the sketch in controlpanel/controlpanel.ino
and manages a switch panel with up to 32 digital pins,
along with a collection of (push-button) rotary encoders on the instrument panel.
The encoders are managed by a GPIO breakout board like this one
MCP23017.
Each encoder requires three pins so a 16-pin breakout
hosts up to five encoders, and can be daisy chained (up to 8 boards I believe).
The Arduino tracks encoder changes via interrupt,
and provides accumulated change along with current switch state on demand via the serial protocol.
The logical mapping of switches from the Arduino pins is configured in switchmap.py
,
and serialmonitor.py
runs a very simple polling routine which checks for state changes
on a regular basis.
-
Use the Raspberry Pi Imager to install Debian 11 (bullseye) 64 bit version
-
Check for any recent updates via:
sudo apt update sudo apt upgrade
-
Install conda miniforge from https://github.com/conda-forge/miniforge
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh bash Miniforge3-Linux-aarch64.sh
-
Clone the repo:
git clone https://github.com/patricksurry/dhc2-beaver-sim.git cd dhc2-beaver-sim conda env update -f environment.yml conda activate beaver-sim
TODO: this will also forward the input actions to FS2020 via python-simconnect.
Tool to disable mouse pointer unless moving
sudo apt-get install unclutter
Wait for the network before launching startup script:
sudo raspi-config # System -> Network -> Wait for network at boot
Create /etc/xdg/lxsession/LXDE-pi/autostart
(or ~/.config/lxsession/LXDE-pi/autostart
;
see https://forums.raspberrypi.com/viewtopic.php?t=294014)
to start the browser and
arduino monitoring at startup, it should contain just:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@bash /home/pi/dhc2-beaver-sim/startup.sh
On restart, logs will be found in:
~/.cache/lxsession/LXDE-pi/run.log
Some tweaking might be necessary for the browser settings, for example
improved framerate;
enable hardware acceleration;
notes on kiosk setup.
The current settings can be found in the startup.sh
script.
It's also fiddly to get the browser to display on two screens,
e.g. the display is always set to 0, wwith the indow position giving the
offset from one screen to the second.
setup rpi screens resolution and orientation (via gui display configuration or cli):
in my case I want orientation > left
click top-left > preferences > screen configuration
or via sudo raspi-config # advanced options > resolution > ...
$ tvservice -l
2 attached device(s), display ID's are :
Display Number 2, type HDMI 0
Display Number 7, type HDMI 1
$ tvservice -s -v 2
state 0x6 [DVI CUSTOM RGB full 4:3], 1024x768 @ 75.00Hz, progressive
$ tvservice -m DMT -v 2
Group DMT has 6 modes:
mode 4: 640x480 @ 60Hz 4:3, clock:25MHz progressive
mode 6: 640x480 @ 75Hz 4:3, clock:31MHz progressive
mode 9: 800x600 @ 60Hz 4:3, clock:40MHz progressive
mode 11: 800x600 @ 75Hz 4:3, clock:49MHz progressive
(prefer) mode 16: 1024x768 @ 60Hz 4:3, clock:65MHz progressive
mode 18: 1024x768 @ 75Hz 4:3, clock:78MHz progressive
$ tvservice -s -v 7
state 0xa [HDMI CUSTOM RGB full 4:3], 1024x768 @ 75.00Hz, progressive
$ tvservice -m DMT -v 7
Group DMT has 11 modes:
mode 4: 640x480 @ 60Hz 4:3, clock:25MHz progressive
mode 5: 640x480 @ 72Hz 4:3, clock:31MHz progressive
mode 6: 640x480 @ 75Hz 4:3, clock:31MHz progressive
mode 8: 800x600 @ 56Hz 4:3, clock:36MHz progressive
mode 9: 800x600 @ 60Hz 4:3, clock:40MHz progressive
mode 10: 800x600 @ 72Hz 4:3, clock:50MHz progressive
mode 11: 800x600 @ 75Hz 4:3, clock:49MHz progressive
mode 16: 1024x768 @ 60Hz 4:3, clock:65MHz progressive
mode 17: 1024x768 @ 70Hz 4:3, clock:75MHz progressive
mode 18: 1024x768 @ 75Hz 4:3, clock:78MHz progressive
mode 85: 1280x720 @ 60Hz 16:9, clock:74MHz progressive
Finding specific LCD panels.
Viewable area, outline area often constrained
Find common sizes (diagonal) via something like https://www.panelook.com/modelsearch.php?op=size
Figure out a size and aspect ratio that suits your needs (e.g. https://en.wikipedia.org/wiki/Display_size)
Either find a used monitor with the right size to disassemble, or get a bare LCD panel on ebay, along with a matching controller board.
19" monitor for main instrument panel - LG Flatron E1911TX, jumped power switch with a secondary push button
center panel: LP156WH4-TLP2 + controller https://www.ebay.ca/itm/163835481523
-
MobiFlight + Arduino + Your Favorite Flight Simulator = Your Home Cockpit!
-
DHC-2 Beaver - xplane model
-
DHC-2 Beaver- FSX, Prepar3D
-
Cessna 172 Flight Simulator Panel - thingiverse parts
-
Cessna 172 Cockpit - servo-driven wet compass etc
-
McMaster-Carr steel bolt-together framing Accueil - MxLab Designs - Impression 3D Printing à La Prairie
-
Street and Racing Seats or junkyard 2 x compact/subcompact two manual adjust front bucket seats on slider tracks https://centredelautovince.wixsite.com/vincentauto
-
GitHub - clearwater/SwitecX25: Arduino library for Switec X25.168 and friends plus “Speedometer Gauge Needles”
-
or hack say a voltmeter gauge? Equus 6268 Voltmeter, Voltmeter - Amazon Canada GitHub - adafruit/Adafruit-MCP23017-Arduino-Library GitHub - maxgerhardt/rotary-encoder-over-mcp23017: Library and example code with which one can controll multiple rotary encoders over the MCP23017 I2C GPIO expander.