Jump to content

DCS-BIOS: Overview and Announcements


FSFIan

Recommended Posts

2 hours ago, byteman59 said:

...

I cannot find a failure but neither have that PCF chip nor the library installed. Wire some switches to the expander and try it out!

In case of trouble double-check the wire protocol initiation (I2C) as it is well documented in the library.

For more questions please open a new topic.

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

6 minutes ago, Vinc_Vega said:

I cannot find a failure but neither have that PCF chip nor the library installed. Wire some switches to the expander and try it out!

In case of trouble double-check the wire protocol initiation (I2C) as it is well documented in the library.

For more questions please open a new topic.

Regards, Vinc

 

Thanks again, here is my original topic i created a while back on the subject.

 

Link to comment
Share on other sites

  • 2 weeks later...
On 2/18/2022 at 1:54 PM, Vinc_Vega said:

I cannot find a failure but neither have that PCF chip nor the library installed. Wire some switches to the expander and try it out!

In case of trouble double-check the wire protocol initiation (I2C) as it is well documented in the library.

For more questions please open a new topic.

Regards, Vinc

 

No, luck. I'm just going to get some MCP23017, they're cheap enough.

thanks

Link to comment
Share on other sites

On 2/18/2022 at 4:26 AM, Vinc_Vega said:

DCS BIOS itself does not support port expanders.

You have to create your own instances for checking the input states from an expander and than send the command to DCS.

That`s how I plan to do the port extension on the VHF Radio Panel switches. I would apply the same logic to the PCF chips as I did for the MCP23017 expander.

  Hide contents
// ---------- VHF FM radio panel ----------

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <Wire.h>

// ----- 16 bit port expander connected @ IC2 address 0x27
#include "MCP23017.h"
MCP23017 mcp;
// Connect pin SCL of the expander to NANO/UNO pin A5
// Connect pin SDA of the expander to NANO/UNO pin A4
// MCP23017 connections
// Physial Pin# PinName PinID
//    21   GPA0    0
//    22   GPA1    1
//    23   GPA2    2
//    24   GPA3    3
//    25   GPA4    4
//    26   GPA5    5
//    27   GPA6    6
//    28   GPA7    7
//    1    GPB0    8
//    2    GPB1    9
//    3    GPB2    10
//    4    GPB3    11
//    5    GPB4    12
//    6    GPB5    13
//    7    GPB6    14
//    8    GPB7    15

// ----- declaration of variables
long lastChangeTime = 0;
const byte period = 10;  // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer)
const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer)
byte VHFFM_FREQEMER = 0;
byte prev_VHFFM_FREQEMER = 0;
byte VHFFM_MODE = 0;
byte prev_VHFFM_MODE = 0;
byte VHFFM_PRESET = 0;
byte prev_VHFFM_PRESET = 0;
byte VHFFM_SQUELCH = 1;
byte prev_VHFFM_SQUELCH = 1;

// ---------- DCS content here below ----------


// ---------- SETUP Loop ----------
void setup() {
  
DcsBios::setup();

  // ----- initialize the 16 bit port expander
    mcp.begin(0x27);
    
    mcp.pinMode(0, INPUT);
    mcp.pullUp(0, HIGH);  
    mcp.pinMode(1, INPUT);
    mcp.pullUp(1, HIGH);  
    mcp.pinMode(2, INPUT);
    mcp.pullUp(2, HIGH);  
    mcp.pinMode(3, INPUT);
    mcp.pullUp(3, HIGH);
    mcp.pinMode(4, INPUT);
    mcp.pullUp(4, HIGH);  
    mcp.pinMode(5, INPUT);
    mcp.pullUp(5, HIGH);  
    mcp.pinMode(6, INPUT);
    mcp.pullUp(6, HIGH);  
    mcp.pinMode(7, INPUT);
    mcp.pullUp(7, HIGH);
    mcp.pinMode(8, INPUT);
    mcp.pullUp(8, HIGH);  
    mcp.pinMode(9, INPUT);
    mcp.pullUp(9, HIGH);  
    mcp.pinMode(10, INPUT);
    mcp.pullUp(10, HIGH);  
// ... continue to pin 15 if necessary

// ----- first read the VHF FM radio switch positions and save to variables
//  Frequency Selection Dial FM/AM/MAN/PRE
if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;}  // Emergency FM
if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;}  // Emergency AM
if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;}  // Manual mode
if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;}  // preselected channel mode
//  Mode OFF/TR/DF
if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;}  // OFF - disables the radio
if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;}  // TR - Transmit and Recieve mode
if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;}  // DF - Direction finding mode for the ADI and HSI
//  Preset Channel Selector
if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;}  // decrease channel selection
if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;}  // increase channel selection
//  Squelch
if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed
if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled
if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;}  // Squelch tone mode

}
// ---------- End of SETUP Loop ----------

// ---------- EXECUTION loop ----------
void loop() {
  readMCP();  // send switch positions on change
  
  // send switch positions regularily
  long now = millis();
  if (now > lastChangeTime + (period*1000))
    {
      readMCP();
      lastChangeTime = now;
    }

}
// ---------- End of EXECUTION loop ----------

// ---------- FUNCTIONS declaration ----------

// read Inputs from MCP23017 and send switch positions only on change
void readMCP()
{
//  //  Frequency Selection Dial FM/AM/MAN/PRE
  if (mcp.digitalRead(0) == 0)
    {
    VHFFM_FREQEMER = 0;
      if (prev_VHFFM_FREQEMER != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0");		// "tryToSendDcsBiosMessage" or "sendDcsBiosMessage"
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(1) == 0)
    {
    VHFFM_FREQEMER = 1;
      if (prev_VHFFM_FREQEMER != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(2) == 0)
    {
    VHFFM_FREQEMER = 2;
      if (prev_VHFFM_FREQEMER != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

  if (mcp.digitalRead(3) == 0)
    {
    VHFFM_FREQEMER = 3;
      if (prev_VHFFM_FREQEMER != 3)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

//  //  Mode OFF/TR/DF
  if (mcp.digitalRead(4) == 0)
    {
    VHFFM_MODE = 0;
      if (prev_VHFFM_MODE != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(5) == 0)
    {
    VHFFM_MODE = 1;
      if (prev_VHFFM_MODE != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(6) == 0)
    {
    VHFFM_MODE = 2;
      if (prev_VHFFM_MODE != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }

// //  Preset Channel Selector
  if (mcp.digitalRead(7) == 0)
    {
    VHFFM_PRESET = 1;
      if (prev_VHFFM_PRESET != 1)
        {
          DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC");
          delay(debounce*10);
          prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  if (mcp.digitalRead(8) == 0)
    {
    VHFFM_PRESET = 2;
      if (prev_VHFFM_PRESET != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC");
            delay(debounce*10);
            prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  
//  //  Squelch
  if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1))  // 2 position switch workaround
    {
    VHFFM_SQUELCH = 1;
      if (prev_VHFFM_SQUELCH != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
       
  if (mcp.digitalRead(9) == 0)
    {
    VHFFM_SQUELCH = 0;
      if (prev_VHFFM_SQUELCH != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
    
  if (mcp.digitalRead(10) == 0)
    {
    VHFFM_SQUELCH = 2;
      if (prev_VHFFM_SQUELCH != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }  
}
// ---------- END of FUNCTIONS declaration ----------

 

 

 

Vinc, trying to use your code for a mcp23017. I'm getting "no matching function for call to 'MCP23017::MCP23017()'" when i run the sketch as is.



 

Link to comment
Share on other sites

Has anyone successfully used a Leonardo or Pro Micro (ATmega32u4) with the Flightpanels dcs-bios fork? The original docs suggested a ATMega328 or ATMega2560 was required. tia

DCS Wishlist: | Navy F-14 | Navy F/A-18 | AH-6 | Navy A-6 | Official Navy A-4 | Carrier Ops | Dynamic Campaign | Marine AH-1 |

 

Streaming DCS sometimes:

Link to comment
Share on other sites

Yes, with the hub version.

You only have to change the statement

#define DCSBIOS_IRQ_SERIAL

into

#define DCSBIOS_DEFAULT_SERIAL

Most of the libraries should do thier job on the other Arduino boards too.

Regards, Vinc

Edit: unfortunately they will not work in connection with the RS485 bus.


Edited by Vinc_Vega
  • Like 1

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

I've successfully tested a Leonardo on the Flightpanels fork.
I did a test with the joystick library acting like an HID, AND receiving data from DCS-BIOS in the same device.
I was able to make the Mosquito bomb bay doors respond to a "joystick button" input from the Leonardo (assigned in the controls binds), and have the DCS-BIOS code light the LED when the doors were open.
I used the "DCSBIOS_DEFAULT_SERIAL" define as mentioned above by Vinc_Vega.
And as Vinc added, they need to have their own USB connection as the 32u4 processor does that itself.  The 328 uses a separate translator chip for USB comms, so it can be bypassed for RS485, and the 2560 has multiple ports.

Link to comment
Share on other sites

On 2/18/2022 at 4:26 AM, Vinc_Vega said:

DCS BIOS itself does not support port expanders.

You have to create your own instances for checking the input states from an expander and than send the command to DCS.

That`s how I plan to do the port extension on the VHF Radio Panel switches. I would apply the same logic to the PCF chips as I did for the MCP23017 expander.

  Reveal hidden contents
