This are the (new) Support Forums for FSUIPC and related products.
These forums replace the old support forums which have been running for 20+ years. The old forums contain a wealth of information on all FSUIPC products, and are still available (until the end of the year) for read-only here.
At the moment these new forums are quite empty – I will be updating the FAQ section and copying across the User Contributions from the old forums in the next few months.
Please note that you will need to Register and Login to post for support, and also to download attachments. You can view these forums without registering.
Support is also available via Discord. Please use the following invite link to join the FSUIPC Discord server:
https://discord.gg/zjwUTrxmmE
Using a trim wheel axis to operate with trim INC and DEC instead
A trim wheel, such as that sold by Saitek, is very nice, but unless it is motorised so that when the autopilot is controlling trim the wheel can be automatically moved to its correct position, it poses difficulties unless you fly under manual control all of the time.
With the autopilot operating the trim for vertical flight control modes, the wheel's position will not often match the actual trim position in FS. This doesn't matter if you don't move it, as axes are not read until moved. But as soon as you move it, the actual setting for the wheel position is immediately applied, resulting in a sudden trim change.
FSUIPC does have an option to disconnect the trim axis when the autopilot is using it (see the DisconnTrimForAP option in the Advanced User's guide), but this doesn't get over the discrepancy in the position when the A/P is disconnected. Really the only satisfactory way of having a trim wheel operate through the trim axis control is to have it motorised so that is always goes to the currently set FS position when the A/P adjusts it, or when you load a new flight.
An alternative, which can work but which does spoil some of the advantages of having a realistic trim wheel, is to revert it to sending elevator trim up and trim down commands to FS, instead of using the value directly as the trim vale. This effectively makes it similar to the NumPad 1 and 7 keys, or the spring-loaded two way toggle switches or levers fitted to many commercial yokes.
The way to do this is to use a Lua plug in which converts the change in axis value to a trim Inc or Dec. Here's an example:
function checkvalue(val)
if prev ~= nil then
if val > prev then ipc.control(65615)
elseif val < prev then ipc.control(65607)
end
end
prev = val
end
event.param("checkvalue")If your axis is reversed, you can switch the control numbers being sent:
function checkvalue(val)
if prev ~= nil then
if val > prev then ipc.control(65607)
elseif val < prev then ipc.control(65615)
end
end
prev = val
end
event.param("checkvalue")Save this as, say, "trimwheel.lua", in the Modules folder and add this to your INI file:
[Auto]
1=Lua trimwheel
Run FS and assign your axis, in the normal FS controls assignment on the left, to "Luavalue trimwheel".
Regards
Pete
UPDATE: by old forum user ThomasAH:
I adjusted Pete's script to solve all three of your issues:
- The script writes directly to offset 0x0BC0
- For larger movements of the wheel the script makes larger changes the offset.
- If the wheel is near the end of its range (upper or lower 1/16th) a warning popup will appear and suggest disconnecting and reconnecting the wheel (I have connected it to the USB hub of my Saitek yoke, so this is easily reachable)
Additionally I have configured the trim wheel to set AP vertical speed or pitch or attitude hold if the AP is enabled instead of acting as a trim wheel.
And for the times I use only a joystick instead of the full setup, I have assigned two joystick buttons to act as trim, with increasing speed if the buttons are hold for a longer time.
Maybe you can adjust it for your own needs:
-- Using a trim wheel axis to operate with trim INC and DEC instead -- http://forum.simflight.com/topic/72492-using-a-trim-wheel-axis-to-operate-with-trim-inc-and-dec-instead/ -- -- [Auto] -- 1=Lua trimwheel -- assign your axis, in the normal FS controls assignment on the left, to "Luavalue trimwheel". boundary = 16384-2048 joystick = "J" -- Saitek Aviator Stick button_dn = 4 -- T1 button_up = 5 -- T2 function trimbutton(joynum, button, downup) factor = 20 direction = (button == button_up) and -1 or 1 trimwheel(factor*direction) ipc.sleep(100) while ipc.testbutton(joynum, button) do if factor < 200 then factor = factor+2 end trimwheel(factor*direction) ipc.sleep(30) end trimwheel(0) end function trimwheel_trim(change) trim = ipc.readSW(0x0BC0) - change if trim < -16384 then trim = -16384 elseif trim > 16383 then trim = 16383 end ipc.writeSW(0x0BC0, trim) end function trimwheel_ap_vs(change) if ipc.readUW(0x07BC) == 0 then -- AP disabled trimwheel_trim(change) elseif change > 0 then ipc.control(65895) -- AP_VS_VAR_DEC elseif change < 0 then ipc.control(65894) -- AP_VS_VAR_INC end end function trimwheel_ap_pitch(change) if ipc.readUW(0x07BC) == 0 then -- AP disabled trimwheel_trim(change) elseif change > 0 then ipc.control(66584) -- AP_PITCH_REF_INC_DN elseif change < 0 then ipc.control(66583) -- AP_PITCH_REF_INC_UP end end function trimwheel_ap_pitch_atthold(change) if ipc.readUW(0x07BC) == 0 then -- AP disabled trimwheel_trim(change) elseif change > 0 then if ipc.readUW(0x07D0) > 0 then -- AP alt lock ipc.control(65804, 1) -- AP_ATT_HOLD_ON end ipc.control(66584) -- AP_PITCH_REF_INC_DN elseif change < 0 then if ipc.readUW(0x07D0) > 0 then -- AP alt lock ipc.control(65804, 1) -- AP_ATT_HOLD_ON end ipc.control(66583) -- AP_PITCH_REF_INC_UP end end function trimwheel_ap_pitch_althold(change) if ipc.readUW(0x07BC) == 0 then -- AP disabled trimwheel_trim(change) elseif change > 0 then if ipc.readUW(0x07D0) > 0 then -- AP alt lock ipc.control(65816, 1) -- AP_ALT_HOLD_OFF end ipc.control(66584) -- AP_PITCH_REF_INC_DN elseif change < 0 then if ipc.readUW(0x07D0) > 0 then -- AP alt lock ipc.control(65816, 1) -- AP_ALT_HOLD_OFF end ipc.control(66583) -- AP_PITCH_REF_INC_UP end end function trimwheel_c182(change) if ipc.readUW(0x07BC) == 0 then -- AP disabled trimwheel_trim(change) elseif change > 0 then ipc.writeLvar("kap140_dn_button", 1) elseif change < 0 then ipc.writeLvar("kap140_up_button", 1) else ipc.writeLvar("kap140_dn_button", 0) ipc.writeLvar("kap140_up_button", 0) end end function aircraftchange(eventtype) if ipc.readSTR(0x3D00, 14) == "C337 Skymaster" then trimwheel = trimwheel_ap_pitch_atthold elseif ipc.readSTR(0x3D00, 5) == "C182_" then trimwheel = trimwheel_c182 elseif ipc.readSTR(0x3D00, 10) == "Cessna 441" then trimwheel = trimwheel_ap_vs elseif ipc.readSTR(0x3D00, 20) == "Boeing Stratocruiser" then trimwheel = trimwheel_ap_pitch_althold else trimwheel = trimwheel_trim end end aircraftchange(nil) -- initialize at least once function checkvalue(val) if prev ~= nil and val ~= prev then -- axis moved if math.abs(val) > boundary then ipc.display(string.format( "Warning:\n\n" .. "Trim wheel value near boundary: %d\n" .. "Reconnect to restore full range.\n", val), 10) else ipc.display("") end trimwheel(val - prev) end prev = val end event.sim(AIRCRAFTCHANGE, "aircraftchange") event.param("checkvalue") event.button(joystick, button_dn, "trimbutton") event.button(joystick, button_up, "trimbutton")
