Switch Bounce?

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Message
Author
fatcharlieuk
Posts: 26
Joined: Tue Dec 22, 2020 7:42 am

Switch Bounce?

#1 Post by fatcharlieuk » Thu Feb 25, 2021 1:32 pm

Hi all,

I'm having an issue with some buttons on my hardware panel. They're connected to a BU0836X board from Leo Bodnar and are tactile momentary switches. There are other switches and buttons attached to the same board.

At best, I often get a situation where the command is repeated (VNAV turns on then immediately off again for instance) - at worst I get an instant CTD out of x-plane.

Is it possible I'm suffering from switch bounce? The issue is confined to four tactile buttons which are different from the rest of the panel, hence my suspicion.

User avatar
Ralph
Posts: 5074
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Switch Bounce?

#2 Post by Ralph » Thu Feb 25, 2021 3:07 pm

That's why we have debouncing in our Arduino code. But I guess that you'll have to ask Leo Bodnar for a solution.

User avatar
Keith Baxter
Posts: 2805
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Switch Bounce?

#3 Post by Keith Baxter » Thu Feb 25, 2021 3:27 pm

Hi

I got this one and just had to use. :mrgreen: :mrgreen:
throwback.gif
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

fatcharlieuk
Posts: 26
Joined: Tue Dec 22, 2020 7:42 am

Re: Switch Bounce?

#4 Post by fatcharlieuk » Thu Feb 25, 2021 8:02 pm

Ralph wrote:
Thu Feb 25, 2021 3:07 pm
That's why we have debouncing in our Arduino code. But I guess that you'll have to ask Leo Bodnar for a solution.
So there's debouncing written in - I guessed so but it's good to have it confirmed. But would switch bounce cause a crash does anyone know?

I'll try moving the switches over to an Arduino (they're in a Bodnar card as a historical hangover from a previous cockpit) - I need to go "full Arduino" anyway and this will get me going! That way I'll know if it's the Bodnar or the witches.

Cheers,

Roger.

fatcharlieuk
Posts: 26
Joined: Tue Dec 22, 2020 7:42 am

Re: Switch Bounce?

#5 Post by fatcharlieuk » Thu Feb 25, 2021 8:03 pm

Keith Baxter wrote:
Thu Feb 25, 2021 3:27 pm
Hi

I got this one and just had to use. :mrgreen: :mrgreen:

throwback.gif

Keith
:-)

fatcharlieuk
Posts: 26
Joined: Tue Dec 22, 2020 7:42 am

Re: Switch Bounce?

#6 Post by fatcharlieuk » Thu Feb 25, 2021 8:35 pm

I've just realised, though, your debounce code is in the Arduino flash rather than in Air Manager, eh?

User avatar
Ralph
Posts: 5074
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Switch Bounce?

#7 Post by Ralph » Fri Feb 26, 2021 4:39 am

Yes that's correct.

User avatar
Corjan
Posts: 2368
Joined: Thu Nov 19, 2015 9:04 am

Re: Switch Bounce?

#8 Post by Corjan » Fri Feb 26, 2021 11:05 am

Hi,

Switch debouncing is done in AM code, not in Arduno code.
Button debouncing is done in Arduino code.

Corjan

User avatar
jph
Posts: 645
Joined: Fri Apr 10, 2020 12:50 pm
Location: Portugal

Re: Switch Bounce?

#9 Post by jph » Fri Feb 26, 2021 12:30 pm

For Bodner, If you ever wanted an external clean option then you could use an R/C filter, or an RC filter / Schmitt trigger combo, or, a potentially easy way if you must use the Bodner board is an MC14490 IC. (6 Channels)
Datasheet - https://www.onsemi.com/pub/Collateral/MC14490-D.PDF
They are cheap as well .
https://www.onsemi.com/pub/Collateral/MC14490-D.PDF
Haven't personally tried them in anger yet ;) , but have a few on order as it is, potentially, a very nice solution that is as good as an R/C / Diode / Schmitt trigger combo.
just a thought..
“Everything in moderation, including moderation.”
“Experience is merely the name men gave to their mistakes.”
Joe (CISSP) -IT security consultant

fatcharlieuk
Posts: 26
Joined: Tue Dec 22, 2020 7:42 am

Re: Switch Bounce?

#10 Post by fatcharlieuk » Fri Feb 26, 2021 9:19 pm

I thinkit's definitely the use of the joystick card.

I'm guessing the switch and button debouncing won't be present, either through arduino or through AM code, as the joystick inputs are handled by the Game Controller interface?

I have a Bodnar card and also a generic 12-button joystick card.

AM doesn't differentiate between the two, so once I'd used up all 12 connections to the generic card, I started using the Bodnar from input 13.

I also had code for the Game Controller interface and an arduino in the same instrument. I separated this into two different instruments earlier today and it's a bit more stable, but I just had another CTD when operating a switch attached to the generic USB joystick card.

I'm feeling, then, that there' something about the game Controller interface regarding switch bounce which is different from the way the Arduino and AM deal with it perhaps? Game Controller inputs don't have a switch_id or button_id...

I have enough spare arduino inputs to move all the switches over - and i will do this in the future, but it's around 30 switches to re-solder, so i kinda want to get this working so i can fly, lol!

I'm using v4 BETA btw.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests