Jump to content

IFF Panel Problems


byteman59

Recommended Posts

  • 7 months later...
On 11/1/2022 at 1:14 PM, Vinc_Vega said:

Hi Bob,

 

I use DCS-BIOS Version: v0.10.0+64, most files of the Library are from April 2019.

The A-10C II modul should be from October 2020.

Regards, Vinc

 

Vinc, 

When wiring a BCD, should i use 5V as common or GRD as common?

Thanks

Link to comment
Share on other sites

I'm confused why this code works in DCS-BIOS but not in the game.

#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
 
// Thumbwheel Code
//Mode-1 Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", 25, 26, 27);
 
//Mode-1 Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel2("IFF_MODE1_WHEEL2", 23, 24);
 
//Mode-3A Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel1("IFF_MODE3a_WHEEL1", 54, 55, 56);
 
//Mode-3A Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel2("IFF_MODE3a_WHEEL2", 60, 59, 58);
 
//Mode-3A Wheel 3 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel3("IFF_MODE3a_WHEEL3", 64, 63, 62);
 
//Mode-3A Wheel 4 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel4("IFF_MODE3a_WHEEL4", 68, 67, 66);


 
void setup() {
  DcsBios::setup();
 
// ThumbWheels
  pinMode (23, INPUT_PULLUP);  
  pinMode (24, INPUT_PULLUP);
  pinMode (25, INPUT_PULLUP);
  pinMode (26, INPUT_PULLUP);
  pinMode (27, INPUT_PULLUP);
  pinMode (54, INPUT_PULLUP);  
  pinMode (55, INPUT_PULLUP);
  pinMode (56, INPUT_PULLUP);
  pinMode (58, INPUT_PULLUP);
  pinMode (59, INPUT_PULLUP);
  pinMode (60, INPUT_PULLUP);
  pinMode (62, INPUT_PULLUP);  
  pinMode (63, INPUT_PULLUP);
  pinMode (64, INPUT_PULLUP);
  pinMode (66, INPUT_PULLUP);
  pinMode (67, INPUT_PULLUP);
  pinMode (68, INPUT_PULLUP);
 
}
 
void loop() {
  DcsBios::loop();

 

am i missing something?

   
}2023-06-14_20-56-09.jpg
Link to comment
Share on other sites

7 hours ago, No1sonuk said:

I don't know how bcdwheel is supposed to work, but generally speaking you don't need the pin mode lines as DCS-BIOS does that for you.

Try removing those pinmode lines in case they're interfering.

When removed nothing happens at all.

Link to comment
Share on other sites

Getting the IFF BCD thumbwheels working on my IFF panel was on my 'to do' list, so this morning after seeing this I started as I always do with a simple test to understand the components a bit better. In pursuit of that I soldered on the connections to one of the Hampolt BCS thumbwheels, and downloaded and installed the sketch from here https://www.instructables.com/Arduino-and-Thumbwheel-Switches/ to check it out. I soldered in some 10K resistors on a patch board and wired up accordingly

Trouble is, it doesn't work! The serial monitor displays '15' when the thumbwheel is at zero, and '0' for any other value

  So, I have searched for an alternative test sketch that maybe uses an alternative schematic, but can't find one. If someone does have a simple test sketch I would like to know about it 

Les

Link to comment
Share on other sites

Thanks, I'll give that a go

 

In the meantime, someone sent me this

// TEST For "Profile switch" currently set to read BCD switch 
// once during setup; move code as noted below for repeated reads

// BCD Switch inputs attached to pins D4-7, common to Ground 
// (use internal pullups)

// Define data bit pins
    int      profile_BIT1  = 4;
    int      profile_BIT2  = 5;
    int      profile_BIT4  = 6;
    int      profile_BIT8  = 7;

// Define profile variable, set to 0

    int      profile = 0;

void setup() {
// initialize serial communication at 9600 bits per second (only needed
// for debugging:
  Serial.begin(9600);

// make the profile switch's pins inputs, with internal pullups on:
  pinMode(profile_BIT1, INPUT_PULLUP);
  pinMode(profile_BIT2, INPUT_PULLUP);
  pinMode(profile_BIT4, INPUT_PULLUP);
  pinMode(profile_BIT8, INPUT_PULLUP);
  
// to make read on each pass move all below this to "loop",  
// uncomment profile reset


// read the input pins: NOTE - CLOSED switch (binary 1) returns "0"
  int val_profile_BIT1 = digitalRead(profile_BIT1);
  int val_profile_BIT2 = digitalRead(profile_BIT2);
  int val_profile_BIT4 = digitalRead(profile_BIT4);
  int val_profile_BIT8 = digitalRead(profile_BIT8);



//int     profile =  0; needed in loop to reset to 0 for each pass

// turn bit values into single profile value by adding decimal value 
// of each bit to profile variable

if (  val_profile_BIT1 ==  0)    { profile = profile + 1; }
if (  val_profile_BIT2 ==  0)    { profile = profile + 2; }
if (  val_profile_BIT4 ==  0)    { profile = profile + 4; }
if (  val_profile_BIT8 ==  0)    { profile = profile + 8; }

// DEBUG - prints out the state of the switch bits and profile value

   {Serial.print("[profile_BIT1: ");
    Serial.print(val_profile_BIT1);
    Serial.print("] ");
    Serial.print("[profile_BIT2: ");
    Serial.print(val_profile_BIT2);
    Serial.print("] ");
    Serial.print("[profile_BIT4: ");
    Serial.print(val_profile_BIT4);
    Serial.print("] ");
    Serial.print("[profile_BIT8: ");
    Serial.print(val_profile_BIT8);
    Serial.print("] ");
    Serial.print("[profile: ");
    Serial.print(profile);
    Serial.println("] ");}
    
  }
  
