Connecting a Real Flap Handle (part deux)

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Message
Author
Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Connecting a Real Flap Handle (part deux)

#1 Post by Kaellis991 »

I designed a way to connect the flap lever to the rotary pot. With that portion of the flap handle project complete, I now have to program Air Manager and connect the rotary pot to an Arduino Micro controller.
Any help on where to start would be welcomed. I cant seem to find any descriptions or videos on specifically how to do that. The closest explanations I can find are the two examples below.
But I cannot make the connection in my mind on how to modify those to increment a rotary pot in (4) discreet steps / angles.

Also the bottom script is what Keith helped me work out for the EGT moving coil meter.
Can any of the code examples below be used as a basis for coding a rotary switch to increment the flap control dataref in Xplane?
Obviously, the throttle and the volume scripts change values consistently from 0 to 1.
If either of those scripts are the basis for a flap lever, then how does one specify the different positions for the flaps?
This is the Piper Arrow dataref that increments to 0, 10, 25 and 40... thranda/anim/flaps
Throttle Pot.jpg
Volume Pot.jpg
EGT.jpg

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

Re: Connecting a Real Flap Handle (part deux)

#2 Post by Keith Baxter »

Hi Karl,

I did the zibo flap lever for the zibo here.

https://www.forums.siminnovations.com/v ... 875#p45875


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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Connecting a Real Flap Handle (part deux)

#3 Post by Kaellis991 »

Keith Baxter wrote: Fri Jun 03, 2022 4:56 pm Hi Karl,

I did the zibo flap lever for the zibo here.

https://www.forums.siminnovations.com/v ... 875#p45875


Keith
Thanks for that Keith…
I’ll work on teaching myself how to modify that code for my setup.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Connecting a Real Flap Handle (part deux)

#4 Post by Kaellis991 »

Keith Baxter wrote: Fri Jun 03, 2022 4:56 pm Hi Karl,

I did the zibo flap lever for the zibo here.

https://www.forums.siminnovations.com/v ... 875#p45875


Keith

What resistance value should I use for this flap potentiometer?

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Connecting a Real Flap Handle (part deux)

#5 Post by jph »

Hi Kirk,

anything from 1K to 10K.

Going much larger in value of the potentiometer is, A. not needed and B. can lead to ADC discrepancies.

4.7K (or 5K) is common but as said, anything from 1K to 10K is fine.

Place a 220 ohm resistor in series with the wiper or the potentiometer to the Arduino Analog pin. This is VERY important ! ..... especially with Air Manager !! :o


Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Connecting a Real Flap Handle (part deux)

#6 Post by Kaellis991 »

jph wrote: Sun Jun 05, 2022 8:24 am Hi Kirk,

anything from 1K to 10K.

Going much larger in value of the potentiometer is, A. not needed and B. can lead to ADC discrepancies.

4.7K (or 5K) is common but as said, anything from 1K to 10K is fine.

Place a 220 ohm resistor in series with the wiper or the potentiometer to the Arduino Analog pin. This is VERY important ! ..... especially with Air Manager !! :o


Joe
Duly noted Joe. Thanks.
I am also working on adding pots for the two dimmer switches, nav and panel lights. The nav light pot will have an SPST on/off function.
Does the same logic for size and resistor use apply to those also?

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Connecting a Real Flap Handle (part deux)

#7 Post by jph »

Hi Kirk,
If they are driving the Arduino Analog input then yes. The 1 to 10K rule for the pot applies, and also the series current limiting protection resistor of 220 ohm.

It is ALWAYS essential to use an appropriate resistor in series with the wiper to any ADC input or indeed ANY input that is also capable of being used as a general I/O !
The reason is that if for some reason you accidentally set the Arduino pin to an output when the ADC pot is connected, then, if the ADC wiper is at the gnd end and the I/O port is set high the Arduino ADC input port or general port will be destroyed.
This is actually very easy to do hence the resistor. In the event of this happening then the resistor will act as a buffer and safely limit the current to indefinitely tolerable levels for the Arduino.

In Air Manager it is possible to set the same Analog capable pin - say - A0, to Analog input, AND digital output in the same code :shock:
It is also extremely difficult to easily check in AM which pins have been assigned so you wont get a warning of a pre-assigned pin.
It is also REALLY easy to run the wrong code - or the code for something else with the same Arduino main ID. RIP Arduino..

Oh for the amazing flexibility and logic of MobiFlight when assigning hardware pins ! ;)

Any INPUT to the Arduino should ALWAYS have a 220 ohm resistor in series with the pin as a matter of course, Analog OR digital, it doesn't matter. This is standard good design practice and a 1 cent resistor will save a complete Arduino.

220 ohm is for the 5V version, 180 is fine for 3.3V

Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Connecting a Real Flap Handle (part deux)

#8 Post by Kaellis991 »

Joe,

I will heed the warnings…
X-plane doesn’t work too easily with Mobiflight or I would have gone that route.

Kirk

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Connecting a Real Flap Handle (part deux)

#9 Post by jph »

HI Kirk,
Understood. I am definitely not advocating mobiflight - at all (It is exceptionally good at what it is designed for though). AM is a different animal and offers different functionality and the flexibility needed to build to an exceptional professional level.
What IS exceptional about MF is the user interface for hardware and the really easy viewing of assignments.
At the end of the day though it all needs to be on paper so no worries really.
I have never used MF with X-P simply because it is, to me, totally crazy to use some basterdised UIPC DLL when X-P does the job PROPERLY from the start and opens all options to the outside world.
Horses for courses of course. The assignment, viewing and test / diagnostics in MF are an area I hope that AM aspires to match or surpass one day.
Joe
Joe. CISSP, MSc.

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Connecting a Real Flap Handle (part deux)

#10 Post by Kaellis991 »

Joe,

AM has been working well for me as long as I can either find a pre-made instrument or get help with the datarefs and programming for creating instruments.

I'm going to keep this thread dedicated to the programming / code implementation and the previous thread focused on the hardware.
With that in mind I have a hardware question I will post on my part one thread about the hardware.

Kirk

Post Reply