Arduino Control Box: a Step by Step Guide – Part 7 – Closing the cirle

At this point, the Control Box should be finished, the last step is downloading the firmware and upload it to the board. I have covered the whole process in this post.

Now it’s testing time!
In order to test buttons and encoders, you can use the Windows Game Controllers (Start→”Set Up USB controllers”). It can check the status of up to 32 buttons, so it’s very, very limited.

A great alternative is Pointy’s Joystick Test. This simple yet very useful program allows you to test way more buttons. I have used it to test both my Auxiliary Panel and the Virpil MongoosT-50 Throttle.

Throubleshooting this Control Box is quite straightforward: software-wise there’s little to nothing to do; the harware continuity test should have been performed and passed already.

Now open DCS and start assigning you buttons. The Control Box will be seen by DCS as any other controller such as joysticks or pedals and identified by the name you have defined when you have changed the VID and PID.

SbS_7-dcs-controls
Assigning functions to the Control Boxes in DCS
Advertisements

Reviewing DCS-BIOS & TFT

Due to the changes to my setup, I had to rotate the TFT. I originally planned to rewrite the code from scratch since in the first implementation I have used different techniques but, at the end of the day, I decided to keep most of the code.

This is the original TFT for the Ka-50, based on DCS-BIOS:
tft

..aaand *drum rolls* this is the new one!

tft-new-dcs-bios
The new implementation of the TFT

I haven’t recorded a video yet, I will do it sooner or later.
I have added a few useful information that normally are not easy to read, such as the RPM limits for the left and right engine (impossible to read if head-down or zoomed in), the UGM8 selector (НР/АКС in Russian) to check the ballistic settings before firing a rocket / gunpod and a reminder of the Auto/Manual authority over the weapons.
A message will also remind me when it’s time to turn on the fuel tanks Cross Feed, plus a status light will confirm the switch position. The four circles represents the external pumps: when they turn off, the external tank is empty.
Finally, the VVI is now digital, with a big symbol indicating the current status: ↑, ↓, =.

October ’18 – Current Setup & Future plans

This is the current status of my setup, although it won’t last long 🙂

setup-201810-complete

The UFC/PRTz/PVI-800 is proving to be one of the best and most useful box I have built so far. I don’t fly the F/A-18 much so I don’t have a concrete idea of how much the UFC is used, but on the Ka-50 is great: the bottom encoder and buttons control the ABRIS, the numpad is great to input data such as target coordinates in the PVI-800 and, by simply toggling the Master Mode, I have control over the PRTz.

setup-201810-UFC

But my update is not finished yet! I have found a 7″ 800×600 LCD monitor that might fit well as Shkval or the F/A-18 moving map (MCPD?).
This is a diagram of the current setup (I always plan my changes in this 1:1 LibreOffice Draw-made diagram):

setup-201810-diagram-1

The first step will be the addition of two boxes, one for each MFD. The TFT will be also rotated horizontally and placed on top of the UFC.

setup-201810-diagram-2-new

Finally, I plan to attach the Saitek Throttle Quadrant to the bottom of the left box to increase the whole stability and, starting by one, adding the 7″ monitors. The Thrustmaster MFDs will be fixed by means of Velcro, so I can remove them in case of flying on the Ka-50.

setup-201810-diagram-3-final

I’m still not sure about the right LCD. It will be a later addition to the setup; I might place it vertically so it will be a decent ABRIS.

Arduino Pills – Setting up IDE and Libraries

Another quick pill about Arduino, this is about setting up the IDE and manage libraries.

Arduino IDE (Integrated Development Environment) is not as advanced as other solutions but it’s quite light and easy to use. It can be found here.

Once installed, you might want to change the default sketchbook location by opening FilePreferences.
Now download, save and open a source file, for instance the one we are using in the Step by Step guide (it can be found here on AM-STUDIO’s GitHub) then compile it. You will get a number of errors, let’s review them.

Libraries

Libraries are, simply put, a collection of methods and functions that tell the board how to perform certain tasks. The default package contains only a little fraction of the available libraries, not to mention the fact that you can write your own. The “Joystick” library, that our project requires, does not come by default so we have to install it in a specific location. That location is the “libraries” subfolder of the aforementioned default sketchbook location.

arduino-pills-2-libraries
“libraries” subfolder location

Let’s download the Joystick library from GitHub and install it.
Careful though to respect the order of the subfolders: the ZIP file comes with a folder called “ArduinoJoystickLibrary-master”; if you copy this folder in your libraries your project won’t compile. So:

  1. open the ZIP file;
  2. open the “ArduinoJoystickLibrary-master” folder;
  3. copy the “Joystick” folder;
  4. Paste it into your Arduino “libraries” folder.