// delay in between reads for stability, uncomment if in loop
//  delay(1000); 

  void loop() {
    
}

You have to reset the Nano after every move of the thumbwheel switch so that it shows on the serial monitor but it does work

For info I tried it with the '8' connection disconnected and predictably position 9 reports as 1 and position 8 reports as 0. I know that the in-game numbers don't go past 7 but I am unsure how to stop the thumbwheels from physically moving to those positions and was hoping to use three connections rather than four to help with that. However it looks like I will have to find another way 

 

Les


Edited by lesthegrngo
Link to comment
Share on other sites

LOL.
I think it should be this:

// TEST For "Profile switch" currently set to read BCD switch 
// once during setup; move code as noted below for repeated reads

// BCD Switch inputs attached to pins D4-7, common to Ground 
// (use internal pullups)

// Define data bit pins
    int      profile_BIT1  = 4;
    int      profile_BIT2  = 5;
    int      profile_BIT4  = 6;
    int      profile_BIT8  = 7;

// Define profile variable, set to 0

 int  profile = 0;

void setup() {
// initialize serial communication at 9600 bits per second (only needed
// for debugging:
  Serial.begin(9600);

// make the profile switch's pins inputs, with internal pullups on:
  pinMode(profile_BIT1, INPUT_PULLUP);
  pinMode(profile_BIT2, INPUT_PULLUP);
  pinMode(profile_BIT4, INPUT_PULLUP);
  pinMode(profile_BIT8, INPUT_PULLUP);
  

    
  }
  


  void loop() {

// read the input pins: NOTE - CLOSED switch (binary 1) returns "0"
  int val_profile_BIT1 = digitalRead(profile_BIT1);
  int val_profile_BIT2 = digitalRead(profile_BIT2);
  int val_profile_BIT4 = digitalRead(profile_BIT4);
  int val_profile_BIT8 = digitalRead(profile_BIT8);



       profile =  0; needed in loop to reset to 0 for each pass

// turn bit values into single profile value by adding decimal value 
// of each bit to profile variable

if (  val_profile_BIT1 ==  0)    { profile = profile + 1; }
if (  val_profile_BIT2 ==  0)    { profile = profile + 2; }
if (  val_profile_BIT4 ==  0)    { profile = profile + 4; }
if (  val_profile_BIT8 ==  0)    { profile = profile + 8; }

// DEBUG - prints out the state of the switch bits and profile value

   {Serial.print("[profile_BIT1: ");
    Serial.print(val_profile_BIT1);
    Serial.print("] ");
    Serial.print("[profile_BIT2: ");
    Serial.print(val_profile_BIT2);
    Serial.print("] ");
    Serial.print("[profile_BIT4: ");
    Serial.print(val_profile_BIT4);
    Serial.print("] ");
    Serial.print("[profile_BIT8: ");
    Serial.print(val_profile_BIT8);
    Serial.print("] ");
    Serial.print("[profile: ");
    Serial.print(profile);
    Serial.println("] ");}

// delay in between reads for stability, uncomment if in loop
   delay(1000); 
    
}

 


Edited by No1sonuk
Link to comment
Share on other sites

Just ran a test using code byteman posted on Discord with a Mega and single BCD switch.
Both Mode 1 wheels work perfectly as written.
None of the Mode 3 wheels work at all as written.
Pins 54+ are A0+ and don't work reliably for the Mode 1 wheels.
I rigged them all to repsond to  pins 25, 26, and 27 at the same time.  Both Mode 1 wheels responded as expected.   None of the Mode 3 wheels moved at all.
So my conclusions are:
1) There appears to be a fault with the Mode 3 wheels in DCS-BIOS (or DCS itself)
EDIT: There was a code error: The 4 code lines said "IFF_MODE3a_WHEEL1", etc. but should be "IFF_MODE3A_WHEEL1", etc...

2) The analogue pins might not be reliable for digital input.


Edited by No1sonuk
Correcting after fault found
Link to comment
Share on other sites

  • 1 month later...

****EDIT - SOLVED*****

I had to reinstall the 'DCS-bios-arduino-master-library', once I did that it recovered it

 

 

Hi all, I have just gone to try to test the BCD thumbweels with a Mega on a dedicated PCB, but now I am getting a "'BcdWheel' is not a member of DCS Bios" error message

I never had that before, here's the sketch below. Have I forgotten to include something?

 


#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 75
//#define TXENABLE_PIN 2


#include <DcsBios.h>
#include <Wire.h>
#include <SPI.h>


void setup()   {                
   {

// Thumbwheel Code

DcsBios::BcdWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", 4, 5, 6, 7);
 
DcsBios::BcdWheel iffMode1Wheel2("IFF_MODE1_WHEEL2", 23, 24);
 
DcsBios::BcdWheel iffMode3aWheel1("IFF_MODE3A_WHEEL1", 26, 27, 28);

DcsBios::BcdWheel iffMode3aWheel2("IFF_MODE3A_WHEEL2", 30, 31, 32);
 
DcsBios::BcdWheel iffMode3aWheel3("IFF_MODE3A_WHEEL3", 33, 34, 35);
 
DcsBios::BcdWheel iffMode3aWheel4("IFF_MODE3a_WHEEL4", 36, 37, 38);
  
}
DcsBios::setup();
}

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

Cheers

 

Les


Edited by lesthegrngo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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