Jump to content
Forum Maintenance between 04:00 - 06:00 UTC ×
Forum Maintenance between 04:00 - 06:00 UTC

A-10C CDU


Deadlyrider19

Recommended Posts

Hey guys,

I'm building the CDU for my A-10C.

I have arduino code for the buttons. All the inputs get stored in a array.

I want to send that data to dcsbios, but I dont know what the best option is here.

I can just repeat DcsBios::Switch2Pos cduX("CDU_X", PIN); for every buton, but that is a lot of code and maybe a lot of delay.

Is there a way that i can send arrays to dcsbios?

Link to comment
Share on other sites

I have my CDU set up exactly like that, with a PCB that connects directly to a Mega on the back of it.

Here's my code (for the RS485 version)

//#define DCSBIOS_DEFAULT_SERIAL

#define DCSBIOS_RS485_SLAVE 74
#define TXENABLE_PIN 2
#include <Wire.h>

//#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>



DcsBios::Switch2Pos cdu0("CDU_0", 36);

DcsBios::Switch2Pos cdu1("CDU_1", 6);

DcsBios::Switch2Pos cdu2("CDU_2", 13);

DcsBios::Switch2Pos cdu3("CDU_3", 12);

DcsBios::Switch2Pos cdu4("CDU_4", 17);

DcsBios::Switch2Pos cdu5("CDU_5", 16);

DcsBios::Switch2Pos cdu6("CDU_6", 14);

DcsBios::Switch2Pos cdu7("CDU_7", 38);

DcsBios::Switch2Pos cdu8("CDU_8", 48);

DcsBios::Switch2Pos cdu9("CDU_9", 50);

DcsBios::Switch2Pos cduA("CDU_A", 10);

DcsBios::Switch2Pos cduB("CDU_B", 8);

DcsBios::Switch2Pos cduBck("CDU_BCK", 55);

DcsBios::Switch3Pos cduBrt("CDU_BRT", 33, 31);

DcsBios::Switch2Pos cduC("CDU_C", 4);

DcsBios::Switch2Pos cduClr("CDU_CLR", 62);

DcsBios::Switch2Pos cduD("CDU_D", 18);

DcsBios::Switch3Pos cduData("CDU_DATA", 69, 52);

DcsBios::Switch2Pos cduE("CDU_E", 19);

DcsBios::Switch2Pos cduF("CDU_F", 20);

DcsBios::Switch2Pos cduFa("CDU_FA", 65);

DcsBios::Switch2Pos cduFpm("CDU_FPM", 37);

DcsBios::Switch2Pos cduG("CDU_G", 11);

DcsBios::Switch2Pos cduH("CDU_H", 7);

DcsBios::Switch2Pos cduI("CDU_I", 3);

DcsBios::Switch2Pos cduJ("CDU_J", 24);

DcsBios::Switch2Pos cduK("CDU_K", 26);

DcsBios::Switch2Pos cduL("CDU_L", 30);

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", 49);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", 29);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", 51);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", 25);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", 47);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", 27);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", 53);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", 23);

DcsBios::Switch2Pos cduM("CDU_M", 15);

DcsBios::Switch2Pos cduMk("CDU_MK", 44);

DcsBios::Switch2Pos cduN("CDU_N", 9);

//DcsBios::Switch2Pos cduNa1("CDU_NA1", 56);

//DcsBios::Switch2Pos cduNa2("CDU_NA2", 57);

DcsBios::Switch2Pos cduNav("CDU_NAV", 43);

DcsBios::Switch2Pos cduO("CDU_O", 5);

DcsBios::Switch2Pos cduOset("CDU_OSET", 39);

DcsBios::Switch2Pos cduP("CDU_P", 22);

DcsBios::Switch3Pos cduPg("CDU_PG", 42, 40);

DcsBios::Switch2Pos cduPoint("CDU_POINT", 32);

DcsBios::Switch2Pos cduPrev("CDU_PREV", 35);

DcsBios::Switch2Pos cduQ("CDU_Q", 61);

DcsBios::Switch2Pos cduR("CDU_R", 28);

DcsBios::Switch2Pos cduS("CDU_S", 46);

DcsBios::Switch3Pos cduScroll("CDU_SCROLL", 56, 57);

DcsBios::Switch2Pos cduSlash("CDU_SLASH", 34);

DcsBios::Switch2Pos cduSpc("CDU_SPC", 59);

DcsBios::Switch2Pos cduSys("CDU_SYS", 45);

DcsBios::Switch2Pos cduT("CDU_T", 58);

DcsBios::Switch2Pos cduU("CDU_U", 60);

DcsBios::Switch2Pos cduV("CDU_V", 67);

DcsBios::Switch2Pos cduW("CDU_W", 66);

DcsBios::Switch2Pos cduWp("CDU_WP", 41);

DcsBios::Switch2Pos cduX("CDU_X", 63);

DcsBios::Switch2Pos cduY("CDU_Y", 64);

