Jump to content

Major Announcement: New software to to connect panels to DCS


FSFIan

Recommended Posts

Tried a new mega. Got the pot to respond. For a while! Then same thing. Quit game. Started game again. Respond for a while. Changing physical pots or pins or even arduino cards and still the pots seem to respond only for a while in the game. Even isolating all or switches and just having one pot and nothing else connected and code for all other switches commented out.

 

If any of you managed to get pots working consistently without failing please share your two cents.

 

I've wired and tested six panels so far. Toggles, push buttons, rotary switches are all fine, except pots.

 

One potential solution if you would be willing to do a pit that uses other systems together with DCS-BIOS is using a Teensy as a USB joystick. Here's a pretty good video going through the process of setting that up:

Link to comment
Share on other sites

  • Replies 398
  • Created
  • Last Reply

Top Posters In This Topic

Tried a new mega. Got the pot to respond. For a while! Then same thing. Quit game. Started game again. Respond for a while. Changing physical pots or pins or even arduino cards and still the pots seem to respond only for a while in the game. Even isolating all or switches and just having one pot and nothing else connected and code for all other switches commented out.

 

If any of you managed to get pots working consistently without failing please share your two cents.

 

I've wired and tested six panels so far. Toggles, push buttons, rotary switches are all fine, except pots.

 

What value is the potentiometer that your using?

Link to comment
Share on other sites

if make a UFC panel, there are need 36 input and output signal include button and led, how can i make them in ONE uno r3, is it possible ?

 

Yes. See Wikipedia: Keyboard Matrix Circuit. You won't need a diode for each button because none of these will be pressed simultaneously anyway.

 

There are existing Arduino libraries that make it easier to work with a keyboard matrix.

 

You will need to write some code to send the right command to DCS-BIOS when you get a key pressed or key released event. The DCS-BIOS Developer Guide describes how the import protocol works (i.e. what strings you have to send over the serial port). You can also look at this example of connecting a PS/2 keyboard to the CDU for inspiration.

Link to comment
Share on other sites

Should the CDU and Caution light panels use matrix as well? Both require too many pins.

 

Yes. For the Caution Lights panel, you should look into a separate LED matrix driver chip like the MAX7219. These have an integrated, software-controllable constant current drive, so you can have programmable display brightness.

Link to comment
Share on other sites

no one else tried hooking up pots through dcs bios? if so what's your take on pots?

 

i had no problems with 1k but it's been a while and my panel is disassembled right now. Ill see if I can reproduce your issue if I get some time.

Link to comment
Share on other sites

Ian;2342118']Yes. See Wikipedia: Keyboard Matrix Circuit. You won't need a diode for each button because none of these will be pressed simultaneously anyway.

 

There are existing Arduino libraries that make it easier to work with a keyboard matrix.

 

You will need to write some code to send the right command to DCS-BIOS when you get a key pressed or key released event. The DCS-BIOS Developer Guide describes how the import protocol works (i.e. what strings you have to send over the serial port). You can also look at this example of connecting a PS/2 keyboard to the CDU for inspiration.

 

Thanks, "Connect a PS/2 keyboard to your CDU with an Arduino and DCS-BIOS " is very very useful for me.

 

:smilewink:

Link to comment
Share on other sites

Help to get Gear up/dn to switch Bf 109K4

 

Hello

 

maybe someone can help me. I like to get the Gear up/down function of the Bf 109K4 module to a switch. I like to this with dcs bios and thats why i have to write the code. At this time i get out the toogle function, warninglights and information for some servos. This was possible with major help of Ian because I am a programing noob. Here is some code from the clickable lua of the Bf 109 K4 modul.

 

1. definition of the default 1 position tumb

 

function default_1_position_tumb ( hint_, device_, command_, arg_, arg_val_, arg_lim_ )

local arg_val_ = arg_val_ or 1

local arg_lim_ = arg_lim_ or {0, 1}

