Jump to content

Need help with DcsBios::Switch3Pos DcsBios::Switch3Pos ufcS("UFC_SEL", PIN_A, PIN_B);


Ganeshka

Recommended Posts

testing my new UFC and have problems with DcsBios::Switch3Pos ufcSel("UFC_SEL", PIN_A, PIN_B);

 

and same on CSMP ... all other buttons on UFC and CMSP work perfect but when i try to use

 

Switch3Pos value switching is not correct ,i press 1 time but in game it switch more , every time number is different sometime it go +2 , sometime more ... if i use same pin for other like MASTER CAUTION or ENT everythig is work fine . Can some one tell me why it wont work correctly ? :cry:

Link to comment
Share on other sites

Your mechanical switch is likely bouncing.

 

Right now there isn't a really good way to do proper per-control debouncing in the DCS-BIOS Arduino library, but here's a crude but effective way to do it for all inputs: add a call to delay() to your loop() function. I'd suggest starting with 10 milliseconds and increasing in steps of 5 ms until the behavior improves.

 

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

 

If you have a logic analyzer or an oscilloscope, you could also measure the duration of the bounce so you don't need to use trial and error to determine the delay.

 

If you don't have a logic analyzer, I suggest typing the magic words "24Mhz 8Ch" into the search function of eBay or AliExpress and ordering a logic analyzer and some test clips. These work with the open-source sigrok software (http://sigrok.org). The clips are annoying to use on anything smaller than 0.1 inch pitch pins, and they might have issues with longer captures at the full 24 MHz, but they are still incredibly useful tools for debugging and learning about digital logic circuits and you can get one for about $10 :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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