// ---------- VHF FM radio panel ----------

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <Wire.h>

// ----- 16 bit port expander connected @ IC2 address 0x27
#include "MCP23017.h"
MCP23017 mcp;
// Connect pin SCL of the expander to NANO/UNO pin A5
// Connect pin SDA of the expander to NANO/UNO pin A4
// MCP23017 connections
// Physial Pin# PinName PinID
//    21   GPA0    0
//    22   GPA1    1
//    23   GPA2    2
//    24   GPA3    3
//    25   GPA4    4
//    26   GPA5    5
//    27   GPA6    6
//    28   GPA7    7
//    1    GPB0    8
//    2    GPB1    9
//    3    GPB2    10
//    4    GPB3    11
//    5    GPB4    12
//    6    GPB5    13
//    7    GPB6    14
//    8    GPB7    15

// ----- declaration of variables
long lastChangeTime = 0;
const byte period = 10;  // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer)
const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer)
byte VHFFM_FREQEMER = 0;
byte prev_VHFFM_FREQEMER = 0;
byte VHFFM_MODE = 0;
byte prev_VHFFM_MODE = 0;
byte VHFFM_PRESET = 0;
byte prev_VHFFM_PRESET = 0;
byte VHFFM_SQUELCH = 1;
byte prev_VHFFM_SQUELCH = 1;

// ---------- DCS content here below ----------


// ---------- SETUP Loop ----------
void setup() {
  
DcsBios::setup();

  // ----- initialize the 16 bit port expander
    mcp.begin(0x27);
    
    mcp.pinMode(0, INPUT);
    mcp.pullUp(0, HIGH);  
    mcp.pinMode(1, INPUT);
    mcp.pullUp(1, HIGH);  
    mcp.pinMode(2, INPUT);
    mcp.pullUp(2, HIGH);  
    mcp.pinMode(3, INPUT);
    mcp.pullUp(3, HIGH);
    mcp.pinMode(4, INPUT);
    mcp.pullUp(4, HIGH);  
    mcp.pinMode(5, INPUT);
    mcp.pullUp(5, HIGH);  
    mcp.pinMode(6, INPUT);
    mcp.pullUp(6, HIGH);  
    mcp.pinMode(7, INPUT);
    mcp.pullUp(7, HIGH);
    mcp.pinMode(8, INPUT);
    mcp.pullUp(8, HIGH);  
    mcp.pinMode(9, INPUT);
    mcp.pullUp(9, HIGH);  
    mcp.pinMode(10, INPUT);
    mcp.pullUp(10, HIGH);  
// ... continue to pin 15 if necessary

// ----- first read the VHF FM radio switch positions and save to variables
//  Frequency Selection Dial FM/AM/MAN/PRE
if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;}  // Emergency FM
if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;}  // Emergency AM
if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;}  // Manual mode
if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;}  // preselected channel mode
//  Mode OFF/TR/DF
if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;}  // OFF - disables the radio
if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;}  // TR - Transmit and Recieve mode
if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;}  // DF - Direction finding mode for the ADI and HSI
//  Preset Channel Selector
if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;}  // decrease channel selection
if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;}  // increase channel selection
//  Squelch
if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed
if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled
if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;}  // Squelch tone mode

}
// ---------- End of SETUP Loop ----------

