Jump to content

Recommended Posts

Posted

I am trying to understand the SwitchMultiPos command in DCS-BIOS.

I am working with a switch on F16,  INS knob, which in game is a 7 position switch.   In DCS-BIOS the reference is

const byte insKnbPins[13] = {PIN_0, PIN_1, PIN_2, PIN_3, PIN_4, PIN_5, PIN_6}
DcsBios::SwitchMultiPos insKnb("INS_KNB", insKnbPins, 13);

When I look at the Two Position switch, such as:

DcsBios::Switch2Pos gpsSw("GPS_SW", PIN);

it has an option for SwitchMultiPos which is:

const byte gpsSwPins[3] = {PIN_0, PIN_1}
DcsBios::SwitchMultiPos gpsSw("GPS_SW", gpsSwPins, 3);

When I look at a Three Position Switch, such as:

DcsBios::Switch3Pos hudAltSw("HUD_ALT_SW", PIN_A, PIN_B);

it has an option for a SwitchMultiPos which is:

const byte hudAltSwPins[5] = {PIN_0, PIN_1, PIN_2
DcsBios::SwitchMultiPos hudAltSw("HUD_ALT_SW", hudAltSwPins, 5);

I am trying to understand what the numbers refers to.

For the INS knob is uses 13, two position switch is uses 3 and three position switch is uses 5.  I cannot see any consistency in this....

 

Also in snippet the ";" is missing from the string starting with "const byte" and if I don't add it I get a compiler error.  And should this declaration of "Const Byte" be up with the other "Int" declarations on the top of the code??

 

My board works, I just am trying to understand the coding.

 

Thank you,

 

Mike

 

Posted

The control ref I have shows:

const byte hudAltSwPins[3] = {PIN_0, PIN_1, PIN_2};
DcsBios::SwitchMultiPos hudAltSw("HUD_ALT_SW", hudAltSwPins, 3);

The number (3 in this case) is how many positions there should be.

I looked at the others, and they're wrong in your examples as well.  Where did they come from?

Posted (edited)

They came directly from DCS-BIOS.  They are "Code" Snippets.

It's shows 5.  That is why I asked LOL.

Mike

 

image.jpeg

Edited by Aronis
Posted
10 hours ago, Biggus said:

What control reference is that?  If it's BIOSBuddy, it's pretty out of date.

Looks like Hub to me.

12 hours ago, Aronis said:

This example shows a 3 but only TWO Pins.  (from the DCS BIOS "The Control Reference")

 

Mike

 

 

Screen Shot 2025-02-12 at 7.19.44 PM.jpg

I think you're using the outdated "Hub" version of DCS-BIOS. You'll need to remove that and use the Skunkworks fork.

I don't have the link available on my phone.

  • Like 1
Posted

my source for all of it was https://dcs-bios.readthedocs.io/en/latest/

perhaps it's not "the latest" LOL.

So, I changed the 13 to 7 and bam it worked properly.

 

I am still having issues with the MIDS/LVT switch.    The in game image of the switch just keeps going back and forth, I have tried using both the code for  3 position switch and rotary switch (with the correction of 3 instead of 5 which appears to be an error). 

 

All the other switches work perfectly.  I did not bother coding nor connecting nuclear consent or the oxygen controls, just put switches in the panel for looks.

The MIDS/LVT switch will drive me nuts.

 

Mike

 

 

IMG_4998.jpg

IMG_4997.jpg

IMG_4996.jpg

Posted

Hub's not actively developed and is increasingly out of date.  Save yourself the pain now and just switch to the FP fork.

Posted

Ok, updated DCS-BIOS in my saved games directory, ran program, ran ok, but the same issue with the MIDS/LVT switch.    it also adversely effects the INS knob function in certain positions. I triple CHECKED for short circuits and tried another rotary switch, etc,

 

Next I am going to make a quick circuit with my Arduino Nano and just program for the MIDS/LVT rotary switch and see if I can get it working as the only item on the program.

 

Also, am I correct in that you cannot update your Arduino with any of the switches closed? I have found I can only update the code on the Arduino if I put all the switches in the Off position (physical off positions, off for two position toggles and center position for three position toggles, and the rotary switches to off (which is odd because that is a digital input also, not an open circuit.)  And it has to be in that same state when DCS is started up, otherwise the board does not work with DCS. Otherwise the Arduino IDE app times out. The first time I saw this I thought the Arduino had died. LOL.

 

Next will be to try making a circuit using an optical encoder instead of rotary switch for the MIDS/LVT.  

 

Mike

oh, other other thing, Do I need a newer version of the DCS-BIOS HUB program????


Mike

Posted
16 hours ago, Aronis said:

Also, am I correct in that you cannot update your Arduino with any of the switches closed? I have found I can only update the code on the Arduino if I put all the switches in the Off position (physical off positions, off for two position toggles and center position for three position toggles, and the rotary switches to off (which is odd because that is a digital input also, not an open circuit.)  And it has to be in that same state when DCS is started up, otherwise the board does not work with DCS. Otherwise the Arduino IDE app times out. The first time I saw this I thought the Arduino had died. LOL.

Don't use digital pins 0 and 1 with Arduinos running DCS-BIOS (or any other serial comms).  Those pins are used by the processor to communicate with the USB interface (and for programming the device).

 

16 hours ago, Aronis said:

oh, other other thing, Do I need a newer version of the DCS-BIOS HUB program????

There is no newer version of the Hub program that is reliable.

There IS a program called DCS-BIOS Bridge that has a graphical connection scheme, but it's very unreliable, and the developer left the whole DCS-BIOS project, so that is "frozen" not recommended for long-term use.

You'll have to manually start the connection using the port number(s) in the connection program(s) for a reliable connection.
 

Posted

Thank you, No1sonuk, I got it working and then saw your post - I was using D0 and D1, that is where I had the MIDS/LVT connected.   Long story short, I moved the rotary switch and worked.   But.....

 

Now the long story....  I did some trial and error, made a new board/test set up first trying the optical encoder,  was difficult to use as the steps were too fast/slow, not sure, but then....This was on pins 2 and 3  It would not jump/jitter back and forth in game, but it was not easy to reliable pick zero/off/on.  So....

I tried a three position switch on my test setup using an Arduino Uno, and connected to 9 and 10, and dam, it worked perfect.  I fired up this board and the other (both Arduino running) and it worked.  ( the three position switch was disconnected and I commented out the code on the Mega's code just to make sure)

So I tried this three position switch back on the Mega in different pin locations and Dam, it worked,  So I rewire the three position switch using these alternate pins 48,50,52 and it works 'perfectly' or not.

So all the switches work....but now when I use the panel in DCS, get this....

THE OBOGS waring light is on and THE OXYGEN LEVEL IN THE SIM IS LOW AND RUNS OUT QUICKLY.   LOL.  CAN'T MAKE THIS )(&()*& UP.

Now what the hell did I do wrong?  It's BIZARE.

 

Mike

Posted (edited)

Thank you, I got it working, I had the code snippets and variables for the Air Conditioning panel which is not hooked up to anything. So I commented those out and bang, problem solved.  So some odd code issue with those snippets?? Who knows.

 

Two last issues.

One is that the oxygen panel middle switch will not work, I'll double check the wiring or is that triple check LOL.

The other is the Mal&Ind LTS  BRT/DIM switch which actually does the Warning Light Panel Test instead of what it is supposed to do.  I looked and the Snippet in that section of DCS-BIOS is the wrong code for that particular switch, it does however work for the code that is there, DcsBios::Switch2Pos malIndLtsTest("MAL_IND_LTS_TEST", PIN); so My bad. LOL.

 

Mike

 

 

code

 

/* Right F16 Panel Board - Mike Aronis 2025 */
/* Variables */

/* Sensor Power Panel */
int fcrPowerSwitch = 49;
int leftHardPointSwitch = 45;
int rightHardPointSwitch = 47;
int radarAltPowerSwPinA = 51;
int radarAltPowerSwPinB = 53;

/* HUD switches */
int hudScalesSwitchPinA = 29;
int hudScalesSwitchPinB = 31;
int hudFpMarkSwitchPinA = 33;
int hudFpMarkSwitchPinB = 35;
int hudDedDSPinA = 39;
int hudDedDSPinB = 37;
int hudDepressRetSwitchPinA = 43;
int hudDepressRetSwitchPinB = 41;
int hudSpeedSwitchPinA = 25;
int hudSpeedSwitchPinB = 27;
int hudAltSwitchPinA = 23;
int hudAltSwitchPinB = 22;
int hudBrtSwitchPinA = 24;
int hudBrtSwitchPinB = 26;
int hudTestSwitchPinA = 28;
int hudTestSwitchPinB = 30;

/* Lighting Potentiometers */
int priConBrtKnob = A1;
int priInstPnlBrtKnob = A2;
int priDataDisplayBrtKnob = A3;
int floodConBrtKnob = A4;
int floodInstPnlBrtKnob = A5;
int malIndLtsTestPin = 32;     //MAYBE WRONG SNIPET? I have to check

/* Avionics Controls */
int mmcPwrSwitch = 15;
int stStaSwitch = 18;
int mfdSwitch = 19;
int ufcSwitch = 20;
int mapSwitch = 21;
int gpsSwitch = 16;
int dlSwitch = 17;
int insKnobPin0 = 8;
int insKnobPin1 = 7;
int insKnobPin2 = 6;
int insKnobPin3 = 5;
int insKnobPin4 = 4;
int insKnobPin5 = 3;
int insKnobPin6 = 2;
int midsLvtKnobPin0 = 50;
int midsLvtKnobPin1 = 52;
int midsLvtKnobPin2 = 48;

/* Air Cond NOT CONNECTED COMMENT OUT  
int tempKnbPin0 = 21;
int tempKnbPin1 = 20;
int tempKnbPin2 = 13;
int tempKnbPin3 = 12;
int tempKnbPin4 = 11;
int tempKnbPin5 = 10;
int tempKnbPin6 = 9;
int airSourceKnbPin0 = A8;
int airSourceKnbPin1 = A9;
int airSourceKnbPin2 = A10;
int airSourceKnbPin3 = A11;
int airSourceKnbPin4 = A12;  */

/* KY58 Panel   NOT CONNNECTED COMMENT OUT
int ky58ModeKnbPin0 =
int ky58ModeKnbPin1 =
int ky58ModeKnbPin2 =
int ky58ModeKnbPin3 =
int ky58FillKnbPin0 =
int ky58FillKnbPin1 =
int ky58FillKnbPin2 =
int ky58FillKnbPin3 =
int ky58FillKnbPin4 =
int ky58FillKnbPin5 =
int ky58FillKnbPin6 =
int ky58FillKnbPin7 =
int ky58PwrKnbPinA =
int ky58PwrKnbPinB =
int ky58VolKnob =   END HERE   */


/* Oxygen Panel  */
int oxyEmergLvrPinA = 10;
int oxyEmergLvrPinB = 11;
int oxyDiluterLvrPin = 9;
int oxySupplyLvrPinA = 12;
int oxySupplyLvrPinB = 13; 

/* Anti Ice and Ant Select */
int engAntiIcePinA = 34;
int engAntiIcePinB = 36;
int iffAntSelSwPinA = 38;
int iffAntSelSwPinB = 40;
int uhfAntSelSwPinA = 42;
int uhfAntSelSwPinB = 44;

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

/* code snippets from the reference documentation  */

/* Sensor Panel */
DcsBios::Switch2Pos fcrPwrSw("FCR_PWR_SW", fcrPowerSwitch);
DcsBios::Switch2Pos hdptSwL("HDPT_SW_L", leftHardPointSwitch);
DcsBios::Switch3Pos rdrAltPwrSw("RDR_ALT_PWR_SW", radarAltPowerSwPinA, radarAltPowerSwPinB);
DcsBios::Switch2Pos hdptSwR("HDPT_SW_R", rightHardPointSwitch);

/* HUD Panel */
DcsBios::Switch3Pos hudScalesSw("HUD_SCALES_SW", hudScalesSwitchPinA, hudScalesSwitchPinB);
DcsBios::Switch3Pos hudFpMarkerSw("HUD_FP_MARKER_SW", hudFpMarkSwitchPinA, hudFpMarkSwitchPinB);
DcsBios::Switch3Pos hudDedDataSw("HUD_DED_DATA_SW", hudDedDSPinA, hudDedDSPinB);
DcsBios::Switch3Pos hudDepressRetSw("HUD_DEPRESS_RET_SW", hudDepressRetSwitchPinA, hudDepressRetSwitchPinB);
DcsBios::Switch3Pos hudSpeedSw("HUD_SPEED_SW", hudSpeedSwitchPinA, hudSpeedSwitchPinB);
DcsBios::Switch3Pos hudAltSw("HUD_ALT_SW", hudAltSwitchPinA, hudAltSwitchPinB);
DcsBios::Switch3Pos hudBrtSw("HUD_BRT_SW", hudBrtSwitchPinA, hudBrtSwitchPinB);
DcsBios::Switch3Pos hudTestSw("HUD_TEST_SW", hudTestSwitchPinA, hudTestSwitchPinB);

/* Lighting Panel */
DcsBios::PotentiometerEWMA<5, 128, 5> priConsolesBrtKnb("PRI_CONSOLES_BRT_KNB", priConBrtKnob);
DcsBios::PotentiometerEWMA<5, 128, 5> priInstPnlBrtKnb("PRI_INST_PNL_BRT_KNB", priInstPnlBrtKnob);
DcsBios::PotentiometerEWMA<5, 128, 5> priDataDisplayBrtKnb("PRI_DATA_DISPLAY_BRT_KNB", priDataDisplayBrtKnob);
DcsBios::PotentiometerEWMA<5, 128, 5> floodConsolesBrtKnb("FLOOD_CONSOLES_BRT_KNB", floodConBrtKnob);
DcsBios::PotentiometerEWMA<5, 128, 5> floodInstPnlBrtKnb("FLOOD_INST_PNL_BRT_KNB", floodInstPnlBrtKnob);
DcsBios::Switch2Pos malIndLtsTest("MAL_IND_LTS_TEST", malIndLtsTestPin);   // this is the wrong code

/* Avionics Panel */
DcsBios::Switch2Pos mmcPwrSw("MMC_PWR_SW", mmcPwrSwitch);
DcsBios::Switch2Pos stStaSw("ST_STA_SW", stStaSwitch);
DcsBios::Switch2Pos mfdSw("MFD_SW", mfdSwitch);
DcsBios::Switch2Pos ufcSw("UFC_SW", ufcSwitch);
DcsBios::Switch2Pos mapSw("MAP_SW", mapSwitch);
DcsBios::Switch2Pos gpsSw("GPS_SW", gpsSwitch);
DcsBios::Switch2Pos dlSw("DL_SW", dlSwitch);
const byte insKnbPins[7] = {insKnobPin0, insKnobPin1, insKnobPin2, insKnobPin3, insKnobPin4, insKnobPin5, insKnobPin6} ;
DcsBios::SwitchMultiPos insKnb("INS_KNB", insKnbPins, 7);
const byte midsLvtKnbPins[3] = {midsLvtKnobPin0, midsLvtKnobPin1, midsLvtKnobPin2};
DcsBios::SwitchMultiPos midsLvtKnb("MIDS_LVT_KNB", midsLvtKnbPins, 3);
//DcsBios::Switch3Pos midsLvtKnb("MIDS_LVT_KNB", midsLvtKnobPin0, midsLvtKnobPin1);

/* Air Cond         NOT CONNECTED COMMENT OUT
const byte tempKnbPins[13] = {tempKnbPin0, tempKnbPin1, tempKnbPin2, tempKnbPin3, tempKnbPin4, tempKnbPin5, tempKnbPin6};
DcsBios::SwitchMultiPos tempKnb("TEMP_KNB", tempKnbPins, 13);
const byte airSourceKnbPins[9] = {airSourceKnbPin0, airSourceKnbPin1, airSourceKnbPin2, airSourceKnbPin3, airSourceKnbPin4};
DcsBios::SwitchMultiPos airSourceKnb("AIR_SOURCE_KNB", airSourceKnbPins, 9);  */

/* KY58 Panel    NOT CONNECTED WILL GO ON THE UNO V3
const byte ky58ModeKnbPins[7] = {ky58ModeKnbPin0, ky58ModeKnbPin1, ky58ModeKnbPin2, ky58ModeKnbPin3}
DcsBios::SwitchMultiPos ky58ModeKnb("KY58_MODE_KNB", ky58ModeKnbPins, 7);
const byte ky58FillKnbPins[15] = {ky58FillKnbPin0, ky58FillKnbPin1, ky58FillKnbPin2, ky58FillKnbPin3, ky58FillKnbPin4, ky58FillKnbPin5, ky58FillKnbPin6, ky58FillKnbPin7}
DcsBios::SwitchMultiPos ky58FillKnb("KY58_FILL_KNB", ky58FillKnbPins, 15);
DcsBios::Switch3Pos ky58PwrKnb("KY58_PWR_KNB",ky58PwrKnbPinA,ky58PwrKnbPinB);
DcsBios::PotentiometerEWMA<5, 128, 5> ky58VolKnb("KY58_VOL_KNB", ky58VolKnob);   EBD HERE */


/* Oxygen Panel */
DcsBios::Switch3Pos oxyEmergLvr("OXY_EMERG_LVR", oxyEmergLvrPinA, oxyEmergLvrPinB);
DcsBios::Switch2Pos oxyDiluterLvr("OXY_DILUTER_LVR", oxyDiluterLvrPin);
DcsBios::Switch3Pos oxySupplyLvr("OXY_SUPPLY_LVR", oxySupplyLvrPinA, oxySupplyLvrPinB); 

/* Anti ice, Ant Select */
DcsBios::Switch3Pos engAntiIce("ENG_ANTI_ICE", engAntiIcePinA, engAntiIcePinB);
DcsBios::Switch3Pos iffAntSelSw("IFF_ANT_SEL_SW", iffAntSelSwPinA, iffAntSelSwPinB);
DcsBios::Switch3Pos uhfAntSelSw("UHF_ANT_SEL_SW", uhfAntSelSwPinA, uhfAntSelSwPinB);


void setup() {
  DcsBios::setup();
}

void loop() {
  DcsBios::loop();
}

 

Edited by Aronis
Posted

As I said in the Discord, I think you're still using Hub-derived code which has errors and is out of date.

I notice you have a part that says "/* KY58 Panel    NOT CONNECTED WILL GO ON THE UNO V3" with a pot in it.  Is the pot connected, or is the pin connected to ground?
Unconnected analogue inputs will have the same value as the input read before it.
Then in parts like this:

const byte tempKnbPins[13] = {tempKnbPin0, tempKnbPin1, tempKnbPin2, tempKnbPin3, tempKnbPin4, tempKnbPin5, tempKnbPin6};
DcsBios::SwitchMultiPos tempKnb("TEMP_KNB", tempKnbPins, 13);

You're telling the code there are 13 pins, but only giving it 7.  That's going to give errors.
And that particular control should be a potentiometer anyway.

Posted

Is there another source of code snippets other than the DCS-Bios HUB????  That HUB also interfaces with the game and the board. Is there an alternative?   'Learning is fun'

 

Mike

 

 

The final result.   I had to adjust the text for the INS knob to match the range of the physical rotary switch.   All buttoned up and still works.

 

Good enough for me.

 

Now the other side.


Mike

IMG_4998.jpg

IMG_4997.jpg

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...