byteman59 Posted November 1, 2022 Author Posted November 1, 2022 Thanks, want to give that a try and see what happens.
byteman59 Posted November 1, 2022 Author Posted November 1, 2022 Looks like Arduino Library v0.2.11 hub works fine. Does this mean it will not work if try to use DCS-Bios forked version?
byteman59 Posted November 2, 2022 Author Posted November 2, 2022 Found this on gitHub, looks like there is class for BCD already written. Seems to work fine. https://github.com/DCSFlightpanels/dcs-bios-arduino-library/wiki/BcdWheel
byteman59 Posted June 8, 2023 Author Posted June 8, 2023 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
Vinc_Vega Posted June 9, 2023 Posted June 9, 2023 Hi, I used common GND for my BCD switches. Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
byteman59 Posted June 15, 2023 Author Posted June 15, 2023 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? }
No1sonuk Posted June 15, 2023 Posted June 15, 2023 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.
byteman59 Posted June 15, 2023 Author Posted June 15, 2023 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.
No1sonuk Posted June 16, 2023 Posted June 16, 2023 I've got some BCD switches coming, so I'll do a proper test, but from jury-rigging using an SPST switch and jumper wires, it looks OK. Maybe you have a hardware fault?
lesthegrngo Posted June 17, 2023 Posted June 17, 2023 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
No1sonuk Posted June 17, 2023 Posted June 17, 2023 (edited) I think there's an error in that instructibles code. I think the line: int readSwitch() Should be: void readSwitch() Edited June 17, 2023 by No1sonuk
lesthegrngo Posted June 17, 2023 Posted June 17, 2023 (edited) 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 June 17, 2023 by lesthegrngo
No1sonuk Posted June 17, 2023 Posted June 17, 2023 Did you notice this part? It's why you have to reset the device every time. // to make read on each pass move all below this to "loop", // uncomment profile reset
lesthegrngo Posted June 17, 2023 Posted June 17, 2023 Yeah, saw it and tried it, but gave errors - as I am a) pretty hung over and b) also trying to watch the cricket I found myself not trying too hard to fix it! Cheers Les
No1sonuk Posted June 17, 2023 Posted June 17, 2023 (edited) 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 June 17, 2023 by No1sonuk
lesthegrngo Posted June 17, 2023 Posted June 17, 2023 Yep, that did it after I put // in front of the word 'needed' - works great! it's a good way to test still ruminating on how to limit the wheel movement, although maybe I'm overthinking it Les
No1sonuk Posted June 17, 2023 Posted June 17, 2023 Limiting movement of the type with an "operating crown" should be relative easy, but the pushbutton types would be harder. I'll have a look when mine come later.
No1sonuk Posted June 17, 2023 Posted June 17, 2023 (edited) 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 June 17, 2023 by No1sonuk Correcting after fault found
lesthegrngo Posted August 10, 2023 Posted August 10, 2023 (edited) ****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 August 11, 2023 by lesthegrngo
Rapti Posted August 14, 2023 Posted August 14, 2023 should there not be a special library you have to call?
Recommended Posts