LewisR Posted October 1, 2024 Posted October 1, 2024 (edited) Hi, I've built a little button box for the F14 RIO seat. I have a Mega 2560 as master and two slave arduinos. The are connected on common GND, 5V, and A/B connections to the master. I have 29 buttons on a 5x6 matrix on slave 1, 2 pots, 3 rot encoders, 2 3 pos momentary toggles and a solo momentary button on slave 2 (waiting on part so not connected). When writing the sketches and waiting for parts I tested a couple of each component type to ensure the commands did what I wanted. Other than both pots controlling both pots in the cockpit and not their individual ones, it all worked (couldn't test the matrix as was waiting on diodes) I have everything wired up now and all the lights look good. But no movement in game. The only component that has any effect is one of the rotary encoders which is wired to pin 15 seems to turn the L light on slave two on and off as I turn it. The rest have no effect in game or on the boards. Master has the L, and ON LEDs lit. The RX led flashes when in the cockpit but not the TX. Slave 1 has the RX and POW lights lit brightly and the TX dimmly but no L. Slave2 has the all but the TX light lit brightly. All three MAX485s have the D1 led lit brightly. My master code is this: /* Tell DCS-BIOS this is a RS-485 Master. You will need to flash this to a Mega 2560. */ #define DCSBIOS_RS485_MASTER /* Define where the TX_ENABLE signals are connected. You can connect up to three half-duplex RS-485 transceivers. Arduino Pin RS-485 Transceiver Pin TXn ------------------- DI (driver input) RXn ------------------- RO (Receiver Output) UARTn_TXENABLE_PIN ---- /RE, DE (active low receiver enable, driver enable) If you have less than three transceivers connected, comment out the corresponding #define UARTn_TEXENABLE_PIN lines for receivers that are not present. */ #define UART1_TXENABLE_PIN 2 //#define UART2_TXENABLE_PIN 3 //#define UART3_TXENABLE_PIN 4 #include "DcsBios.h" void setup() { DcsBios::setup(); pinMode(13, INPUT); } void loop() { DcsBios::loop(); } Slave 1: #include <Key.h> #include <Keypad.h> /* The following #define tells DCS-BIOS that this is a RS-485 slave device. It also sets the address of this slave device. The slave address should be between 1 and 126 and must be unique among all devices on the same bus. */ #define DCSBIOS_RS485_SLAVE 1 /* The Arduino pin that is connected to the /RE and DE pins on the RS-485 transceiver. */ #define TXENABLE_PIN 2 #include "DcsBios.h" const byte ROWS=5; const byte COLS=6; char keys[ROWS][COLS] = { {'1', '2', '3', 'A', 'B', 'C'}, {'4', '5', '6', 'D', 'E', 'F'}, {'7', '8', '9', 'G', 'H', 'I'}, {'*', '0', '#', 'J', 'K', 'L'}, {'M', 'N', 'O', 'P', 'Q', 'R'} }; byte rowPins[ROWS] = {3,4,5,6,7}; byte colPins[COLS] = {8,9,10,11,12,13}; Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); /* paste code snippets from the reference documentation here */ void setup() { DcsBios::setup(); pinMode(13, INPUT); } void loop() { DcsBios::loop(); char key1 = keypad.getKey(); if (key1) { switch (key1){ case '1': DcsBios::Switch2Pos rioCapLat1("RIO_CAP_LAT_1", '1'); /* ***LED NOT IN USE*** */ break; case '2': DcsBios::Switch2Pos rioCapNbr2("RIO_CAP_NBR_2", '2'); /* ***LED NOT IN USE*** */ break; case '3': DcsBios::Switch2Pos rioCapSpd3("RIO_CAP_SPD_3", '3'); /* ***LED NOT IN USE*** */ break; case '4': DcsBios::Switch2Pos rioCapAlt4("RIO_CAP_ALT_4", 'A'); /* ***LED NOT IN USE*** */ break; case '5': DcsBios::Switch2Pos rioCapRng5("RIO_CAP_RNG_5", 'B'); /* ***LED NOT IN USE*** */ break; case '6': DcsBios::Switch2Pos rioCapLong6("RIO_CAP_LONG_6", 'C'); /* ***LED NOT IN USE*** */ break; case '7': DcsBios::Switch2Pos rioCap7("RIO_CAP_7", '4'); /* ***LED NOT IN USE*** */ break; case '8': DcsBios::Switch2Pos rioCapHdg8("RIO_CAP_HDG_8", '5'); /* ***LED NOT IN USE*** */ break; case '9': DcsBios::Switch2Pos rioCap9("RIO_CAP_9", '6'); /* ***LED NOT IN USE*** */ break; case '10': DcsBios::Switch2Pos rioCapBrg0("RIO_CAP_BRG_0", 'D'); /* ***LED NOT IN USE*** */ break; case '11': DcsBios::Switch2Pos rioCapBtn1("RIO_CAP_BTN_1", 'E'); /* ***LED NOT IN USE*** */ break; case '12': DcsBios::Switch2Pos rioCapBtn2("RIO_CAP_BTN_2", 'F'); /* ***LED NOT IN USE*** */ break; case '13': DcsBios::Switch2Pos rioCapBtn3("RIO_CAP_BTN_3", '7'); /* ***LED NOT IN USE*** */ break; case '14': DcsBios::Switch2Pos rioCapBtn4("RIO_CAP_BTN_4", '8'); /* ***LED NOT IN USE*** */ break; case '15': DcsBios::Switch2Pos rioCapBtn5("RIO_CAP_BTN_5", '9'); /* ***LED NOT IN USE*** */ break; case '16': DcsBios::Switch2Pos rioCapBtn6("RIO_CAP_BTN_6", 'G'); /* ***LED NOT IN USE*** */ break; case '17': DcsBios::Switch2Pos rioCapBtn7("RIO_CAP_BTN_7", 'H'); /* ***LED NOT IN USE*** */ break; case '18': DcsBios::Switch2Pos rioCapBtn8("RIO_CAP_HDG_8", 'I'); /* ***LED NOT IN USE*** */ break; case '19': DcsBios::Switch2Pos rioCapBtn9("RIO_CAP_HDG_9", '*'); /* ***LED NOT IN USE*** */ break; case '20': DcsBios::Switch2Pos rioCapBtn10("RIO_CAP_BTN_10", '0'); /* ***LED NOT IN USE*** */ break; case '21': DcsBios::Switch2Pos rioCapClear("RIO_CAP_CLEAR", '#'); /* ***LED NOT IN USE*** */ break; case '22': DcsBios::Switch2Pos rioCapSw("RIO_CAP_SW", 'J'); /* ***LED NOT IN USE*** */ break; case '23': DcsBios::Switch2Pos rioCapNe("RIO_CAP_NE", 'K'); /* ***LED NOT IN USE*** */ break; case '24': DcsBios::Switch2Pos rioCapEnter("RIO_CAP_ENTER", 'L'); /* ***LED NOT IN USE*** */ break; case '25': DcsBios::Switch2Pos rioRadarPdsrch("RIO_RADAR_PDSRCH", 'M'); /* ***LED NOT IN USE*** */ break; case '26': DcsBios::Switch2Pos rioRadarRws("RIO_RADAR_RWS", 'N'); /* ***LED NOT IN USE*** */ break; case '27': DcsBios::Switch2Pos rioRadarTwsauto("RIO_RADAR_TWSAUTO", 'O'); /* ***LED NOT IN USE*** */ break; case '28': DcsBios::Switch2Pos rioRadarTwsman("RIO_RADAR_TWSMAN", 'P'); /* ***LED NOT IN USE*** */ break; case '29': DcsBios::Switch2Pos rioRadarPulse("RIO_RADAR_PULSE", 'Q'); /* ***LED NOT IN USE*** */ break; } } } Slave 2: /* The following #define tells DCS-BIOS that this is a RS-485 slave device. It also sets the address of this slave device. The slave address should be between 1 and 126 and must be unique among all devices on the same bus. */ #define DCSBIOS_RS485_SLAVE 2 /* The Arduino pin that is connected to the /RE and DE pins on the RS-485 transceiver. */ #define TXENABLE_PIN 2 #include <Encoder.h> #include "DcsBios.h" #define ENCODER_PIN_A 8 #define ENCODER_PIN_B 9 #define ENCODER_PIN_C 10 #define ENCODER_PIN_D 11 #define ENCODER_PIN_E 12 #define ENCODER_PIN_F 13 Encoder AZselect(ENCODER_PIN_A, ENCODER_PIN_B); Encoder ElvBAR(ENCODER_PIN_C, ENCODER_PIN_D); Encoder catSEL(ENCODER_PIN_E, ENCODER_PIN_F); long oldPosition1 = -999; long oldPosition2 = -999; long oldPosition3 = -999; DcsBios::Switch2Pos rioWeaponAaLaunch("RIO_WEAPON_AA_LAUNCH", 3); DcsBios::Switch3Pos rioRadarVsl("RIO_RADAR_VSL", 4, 5); DcsBios::Switch2Pos rioHcuDdd("RIO_HCU_DDD", 6); DcsBios::Switch2Pos rioHcuTid("RIO_HCU_TID", 7); /* paste code snippets from the reference documentation here */ void setup() { DcsBios::setup(); pinMode(13, INPUT); } void loop() { DcsBios::loop(); // Azimuth long newPosition1 = AZselect.read(); if (newPosition1 != oldPosition1){ if(newPosition1 > oldPosition1){ DcsBios::sendDcsBiosMessage("RIO_RADAR_AZI_SCAN", "+1"); } else { DcsBios::sendDcsBiosMessage("RIO_RADAR_AZI_SCAN", "-1"); } oldPosition1 = newPosition1; } // Elevation Bars long newPosition2 = ElvBAR.read(); if (newPosition2 != oldPosition2){ if(newPosition2 > oldPosition2){ DcsBios::sendDcsBiosMessage("RIO_RADAR_ELE_BARS", "+1"); } else { DcsBios::sendDcsBiosMessage("RIO_RADAR_ELE_BARS", "-1"); } oldPosition2 = newPosition2; } // CATEGORY SELECT long newPosition3 = catSEL.read(); if (newPosition3 != oldPosition3){ if(newPosition3 > oldPosition3){ DcsBios::sendDcsBiosMessage("RIO_CAP_CATRGORY", "+1"); } else { DcsBios::sendDcsBiosMessage("RIO_CAP_CATRGORY", "-1"); } oldPosition3 = newPosition3; } // Check potentiometer A1 (Azimuth Center) int aziVal = analogRead(A1); DcsBios::PotentiometerEWMA<5, 128, 5> rioRadarAziCenter("RIO_RADAR_AZI_CENTER", aziVal); // Check potentiometer A2 (Elevation Center) int eleVal = analogRead(A2); DcsBios::PotentiometerEWMA<5, 128, 5> rioRadarEleCenter("RIO_RADAR_ELE_CENTER", eleVal); } If you like I can send across my AutoCAD for wiring although there were some changes made after design as there often is;) But know all buttons have a diode on one of the two pins with the stripe away from the leg towards the board. All the common connections join and are connected to bus bars that then go to the relevant pins on the nanos. Edited October 1, 2024 by LewisR Repeated Slave 1
LewisR Posted October 1, 2024 Author Posted October 1, 2024 (edited) Ignore the rats nest Edited October 1, 2024 by LewisR messy
No1sonuk Posted October 1, 2024 Posted October 1, 2024 Is there a reason you're writing the encoder code yourself, rather than using the DCS-BIOS rotary encoder function?
LewisR Posted October 1, 2024 Author Posted October 1, 2024 (edited) 17 minutes ago, No1sonuk said: Is there a reason you're writing the encoder code yourself, rather than using the DCS-BIOS rotary encoder function? Ummmm..... No... I looking at my code that wasn't working before and I watched a video by warthog project and found out about the other control references which fixed it and I guess I never changed my code. I am not sure but surely this would not completely prevent the box from working as the button matrix is on a separate nano and is correct as far as I know... Additional Context: I've just run a simple send and receive across the Nanos and Mega to test the RS485 network and I am receiving response properly: Master: #define DE_PIN 2 #define RE_PIN 2 void setup() { Serial.begin(9600); // USB Serial for debugging Serial1.begin(9600); // RS485 Serial pinMode(DE_PIN, OUTPUT); digitalWrite(DE_PIN, HIGH); // Start by enabling transmission } void loop() { // Send a message digitalWrite(DE_PIN, HIGH); // Enable transmitter mode Serial1.println("Hello from Master"); Serial.println("Sent: Hello from Master"); // Switch to receiving mode to listen for responses digitalWrite(DE_PIN, LOW); // Enable receiver mode (DE and RE LOW) delay(2000); // Small delay to allow the message to be sent if (Serial1.available()) { String receivedMessage = Serial1.readString(); Serial.println("Master received: " + receivedMessage); } delay(2000); } Slave 1 and 2 with delay of 1000ms on 1 but same coding: #define DE_PIN 2 // DE and RE connected to Pin 2 void setup() { Serial.begin(9600); // For USB debugging Serial.begin(9600); // RS485 communication pinMode(DE_PIN, OUTPUT); digitalWrite(DE_PIN, LOW); // Enable receiving mode } void loop() { if (Serial.available()) { String receivedMessage = Serial.readString(); Serial.println("Slave 2 received: " + receivedMessage); delay(1500); // Switch to sending mode digitalWrite(DE_PIN, HIGH); // Enable transmitter mode Serial.println("Reply from Slave 2"); delay(1500); // Return to receiving mode digitalWrite(DE_PIN, LOW); } } Response on serial monitor: Sent: Hello from Master Master received: Reply from Slave 1 Reply from Slave 2 Edited October 1, 2024 by LewisR Delay
No1sonuk Posted October 1, 2024 Posted October 1, 2024 Have you tried disconnecting the RS485 transceivers and recoding the slaves for USB? i.e. comment out the RS485 part and put in IRQ SERIAL? It might not be RS485 related at all.
LewisR Posted October 1, 2024 Author Posted October 1, 2024 (edited) 15 minutes ago, No1sonuk said: Have you tried disconnecting the RS485 transceivers and recoding the slaves for USB? i.e. comment out the RS485 part and put in IRQ SERIAL? It might not be RS485 related at all. Okay, used this code on what was slave 1: #include <Key.h> #include <Keypad.h> /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" const byte ROWS=5; const byte COLS=6; char keys[ROWS][COLS] = { {'1', '2', '3', 'A', 'B', 'C'}, {'4', '5', '6', 'D', 'E', 'F'}, {'7', '8', '9', 'G', 'H', 'I'}, {'*', '0', '#', 'J', 'K', 'L'}, {'M', 'N', 'O', 'P', 'Q', 'R'} }; byte rowPins[ROWS] = {3,4,5,6,7}; byte colPins[COLS] = {8,9,10,11,12,13}; Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); /* paste code snippets from the reference documentation here */ void setup() { DcsBios::setup(); pinMode(13, INPUT); } void loop() { DcsBios::loop(); char key1 = keypad.getKey(); if (key1) { switch (key1){ case '1': DcsBios::Switch2Pos rioCapLat1("RIO_CAP_LAT_1", '1'); /* ***LED NOT IN USE*** */ break; case '2': DcsBios::Switch2Pos rioCapNbr2("RIO_CAP_NBR_2", '2'); /* ***LED NOT IN USE*** */ break; case '3': DcsBios::Switch2Pos rioCapSpd3("RIO_CAP_SPD_3", '3'); /* ***LED NOT IN USE*** */ break; case '4': DcsBios::Switch2Pos rioCapAlt4("RIO_CAP_ALT_4", 'A'); /* ***LED NOT IN USE*** */ break; case '5': DcsBios::Switch2Pos rioCapRng5("RIO_CAP_RNG_5", 'B'); /* ***LED NOT IN USE*** */ break; case '6': DcsBios::Switch2Pos rioCapLong6("RIO_CAP_LONG_6", 'C'); /* ***LED NOT IN USE*** */ break; case '7': DcsBios::Switch2Pos rioCap7("RIO_CAP_7", '4'); /* ***LED NOT IN USE*** */ break; case '8': DcsBios::Switch2Pos rioCapHdg8("RIO_CAP_HDG_8", '5'); /* ***LED NOT IN USE*** */ break; case '9': DcsBios::Switch2Pos rioCap9("RIO_CAP_9", '6'); /* ***LED NOT IN USE*** */ break; case '10': DcsBios::Switch2Pos rioCapBrg0("RIO_CAP_BRG_0", 'D'); /* ***LED NOT IN USE*** */ break; case '11': DcsBios::Switch2Pos rioCapBtn1("RIO_CAP_BTN_1", 'E'); /* ***LED NOT IN USE*** */ break; case '12': DcsBios::Switch2Pos rioCapBtn2("RIO_CAP_BTN_2", 'F'); /* ***LED NOT IN USE*** */ break; case '13': DcsBios::Switch2Pos rioCapBtn3("RIO_CAP_BTN_3", '7'); /* ***LED NOT IN USE*** */ break; case '14': DcsBios::Switch2Pos rioCapBtn4("RIO_CAP_BTN_4", '8'); /* ***LED NOT IN USE*** */ break; case '15': DcsBios::Switch2Pos rioCapBtn5("RIO_CAP_BTN_5", '9'); /* ***LED NOT IN USE*** */ break; case '16': DcsBios::Switch2Pos rioCapBtn6("RIO_CAP_BTN_6", 'G'); /* ***LED NOT IN USE*** */ break; case '17': DcsBios::Switch2Pos rioCapBtn7("RIO_CAP_BTN_7", 'H'); /* ***LED NOT IN USE*** */ break; case '18': DcsBios::Switch2Pos rioCapBtn8("RIO_CAP_HDG_8", 'I'); /* ***LED NOT IN USE*** */ break; case '19': DcsBios::Switch2Pos rioCapBtn9("RIO_CAP_HDG_9", '*'); /* ***LED NOT IN USE*** */ break; case '20': DcsBios::Switch2Pos rioCapBtn10("RIO_CAP_BTN_10", '0'); /* ***LED NOT IN USE*** */ break; case '21': DcsBios::Switch2Pos rioCapClear("RIO_CAP_CLEAR", '#'); /* ***LED NOT IN USE*** */ break; case '22': DcsBios::Switch2Pos rioCapSw("RIO_CAP_SW", 'J'); /* ***LED NOT IN USE*** */ break; case '23': DcsBios::Switch2Pos rioCapNe("RIO_CAP_NE", 'K'); /* ***LED NOT IN USE*** */ break; case '24': DcsBios::Switch2Pos rioCapEnter("RIO_CAP_ENTER", 'L'); /* ***LED NOT IN USE*** */ break; case '25': DcsBios::Switch2Pos rioRadarPdsrch("RIO_RADAR_PDSRCH", 'M'); /* ***LED NOT IN USE*** */ break; case '26': DcsBios::Switch2Pos rioRadarRws("RIO_RADAR_RWS", 'N'); /* ***LED NOT IN USE*** */ break; case '27': DcsBios::Switch2Pos rioRadarTwsauto("RIO_RADAR_TWSAUTO", 'O'); /* ***LED NOT IN USE*** */ break; case '28': DcsBios::Switch2Pos rioRadarTwsman("RIO_RADAR_TWSMAN", 'P'); /* ***LED NOT IN USE*** */ break; case '29': DcsBios::Switch2Pos rioRadarPulse("RIO_RADAR_PULSE", 'Q'); /* ***LED NOT IN USE*** */ break; } } } Had to disconnect physically RS485 and all common gnd and 5v for it to allow connection. No affect in game. Rx light flashes when sending message through serial plotter. DCS BIOS shows connected on cockpit and com port. I am using the DCS BIOS library that has this logo: null I understand there is more than one, can't remember where I got mine for the life of me. Is there a good and a bad one? Are they all identical just managed by different people? Edit: Found this in the documentation: https://github.com/dcs-bios/dcs-bios/releases/tag/v0.10.0 Edited October 1, 2024 by LewisR Found link
No1sonuk Posted October 1, 2024 Posted October 1, 2024 7 minutes ago, LewisR said: I am using the DCS BIOS library that has this logo: null I understand there is more than one, can't remember where I got mine for the life of me. Is there a good and a bad one? Are they all identical just managed by different people? Edit: Found this in the documentation: https://github.com/dcs-bios/dcs-bios/releases/tag/v0.10.0 This is most likely your problem. The "HUB" version of DCS-BIOS hasn't been properly maintained for literally years. I wish there was a way to disable that site... You'll need to uninstall that completely and try the "Skunkworks" fork from here: https://github.com/DCS-Skunkworks
LewisR Posted October 1, 2024 Author Posted October 1, 2024 1 minute ago, No1sonuk said: This is most likely your problem. The "HUB" version of DCS-BIOS hasn't been properly maintained for literally years. I wish there was a way to disable that site... You'll need to uninstall that completely and try the "Skunkworks" fork from here: https://github.com/DCS-Skunkworks Are the commands the same or am I in for a treat re-writing it all?
No1sonuk Posted October 1, 2024 Posted October 1, 2024 4 minutes ago, LewisR said: Are the commands the same or am I in for a treat re-writing it all? SHOULD be the same - primarily because I think the F-14 would have been added to HUB by the Skunkworks guys. There are a few differences, but they're primarily added to the original for backwards-compatability. e.g. Hub doesn't allow adding the "true" parameter to the LED class to make an active-low LED, rather than the default active-high. That was added to the Skunkworks library (which is now available in the Arduino IDE library manager). BTW, the Skunkworks fork has a Discord for support, etc. https://discord.gg/f3P58MHK There's a setup guide here: While the guy annoys me somewhat, and uses some coding techniques that aren't wonderful, the basics are there.
LewisR Posted October 1, 2024 Author Posted October 1, 2024 5 minutes ago, No1sonuk said: While the guy annoys me somewhat, and uses some coding techniques that aren't wonderful, the basics are there. Yeah some of his stuff annoyed me two like insisting on naming each pin to a variable and then writing that into the command lines. Pointless extra effort, especially if you need to change pin functions. Thanks for all the help so far, I’ll give it a go tomorrow - hopefully - and come back here with good or bad news (for me at least).
No1sonuk Posted October 1, 2024 Posted October 1, 2024 Yeah. I can understand using constants for that, but not variables.
LewisR Posted October 2, 2024 Author Posted October 2, 2024 Okay so got it running on the skunkworks fork. COM 4 connected with my Mega as master on the same setup as before. Same lights... Master: L and RX when the is game unpaused Slave 1: RX and POW bright TX dim. Slave 2: POW and RX bright TX dim. L is also lit on SLV 2 but I think that's to do with the rot encoder on pin 13 as it flashes when turning although I have it set to input in setup... I can see the bits or whatever flashing by on the cmd prompt window for "connect-serial-port.cmd" and if I use the bridge helper I can see the write mb ticking up but the read is blank. I am guessing the write is writing to the Arduino as the RX LED is flashing on the master. I will check tomorrow with my multimeter (I left it at work) to ensure I have a connection for every pin from the headers to the breakout, then the breakout to the bus bars, and then the bus bars to the components. I will also double-check all grounding and power although I feel it wouldn't start if there were a power or grounding issue. I know for certain the 3 pos switches and rotaries are functioning. I tested them before it was all assembled. I tried disconnecting all the RS485 and common GND/5V and tried an IRQSerial style sketch on both Slave 1 and Slave 2 with nothing to show for it. Feels like 1 step forward two steps back. Hopefully, the wiring checks out and I don't have to re-solder a tone of Diodes! One thing I am uncertain on and may seem an obvious blunder; I currently have the a and b lines spliced together so they basically form a triangle of cables with female duponts at each end connecting to the a and b pins on the MAX485s. Should I instead have it set up like this: MAX485_1 A PIN--->MAX485_2 A PIN then MAX485_2 A SCREW TERMINAL ---> MAX485_3 A SCREW TERMINAL? In my head, I can't see why as it looks like it is just a direct connection on the PCB from the pin to the terminal so there is nothing happening in between. And like a CANBUS it's using differential signalling so it shouldn't matter "where" the board is it just needs to send the right bits. Correct?
No1sonuk Posted October 2, 2024 Posted October 2, 2024 WRT the L light coming on - It's directly connected to pin 13 (through a current-limiting resistor), so any +5V input on that pin will turn on the light as well as output. WRT the bus: I'm not sure what you're getting at, but all the A should be connected together and all the Bs connected together, but not A to B except for bus termination. Is your issue not covered here:
LewisR Posted October 3, 2024 Author Posted October 3, 2024 (edited) 23 hours ago, No1sonuk said: WRT the bus: I'm not sure what you're getting at, but all the A should be connected together and all the Bs connected together, but not A to B except for bus termination. I cut out all the potentially problematic comms boards and am running directly on a mega now. Still no movement. I re-wrote my code to use the DCS BIOS encodes, I have checked voltages from multiple points to ensure they are not causing the issue. I even disconnected all the button matrix cables, disabled/deleted the related code, and disabled the 3 pos toggles. I know the Mega at least was good, as I used it as the test board when components were arriving in the post. I still only get the RX light when running the game and BIOS. I get this message when connecting the COM port: Enter a COM Port Number:4 Status for device COM4: ----------------------- Baud: 250000 Parity: None Data Bits: 8 Stop Bits: 1 Timeout: OFF XON/XOFF: OFF CTS handshaking: OFF DSR handshaking: OFF DSR sensitivity: OFF DTR circuit: OFF RTS circuit: OFF Waiting for 0 seconds, press a key to continue ... And the expected nonsense when the game is unpaused. Currently my code looks like this: /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Key.h> #include <Keypad.h> #include "C:\Users\lewis\Saved Games\DCS\Scripts\DCS-BIOS\doc\Addresses.h" const byte ROWS=5; const byte COLS=6; char keys[ROWS][COLS] = { {'1', '2', '3', 'A', 'B', 'C'}, {'4', '5', '6', 'D', 'E', 'F'}, {'7', '8', '9', 'G', 'H', 'I'}, {'*', '0', '#', 'J', 'K', 'L'}, {'M', 'N', 'O', 'P', 'Q', 'R'} }; byte rowPins[ROWS] = {23,24,25,26,27}; byte colPins[COLS] = {28,29,30,31,32,33}; Keypad keypad = Keypad(makeKeymap(keys), colPins, rowPins, COLS, ROWS); //paste code snippets from the reference documentation here DcsBios::Switch3Pos rioRadarVsl("RIO_RADAR_VSL", 44, 45); DcsBios::Switch2Pos rioHcuDdd("RIO_HCU_DDD", 46); DcsBios::Switch2Pos rioHcuTid("RIO_HCU_TID", 47); DcsBios::Switch2Pos rioWeaponAaLaunch("RIO_WEAPON_AA_LAUNCH", 42); DcsBios::LED rioLaunchLight1(F_14_RIO_LAUNCH_LIGHT_1_AM, 41); DcsBios::RotaryEncoder rioCapCatrgory("RIO_CAP_CATRGORY", "DEC", "INC", 52, 53); DcsBios::RotaryEncoder rioRadarAziScan("RIO_RADAR_AZI_SCAN", "DEC", "INC", 48, 49); DcsBios::RotaryEncoder rioRadarEleBars("RIO_RADAR_ELE_BARS", "DEC", "INC", 50, 51); DcsBios::Potentiometer rioRadarEleCenter("RIO_RADAR_ELE_CENTER", A1); DcsBios::Potentiometer rioRadarAziCenter("RIO_RADAR_AZI_CENTER", A2); void setup() { DcsBios::setup(); Serial2.begin(9600); // Initialize serial communication for (int i = 0; i < COLS; i++) { pinMode(colPins[i], INPUT_PULLUP); } pinMode(41, OUTPUT); } void loop() { DcsBios::loop(); for (int i = 0; i < ROWS; i++) { Serial2.print("Row "); Serial2.print(i); Serial2.print(": "); Serial2.println(digitalRead(rowPins[i])); } // Test column states for (int j = 0; j < COLS; j++) { Serial2.print("Column "); Serial2.print(j); Serial2.print(": "); Serial2.println(digitalRead(colPins[j])); } char key1 = keypad.getKey(); if (key1) { Serial2.print("Key pressed: "); Serial2.println(key1); // Print the key that was pressed switch (key1){ case '1': DcsBios::Switch2Pos rioCapLat1("RIO_CAP_LAT_1", '1'); /* ***LED NOT IN USE*** */ break; case '2': DcsBios::Switch2Pos rioCapNbr2("RIO_CAP_NBR_2", '2'); /* ***LED NOT IN USE*** */ break; case '3': DcsBios::Switch2Pos rioCapSpd3("RIO_CAP_SPD_3", '3'); /* ***LED NOT IN USE*** */ break; case '4': DcsBios::Switch2Pos rioCapAlt4("RIO_CAP_ALT_4", 'A'); /* ***LED NOT IN USE*** */ break; case '5': DcsBios::Switch2Pos rioCapRng5("RIO_CAP_RNG_5", 'B'); /* ***LED NOT IN USE*** */ break; case '6': DcsBios::Switch2Pos rioCapLong6("RIO_CAP_LONG_6", 'C'); /* ***LED NOT IN USE*** */ break; case '7': DcsBios::Switch2Pos rioCap7("RIO_CAP_7", '4'); /* ***LED NOT IN USE*** */ break; case '8': DcsBios::Switch2Pos rioCapHdg8("RIO_CAP_HDG_8", '5'); /* ***LED NOT IN USE*** */ break; case '9': DcsBios::Switch2Pos rioCap9("RIO_CAP_9", '6'); /* ***LED NOT IN USE*** */ break; case '10': DcsBios::Switch2Pos rioCapBrg0("RIO_CAP_BRG_0", 'D'); /* ***LED NOT IN USE*** */ break; case '11': DcsBios::Switch2Pos rioCapBtn1("RIO_CAP_BTN_1", 'E'); /* ***LED NOT IN USE*** */ break; case '12': DcsBios::Switch2Pos rioCapBtn2("RIO_CAP_BTN_2", 'F'); /* ***LED NOT IN USE*** */ break; case '13': DcsBios::Switch2Pos rioCapBtn3("RIO_CAP_BTN_3", '7'); /* ***LED NOT IN USE*** */ break; case '14': DcsBios::Switch2Pos rioCapBtn4("RIO_CAP_BTN_4", '8'); /* ***LED NOT IN USE*** */ break; case '15': DcsBios::Switch2Pos rioCapBtn5("RIO_CAP_BTN_5", '9'); /* ***LED NOT IN USE*** */ break; case '16': DcsBios::Switch2Pos rioCapBtn6("RIO_CAP_BTN_6", 'G'); /* ***LED NOT IN USE*** */ break; case '17': DcsBios::Switch2Pos rioCapBtn7("RIO_CAP_BTN_7", 'H'); /* ***LED NOT IN USE*** */ break; case '18': DcsBios::Switch2Pos rioCapBtn8("RIO_CAP_HDG_8", 'I'); /* ***LED NOT IN USE*** */ break; case '19': DcsBios::Switch2Pos rioCapBtn9("RIO_CAP_HDG_9", '*'); /* ***LED NOT IN USE*** */ break; case '20': DcsBios::Switch2Pos rioCapBtn10("RIO_CAP_BTN_10", '0'); /* ***LED NOT IN USE*** */ break; case '21': DcsBios::Switch2Pos rioCapClear("RIO_CAP_CLEAR", '#'); /* ***LED NOT IN USE*** */ break; case '22': DcsBios::Switch2Pos rioCapSw("RIO_CAP_SW", 'J'); /* ***LED NOT IN USE*** */ break; case '23': DcsBios::Switch2Pos rioCapNe("RIO_CAP_NE", 'K'); /* ***LED NOT IN USE*** */ break; case '24': DcsBios::Switch2Pos rioCapEnter("RIO_CAP_ENTER", 'L'); /* ***LED NOT IN USE*** */ break; case '25': DcsBios::Switch2Pos rioRadarPdsrch("RIO_RADAR_PDSRCH", 'M'); /* ***LED NOT IN USE*** */ break; case '26': DcsBios::Switch2Pos rioRadarRws("RIO_RADAR_RWS", 'N'); /* ***LED NOT IN USE*** */ break; case '27': DcsBios::Switch2Pos rioRadarTwsauto("RIO_RADAR_TWSAUTO", 'O'); /* ***LED NOT IN USE*** */ break; case '28': DcsBios::Switch2Pos rioRadarTwsman("RIO_RADAR_TWSMAN", 'P'); /* ***LED NOT IN USE*** */ break; case '29': DcsBios::Switch2Pos rioRadarPulse("RIO_RADAR_PULSE", 'Q'); /* ***LED NOT IN USE*** */ break; } } } While writing this up I decided to plug my launch button into my uno and just have that scripted and it worked. So I tried the same on my mega, and it worked. However, it only works with the new sketch, not the old for some reason. I re-wrote all the code into a new sketch and it all works bar my button matrix! Button matrix maybe a hardware issue though as I am getting ~5 volts on some cables to Gnd but not others. Edited October 3, 2024 by LewisR Code
LewisR Posted October 4, 2024 Author Posted October 4, 2024 RESOLVED: No TX issue was resolved using a fresh sketch file after removing the Nanos and MAX485s and running it all on one Mega. I assume there must have been something lingering in the file somehow, but I'm not certain. I will revisit this one day to add the Nanos back in and see how they act on fresh sketches. Button Matrix not TXing resolved by "inverting" the whole button matrix. Rokreder on the Skunkworks Discord pointed me in the right direction regarding that. Incorrect presses were a matter of ensuring the cases were properly assigned on the sketch. Thanks, No1sonuk for all the help.
Recommended Posts