DSoldano Posted August 14, 2021 Posted August 14, 2021 I'm just finishing up my A10-C Intercom Panel and I'm having some trouble getting the Mode Dial to work correctly. I'm using a 12 position rotary switch with the limiting ring set for 5 positions. I have the center post wired to ground and then switch pins 0, 1, 2, 3, 4 wired to the Arduino Mega digital pins 22, 24, 26, 28, 30. Here's my code: const byte intModePins[9] = {22, 24, 26, 28, 30}; DcsBios::SwitchMultiPos intMode("INT_MODE", intModePins, 9); When I turn the switch it jumps around to various positions (Blank, FM, Blank, HF, Blank) then when I go back to position 0 it goes (Int, Blan, FM, Blank, Blank). I have no idea what's going on. Any ideas? Dominick
No1sonuk Posted August 15, 2021 Posted August 15, 2021 (edited) The normal rotary switches break one contact before connecting the next ("break-before-make" or "non-shorting"). This means that momentarily, no pins are connected to gnd, so you get weird behaviour. The easy way to fix it is to get a "make-before-break" or "shorting" type of rotary switch. There may be a way to use code to ignore the spurious positions. e.g. If the switch is in position 2, the only valid next positions are 1 or 3. If neither of those occurs, leave the signal to the computer at 2. This option requires not using the normal switch code and writing your own. I've not looked at this option WRT DCS-BIOS. However, the positions can be bound individually in the controls screen, so an option might be to use an Arduino with a 32u4 processor, such as a Pro Micro to simulate joystick buttons. You can then encode whatever behaviour you like. BTW, as far as I can see, there are only 4 positions on the rotary switch in the cockpit, not 5. EDIT: Apparently, there was an update to DCS-BIOS that should prevent that issue. Maybe it has been counteracted somehow? https://github.com/dcs-bios/dcs-bios-arduino-library/releases/tag/v0.2.5 Edited August 15, 2021 by No1sonuk
DSoldano Posted August 15, 2021 Author Posted August 15, 2021 12 hours ago, No1sonuk said: The normal rotary switches break one contact before connecting the next ("break-before-make" or "non-shorting"). This means that momentarily, no pins are connected to gnd, so you get weird behaviour. The easy way to fix it is to get a "make-before-break" or "shorting" type of rotary switch. There may be a way to use code to ignore the spurious positions. e.g. If the switch is in position 2, the only valid next positions are 1 or 3. If neither of those occurs, leave the signal to the computer at 2. This option requires not using the normal switch code and writing your own. I've not looked at this option WRT DCS-BIOS. However, the positions can be bound individually in the controls screen, so an option might be to use an Arduino with a 32u4 processor, such as a Pro Micro to simulate joystick buttons. You can then encode whatever behaviour you like. BTW, as far as I can see, there are only 4 positions on the rotary switch in the cockpit, not 5. EDIT: Apparently, there was an update to DCS-BIOS that should prevent that issue. Maybe it has been counteracted somehow? https://github.com/dcs-bios/dcs-bios-arduino-library/releases/tag/v0.2.5 No1sonuk, Thanks for the response. I think I may not understand how the pin array works. When I first started programming I had some strange behavior when I didn't explicitly set the pin mode to INPUT_PULLUP but these are all set so that's not it. The DCS BIOS definition for the control is: Intercom Selector Switch INT/FM/VHF/HF/Blank - so there are 5 positions (one is blank) and you can turn the switch in the aircraft to the blank position. Unless I'm not understanding the definition. I'll keep plugging away at it. Dominick
DSoldano Posted August 15, 2021 Author Posted August 15, 2021 Problem Solved - It is either the issue that No1sonuk mentioned above or just some really noisy switches and probably a lack of understanding of how the DCS BIOS SwitchMultiPos works. I played around with the code and changed the bit array to intModePins[9] = {22, 24, 26, 28}; which is only 4 pins but the last position (BLANK - 5th position on the rotary switch) still works for some reason - seems very strange to me. Then I added a intMode.pollInputCurrent(); to the loop so that even if there is spurious noise it pulls the in sim dial back to the condition the switch finally settles down to. Not an idea solution as there is an occasional stutter in the dial but it works for now. Dominick
No1sonuk Posted August 15, 2021 Posted August 15, 2021 Something else I just noticed: Why are you using intModePins[9] and not intModePins[5] ? The control reference for IntMode says: const byte intModePins[5] = {PIN_0, PIN_1, PIN_2, PIN_3, PIN_4}; DcsBios::SwitchMultiPos intMode("INT_MODE", intModePins, 5); Maybe that's the problem?
DSoldano Posted August 15, 2021 Author Posted August 15, 2021 (edited) 1 hour ago, No1sonuk said: Something else I just noticed: Why are you using intModePins[9] and not intModePins[5] ? The control reference for IntMode says: const byte intModePins[5] = {PIN_0, PIN_1, PIN_2, PIN_3, PIN_4}; DcsBios::SwitchMultiPos intMode("INT_MODE", intModePins, 5); Maybe that's the problem? No1sonuk, maybe I have an old version. I copied this straight from the interactive control reference. The only thing I changed were the PIN numbers. const byte intModePins[9] = {22, 24, 26, 28, 30}; DcsBios::SwitchMultiPos intMode("INT_MODE", intModePins, 9); I’ll check. Dominick Edited August 15, 2021 by DSoldano
No1sonuk Posted August 15, 2021 Posted August 15, 2021 3 hours ago, DSoldano said: No1sonuk, maybe I have an old version. I copied this straight from the interactive control reference. The only thing I changed were the PIN numbers. I just looked at my old HUB version install, and that says 9. The latest "flightpanels" version I'm now using says 5. Hub isn't maintained anymore, but Flightpanels is, so I assume the discrepency was spotted and corrected in the Flightpanels branch docs.
DSoldano Posted August 15, 2021 Author Posted August 15, 2021 4 hours ago, No1sonuk said: I just looked at my old HUB version install, and that says 9. The latest "flightpanels" version I'm now using says 5. Hub isn't maintained anymore, but Flightpanels is, so I assume the discrepency was spotted and corrected in the Flightpanels branch docs. No1sonuk, Thanks. Actually a lot of the SwitchMultiPos have array dimensions that don’t match the sim. I’ll try to find the updated files on flightpanels. Dominick
DSoldano Posted August 16, 2021 Author Posted August 16, 2021 20 hours ago, No1sonuk said: I just looked at my old HUB version install, and that says 9. The latest "flightpanels" version I'm now using says 5. Hub isn't maintained anymore, but Flightpanels is, so I assume the discrepency was spotted and corrected in the Flightpanels branch docs. No1sonuk, I downloaded the FlightPanels version of DCS-BIOS (DCS BIOS MAster) and I am unsure how to install it. I put the updated Arduino Library (dcs-bios-arduino-library-master) in my libraries folder and now when I try to compile I get an error for every control, for example "cannot declare variable 'intIntVol' to be of abstract type 'DcsBios::PotentiometerEWMA<>'". Everything compiled fine before the new library was added. Any idea what I'm doing wrong? Dominick
No1sonuk Posted August 16, 2021 Posted August 16, 2021 I didn't do anything with my Arduino IDE when I changed to Flightpanels. Maybe I should... In any case, you need to make the IDE recognise the library. This is from the original "Hub" installation instructions that should hold true for flightpanels: "After downloading the library, open the Arduino IDE, select “Sketch” > “Include Library” > “Add .ZIP Library…” from the menu and choose the .ZIP file you downloaded."
DSoldano Posted August 17, 2021 Author Posted August 17, 2021 21 hours ago, No1sonuk said: I didn't do anything with my Arduino IDE when I changed to Flightpanels. Maybe I should... In any case, you need to make the IDE recognise the library. This is from the original "Hub" installation instructions that should hold true for flightpanels: "After downloading the library, open the Arduino IDE, select “Sketch” > “Include Library” > “Add .ZIP Library…” from the menu and choose the .ZIP file you downloaded." I got it working. I installed the library just fine. There were 2 issues. One, it wasn't liking the Potentiometer<EW......> definition with the brackets at the end and the other was that the Switches.h and Poteniometers.h files didn't have the .pollInputCurrent(); method defined as I was using modified files. Once I changed all of the Potentiometer definitions by deleting the brackets and added the modified code (new public methods) to the .h files it worked just fine. The added methods - intIntVol.pollInputCurrent(); - reads the state of a switch or pot on startup and sets the control in DCS World to match so your physical and virtual cockpits are synced at startup. I wish I could apply it to my Warthog HOTAS as well - I have to physically switch those and move the throttles to get it to read them initially - but at least I don't have to do it for every panel. If you want those .h files I'm happy to send them to you. Dominick
No1sonuk Posted August 17, 2021 Posted August 17, 2021 I'm fine, thanks. I don't have anything approaching a full cockpit. I don't have the room for a start. I'm making bits and pieces to make things easier, and for the challenge.
gersonh Posted August 18, 2021 Posted August 18, 2021 There may be a way to use code to ignore the spurious positions. e.g. If the switch is in position 2, the only valid next positions are 1 or 3. I don't have anything approaching a full cockpi Use fertility specialist near me for trip Paris
Recommended Posts