DcsBios::Switch2Pos cduZ("CDU_Z", 68);



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

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

As you can see, apart from the rocker type switches, each individual button is allocated a pin number. You just have to modify that for your array

Cheers


Les

Link to comment
Share on other sites

5 hours ago, lesthegrngo said:

I have my CDU set up exactly like that, with a PCB that connects directly to a Mega on the back of it.

Here's my code (for the RS485 version)

//#define DCSBIOS_DEFAULT_SERIAL

#define DCSBIOS_RS485_SLAVE 74
#define TXENABLE_PIN 2
#include <Wire.h>

//#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>



DcsBios::Switch2Pos cdu0("CDU_0", 36);

DcsBios::Switch2Pos cdu1("CDU_1", 6);

DcsBios::Switch2Pos cdu2("CDU_2", 13);

DcsBios::Switch2Pos cdu3("CDU_3", 12);

DcsBios::Switch2Pos cdu4("CDU_4", 17);

DcsBios::Switch2Pos cdu5("CDU_5", 16);

DcsBios::Switch2Pos cdu6("CDU_6", 14);

DcsBios::Switch2Pos cdu7("CDU_7", 38);

DcsBios::Switch2Pos cdu8("CDU_8", 48);

DcsBios::Switch2Pos cdu9("CDU_9", 50);

DcsBios::Switch2Pos cduA("CDU_A", 10);

DcsBios::Switch2Pos cduB("CDU_B", 8);

DcsBios::Switch2Pos cduBck("CDU_BCK", 55);

DcsBios::Switch3Pos cduBrt("CDU_BRT", 33, 31);

DcsBios::Switch2Pos cduC("CDU_C", 4);

DcsBios::Switch2Pos cduClr("CDU_CLR", 62);

DcsBios::Switch2Pos cduD("CDU_D", 18);

DcsBios::Switch3Pos cduData("CDU_DATA", 69, 52);

DcsBios::Switch2Pos cduE("CDU_E", 19);

DcsBios::Switch2Pos cduF("CDU_F", 20);

DcsBios::Switch2Pos cduFa("CDU_FA", 65);

DcsBios::Switch2Pos cduFpm("CDU_FPM", 37);

DcsBios::Switch2Pos cduG("CDU_G", 11);

DcsBios::Switch2Pos cduH("CDU_H", 7);

DcsBios::Switch2Pos cduI("CDU_I", 3);

DcsBios::Switch2Pos cduJ("CDU_J", 24);

DcsBios::Switch2Pos cduK("CDU_K", 26);

DcsBios::Switch2Pos cduL("CDU_L", 30);

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", 49);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", 29);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", 51);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", 25);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", 47);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", 27);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", 53);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", 23);

DcsBios::Switch2Pos cduM("CDU_M", 15);

DcsBios::Switch2Pos cduMk("CDU_MK", 44);

DcsBios::Switch2Pos cduN("CDU_N", 9);

//DcsBios::Switch2Pos cduNa1("CDU_NA1", 56);

//DcsBios::Switch2Pos cduNa2("CDU_NA2", 57);

DcsBios::Switch2Pos cduNav("CDU_NAV", 43);

DcsBios::Switch2Pos cduO("CDU_O", 5);

DcsBios::Switch2Pos cduOset("CDU_OSET", 39);

DcsBios::Switch2Pos cduP("CDU_P", 22);

DcsBios::Switch3Pos cduPg("CDU_PG", 42, 40);

DcsBios::Switch2Pos cduPoint("CDU_POINT", 32);

DcsBios::Switch2Pos cduPrev("CDU_PREV", 35);

DcsBios::Switch2Pos cduQ("CDU_Q", 61);

DcsBios::Switch2Pos cduR("CDU_R", 28);

DcsBios::Switch2Pos cduS("CDU_S", 46);

DcsBios::Switch3Pos cduScroll("CDU_SCROLL", 56, 57);

DcsBios::Switch2Pos cduSlash("CDU_SLASH", 34);

DcsBios::Switch2Pos cduSpc("CDU_SPC", 59);

DcsBios::Switch2Pos cduSys("CDU_SYS", 45);

DcsBios::Switch2Pos cduT("CDU_T", 58);

DcsBios::Switch2Pos cduU("CDU_U", 60);

DcsBios::Switch2Pos cduV("CDU_V", 67);

DcsBios::Switch2Pos cduW("CDU_W", 66);

DcsBios::Switch2Pos cduWp("CDU_WP", 41);

DcsBios::Switch2Pos cduX("CDU_X", 63);

DcsBios::Switch2Pos cduY("CDU_Y", 64);

DcsBios::Switch2Pos cduZ("CDU_Z", 68);



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

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

As you can see, apart from the rocker type switches, each individual button is allocated a pin number. You just have to modify that for your array

Cheers


Les

okay thank you. I'm afraid that using that method results in a massive delay between button presses. I guess it is just testing out and seeing what the results are.

Link to comment
Share on other sites