return {

class = {class_type.TUMB},

hint = hint_,

device = device_,

action = {command_},

arg = {arg_},

arg_value = {arg_val_},

arg_lim = {arg_lim_},

updatable = true,

use_OBB = true

 

2. specific function which i like to get out and connecting a switch to it ( undercarriage up/dn)

 

-- Main Panel Controls

-- Undercarriage Controls

-- U/C Plungers Cover

elements["UC_COVER"] = default_2_position_tumb(_("Undercarriage Controls Cover"), devices.CONTROLS, device_commands.Button_39, 53)

elements["UC_COVER"].sound = {{SOUND_METALLIC_TAB, SOUND_METALLIC_TAB}, {SOUND_METALLIC_TAB, SOUND_METALLIC_TAB}}

-- U/C Raise Plunger

elements["UC_UP"] = default_1_position_tumb(_("Undercarriage Raise"), devices.CONTROLS, device_commands.Button_1, 54, 1, {1.0, 1.0})

-- U/C Extension Plunger

elements["UC_DN"] = default_1_position_tumb(_("Undercarriage Lower"), devices.CONTROLS, device_commands.Button_2, 55, 1, {1.0, 1.0})

-- U/C Locks Release Pull Handle

elements["UC_EMER"] = pull_handle(_("Undercarriage Emergency Release"), devices.CONTROLS, device_commands.Button_4, 63, 5.0)

 

3. My code which seems not correct

 

defineTumb("UC_DN", 4, 3002, 55, 1, {1, 1}, nil, false, "GEAR", "UC_DN")

defineTumb("UC_UP", 4, 3001, 54, 1, {1, 1}, nil, false, "GEAR", "UC_UP")

 

Thank you very much

 

avidflyer

Link to comment
Share on other sites

no one else tried hooking up pots through dcs bios? if so what's your take on pots?

 

I installed 10k pots in several panels but the amount of data from the pots was huge and they were constantly outputting data. I was concerned I would have the same issue I had with Helios and pots. It caused so much lag I couldn't use Helios. I even had the cascade box checked in Helios but to no avail.

 

I did find a cure though...I switched everything to rotary encoders. They work as well if not better than pots. The only draw back is that rotary encoders require the use of 2 pins whereas pots only need 1. But it was worth it. No lag and no constant stream of data clogging up everything.

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

Having trouble with 3 pos switch

 

Hi all,

 

Long time lurker here, so please be gentle!

I would like to say a big thank you to Ian for helping me come out of my shell and try to make an AHCP panel for the A-10.

 

I got my Arduino and toggle switch for the CICU working like a charm, using a SPDT Toggle switch (ON-ON). :thumbup:

 

However I am struggling with my IFCC switch - I have a DPDT switch (ON-OFF-ON), up is wired to pin 7, down to pin 9. I have used the switch3pos code for the IFCC from the reference document, assigning PIN_A to 7 and PIN_B to 9.

 

If I throw my switch up, the IFCC goes up :thumbup:

 

If I move my switch to the middle position (OFF), the virtual switch jumps to off (down), missing test (middle).

If I move my physical switch down, the virtual switch just stays down. Like wise if I move back to the middle, the virtual switch stays down. :helpsmilie:

 

I'm a novice when it comes to electronics so I'm probably doing something stupid. I'm pretty sure my switch isn't broken however, as I've hooked up some LEDs to both poles and they work as I'd expect.

 

Any help would be appreciated!

Link to comment
Share on other sites

Skorak: Try testing it without your physical switch. Take a wire and connect one end to ground. Touch the other end to pin 7 -- the switch should go up. Break the contact, the switch should go to the middle position. Touch pin 9, the switch should go down.

 

If that works, your switch was not wired correctly. If it does not work, post your code here so I can take a look.

Link to comment
Share on other sites

I installed 10k pots in several panels but the amount of data from the pots was huge and they were constantly outputting data. I was concerned I would have the same issue I had with Helios and pots. It caused so much lag I couldn't use Helios. I even had the cascade box checked in Helios but to no avail.

 

I did find a cure though...I switched everything to rotary encoders. They work as well if not better than pots. The only draw back is that rotary encoders require the use of 2 pins whereas pots only need 1. But it was worth it. No lag and no constant stream of data clogging up everything.

 

Warhog, thanks for sharing your solution. Pots normally rotate about 300 degrees but encoders have no restrictions. Switching from a pot to encoder, did you add something below the panel to restrict the encoder from rotating round and round?

Link to comment
Share on other sites

Warhog, thanks for sharing your solution. Pots normally rotate about 300 degrees but encoders have no restrictions. Switching from a pot to encoder, did you add something below the panel to restrict the encoder from rotating round and round?

 

Nope. It didn't make any difference to me whether it rotated 300 degrees or 5 x 360 degrees.

 

I'm not sure a blocking solution would work as the encoder wouldn't work properly if you jumped into an aircraft in flight and the volumes in the cockpit were all set to high. You couldn't turn them down.

 

But in the big scheme of things, I would prefer this little irregularity to a barrel full of data jamming up my serial connections.

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

Thanks Ian, your tip helped me work it out - a simple wiring error. :doh:

I don't know how I got my first switch to work the way I was wiring it up, must have been beginner's luck!

I have now worked out the correct way to connect my switches and everything is working as it should :thumbup:

 

Now I just need to figure out how to turn my mass of wiring into something less messy...

Link to comment
Share on other sites

I installed 10k pots in several panels but the amount of data from the pots was huge and they were constantly outputting data.

 

I solved this problem by implementing sort of a hysteresis between input and reported value, similar to the debouncing of switches.

 

I added two more private variables in Potentiometer : PollingInput...

unsigned int lastState_;
unsigned int lastRepState_;

 

...and then used a two-stages approach. First detect, if the difference between actual and last state is greater then 3, then apply some sort of rounding for the reported value and compare if it differs from the last reported value.

 

void Potentiometer::pollInput() {
   unsigned int state = (analogRead(pin_));
   if (abs(state - lastState_)>3) {
       int rep=(state/4)*256;
       if (rep != lastRepState_)
       {
         char buf[6];
         utoa(rep, buf, 10);
         sendDcsBiosMessage(msg_, buf);
         lastRepState_=rep;
       }
       lastState_ = state;
   }  
}

 

By doing that, the accuracy is reduced to a 4th, but I do not get these constant output flows.

 

Hope that helps,

Dirk

Link to comment
Share on other sites

what I mean is to physically put something behind the panel to let the encoder turn from 7 o'clock to say 5 o'clock position, for most volume and brightness dials which seem to use these angles.

 

I did understand what you were asking and I had considered doing it as well. But after thinking about how the r encoders work and how they are synced in game, there will be situations where you won't get them to work like you want them to.

 

Consider you just got into an airframe that is already in flight. The volumes on the radios are set on high. Your r. encoder is turned to low and a hard stop is preventing it from moving any lower. You can turn the encoder higher but the radio volumes are already on high. So how'd do you turn them down with you r encoder now that its movement is limited because you have a hard stop installed. You can't.

 

That's the problem. I don't see a solution to it other than letting your r. encoders turn freely.

 

@dirkr. When you say the accuracy decreases to a forth I'm not sure how I should interpret that in physical movement of the pot vs reported values. Can you expand on that statement as to what exactly you could expect after implementing the code.

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

  • Recently Browsing   0 members

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