Elevator Trim position indicator using LEDS?

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

Re: Elevator Trim position indicator using LEDS?

#11 Post by Kaellis991 »

@SimPassion

Wow, thanks for all of that.
It works in AM allowing me to make the connections to the arduino pins.
But I don't know how to add the rotary encoder to scroll through the lights as I rotate the trim wheel.

I like the idea of the bar graph, but for me I would need a shorter version if I can get a straight section of lights to work.
There may be a way to add individual small LEDs (maybe miniature SMD types?) on a curved board somehow, but that will take some engineering on my part.

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

Re: Elevator Trim position indicator using LEDS?

#12 Post by Kaellis991 »

Perhaps a stepper or servo with a needle that sticks through the slot might be another solution.
Though I have never worked with those motors before.

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

Re: Elevator Trim position indicator using LEDS?

#13 Post by Ralph »

Nooo! Do not start messing in the script, just set the number of LED's you want to use.
The trim wheel and indicator do not need to know about each other, there's no link between these two.

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Elevator Trim position indicator using LEDS?

#14 Post by SimPassion »

So it works with the Piper Arrow III, quick and dirty (script updated for fixes) :

image.png

On first run with trim in neutral position

image.png

In-sim DN position
image.png

related leds showing

image.png

could be in the reverse way on leds

image.png

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Elevator Trim position indicator using LEDS?

#15 Post by SimPassion »

Kaellis991 wrote: Mon Apr 03, 2023 1:09 pm Perhaps a stepper or servo with a needle that sticks through the slot might be another solution.
Though I have never worked with those motors before.
Simple, with an encoder, just use "sim/flight_controls/pitch_trim_down" and "sim/flight_controls/pitch_trim_up" command depending on the way we rotate the encoder

Code: Select all

function pr_trim_change(dir)
	if dir == -1 then
		xpl_command("sim/flight_controls/pitch_trim_up")
	elseif dir == 1 then
		xpl_command("sim/flight_controls/pitch_trim_down")
	end
end

hw_dial_add("TRIM Encoder",pr_trim_change)
Just checked it works, all in the same logic.lua !

image.png

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Elevator Trim position indicator using LEDS?

#16 Post by SimPassion »

Just added hw_add_button to set trim straight forward for takeoff :

Code: Select all

--====================================================================================
--								CHECK PURPOSE
--====================================================================================

led_id_0 = hw_led_add("LED 0", 0)
led_id_1 = hw_led_add("LED 1", 0)
led_id_2 = hw_led_add("LED 2", 0)
led_id_3 = hw_led_add("LED 3", 0)
led_id_4 = hw_led_add("LED 4", 1)
led_id_5 = hw_led_add("LED 5", 0)
led_id_6 = hw_led_add("LED 6", 0)
led_id_7 = hw_led_add("LED 7", 0)
led_id_8 = hw_led_add("LED 8", 0)

led_nbr = 9

function compute_SI_Trim(trim_in)
	trim = var_cap(math.floor((led_nbr-(trim_in * 4.5)) - 4.5),0,8)
	-- trim = led_nbr - trim - 1		-- if it's required to invert the way leds are displayed, just un-comment this line
	-- print(trim)
	hw_led_set(led_id_0, trim==0)
	hw_led_set(led_id_1, trim==1)
	hw_led_set(led_id_2, trim==2)
	hw_led_set(led_id_3, trim==3)
	hw_led_set(led_id_4, trim==4)
	hw_led_set(led_id_5, trim==5)
	hw_led_set(led_id_6, trim==6)
	hw_led_set(led_id_7, trim==7)
	hw_led_set(led_id_8, trim==8)
end

xpl_dataref_subscribe("sim/cockpit2/controls/elevator_trim","FLOAT",compute_SI_Trim)

function pr_trim_change(dir)
	if dir == -1 then
		xpl_command("sim/flight_controls/pitch_trim_up")
	elseif dir == 1 then
		xpl_command("sim/flight_controls/pitch_trim_down")
	end
end

hw_dial_add("TRIM Encoder",pr_trim_change)

function pr_trim_takeoff()
    xpl_command("sim/flight_controls/pitch_trim_takeoff")
end
hw_button_add("TRIM Takeoff set", pr_trim_takeoff)

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Elevator Trim position indicator using LEDS?

#17 Post by SimPassion »

Not missing Ralph's mentioned Trim LEDs Indicator :

image.png
image.png
image.png (7.23 KiB) Viewed 2643 times
image.png

Just add the encoder handling in an own custom instrument logic.lua script

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

Re: Elevator Trim position indicator using LEDS?

#18 Post by Kaellis991 »

So much to unpack there.
You guys make it look so easy....

Thanks for the code and the information.
I will set it all up this coming weekend.

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

Re: Elevator Trim position indicator using LEDS?

#19 Post by Ralph »

Don't mind the number of LED's in the Create/Edit tab, which is always 10, that's a bug in Air Manager. This bug is fixed in 4.2. It works good in the Home tab.

SimPassion
Posts: 5339
Joined: Thu Jul 27, 2017 12:22 am

Re: Elevator Trim position indicator using LEDS?

#20 Post by SimPassion »

Ralph wrote: Mon Apr 03, 2023 3:17 pm Don't mind the number of LED's in the Create/Edit tab, which is always 10, that's a bug in Air Manager. This bug is fixed in 4.2. It works good in the Home tab.
Thanks, I confirm I've seen this Ralph, though I've not taken it in account, however I'd let it on the side while taking a screenshot, to avoid to Kirk going to wonder

Post Reply