A couple of friends had to install the “keypad” folder as well. This library can be installed in a different and faster way. Go to SketchInclude LibraryManage Libraries and look for “keypad”. Scroll until you find the library I have selected in the following screenshot and install it.

arduino-pills-2-keypad-library
Installation of the Keypad library

Lord of the boards

Last step is selecting the correct board and the relative port. Depending on which board you have bought, select either “Arduino Leonardo” or “Arduino/Genuino Micro” from the ToolsBoard: “xyz”. Then, in a similar way, select the correct port from the “Port” menu: ToolsPort: “xyz”.
Both entries report the last option selected.

Quick troubleshooting

Always try to isolate the issue. Since we are using a source code that definitely work you should fairly easily found the issue, at this stage is either a library problem or missing or a connectivy issue. The IDE suggests you where the problem is. The following, for instance, is caused by the selection of an incorrect Port.

arduino-pills-2-error
Arduino uploading error: wrong port selected

Arduino Control Box: a Step by Step Guide – Part 6 – Release the Solderer!

“Solderer” – Is that even English? Not sure.. I’ve just seen the release trailer for the Kraken in Star Citizen and I got carried away..


Anyway, part 5 ended with every component allocated and screwed in its location. Now it’s time to replicate the wiring diagram into reality.

SbS_6-soldering-control-column

Soldering the wires is not difficult at all, it’s just a matter of practice. Here are a couple advices that might help you:

  • Don’t overheat! don’t leave the soldering iron in contact with wires and components for too long. You can melt the plastics of both the components and the wires.
  • Leave the Arduino board for last. Especially if you are not used to solder, it might happen to drop drops of melted solder wire. If one of them falls on the board, it might cause severe damages to it.
  • Place the wires first. Most of the components have a small hole on their pins. You can usually place your wire there before soldering it.
  • Pre-solder wires and contacts of any component that haven’t the aforementioned hole. By doing that you will need to hold your wire with one hand, the soldering iron with the other and that’s it: the solder material is already in place.
    To pre-solder just place the iron and the solder in contact with the uncovered core of a wire. You will notice that it will be quickly covered by the solder; making your life much, much easier.
  • Clean your soldering iron every now and then. Solder and antioxidant might accumulate on the iron after a while (they usually form a black mass). Hold the soldering iron tight with your hand, make sure there’s nothing in the area underlying the iron and hit your table with your fist: the burnt material will drop from the soldering iron. Nice and easy.
  • Save your furniture! Melted solder and the iron itself are hot, easily more than 300+ deg C. Although the solder becomes cold in milliseconds, it can still damage your furniture. Place some cardboard or do your soldering on an appropriate surface. You will thank me when your wife won’t kill you for damaging her precious table 😉
  • If you have to connect a wire where another one is already soldered, add some solder and pre-solder the new wire. The new material will help spreading the heat.
  • Same as the previous point, if you do a mistake and can’t remove a soldered wire, add some solder: it may sound unintuitive but it helps spreading the heat uniformly.

That being said, this phase is quite straightforward as long as you follow a plan. I usually follow the same order I adopt when designing the wiring diagram; therefore I start from the wire that comes from the top pin of the board (although the board is always my last step) then proceed with every common connection such as GND. When the matrix is completed I then solder the encoders.

SbS_6-soldering-ufc

After completing the soldering of the circuit we can proceed and perform a quick test the continuity of GND, lines and buses by means of a multimeter. Do this check before connecting the board to the USB. The board is protected and we are working with low tensions but you know, better safe than sorry.
If the test doesn’t show any issue we can plug the board, load up Arduino IDE and write our firmware.

Arduino Control Box: a Step by Step Guide – Part 5 – Drilling time!

Part V of the guide, we’re almost there: the wiring diagram is ready, we have our buttons and encoders and we have our box. Before starting the assembling phase, let’s review some of the tools that might come handy.

Drill driver: I have an old DeWalt cordless drill driver, it holds drill bits max Ø10mm. It does the job.
Drill bits: I used to build model for WH40k years ago and I have a 1-5mm set. I have bought another cheap set, max Ø10mm. I recommend two sizes: a small one, to prepare a guide for wider holes (2-3mm will do, whatever you have in your garage). Most of the smaller buttons I have found have a diameter of 5-6mm so a second drill bit of that size will come handy.
Cone drill bits: I have bought a cheap set only recently and damn, they make your life so much easier. Since we will be working mostly with plastic, even quite cheap sets work like a charm.
Countersink drill bit: optional. Before buying the Cone bits I used this tool to make holes wide enough to host some particularly wide buttons. It comes handy when dealing with unusual diameters or to “clean” the hole instead of using sandpaper.
Caliper: the real man best friend 🙂 Simply a must have; you need one.
Thin permanent marker: you can decided to either mark the points to drill with a marker or cut them into the plastic. It’s up to you, I personally do both.
Multimeter: a must have for debugging the wiring. Unless you have done everything perfectly and I bow to you 🙂

