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
User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Controlling the Baron D55 Electric Flaps Gauge

#21 Post by Ralph »

There might also be a flaps position indicator as a virtual instrument in Air Manager, which you can check.

I guess there is some kind of buffer there, but it shouldn't get messed up by so little data :)

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#22 Post by BaronD55 »

Yes Ralph. I will have a look for that as well.
Cheers

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#23 Post by BaronD55 »

Hello fellow Sim Innovators.

I have had success :)

Ralph, I downloaded a virtual gauge that was P3D compatible and immediately noticed how neatly the script was organised so I set about sorting out my own head and rewriting my script.

When I ran the virtual gauge the virtual needle moved smoothly through the full range as I lowered the flaps in the sim.

It was subscribed to the same variable that I had chosen.

By carefully choosing different places to insert the "print" command I discovered that my bottleneck was in the line of code that I had written in to round off the incoming data to two decimal places.

I simply took out the word "round" and it started to run smoothly. as it should. (Sorry I can't show you the movie).

Code: Select all

-- Load images
img_add_fullscreen("Face.png")
img_needle = img_add_fullscreen("NeedleFlaps.png")
img_add_fullscreen("FlapsCapNeedle.png")

-- Define PWM pin
pwm_flaps_position = hw_output_pwm_add("ARDUINO_UNO_A_D9", 1000, 0.0)

-- Functions
function flaps_pos(flaps)
	angle = var_cap(flaps, 0, 1)
	rotate(img_needle, angle *180)	
end

function new_flaps_pos(flaps)
        flaps_pos(flaps / 100)
        my_gauge(flaps / 100)
end

function my_gauge(position)
        duty_cycle = position
         print("duty cycle: " ..duty_cycle)
       hw_output_pwm_duty_cycle(pwm_flaps_position, duty_cycle)
end

-- Data bus subscribe
fsx_variable_subscribe("TRAILING EDGE FLAPS LEFT PERCENT", "PERCENT", new_flaps_pos)

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#24 Post by jph »

Nice :D
We love it when a plan comes together. Nice job and a bit of aviation history saved and doing the job it was meant to do. Isn't it fadcinating and rewarding when something like that comes to life again? a thing of beauty that few can relate to.

Is it not possible to get more parts from the aircraft ?

Having hardware parts and 'steam' gauges is so rewarding. I really fail to see the attraction of 'glass cockpit' GA aircraft at all (in a simulator context). Even in the best sim there is little actual 'feel' difference to a light single of any make and similar weight / power. In my mind, as soon as something like a G1000 is added to a sim then you might as well be flying any aircraft of as similar type. It also takes all the fun out of flying and becomes an a to b brain dead device. But hey ;) just my opinion of course. You will be making your own gauges next :D
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

#25 Post by BaronD55 »

jph I totally agree with you.
Fascinating and rewarding indeed. In the past I have restored a vintage motorbike, a vintage car and a live steam locomotive plus built a 1/48 scale working model if it - so I definitely understand what you mean. Such a sense of achievement too. I've never used the PWM output functionality before so this little baby step opens up all sorts of possibilities for me.
I flew this Baron P2-MFA in Papua New Guinea back in the early 90's so it is of immense sentimental value to me.
More parts off another D55 Baron are available but I simply cannot afford them. Although I have bought the bits I need to re-assemble the Central Control Consol. Add to the huge price for these parts the fact that shipping sometimes costs up to 5 times the price of the item it becomes a total impossibility for me.
However, a 3D printer helps to fill in the gaps and provide enough to allow a satisfactory immersive experience.

Thanks for your enthusiasm and advise - both you and Ralph.

Just to round off our discussion her is what my sim looked like before I started rebuilding as a Baron:-
191207.JPG
Next step is to replace all that generic Saitek stuff.
Main challenge there is finding out how to build the GNS530.
Kind regards
David
New Zealand

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#26 Post by Ralph »

I have some suggestions for your script, but I'll post that tomorrow.

It would be great if you can find a real GNS530 somewhere. But as long as they're functioning, they're very expensive. Would be great if you can find one that is broken...

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#27 Post by BaronD55 »

Hi Ralph.
I am keen to see your suggestions for my script. :)

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#28 Post by Ralph »

This should be sufficient.

Code: Select all

-- Define PWM pin
pwm_flaps_position = hw_output_pwm_add("ARDUINO_UNO_A_D9", 1000, 0.0)

-- Data bus subscribe and function
fsx_variable_subscribe("TRAILING EDGE FLAPS LEFT PERCENT", "PERCENT", function(position)
    local duty_cycle = var_cap(position / 100, 0, 1)
    hw_output_pwm_duty_cycle(pwm_flaps_position, duty_cycle)
end)

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#29 Post by BaronD55 »

Ahhh - the old nested function trick. I didn't think of that one. Very neat. Thanks for showing me that.

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

Re: Controlling the Baron D55 Electric Flaps Gauge

#30 Post by jph »

djw4250@gmail.com wrote: Sat Feb 19, 2022 6:20 pm jph I totally agree with you.
Fascinating and rewarding indeed. In the past I have restored a vintage motorbike, a vintage car and a live steam locomotive plus built a 1/48 scale working model if it - so I definitely understand what you mean. Such a sense of achievement too. I've never used the PWM output functionality before so this little baby step opens up all sorts of possibilities for me.
I flew this Baron P2-MFA in Papua New Guinea back in the early 90's so it is of immense sentimental value to me.
More parts off another D55 Baron are available but I simply cannot afford them. Although I have bought the bits I need to re-assemble the Central Control Consol. Add to the huge price for these parts the fact that shipping sometimes costs up to 5 times the price of the item it becomes a total impossibility for me.
However, a 3D printer helps to fill in the gaps and provide enough to allow a satisfactory immersive experience.

Thanks for your enthusiasm and advise - both you and Ralph.

Just to round off our discussion her is what my sim looked like before I started rebuilding as a Baron:-

191207.JPG

Next step is to replace all that generic Saitek stuff.
Main challenge there is finding out how to build the GNS530.
Kind regards
David
New Zealand
Lovely job on the 'pit' David.
Real quality. A total credit to you and something a lot of users will be enviable of and will offer them a target to hope to achieve.
First class.
Joe
Joe. CISSP, MSc.

Post Reply