Jump to content

DCS-BIOS: Sending a Keypad Matrix' Output via RS485


Tekkx

Recommended Posts

Oh. I failed myself: D2 to D13 are 12 I/Os.

Your answer is close, but false. "42" (not "41") is the answer to “life, the universe and everything”.

 

With 11 I/Os you can make 5x6=30 Inputs

With 12 I/Os you can make 6x6=36 Inputs

 

Connect a Pot like this:

Left leg (or left lead out): to GND

Right leg: to 5V

Center leg: to analog Pin of Arduino

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

Oh. I failed myself: D2 to D13 are 12 I/Os.

Your answer is close, but false. "42" (not "41") is the answer to “life, the universe and everything”.

 

With 11 I/Os you can make 5x6=30 Inputs

With 12 I/Os you can make 6x6=36 Inputs

 

Connect a Pot like this:

Left leg (or left lead out): to GND

Right leg: to 5V

Center leg: to analog Pin of Arduino

 

Thanks for your help Tekkx,

 

Now to make the matrix!

Link to comment
Share on other sites

  • 4 weeks later...

Obviously it doesn't work!

 

2I0y1iq.jpg

 

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

 

DcsBios::Switch2Pos ufc1("UFC_1", 5);

DcsBios::Switch2Pos ufc2("UFC_2", 6);

DcsBios::Switch2Pos ufc3("UFC_3", 7);

DcsBios::Switch2Pos ufc4("UFC_4", 5,9);

DcsBios::Switch2Pos ufc5("UFC_5", 6,9);

DcsBios::Switch2Pos ufc6("UFC_6", 7,9);

DcsBios::Switch2Pos ufc7("UFC_7", 5,10);

DcsBios::Switch2Pos ufc8("UFC_8", 6,10);

DcsBios::Switch2Pos ufc9("UFC_9", 7,10);

DcsBios::Switch2Pos ufcSpc("UFC_SPC", 5,11);

DcsBios::Switch2Pos ufcClr("UFC_CLR", 6,11);

DcsBios::Switch2Pos ufc10("UFC_10", 7,11);

 

 

 

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

Your schematic had a diode in order to press two buttons at once? I might have bitten off more than I can chew with DCS Bios and Matrixs!

Link to comment
Share on other sites

Hallo, Mr_Burns. Glad to see, you not surrendered yet. :)

 

As the wires at your Photo are a little bit cluttered, I just assume everything is OK. One Leg of a Button/Switch is connected to Row, the other Leg is connected to Column?

I can't see, what the two blue wires (some longer than the others) are for.

Diodes are just for pressing more than one Button at one time. I suggest, to let them out. Just for the beginners phase!

 

The Switch2Pos-Function (or -Methode?) is not appropriate here. Also it can just read ONE Pin (Pin" means a real physical pin of the Arduino. In a Matrix this works a little bit different.):

DcsBios::Switch2Pos ufc6("UFC_6", PIN);

This is an example copied out of the http://dcs-bios.a10c.de/docs/v0.5.0/control-reference.html. As you'll see, there is just one PIN variable used.

 

 

 

sendDcsBiosMessage("UFC_6", "1");

This is an example of code, I used in the matrix.

There are some differences to the first example:

First: It is not linked to a PIN, but it sends a command to DCS each time it is called. In the example it says: "Push Button 6 of the UFC!".

Second: It says just "push" as there is noted "1" (for "Push"). Release the Button will be another command. ("0" is here for "Release")

Look at former posts of this Thread:

You have to define a Matrix also inside your code. Otherwise Arduino do not know what to do.

You have to write some code to tell trhe Arduino under wich circumstances (condition) it has to send "Push the Button" (or: "Release the Button").

 

This is all done inside the code example somewhere at the start of this Thread. Look there.

 

And: Hang on!!!! Someday you'll get it!

 

What kind of Plane to do want to control with your device? You UFC-examples are of the A-10C.


Edited by Tekkx

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

That might be the problem, both column and row are connected to one side of the button, ground (the blue) to the other side.

 

So Arduin doesn't need a ground to complete a circuit?

 

When using the Arduino to implement a matrix, you are using the row as the supply and the column as the ground (or vice versa). Pressing a button completes the circuit.

 

The logic implemented in the matrix handling class is:

 

for each row
{
 set the output high
 for each column
 {
   if the input is now high (because a switch has closed the circuit)
   {
     set a flag to indicate that the appropriate key has been pressed based on the row and column
   }
 }
}

 

This explains it really well: https://www.baldengineer.com/arduino-keyboard-matrix-tutorial.html

 

Here is a very simple example, hooking up the 4 N, S, E, W buttons from the UFC.

 

hqEhnoQ

 

You would connect on pin from the N key to D0 and the other to D2

You would connect on pin from the S key to D1 and the other to D2

You would connect on pin from the E key to D0 and the other to D3

You would connect on pin from the W key to D1 and the other to D3

 

The logic is exactly the same as you make the matrix larger.

Note also that for the UFC you would only use the matrix for the (momentary) push button switches.

For the 2 position and 3 position switches you are going to need to use 1 and 2 extra digital input pins respectively for each switch.


Edited by Bullant

Intel i7 13700K @ 5.3 GHz / ASUS TUF Gaming Z490-Plus / 64 Gb G.Skill DDR4-3600 / RTX 4090 / 2TB Kingston KC3000 NVME / Win 10 x64 Pro / Pimax Crystal / WINWING F/A-18 HOTAS

A-10C, AJS-37, AV-8B, F-4E, F-5E, F-14, F-15E, F-16, F/A-18C, F-86F, FC3, Christen Eagle 2, FW190D-9, Mosquito, P-47D, P-51D, Spitfire, AH-64D, KA-50, UH-1H

Combined Arms, WWII Asset Pack, China Assets Pack, Super Carrier, Falklands Assets

Nevada, Normandy, Persian Gulf, The Channel, Syria, Mariana Islands, South Atlantic, Sinai

Link to comment
Share on other sites

...

So Arduin doesn't need a ground to complete a circuit?

No and Yes. :)

 