// ---------- EXECUTION loop ----------
void loop() {
  readMCP();  // send switch positions on change
  
  // send switch positions regularily
  long now = millis();
  if (now > lastChangeTime + (period*1000))
    {
      readMCP();
      lastChangeTime = now;
    }

}
// ---------- End of EXECUTION loop ----------

// ---------- FUNCTIONS declaration ----------

// read Inputs from MCP23017 and send switch positions only on change
void readMCP()
{
//  //  Frequency Selection Dial FM/AM/MAN/PRE
  if (mcp.digitalRead(0) == 0)
    {
    VHFFM_FREQEMER = 0;
      if (prev_VHFFM_FREQEMER != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0");		// "tryToSendDcsBiosMessage" or "sendDcsBiosMessage"
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(1) == 0)
    {
    VHFFM_FREQEMER = 1;
      if (prev_VHFFM_FREQEMER != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(2) == 0)
    {
    VHFFM_FREQEMER = 2;
      if (prev_VHFFM_FREQEMER != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

  if (mcp.digitalRead(3) == 0)
    {
    VHFFM_FREQEMER = 3;
      if (prev_VHFFM_FREQEMER != 3)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

//  //  Mode OFF/TR/DF
  if (mcp.digitalRead(4) == 0)
    {
    VHFFM_MODE = 0;
      if (prev_VHFFM_MODE != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(5) == 0)
    {
    VHFFM_MODE = 1;
      if (prev_VHFFM_MODE != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(6) == 0)
    {
    VHFFM_MODE = 2;
      if (prev_VHFFM_MODE != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }

// //  Preset Channel Selector
  if (mcp.digitalRead(7) == 0)
    {
    VHFFM_PRESET = 1;
      if (prev_VHFFM_PRESET != 1)
        {
          DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC");
          delay(debounce*10);
          prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  if (mcp.digitalRead(8) == 0)
    {
    VHFFM_PRESET = 2;
      if (prev_VHFFM_PRESET != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC");
            delay(debounce*10);
            prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  
//  //  Squelch
  if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1))  // 2 position switch workaround
    {
    VHFFM_SQUELCH = 1;
      if (prev_VHFFM_SQUELCH != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
       
  if (mcp.digitalRead(9) == 0)
    {
    VHFFM_SQUELCH = 0;
      if (prev_VHFFM_SQUELCH != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
    
  if (mcp.digitalRead(10) == 0)
    {
    VHFFM_SQUELCH = 2;
      if (prev_VHFFM_SQUELCH != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }  
}
// ---------- END of FUNCTIONS declaration ----------

 

 

 

Which library are you using for MCP23017?

Tried the following but does not seem to work. I'm using with  a Arduino Mega.

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <Wire.h>
#include<Adafruit_MCP23017.h>

// ----- 16 bit port expander connected @ IC2 address 0x27
Adafruit_MCP23017 mcp;


// Connect pin SCL of the expander to NANO/UNO pin A5
// Connect pin SDA of the expander to NANO/UNO pin A4
// MCP23017 connections
// Physial Pin# PinName PinID
//    21          GPA0    0
//    22          GPA1    1
//    23          GPA2    2
//    24          GPA3    3
//    25          GPA4    4
//    26          GPA5    5
//    27          GPA6    6
//    28          GPA7    7
//    1           GPB0    8
//    2           GPB1    9
//    3           GPB2    10
//    4           GPB3    11
//    5           GPB4    12
//    6           GPB5    13
//    7           GPB6    14
//    8           GPB7    15

// ----- declaration of variables
long lastChangeTime = 0;

const byte period = 10;  // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer)
const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer)

byte VHFFM_FREQEMER = 0;
byte prev_VHFFM_FREQEMER = 0;
byte VHFFM_MODE = 0;
byte prev_VHFFM_MODE = 0;
byte VHFFM_PRESET = 0;
byte prev_VHFFM_PRESET = 0;
byte VHFFM_SQUELCH = 1;
byte prev_VHFFM_SQUELCH = 1;

// ---------- DCS content here below ----------


// ---------- SETUP Loop ----------
void setup() {
  
DcsBios::setup();

  // ----- initialize the 16 bit port expander
    mcp.begin();
    mcp.pinMode(0, INPUT);
    mcp.pullUp(0, HIGH);  
    mcp.pinMode(1, INPUT);
    mcp.pullUp(1, HIGH);  
    mcp.pinMode(2, INPUT);
    mcp.pullUp(2, HIGH);  
    mcp.pinMode(3, INPUT);
    mcp.pullUp(3, HIGH);
    mcp.pinMode(4, INPUT);
    mcp.pullUp(4, HIGH);  
    mcp.pinMode(5, INPUT);
    mcp.pullUp(5, HIGH);  
    mcp.pinMode(6, INPUT);
    mcp.pullUp(6, HIGH);  
    mcp.pinMode(7, INPUT);
    mcp.pullUp(7, HIGH);
    mcp.pinMode(8, INPUT);
    mcp.pullUp(8, HIGH);  
    mcp.pinMode(9, INPUT);
    mcp.pullUp(9, HIGH);  
    mcp.pinMode(10, INPUT);
    mcp.pullUp(10, HIGH);  
// ... continue to pin 15 if necessary

// ----- first read the VHF FM radio switch positions and save to variables
//  Frequency Selection Dial FM/AM/MAN/PRE
if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;}  // Emergency FM
if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;}  // Emergency AM
if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;}  // Manual mode
if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;}  // preselected channel mode
//  Mode OFF/TR/DF
if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;}  // OFF - disables the radio
if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;}  // TR - Transmit and Recieve mode
if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;}  // DF - Direction finding mode for the ADI and HSI
//  Preset Channel Selector
if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;}  // decrease channel selection
if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;}  // increase channel selection
//  Squelch
if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed
if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled
if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;}  // Squelch tone mode

}
// ---------- End of SETUP Loop ----------


// ---------- EXECUTION loop ----------
void loop() {
  readMCP();  // send switch positions on change
  
  // send switch positions regularily
  long now = millis();
  if (now > lastChangeTime + (period*1000))
    {
      readMCP();
      lastChangeTime = now;
    }

}
// ---------- End of EXECUTION loop ----------


// ---------- FUNCTIONS declaration ----------

// read Inputs from MCP23017 and send switch positions only on change
void readMCP()
{
//  //  Frequency Selection Dial FM/AM/MAN/PRE
  if (mcp.digitalRead(0) == 0)
    {
    VHFFM_FREQEMER = 0;
      if (prev_VHFFM_FREQEMER != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0");    // "tryToSendDcsBiosMessage" or "sendDcsBiosMessage"
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(1) == 0)
    {
    VHFFM_FREQEMER = 1;
      if (prev_VHFFM_FREQEMER != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(2) == 0)
    {
    VHFFM_FREQEMER = 2;
      if (prev_VHFFM_FREQEMER != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

  if (mcp.digitalRead(3) == 0)
    {
    VHFFM_FREQEMER = 3;
      if (prev_VHFFM_FREQEMER != 3)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

//  //  Mode OFF/TR/DF
  if (mcp.digitalRead(4) == 0)
    {
    VHFFM_MODE = 0;
      if (prev_VHFFM_MODE != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(5) == 0)
    {
    VHFFM_MODE = 1;
      if (prev_VHFFM_MODE != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(6) == 0)
    {
    VHFFM_MODE = 2;
      if (prev_VHFFM_MODE != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }

// //  Preset Channel Selector
  if (mcp.digitalRead(7) == 0)
    {
    VHFFM_PRESET = 1;
      if (prev_VHFFM_PRESET != 1)
        {
          DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC");
          delay(debounce*10);
          prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  if (mcp.digitalRead(8) == 0)
    {
    VHFFM_PRESET = 2;
      if (prev_VHFFM_PRESET != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC");
            delay(debounce*10);
            prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  
//  //  Squelch
  if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1))  // 2 position switch workaround
    {
    VHFFM_SQUELCH = 1;
      if (prev_VHFFM_SQUELCH != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
       
  if (mcp.digitalRead(9) == 0)
    {
    VHFFM_SQUELCH = 0;
      if (prev_VHFFM_SQUELCH != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
    
  if (mcp.digitalRead(10) == 0)
    {
    VHFFM_SQUELCH = 2;
      if (prev_VHFFM_SQUELCH != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }  
}
// ---------- END of FUNCTIONS declaration ----------
 

 

Link to comment
Share on other sites

 

see 6 postings above

Edit: use Pins 20 and 21 for I2C connection with the Mega (SDA / SCL)

 

9 hours ago, byteman59 said:

Which library are you using for MCP23017?  ...


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

3 hours ago, Vinc_Vega said:

 

see 6 postings above

Edit: use Pins 20 and 21 for I2C connection with the Mega (SDA / SCL)

 

 

Confirmed connections to pins 20 and 21.

I used a  RS26 1 Pole Position 12 Selectable Band Rotary Channel Selector Switch, using GND and pins 1, 2, 3, and 4 on the switch for the VHFFM_FREQEMER 0, 1, 2 ,3 respectively.

Did not see any moved in DCS.

Confirmed, DCS-BIOS running and connected to Arduino.

Link to comment
Share on other sites

Yes, the switch should move.

What MCP23017 chip or module do you use?

Are you able to read the switch, using the input example from the MCP library?

 

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Confirmed:

1) sketch running on a NANO and an UNO.

2) sketch not running on the Mega2560

Sorry for that!

 

Edit: must be something different to the sketch, my Mega is not connecting to DCS-bios. Even the Master Caution example is no longer working  😞

PS: In my sketch on previous page (2/18/2022 at 10:26 AM), within the Loop-section the DcsBios::loop(); statement is missing. I corrected that. Nevertheless the MCP connection to DCS should work without the statement.


Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

On 3/4/2022 at 9:55 AM, Vinc_Vega said:

Confirmed:

1) sketch running on a NANO and an UNO.

2) sketch not running on the Mega2560

Sorry for that!

 

Edit: must be something different to the sketch, my Mega is not connecting to DCS-bios. Even the Master Caution example is no longer working  😞

PS: In my sketch on previous page (2/18/2022 at 10:26 AM), within the Loop-section the DcsBios::loop(); statement is missing. I corrected that. Nevertheless the MCP connection to DCS should work without the statement.


Regards, Vinc

 

So i understand this correctly, you are not able to get a Mega working with your sketch?

 

FYI

Using a modile from amazon https://www.amazon.com/gp/product/B08YN7T13G/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1

I did ground A0 A1 and A2 for default 0x20 on module.

Link to comment
Share on other sites

Edited post: After updating DCS my Mega works fine again. I have no idea what happened.

I herewith confirm the below sketch running on an original Mega2560, using the attached library and the waveshare board.

Spoiler
// ---------- VHF FM radio panel ----------

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <Wire.h>

// ----- 16 bit port expander connected @ IC2 address 0x27
#include "MCP23017.h"
MCP23017 mcp;
// Connect pin SCL of the expander to NANO/UNO pin A5
// Connect pin SDA of the expander to NANO/UNO pin A4
// MCP23017 connections
// Physial Pin# PinName PinID
//    21   GPA0    0
//    22   GPA1    1
//    23   GPA2    2
//    24   GPA3    3
//    25   GPA4    4
//    26   GPA5    5
//    27   GPA6    6
//    28   GPA7    7
//    1    GPB0    8
//    2    GPB1    9
//    3    GPB2    10
//    4    GPB3    11
//    5    GPB4    12
//    6    GPB5    13
//    7    GPB6    14
//    8    GPB7    15

// ----- declaration of variables
long lastChangeTime = 0;
const byte period = 10;  // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer)
const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer)
byte VHFFM_FREQEMER = 0;
byte prev_VHFFM_FREQEMER = 0;
byte VHFFM_MODE = 0;
byte prev_VHFFM_MODE = 0;
byte VHFFM_PRESET = 0;
byte prev_VHFFM_PRESET = 0;
byte VHFFM_SQUELCH = 1;
byte prev_VHFFM_SQUELCH = 1;

// ---------- DCS content here below ----------


// ---------- SETUP Loop ----------
void setup() {
  
DcsBios::setup();

  // ----- initialize the 16 bit port expander
    mcp.begin(0x27);
    
    mcp.pinMode(0, INPUT);
    mcp.pullUp(0, HIGH);  
    mcp.pinMode(1, INPUT);
    mcp.pullUp(1, HIGH);  
    mcp.pinMode(2, INPUT);
    mcp.pullUp(2, HIGH);  
    mcp.pinMode(3, INPUT);
    mcp.pullUp(3, HIGH);
    mcp.pinMode(4, INPUT);
    mcp.pullUp(4, HIGH);  
    mcp.pinMode(5, INPUT);
    mcp.pullUp(5, HIGH);  
    mcp.pinMode(6, INPUT);
    mcp.pullUp(6, HIGH);  
    mcp.pinMode(7, INPUT);
    mcp.pullUp(7, HIGH);
    mcp.pinMode(8, INPUT);
    mcp.pullUp(8, HIGH);  
    mcp.pinMode(9, INPUT);
    mcp.pullUp(9, HIGH);  
    mcp.pinMode(10, INPUT);
    mcp.pullUp(10, HIGH);  
// ... continue to pin 15 if necessary

// ----- first read the VHF FM radio switch positions and save to variables
//  Frequency Selection Dial FM/AM/MAN/PRE
if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;}  // Emergency FM
if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;}  // Emergency AM
if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;}  // Manual mode
if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;}  // preselected channel mode
//  Mode OFF/TR/DF
if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;}  // OFF - disables the radio
if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;}  // TR - Transmit and Recieve mode
if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;}  // DF - Direction finding mode for the ADI and HSI
//  Preset Channel Selector
if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;}  // decrease channel selection
if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;}  // increase channel selection
//  Squelch
if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed
if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled
if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;}  // Squelch tone mode

}
// ---------- End of SETUP Loop ----------

// ---------- EXECUTION loop ----------
void loop() {
  DcsBios::loop();
  readMCP();  // send switch positions on change
  
  // send switch positions regularily
  long now = millis();
  if (now > lastChangeTime + (period*1000))
    {
      readMCP();
      lastChangeTime = now;
    }

}
// ---------- End of EXECUTION loop ----------

// ---------- FUNCTIONS declaration ----------

// read Inputs from MCP23017 and send switch positions only on change
void readMCP()
{
//  //  Frequency Selection Dial FM/AM/MAN/PRE
  if (mcp.digitalRead(0) == 0)
    {
    VHFFM_FREQEMER = 0;
      if (prev_VHFFM_FREQEMER != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0");		// "tryToSendDcsBiosMessage" or "sendDcsBiosMessage"
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(1) == 0)
    {
    VHFFM_FREQEMER = 1;
      if (prev_VHFFM_FREQEMER != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }
  
  if (mcp.digitalRead(2) == 0)
    {
    VHFFM_FREQEMER = 2;
      if (prev_VHFFM_FREQEMER != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

  if (mcp.digitalRead(3) == 0)
    {
    VHFFM_FREQEMER = 3;
      if (prev_VHFFM_FREQEMER != 3)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3");
            prev_VHFFM_FREQEMER = VHFFM_FREQEMER;
        }
    }

//  //  Mode OFF/TR/DF
  if (mcp.digitalRead(4) == 0)
    {
    VHFFM_MODE = 0;
      if (prev_VHFFM_MODE != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(5) == 0)
    {
    VHFFM_MODE = 1;
      if (prev_VHFFM_MODE != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }
  if (mcp.digitalRead(6) == 0)
    {
    VHFFM_MODE = 2;
      if (prev_VHFFM_MODE != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2");
            prev_VHFFM_MODE = VHFFM_MODE;
        }
    }

// //  Preset Channel Selector
  if (mcp.digitalRead(7) == 0)
    {
    VHFFM_PRESET = 1;
      if (prev_VHFFM_PRESET != 1)
        {
          DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC");
          delay(debounce*10);
          prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  if (mcp.digitalRead(8) == 0)
    {
    VHFFM_PRESET = 2;
      if (prev_VHFFM_PRESET != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC");
            delay(debounce*10);
            prev_VHFFM_PRESET = 0;  // reset to accept next push botton signal
        }
    }
  
//  //  Squelch
  if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1))  // 2 position switch workaround
    {
    VHFFM_SQUELCH = 1;
      if (prev_VHFFM_SQUELCH != 1)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
       
  if (mcp.digitalRead(9) == 0)
    {
    VHFFM_SQUELCH = 0;
      if (prev_VHFFM_SQUELCH != 0)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }
    
  if (mcp.digitalRead(10) == 0)
    {
    VHFFM_SQUELCH = 2;
      if (prev_VHFFM_SQUELCH != 2)
        {
            DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2");
            prev_VHFFM_SQUELCH = VHFFM_SQUELCH;
        }
    }  
}
// ---------- END of FUNCTIONS declaration ----------

 

Before connecting to DCS, try to read the switch state by using a simple input example from the MCP library.

You are right, when setting up the pullups High within the Setup loop, than switches have to be connected to Ground. If pullups work for you, should be documented in your library.

As the original resistors seem to be weak, the module at Amazon is recommended to be used with additional pullup resistors for the I2C connection.

Regards, Vinc

 

MCP23017.rar


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 1 month later...

Question on using an LED with DCSBIOS.

Looking to use the Un-Mute's LED's on the Intercom Panel. So that when mute is on, the LED for that control goes off.

Code has DcsBios::LED intAimUnmute(0x11a6, 0x0004, PIN);

I assume the PIN should run in series with the LED. My LED is a 3.2Vf.

Can i run 3.3V to LED, then from LED to 5, with pinMode(5,HIGH)

Example: 

//AIM Un-Mute

pinMode(5,HIGH)

DcsBios::LED intAimUnmute(0x11a6, 0x0004, 5);

 

Thanks

Bob

Link to comment
Share on other sites

1 hour ago, byteman59 said:

Question on using an LED with DCSBIOS.

Looking to use the Un-Mute's LED's on the Intercom Panel. So that when mute is on, the LED for that control goes off.

Code has DcsBios::LED intAimUnmute(0x11a6, 0x0004, PIN);

I assume the PIN should run in series with the LED. My LED is a 3.2Vf.

Can i run 3.3V to LED, then from LED to 5, with pinMode(5,HIGH)

Example: 

//AIM Un-Mute

pinMode(5,HIGH)

DcsBios::LED intAimUnmute(0x11a6, 0x0004, 5);

 

Thanks

Bob

You'd still need the resistor in series with the LED.

Link to comment
Share on other sites

  • 3 weeks later...

Finishing up first panel, the Intercom Panel, including Antenna and EGI

Have everything working except for "SAT ANT" and "EGI HQ TOD" switches. 

Cannot get these switches to move within DCS, either with my panel or within sim. Any ideas?

 

Thanks!


Edited by byteman59
Link to comment
Share on other sites

  • 3 weeks later...

@v81 this link is for profiles for DCSFlightpanel Software. Not for BIOS

HUB may get the profile if there is a Maintainer.

No1sunk mean our fork. Will require a new install of BIOS.

https://github.com/DCSFlightpanels/dcs-bios


Edited by BlackLibrary
  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   1 member

×
×
  • Create New...