Do you mean you are worried about my method giving delays? If so no need to worry as it is instantaneous, only one or two buttons ever get pressed at once

another way to deal with it is to use a Bodnar BBI-64 , I used it before changing to the Mega version (for packaging reasons) and it is a really good solution as long as you are ok with all the spaghetti 

cheers 

Les


Edited by lesthegrngo
Link to comment
Share on other sites

1 hour ago, lesthegrngo said:

Do you mean you are worried about my method giving delays? If so no need to worry as it is instantaneous, only one or two buttons ever get pressed at once

another way to deal with it is to use a Bodnar BBI-64 , I used it before changing to the Mega version (for packaging reasons) and it is a really good solution as long as you are ok with all the spaghetti 

cheers 

Les

 

Yes i was worried about giving it a delay, because it needs to send like 68 bits of data whenever you press a button. If you say it's instant then i trust that. Thank you for the information.

 

Just to be sure. Do you know if it is the same with a arduino nano. I have no clue if the processor of the arduino nano is (almost) as fast as the arduino mega.


Edited by Deadlyrider19
Link to comment
Share on other sites

37 minutes ago, lesthegrngo said:

As you are only pressing one button, therefore it is not having to process tons of information at the same time, I am pretty confident it should be OK - I am certain that Vinc or No1SonUK can confirm

Les

okay thank you very much for your help

Link to comment
Share on other sites

  • 2 weeks later...

Let me introduce you to SendDcsBiosMessage...

This magic function is what's at the bottom of all the other functions like switch2pos, etc.

So for example:

SendDcsBiosMessage ("CDU_V", "1");  // This tells DCS that CDU button V has been pressed.

SendDcsBiosMessage ("CDU_V", "0");  // This tells DCS that CDU button V has been released.

You could write your code to use this using switch/case code

 

Link to comment
Share on other sites

  Edited:

 

7 hours ago, lesthegrngo said:

Would you need a #define pin x statement?

Les

 

No, it's just a "send command" in text form like this

DcsBios::tryToSendDcsBiosMessage("FSCP_BOOST_MAIN_L", "1");

The pins have to be declared and read within normal Arduino code. Than and under defined conditions (pin high or low) the command will be send.

 

Now that I'm back at my laptop, I may give further hints. If you follow the sketchbook entry for the 16bit expander, you'll see a few more examples on how to use such code. Beware of that the text messages to DcsBios only have to be send if a signal has changed (e.g. switch to a new position), else it may block the bus traffic.

 

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 hours ago, Vinc_Vega said:

No, it's just a "send command" in text form like this

DcsBios::tryToSendDcsBiosMessage("FSCP_BOOST_MAIN_L", "1");

 

I'm pretty sure the "DcsBios::" is not required.  I don't remember using it with this function. SendDcsBiosMessage is a bottom level function.

IIRC, "SendDcsBiosMessage" will wait until DCS confirms it has received the message, but "tryToSendDcsBiosMessage" doesn't wait.

  • Thanks 1
Link to comment
Share on other sites

Just got back from business travel so my mind is a bit slow - the "1" in the code below is the pin selection?

9 hours ago, No1sonuk said:
DcsBios::tryToSendDcsBiosMessage("FSCP_BOOST_MAIN_L", "1");

I read the 

SendDcsBiosMessage ("CDU_V", "1");  // This tells DCS that CDU button V has been pressed.

SendDcsBiosMessage ("CDU_V", "0");  // This tells DCS that CDU button V has been released.

 

where "1" meant switch on and "0" was switch off in a digital sense, so I think I was confusing myself

Les

Link to comment
Share on other sites

You understood almost right, there are no pins within the text statement. But the switch position statement even for the multi pos switches may reach from 0 to more than 1. So it isn't really digital. Follow the above linked expander example and have a look at the Frequency Selection Dial switch. It has 4 positions to send (0 to 3).

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

This is 3-position code with previous state checking:
 

/*
  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"

int LandLightSWprevState = 1;
int LandLightSWstate = 1;

#define LandLightPin 3
#define TaxiLightPin 2

/* paste code snippets from the reference documentation here */


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

  pinMode ( LandLightPin, INPUT_PULLUP);
  pinMode ( TaxiLightPin, INPUT_PULLUP);
}

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

  LandLightSW();

}

void LandLightSW () {
  LandLightSWstate = 1;

  if (digitalRead(LandLightPin) == LOW) {LandLightSWstate = 2;}
  else if (digitalRead(TaxiLightPin) == LOW) {LandLightSWstate = 0;}

  if (LandLightSWstate != LandLightSWprevState){
    
    char buffer[2];         //the ASCII of the integer will be stored in this char array
    utoa(LandLightSWstate,buffer,10); //(integer, yourBuffer, base)

    sendDcsBiosMessage ("LANDING_LIGHTS", buffer);

    LandLightSWprevState = LandLightSWstate ;
    
    }


}

This is for the A-10 landing/taxi light switch.  It has no debouncing code, so be careful if that's a problem.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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