It's understood, you'll need two points to close a "circuit". It's all relative. But it's going too far, if I start to explain the nature of Logic-Levels. It's not my natural environment and ... not my language. So you have to trust me. :)

Spoken in "Arduino": You will have to connect your wire to something like a Ground-Potential ("Ground" means here: a few Volts lower than the Output) to pull down an Output.

 

If you have a Matrix there happens something similar: You connect two wires of different Voltage-Level (Potential). If you connect two wires of your Matrix, Arduino will interprete this (if there is the adequate code running) as pushing a certain button.

 

Short answer: Don't care for Ground! Keypad-Library will do that for you.

 

edit: Thank you, Andrew. You already sent your post as I was still typing. :)

Manual for my version of RS485-Hardware, contact: tekkx@dresi.de

Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You.

Link to comment
Share on other sites

I am building up an excel spreadsheet right now to work out how many of each type of switch/pot/encoder etc I will need.

 

For your UFC/HUD control as posted on the previous page, by my calculations you will need:

 

26 momentary push buttons which can use a 6 x 5 keyboard matrix and therefore only use 11 pins.

10 two position switches (10 more pins, with the other leg of each switch connected to ground). 4 of these are for the comms volume, HUD brightness and AOA brightness pots that will need to have an integrated switch for the OFF position.

2 three positions switches (4 more pins)

2 rotary encoders (4 more pins)

 

That gives a total of 29 digital I/O pins.

You will also need 7 analog inputs for the 7 pots.

 

A uno isn't going to cut it, will need to move up to a Mega or use two unos and split the functions across the two boards.

Intel i7 13700K @ 5.3 GHz / ASUS TUF Gaming Z490-Plus / 64 Gb G.Skill DDR4-3600 / RTX 4090 / 2TB Kingston KC3000 NVME / Win 10 x64 Pro / Pimax Crystal / WINWING F/A-18 HOTAS

A-10C, AJS-37, AV-8B, F-4E, F-5E, F-14, F-15E, F-16, F/A-18C, F-86F, FC3, Christen Eagle 2, FW190D-9, Mosquito, P-47D, P-51D, Spitfire, AH-64D, KA-50, UH-1H

Combined Arms, WWII Asset Pack, China Assets Pack, Super Carrier, Falklands Assets

Nevada, Normandy, Persian Gulf, The Channel, Syria, Mariana Islands, South Atlantic, Sinai

Link to comment
Share on other sites

OK thanks guys. So that top row where i have no column just D1,2 and 3 will need a column (say D8).

 

I might use 2 or get a Mega, after this small test I though about just wiring everything to a GGG and Nano but I am trying to get the F/A-18 HUD as thin as possible so I can use a monitor to give it its displays (as well as the MFD and engine Data)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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