Button Box Experience
-
@Vandal I’m going the same route with keyboard emulation and sending keystrokes that are mapped to my BMS Keyfile. I’ve worked though some quirks and will share my experience if you’re interested.
One of the first things I found I had to do was map individual on/off states instead of toggles. i.e. Add mappings to my key file for SimParkingBrakeOn (Ctrl/Alt/P) and SimParkingBrakeOff (Shift/Ctrl/Alt/P) and program the pin low/high accordingly. I just couldn’t see a sensible way to use the default keymap of SimParkingBrakeToggle.Some programming experience is a definite plus…be sure to brush up on handling arrays…you’ll need it!
Hopefully I’ll get the switches mounted in my project box and wired up this weekend.
Enjoy!
-GrowlerOh yeah I forgot about toggles not being ideal and having to add to the default keymap. Yes, I agree, avoid toggles like the plague and so I have assigned quite a few keybinds to the default BMS map. So I guess I’ll have to share the keymap file t0o. But I don’t change any of the default keys I’ve just been adding to it. So, as you elude, if you push a button or flip a switch and the thing already is on, you don’t accidentally turn it off. The parking brake and speed brake is a perfect example of that issue. Please share the things you worked through here or write a blog post and link to it here, etc. if you would be so kind!
-
Here’s some of the high-level issues I worked through:
- I use the keyboard method to send the key combos. This is a link to the Teensy documentation, but I believe it’ll work with any Arduino: https://www.pjrc.com/teensy/td_keyboard.html
- To Bounce or Not to Bounce - There’s a couple of Arduino libraries for handling noisy buttons/switches: bounce.h (legacy) and bounce2.h (newer). This seemed like the way to go, but for the life of me I could not figure out how to get the debounce objects into an array. I gave up and based my code on this video:
I’ve modified it a bit to suite my needs, but this is what I started with and it works. Let me know if you have any luck using the bounce libraries. I plan to revisit this in button box version 2.0. - Beware Double-Duty Key Combos - I found that some key combos gave unexpected results, [ctrl/alt/F8] must be used on my pc somewhere. I had to map a different combo.
It’s a fun project and I’m interested in how yours progresses. I can share my Arduino code if you are interested.
-
The custom made pcb has a small navigation switch that acts as the DCS switch, it can be replaced by a real one if you ever get one.
http://i1258.photobucket.com/albums/ii535/Redneck87th/20150616_174437_zpsd6hozvor.jpg
Nice work, I would give my left testicle for a good ICP. Cant sell a kidney as their both shot. :drink:
-
@Vandal - I got my button box built and tested today. Lots of wires and solder! I put the functions on it that I thought I used the most in the pit. I flew a couple of missions and it worked a charm.
Mounted it on a thriftstore tripod.
-
@Growler4135: Wow thanks for sharing that, I really like the faceplate. Is that printed out on paper and maybe some sort of flat matte plastic laminate over the top? BTW, I did get my toggle switches and Leonardo in on Friday so I’ll be working on it for sure tomorrow. This is going to be great “frunstration” (fun + frustration)!
-
Hey Vandal - It was an interesting project and I’m pretty happy with how it turned out. It’s interesting how easy the switches are to find when I’m in the pit. After a few minutes I don’t even have to look for them. Going Cat I is much easier, as well as setting AP modes.
I used a graphic of the panels from this site: http://xflight.de/pg_org_doc.htm. I used Windows Snipping Tool to grab the panels I was working with. Then I used Gimp (Photoshop wannabe) to lay everything out based on the dimensions of my project box. I did rearrange the Misc panel.
I printed it on matte photo paper and hot laminated it. It seems pretty durable. I used some spray photo adhesive to stick it to the top of box. That made a nifty template for drilling the holes.Here’s some pics from my build:
https://goo.gl/photos/t53QUnzXtU3QBQ4F9I’m interested in seeing how you get along with the Leonardo board.
On thing I learned with setting the device type…I’d set mine to Keyboard/Mouse/Joystick in the Arduino IDE. The Joystick part confused BMS and I lost all of my HOTAS mappings. I set it to just Keyboard and that works just fine. I’m not using any joystick functions in this project anyway.
Have fun!
-
Yeah that’s a pretty cool faceplate and a cost effective solution as well. I am going to borrow that idea for sure. I can use Inkscape to make it a vector graphic (which is easier for me to work with although I can muddle in GIMP). I am pretty excited about what you did because I really was at a loss on what to do for a faceplate, but this will be great for me! I am going to first play with a temporary mounted switch, button, and encoder to see what it takes to get it working. I’ll post my progress, or lack of it, here of course.
Thanks for all the tips!
-
Oh and was thinking about joystick mode confusing BMS. As I understand it there’s three files that Falcon tries to automatically “fix for use” if your controller devices change up (including connecting a new device or forgetting to load a virtual device driver i.e. TARGET for Thrustmaster before starting Falcon).
devicesorting.txt,
axismapping.dat, and
[yourkeyfile].keyAll in your \user\config folder IIRC. So what I have done, after I got them all set up how I want is to set those to readonly. So far, again as I understand it, this has kept Falcon from automatically remapping stuff to make the current configuration work. Anyway, that’s what I think is going on. So maybe it’s not Falcon getting confused but Falcon confusing the user by changing things without your knowledge and confusing us LOL.
-
So today I finally got started and the first problem I ran into was the Arduino IDE. The installation instructions for Linux didn’t work for Linux Mint 18 (at least for me). So I go onto Arduino’s site and can’t find anything and then I just copy and paste the first paragraph of the error into ixquick.eu and find a github thread on it. So in the install.sh file all I had to do was change the resource name to RESOURCE_NAME=arduino-arduinoide. I think it was cc.arduino.arduinoide before. Then it installed perfectly and the IDE seems to be working just fine.
So the next thing I do is go to YT to look up how to connect a switch and it generally looks like people are using resistors. My knowledge of electricity is not much more than if you grab wires, sometimes you get dead real quick. Well I can remember a little bit more than that, but not a whole bunch. Anyway, the idea of needing a resistor to connect up a toggle switch doesn’t make any sense to me. Then I learn that about floating pins and EM noise causing problems and pull up resistors that can help eliminate this problem but that with Arduino you can change INPUT to INPUT_PULLUP and the board will act as your pullup resistor. Then there’s another guy that says this is all fine unless you accidentally set the pin to be an OUTPUT HIGH and then you can “blow up” (I think he means actually damage your board) so to guard against that you can add a second resistor.
Well, HOLY BATSISTORS BATMAN, this has got me scratching my head a bit. I think it’s okay not to use resistors for a switch if you are very careful not to do OUTPUT HIGH through that pin. I think for example, you just hook up the switch to say Pin 2 on one side and ground on the other, and then if you define Pin 2 as INPUT_PULLUP it will work just fine so long as you remember that you are reading HIGH when the switch is OPEN and it’s LOW when the switch is CLOSED. You can do this for your own project but if you sent this board out and someone changed the programming for the switch they could blow things up if they set Pin 2 OUTPUT to HIGH. Anyway, I wanted to post this here, do some more research, and sleep on it before going ahead and doing anything. FWIW if I do blow up the board it’s only $20 or so, but I only bought the one board and if I do burn something up I’ll have to wait until I get a new one in. I am definitely going to place an order for a second board this week because this is pretty darn nervewracking since I haven’t really absorbed Ohms law just yet.
-
Yeah, there’s a big learning curve! Here’s a link that explains the PULLUP pretty well, http://www.ladyada.net/learn/arduino/lesson5.html.
I haven’t used any resistors in my build, but like you said, for myself that works fine. I’d want to square it up if I was building it for someone else though.I wound up not using any debouncing in my code. I haven’t had any issues after using it for a week. Are you looking at using any debouncing?
Thanks for the ref to Inkscape. I had never heard of it before. I’ll use in on my BMS Button Box 2.0! -
I have hit a hitch and trying to get support from Arduino on it. I can’t even upload an example program even though the port seems to be working fine. I may have a bad board. But I don’t even know yet what debouncing is, I’ve seen it as a topic so I guess I’ll look into it and get back to you on that! But yeah looking at the examples I can follow them pretty use and the Arduino site has a code reference so once I understand the board a bit more, and understand this electricity and resistors and such I am expecting pretty smooth sailing. I saw one tutorial on putting a bunch of buttons on 1 pin using a resistor ladder. That’s going to be great I am thinking one Leonardo or micro then could run an entire pit (or darn close)!
-
Alrighty I have overcome the uploading the program problem (sort of). I was having trouble on Linux and not getting any support from Arduino and so today I broke down and transferred my little test program to my Windows 10 game machine and I was able to upload it.
I now have a toggle switch that sends “HELLO WORLD I AM A TOGGLE SWITCH” when you throw it up. All I have to do is tinker with the code a bit to send the keyboard command/callback for raise gear then lower gear when the switch is thrown the other way and start mounting switches! Heh heh so cool. There’s only so many pins on this Leonardo board so I am going to try to figure out the resistor ladders, I saw an example where a guy got four momentary switches per pin.
[Corrections] If that trick works for toggle switches I can get four switches per [analog] pin at least! This board has [6 analog] pins so unless it creates some sort of voltage/amp issue using a resistor ladder that’s 24 (4x6) callbacks right there. There’s also [14 digital pins and each pin can do one, two, or several callbacks depending on how you set it up (i.e. toggle switch 1 can do gear up and gear down if you want). So lots and lots of fun ahead!
Oh man this is soooo cool!
-
I hope it’s okay to use a forum to keep updating my progress.
So today I finally jumped in and really took the time to figure out how to program the Leonardo to do what I want. I now have my take off/landing switches all hooked up, soldered, and working.
1. Gear Up/Down;
2. Flaps Null/Full;
3. Hook Up/Down;
4. Canopy Closed/Open; and
5. Parking Brake Off/On.It all is working just great!
Also, I made labels for the switches and mounted it all on a sandwich sized tupperware container LOL.
So I am really happy with the functionality and have proven to myself that I can get this stuff to work, but I used really cheap switches and mount for it because – like I say – I needed to prove I wasn’t just wasting money. Now that I know how to do it, I am going to pick up some better switches and mounting solution. Plus, I am going to add for sure Master Arm, Laser Arm, Radar On/Silent/Off, and some other stuff I am sure. I should have pictures as soon as the good switches and buttons get from Amazon to here.
-
Based on @Growler’s faceplate I wanted to describe my upcoming under the desktop mount and faceplate solution.
So I wanted to find an inexpensive tray that I could mount underneath my desk like a drawer (since my computer desk doesn’t have a drawer under the monitor it has a slide out tray for the keyboard and mouse). The typical button box is done with a project box (similar to my rectangular 4" x 6" x 2"ish tupperware container). Typically, the buttons and switches are mounted on the lid (which I did on my prototype as well). The problem is that the container isn’t really going to fit the area between the bottom of my desk and keyboard platform.
So, I thought I should mount the switches on the 2"ish side (which I will do later tonight or tomorrow), but I also looked for trays on Amazon and found inexpensive faux leather and ABS plastic jewelry trays. From the pictures the material of some of these looks like painted metal (black). So, I am going to order a couple of different ones.
That leaves me with working out an inexpensive faceplate. What I am thinking I will do is do a printout of a faceplate similar to what Growler did above onto a 8-1/2" label, trim it up, and wrap it around some tin flashing I have out in the shed. I’ll wrap that in a self-adhesive plastic laminate sheet (matte finish). Then I will take four or more black machine screws and mount the plate to the jewelry tray. I’ll mount and wire up the switches and the buttons and then mount the whole thing underneath my desktop surface. It will hang down 1" or 2". I will put a couple of spacers at each end of the tray and drill holes through those so I can take four 2-1/4" wood screws and just snug it right into place.
Anyway that’s the plan, I’ll post the pictures when it’s finished.
-
@Vandal - It sounds like your project is coming along nicely! Using a jewelry tray is brilliant, really thinking outside the box (yeah, I did that). I over-sized the box I use, but It does leave room for expansion. I may put some white-board tape on it so I can jot down fight notes - C/S, UHF, VHF, Tacan, etc.
The RF switch is a good idea too. I’ve put that on my list of improvements.
After using my switches for a week or so, the ones I’ve found the most useful are for the auto pilot. (Especially useful when using Delilahs and LGBs.) I used a couple of ON-OFF-ON swtiches for those. Also having Master Arm and Ext Lighting Master is handy for fencing in and out.
I’ve been working with Inkscape, I’m glad there’s lots of Youtubes out there, it just takes practice to become proficient. It’ll give a much cleaner look over a resized jpg image.
Keep the updates coming!
-
Oh heck yeah to, Autopilot, Master Lights, and I think Jammer On/Off as well! LOL – I probably won’t be able to stop until I have all the callbacks mapped.
And I didn’t have any issues with BMS getting confused. Again I think bc I have devicesorting.txt, [mykeymap].key, and axismapping.dat set to read only. Since I haven’t started using pots, axismapping probably wouldn’t have got confused at this point, but I do plan on putting in knobs for HSI CRS, HSI HDG, and also the pressure setting knob.
I’ve been thinking about the the ICP and how to do that without running out of pins. I think I’ll try to put these switches onto a resistor ladder or two. That should free up a all the digital pins. Then I think I can treat pins 2 through 14 as a matrix as needed (I hope).
So pin 2 and pin 3 both to HIGH might be “0”; 2 and 4 both to HIGH might be “1”; 2 and 5 both to HIGH might be “3”; etc. So, instead 12 buttons there I would get up to 144 I think. I am not sure if that will work and the wiring will get complicated. But I think it’s doable. Hopefully, if that’s wrong someone will let me know.
-
So I started prototyping an ICP with some cheap components and proved the concept of using an analog pin to read multiple buttons. I pretty much followed this example but instead of using a keypad membrane I used a flat piece of plastic and mounted seven rows and three columns of those cheap 12mm momentary buttons. Short story, IT WORKS. Long story, I have no idea how. LOL.
On the positive side I first have a 4.7k ohm resistor and I really don’t understand its function. Then my positive splits. One wire on its way to an analog pin on the Leonardo and the other to the positive side of the button switches. I used 220ohm resistors to connect the negative side of the button switches (the buttons are so close I had to trim the resistor leads) which also is heading towards the analog pin and also the ground pin. I just keep looking at this doohickey and can’t figure out why the positive splits to the buttons and to the analog pin and the negative side splits to the analog pin and to ground? I definitely need to learn more about circuits.
But the result is quite amazing. Reading the ONE analog pin I will get numbers between 0 - 1023 depending upon which button is being pressed. Well actually I get 1023 when no button is being pressed and the seven buttons wired so far give me 0 to 200 something. So all I have to do now is say, for example, IF analogpin reads approximately 44, send Numpad 1 to the computer. IF approximately 70 send Numpad 2. That sort of thing.
So now that I have tested it and know it works I am in the process of planning on making an ICP with Cherry MX switches. I’ve come to the conclusion that I’ll need a plate for mounting the switches and a specialized housing for the whole thing. So I am going to take the plunge and get a small milling machine. The plan is to mill out the circuits on PCB but I’ll also be able to mill out a plate for the switches to fit nice and snug.
Also I am thinking about mounting some female plugs on to PCB. I am leaning towards either RJ45 ethernet plugs and-or HDMI plugs running on the outside (think of a ethernet switch with a row of plugs) and on the inside I’ll break it out the plug so you can run any wire from the plug to any pin on the micro-controller. That way I can make a gear panel, a comm panel, and-or a lighting panel, and just run an HDMI cable from that panel to the micro-controller box. Using readily available cables like this should make it easy to move, adjust, readjust, setup, takedown, etc.
So, as predicted early on by some folks, I am right now spending more time on tinkering with these cockpit controls than I am flying. Why didn’t someone STOP me! LOL