Controlling the Baron D55 Electric Flaps Gauge

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

Moderators: russ, Ralph

Message
Author
BaronD55
Posts: 33
Joined: Tue Jul 21, 2020 3:52 am
Location: 40°S,177°E

Controlling the Baron D55 Electric Flaps Gauge

#1 Post by BaronD55 »

I have been revisiting the tutorial videos to see what ideas there were there for me to control the reading on my electric flap indicator gauge.
Face.jpg
I was given this gauge along with the central Control Console that included the engine controls and all the trim wheels from a D55 Baron that I flew once back in the 90's (P2-MFA).
So I am rebuilding my sim as a full scale replica of that particular Baron.

The gauge still works and I have found that it gives full scale deflection with 5 Volts and a 15k Ohms resistor. I put in a potentiometer and was able to control the deflection of the needle.

This led me to the idea that If I can persuade Air Manager to give me a smoothly changing voltage at an Analog pin, then I can have this gauge follow the flaps extension in the simulator.
I re-watched all the tutorial videos from 1 - 6, then 11 & 12 and then 26 & 27. Good thing my wife's away!
To my dismay and amusement, the only topic that was not covered was "analog output'.

Can anyone point me to a tutorial that will cover this topic?

Cheers

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#2 Post by Ralph »

That's because there is only a 3 Arduino's on the market that have an DAC, like the Due, which we do not support. Also, the Due has 3.3V IO.

The first thing you can try is using PWM. I'm not sure what frequency works best, you can start at 500 Hz or 1000 Hz for example and then try to find tune.

Or you can use one of those DAC boards with I2C, but then you'll also need to use your own Arduino Sketch.
https://learn.adafruit.com/mcp4725-12-b ... o?view=all

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#3 Post by jph »

You can use the built in PWM from AM and a low pass RC filter. (you MUST use a low pass RC filter) Here the RC filter is first order and purely a simple resistor followed by a capacitor.
If you use a 1kHz PWM signal and a first order low pass RC filter followed by a 15K resistor the it should work fine.
I would use a variable resistor instead of the 15K, for example a 22K variable.

With a PWM frequency of 1Khz use a 470ohm resistor followed by a 100uF capacitor to ground. Follow this by the 22K variable.

Arduino pin-----470-----------------------22kVAR-------
...................................I ....................... I
............................... 100uF .............. Flap gauge
...................................I ....................... I
GND--------------------------------------------------------


That gives very low ripple with a response (settle time) of around 100mS

That all you need. Just set 100% PWM and adjust the 22KVar for max deflection. Then adjust the PWM for the appropriate needle positions.
If you want to add needle movement damping (purely optional but can be very effective) then you can increase the Value of the first resistor up to around 4.7K but start at 470. Damping is purely optional and does vary with PWM frequency. If the damping doesn't mean much to you then ignore it ;)

Joe
Joe. CISSP, MSc.

BaronD55
Posts: 33
Joined: Tue Jul 21, 2020 3:52 am
Location: 40°S,177°E

Re: Controlling the Baron D55 Electric Flaps Gauge

#4 Post by BaronD55 »

Thank you for the swift responses.
The PWM option seems like the most achievable for me so I will have some fun with that first.

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#5 Post by jph »

djw4250@gmail.com wrote: Sun Feb 06, 2022 9:53 am Thank you for the swift responses.
The PWM option seems like the most achievable for me so I will have some fun with that first.
Hi, no problem, the PWM will work perfectly for this usage. It is a very common way to make a pseudo DAC with all forms of microprocessor and is certainly not specific to AM. You wouldn't notice any difference at all in this use if you used a 14bit DAC.
When used with a meter like this - which is all the flaps gauge is - there is just no benefit to using anything else.
Have fun :)
Joe
Joe. CISSP, MSc.

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#6 Post by jph »

Anyone wanting to make a PWM DAC then the following calculator for the Low Pass Filter is great. - the filter is classed as a 'First Order' Low Pass Filter.
Remember to keep the 'Cut Off' frequency as low as possible as we are looking for a pseudo DC output.
The ripple voltage should be as low as possible, certainly less than 100mV preferably less than 50mV. In this case I set it to 20mV due to using an analogue meter but you could get away with quite high ripple - however, there is simply no need to as it can be easily designed out. The 'settling time' is the time taken to respond to the change in voltage 100mS or less is fine. Higher 'settling time' adds a slower DC voltage change response in relation to a change in PWM duty cycle - hence acts as a damper on the needle deflection. You can experiment with this up to a second or two just for sh!ts and giggles. ;) . Here I set it to 100mS but it can be changed to 1000mS (1 second) by multiplying the resistor value by 10 - so 470 ohms becomes 4.7K but at the expense of a slight increase in 'CUT OFF' frequency. Altering PWM base frequency can be done to dial that out and make the ideal unit for your needs. Here I just used 1kHz because it seemed like a nice starting point and have the required results.
Worth bookmarking for anyone that may want to use a PWM DAC. With a bit of care with the low pass filter you can get absolutely excellent results. Play around with it. Extremely useful.
http://sim.okawa-denshi.jp/en/PWMtool.php
Joe. CISSP, MSc.

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#7 Post by Ralph »

That would even be better, thanks for the detailed explanation Joe.

BaronD55
Posts: 33
Joined: Tue Jul 21, 2020 3:52 am
Location: 40°S,177°E

Re: Controlling the Baron D55 Electric Flaps Gauge

#8 Post by BaronD55 »

Hi there Ralph and jph.
I have been evolving my setup and code and thought I'd post this update so you can nudge me back on track if I have erred.
Thanks for your earlier input too. It was much appreciated and highly motivating. Cheers
IMG_1190.jpg
My code looks so simple I'm suspicious of it.

Code: Select all

1 pwm_flaps_position = hw_output_pwm_add("ARDUINO_UNO_A_D9", 1000, 0.0)
2
3 function new_position(extension)
4	hw_output_pwm_duty_cycle(pwm_flaps_position, extension/100)
5 end
6
7 xpl_data_ref_subscribe("TRAILING EDGE FLAPS LEFT PERCENT", "Percent", new_position)

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#9 Post by jph »

Seems fine to me ... I don't notice your variable resistor in the little drawing you have ? - just to check you have it connected ? - Providing you have the variable resistor at the appropriate level to protect the meter for full scale then ...............................

Turn it on and stand well back with a large fire extinguisher, an Axe and a life jacket........ :mrgreen:
Joe. CISSP, MSc.

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#10 Post by Ralph »

Looks fine. Although I'm not sure if X-Plane also might work with 0-1 and not 0-100.

Post Reply