Dudester22 Posted May 30, 2014 Posted May 30, 2014 (edited) I just got the Bodnar BBI-32 board and some On Off switches to make some toggle switches for the A10C. However, I have ran straight into a problem with this. I placed one wire in B17 and one in GND on the board to test it and then went to set the Battery power switch in the controls of DCS A10C. The problem \\I found is that the Battery only has one function in the control section in the A10C menu which is called Battery power. There is no Battery power ON & Off option so all my switch does is switch On but not Off. I have to switch it to the ON position two times for it to switch Off in the Sim. Can someone tell me if there is a way around this or has this been a waste of money. Thanks! Update: Another problem I found is when a switch does have an On Off function, (like the APU start) it's only the On switch that works in the Sims cockpit. When I turn my switch to Off, it just remains On in the Sims cockpit. I already own the TM hotas, but I wanted this board to set switches for things like Battery power & lights ..ect. Any ideas anyone? Edited May 30, 2014 by Dudester22
Dudester22 Posted May 30, 2014 Author Posted May 30, 2014 (edited) I read this guide (link below) but am a bit confused as to what to put in the LUA file for an A10C. I am trying to get an On Off toggle switch to work with the Battery power switch, but I'm not sure what to write in the LUA to make this work. Can you just copy and paste me a line to put in the LUA file to get this to work? Then I would be able to work out my other switches from there. Thanks! http://forums.eagle.ru/showthread.php?t=89226 Edited May 30, 2014 by Dudester22
Warhog Posted May 30, 2014 Posted May 30, 2014 That's an easy fix but you can't use the same toggle switch. I assume you are using on-off toggles with two connections. In these situations you use an on-on switch. It still switches to two positions, up and down, but has three connections. The middle is the ground. The other two are joined together and go to one input on the board. When you switch up it toggles, let's say B3 and when you switch down it toggles B3 again. So now your APU is turning on when switched up and off when switched down as it should. You will find that you need several different types of toggle switches to make all the A10 panels. Have you been through Tigersharks thread on Building flight panel controller? http://forums.eagle.ru/showthread.php?t=65998 It is an absolute MUST read before you go farther. It deals with all of the issues you will come across. Read all of it and watch all the videos. It will prepare you for what could be a very frustrating time if you don't. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
Devon Custard Posted May 30, 2014 Posted May 30, 2014 Actually you can do it with the same toggle switch. You just need to manage a static variable that you update when the toggle state changes. When the state changes then you do the performClickableAction. In lua youre effectively using a global variable to do this. Going the On On route requires you to use two of the Bodnar switch terminals instead of one. Youre going to halve your boards capacity for the sake of taking the slightly easier route. Personally i prefer to do the control/switch logic at the microcontroller as it keeps it modular. The more complex you make the lua the slower it takes to process it and the more likely you are to break it. Hopwever it took several iterations to arrive at that point - which is why i have 2 Bodnar boards myself sitting there doing nothing :) Enjoy the ride. In the end, do whats right for you, if i were in your position id get it working one way and then the other. In arduino i do this void GetSwitches() { static int state_tswitch=0; int v=digitalRead(tswitch); if (v!=state_tswitch) { state_tswitch=v; SendCommand("UFC Master Caution Button",String(state_tswitch)); } } The SendCommand only executes when the switch state changes. Also when you start using double throw switches (3 positions) youre going to hit the same issue and it gets harder to source switches cheaply that will do what your want. Oh and btw this is exactly the same for momentary switches whether they are the tactile push kind or the toggle kind.
Warhog Posted May 30, 2014 Posted May 30, 2014 Sorry DC but that just flew right over my head. :cry: Unfortunately, my ability to understand some of the programming aspects of electronics is severely lacking. To that end I try and keep it simple from my perspective and as much as what you described is probably a much better solution, it is black magic to me.:dunno: However I am really good at following instructions so once the Wiki explains how to do it, I will be able to cut and paste things into whatever and everything will work perfectly.:D DC...is there anywhere you know of that has a simple "how to" for setting up an Arduino mega to use with DCS. By simple, I use the BBI-32 board as an example. That was easy to understand and implement. Soon as I need to start downloading multiple sketches and make them all work together, I'm out of my league. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
Dudester22 Posted May 30, 2014 Author Posted May 30, 2014 @Warhog- So I can just use one like B3 for 2 connections and the GND for ground? I don't have to use two like B2 & B3? Thanks!
Devon Custard Posted May 30, 2014 Posted May 30, 2014 Sorry DC but that just flew right over my head. :cry: Unfortunately, my ability to understand some of the programming aspects of electronics is severely lacking. To that end I try and keep it simple from my perspective and as much as what you described is probably a much better solution, it is black magic to me.:dunno: However I am really good at following instructions so once the Wiki explains how to do it, I will be able to cut and paste things into whatever and everything will work perfectly.:D DC...is there anywhere you know of that has a simple "how to" for setting up an Arduino mega to use with DCS. By simple, I use the BBI-32 board as an example. That was easy to understand and implement. Soon as I need to start downloading multiple sketches and make them all work together, I'm out of my league. No worries hog, we all start somewhere. I feel just like this when im reading my engraving thread, im so far out of my depth there i feel like im drowning in a puddle. Re your question theres no simple guide because its all about what you want to do achieve. Send me a pm with what you want to do and i can walk you thru the tutorial and show you how to do it. Im a more teach a man to fish person than give a man a fish. if you catch my drift....
Devon Custard Posted May 30, 2014 Posted May 30, 2014 Regarding what i was saying about state. State is common concept in programming. Its a way to persist information about something between function iterations. Its incredibly difficult to describe without resorting to programming terms but ill try. Every time you call a function in code, any variables normally defined within that function are reset to default values. To maintain state or "remember" what that value was the last time you called the function you need to define a static variable (doesnt get reset) or use a variable that is defined outside the function (commonly called a public or global variable) So in this case we would define a global variable called HOG(because LUA doesnt support static vairables). We start with saying that HOG is equal to null. We have a switch called X. We define a function called ReadSwitch that reads the switch state of X and compares it to HOG. The first time this runs it HAS to be different because we set HOG to null and the switch can only return 1 or 0 or ON or OFF. If the switch state was different we call another function called ClickSwitch. ClickSwitch performs the steps necessary to send the data to DCS i.e. performClickable...... Finally ReadSwitch updates the value of HOG to the new switchstate. Because youre reading the voltage differential you are only dealing with On and Off which in Arduino is 1 and 0. The next time you call ReadSwitch it checks the state of the switch against the value stored in HOG. If it didnot change then nothing happens. Arduino constantly runs in a loop so it will call ReadSwitch ad infinitum or until you pull the power. lather rinse repeat. The important thing to consider here is how fast the arduino is going to do this, for a switch that is constantly on you are going to read that switch potentially millions of times before it changes again. Therefore you really only want to do something when it changes state. Once you grasp that simple logic (take the time to think it through you'll get there) you can then start to extend it to perfom more complex steps. Ive started to write about this on the wiki http://deadfrogstudios.com/warthogpit/index.php?title=Category:Importing_Data its by no means complete and is a temporary page but its a start. PM if you want to exchange email about this. More than happy to talk about your specific setup if you want to.
Devon Custard Posted May 30, 2014 Posted May 30, 2014 @Warhog- So I can just use one like B3 for 2 connections and the GND for ground? I don't have to use two like B2 & B3? Thanks! Nope you can only wire one terminal to a single connection on the Bodnar boards. You basically connect B2 to GRD via a switch. Some smart alec might try to confuse this by talking about a matrix and yes you can go that route but i would strongly advise you to solve the coding first because you HAVE to do that for DCS no matter what route you take. Plus going the matrix route also involves a much more intricate coding issue. Its also worth pointing out that DCS only uses state for certain actions, which is why you really need to understand this.
Warhog Posted May 30, 2014 Posted May 30, 2014 Thank you for the offer DC. I will definitely take you up on it as I start to learn more about it. BTW, that was a good explanation. I actually understood what you where talking about. You know what will happen when I learn how to more of this stuff... it scares me.:lol: With respect to the toggle switch though, if you have a common ground on it and two additional contacts ,both attached to B3 on the card, only one of those 2 contacts can be shorted at a time. So if you flip the switch to one side it shorts to, B3. When you flip it the other way it would again short to B3. It is in effect toggling the APU on and off as he wanted. Each flip of the switch sends a pulse as B3 to DCS. That is of course assuming you use an On-On toggle switch. I do believe that's how I wired mine up as you can't assign 2 different buttons (say B3 and B4) to one command on the options page so you have to resort to resending the same button press to toggle it on or off. Thanks again for the offer. I'll be in touch. I look forward to reading your tutorial on the coding for Arduino on the Wiki. I sure am pleased that the Wiki got started. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
Devon Custard Posted May 30, 2014 Posted May 30, 2014 Never said your way was wrong.... .:) Youre right. My way (and to my way of thinking )is more efficient in its use of connections on the bodnar board. They arent cheaper than writing code :) As i said, you do whats feels right, as i frequently point out, most people will go thru several iterations of code and board design as they learn more about how these things work. The fun is in the learning. Hopefully by reading this you'll have a lightbulb moment at some point in the future and say to yourself "ah now i know what that arrogant idiot was talking about!!!!" :doh:, I know ive had several, and one only just last week :music_whistling:
Warhog Posted May 30, 2014 Posted May 30, 2014 Never said your way was wrong.... .:) Youre right. My way (and to my way of thinking )is more efficient in its use of connections on the bodnar board. They arent cheaper than writing code :) As i said, you do whats feels right, as i frequently point out, most people will go thru several iterations of code and board design as they learn more about how these things work. The fun is in the learning. Hopefully by reading this you'll have a lightbulb moment at some point in the future and say to yourself "ah now i know what that arrogant idiot was talking about!!!!" :doh:, I know ive had several, and one only just last week :music_whistling: To be more accurate I would replace "arrogant and idiot" with intelligent and helpful. And I too have had several of those moments as I travel this road. I would just like to have one with the Arduino board sooner than later. All it really requires is someone to explain some of the basics in a way that it can be easily understood. Your short dissertation was a really good start. When you started by using terms such as "function iterations",:dunno:I started to worry but then you began to describe things in real world terms. The problem is using terminology that a novice doesn't understand and as a result can not connect the dots when all is said and done. Once the communication gap is filled then learning becomes much easier. You did that and I understood what you were talking about. As I learn more I will also start to understand the terminology associated with this discipline and then everything will start to fall in to place much easier. Sorry Dudester22. We got a little sidetracked here but I do believe you understand what your options are now. If you have any more problems, this is the place to come.:thumbup: Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals
DeJohn Posted May 30, 2014 Posted May 30, 2014 Dudester22; Have you figured out how to work with your Leo Bodnar card. If not PM me and I'll try to help you out as I also used the Bodnar's cards.
Hobo Posted May 31, 2014 Posted May 31, 2014 (edited) Isn't most of this eliminated with LUA programming of the default keys LUA? Now the disclaimer is for the keys that are "on/off" with one command, you have to be self-conscious of what state your switch is to what it should be in the sim when you hop in the pit. Currently I have my switches programmed as a combo setting in the LUA file. So in my case I use the GP-Wiz 40. I have switch 1, which is a SPST switch, with the hot terminal plugged into A on the board and the ground to the common ground port. Now say I have this programmed for the APU. In the combo setting of the LUA I have the pressed state being the "on" feature and the up state being the off. I do believe the APU has two different commands, one for the on setting, and one for the off. Unfortunately, I'm not near my computer currently to show an example if needed. Hope I didn't muck up the waters on this one. Edited May 31, 2014 by Hobo
Hobo Posted June 1, 2014 Posted June 1, 2014 (edited) Now that I'm back at my computer, I have a chance to add the code in there. Electrical Panel: {combos = {{key = 'JOY_BTN21'}} , down = iCommandAPUGeneratorPower , up = iCommandAPUGeneratorPower , name = 'APU generator power' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN24'}} , down = iCommandEmergencyFlood , up = iCommandEmergencyFlood , name = 'Emergency Flood' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN20'}} , down = iCommandBatteryPower , up = iCommandBatteryPower , name = 'Battery power' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN22'}} , down = iCommandElectricalPowerInverterSTBY , up = iCommandElectricalPowerInverterOFF , name = 'Inverter STBY' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN23'}} , down = iCommandElectricalPowerInverterTEST , up = iCommandElectricalPowerInverterOFF , name = 'Inverter Test' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN18'}} , down = iCommandPowerGeneratorLeft , up = iCommandPowerGeneratorLeft , name = 'AC generator power left' , category = 'Electrical power control panel'}; {combos = {{key = 'JOY_BTN19'}} , down = iCommandPowerGeneratorRight , up = iCommandPowerGeneratorRight , name = 'AC generator power right' , category = 'Electrical power control panel'}; APU Generator, Emergency Flood, Battery Power, and AC Gens left and right are each on their own SPST (On-Off) switch. Inverter STBY, TEST, and Off are on a single SPDT (On-Off-On) switch. Is this what you're looking for Dudester? Like in my previous disclaimer, you have to be self-conscious of your switch positions when exiting the simulator. Easiest way to ensure this is to make do a shutdown on the ramp after landing. If you forgot to and you are OCD about it, you can click on the switch in the pit to match that of your physical switches. Edited June 1, 2014 by Hobo
HornetUK Posted June 13, 2014 Posted June 13, 2014 HELP I can not get my switches for the electrical power on and off to work correctly on this board. I only get one file Button Box Interface {384C5950-F18C-11e3-8001-444553540000}.diff and not the other one like with the other control I have say the warthog. I can only get it to switch on and can not get it to recognise being off. I have tried to make a file but I have not got a clue how to make it correctly. Can someone show me how to do it as it is all dubble dutch the codeing to me. I have read what has come before!
DeJohn Posted June 13, 2014 Posted June 13, 2014 HornetUK; What I find the easiest way to deal with DCS and switches for the button board is to not try and program them through the options menu. Instead I enter what I want directly into the lua file. First make a folder on your desktop called A-10C, or which ever module you want to program for. Then goto you (Eagle Dynamics\DCS World\Mods\Aircraft\A-10C\Input\A-10C\Joystick) folder, and copy the Default.lua file. Then paste that into the folder you made on your desktop. Then paste it in the same folder again, you want the original and a copy in that folder. Now rename the copy 'ButtonBox Interface' or how ever your computer has named the card. Note... if there are numbers after the cards' name don't include them, just the words. Now open the the file you just renamed with notepad ++ Somewhere around line # 439 will be this line {down = iCommandBatteryPower , name = 'Battery power', category = 'Electrical power control panel'}, Now since this is an iCommand function you don't need to add values for down or up. Your going to add combos = {{key = 'JOY_BTN2'}}, to beginning of the line and up = iCommandBatteryPower , after the down command so that the line looks like {combos = {{key = 'JOY_BTN2'}}, down = iCommandBatteryPower , up = iCommandBatteryPower , name = 'Battery power', category = 'Electrical power control panel'}, Remember to change the button number to the one you want to use, When you are done making changes that you want you’ll click ‘save’. Then you highlite and copy your BottonBox Interface.lua file and paste it in the (Eagle Dynamics\DCS World\Mods\Aircraft\A-10C\Input\A-10C\Joystick) folder, and you’re done.
bouncerj21 Posted February 15, 2016 Posted February 15, 2016 Hi All Does this still work in 1.5 and 2.0 ? Had a try and can't seem to get it to work ? Thanks
Hansolo Posted February 25, 2016 Posted February 25, 2016 Hi bouncerj21, What are you trying to achieve? I got my setup working kinda similar to this although without the iCommand. It is somewhat described here; http://forums.eagle.ru/showpost.php?p=2017801&postcount=52 If you want I can just post my modded joystick lua file. Cheers Hans 132nd Virtual Wing homepage & 132nd Virtual Wing YouTube channel My DCS-BIOS sketches & Cockpit Album
Recommended Posts