Mirror mirror

IMPORTANT! We will drill on the internal part of the enclosure. Therefore, when planning and defining the position of the holes, remember that our wiring diagram is the specular image of what we actually need.
The easiest solution is to paste the image in GIMP and flip it.

Marking time

Get the wiring diagram on your PC and calculate the distances between the borders or the box and the centre of the buttons. I’ve found that drawing a reference matrix is actually easier. If you are using LibreOffice Draw, this operation will take just a few minutes and will be also very precise if you have draw your components and the box in 1:1 scale.

Now get the cover of the enclosure and the calipre. Measure the distances between the borders of the box, both vertically and horizontally and mark the points where your components will be placed with the marker. Proceed until every button of your UFC has is respective dot on the cover. For sake of clarity and to avoid confusion, you can write the expected diameter of every hole near every reference dot.

This is a detail of my Auxiliary Box. As you can see, the marks and cuts are clearly visible inside the enclosure cover (green arrows).

SbS_5-enclosure-cover-cuts
Reference marks and cuts inside the enclosure cover

Once every reference is marked, it’s time to start drilling. I usually start with a drill bit of very small diameter, then enlarge it depending on the final diameter required. This is a fairly quick operation, assuming every button is Ø12mm, you can start with the 2mm drill, check that the hole is exactly where you want it then use any other drill to make the hole wider enough to use the Cone drill bit. The Cone drill bit cuts throught the plastic very easily so pay attention and avoid making an excessively large hole.

When everything is done, get your buttons and encoders, place them in their slots and clamp screws and nuts and check the result.
SbS_5-bolts-and-nuts
Don’t put the encoders knobs in place, you risk unnecessary scratches.

Some buttons won’t be perfectly aligned but remember we are not using a CNC or any very precise tool. Small errors and imperfections might occur.

The manual part is almost over. Next step is soldering and then, finally, my favourite part: coding!

PS: it may sounds taken for granted but remeber to drill a hole for the USB cable 🙂

Arduino Control Box: a Step by Step Guide – Part 4 – Wiring Diagram II

I have decided to split the chapter about the Wiring Diagram to ease the reading of the guide.

Wiring Diagram

IMPORTANT NOTE: there’s an almost infinite amount of ways to wire a button matrix, mine is just one of them. I usually start from the top pin then proceed vertically. If you prefer any other order, go for it!
less important note: the order of the buttons might be a bit wonky, unless amended via code. I personally don’t care at all about it: we will assign controls in DCS by pressing a button, not by selecting it from a combo box or something like that.

SbS_4-diagram-wiring-full

Too messy? Let’s clean the diagram and analyse it step by step.
I usually separate the wires into vertical and horizontal. The fact that I start from the vertical wires is clearly reflected on the wiring diagram.


The task of the horizontal wires – I usually refer to them as buses; whereas I call the vertical as lines – is to link the vertical wires and intuitively you can understand why their path is much more complex. In other words, each bus has to “touch” every line, one per colour and only once, with just one noticeable exception.

A 3-way Conundrum

A 3-way switch has three pins. How come? If you google 3-way switch diagram (←sorry) you find plenty of explanations from the electrical point of view. From the button matrix PoV instead, a 3-way switch is a combination of two buttons. The common pin is normally the middle one and it should be wired to a bus, whereas the top and bottom pins should be wired to two different lines.
When the bus is wired to the middle pin it is de facto connecting two different lines in one go: the switch basically counts as two; that’s why the red, blue and yellow buses connect a total of four physical switches, whereas the grey and the green connect five buttons.

Still having issue? Take a look at this pic:
SbS_4-diagram-wiring-3-way
In this application, there is no difference between a single 3-way momentary switch and the two pushbuttons. This image also makes even more clear how a single bus manages to connect two lines.
We can, therefore, replace the 3×3-way switches with 6x pushbuttons:

SbS_4-diagram-wiring-3-way-swap
6x pushbuttons as 3×3-way momentary switches

Encoders: the Easy Part

Encoders are the easiest part. They come with 3 pins (as we have already seen, the two separated pins are the pushbutton): mid is the GND, the others two go in the order you prefer, straight to the the Arduino board.

SbS_4-diagram-wiring-encoders
Wiring Diagram – Encoders

Any GND pin can be used, so pick the one that makes your life easier 🙂

If everything is clear – drop a message here or ED’s forum otherwise – we can move on and start the dirty, manual part: drilling and soldering.