Jump to content
Sign in to follow this  
C2615

Working on HGJ Mercure AP with a HDG problem (deg vs rad)

Recommended Posts

Hi, I'm now trying to make a HGJ Mecure module for my own use, mostly for AutoPilot function, so far so good, the only problem is Heading bug

I use:

function DM_HDG_dec()
    local HDG = ipc.readLvar("L:HDG HOLD")
    HDG = HDG - 1
    if HDG < 0 then
        HDG = 359
    end
    ipc.writeLvar("L:HDG HOLD",HDG)
end

function DM_HDG_inc()
    local HDG = ipc.readLvar("L:HDG HOLD")
    HDG = HDG + 1
    if HDG > 359 then
        HDG = 000
    end
    ipc.writeLvar("L:HDG HOLD",HDG)
end

To input heading knob, while the heading window on AP panel shows correct and AP flies what shown here in degree, the BUG on HSI jumps about 50 more degree (about exactly 1 radian:57.30degree if it's a coincidence),

I jumped into the gauges' xml, and find in AP panel, the xml is use: (L:HDG HOLD,degrees), but in HSI it uses: (L:HDG HOLD,radians). I can't simply change them as they also interact with other elements in their space.

eg:

HSI:
	<Element>
		<Position X="125.5" Y="126.5"/>
		<Image Name="HSI_POINTER_HDG.bmp" Luminous="Yes">
			<Axis X="5.5" Y="86.5"/>
		</Image>
		<Rotate>
			<Value>(L:HDG HOLD,radians) (L:VG2_HDG,number) -</Value>
		</Rotate>
	</Element>

AP:
		<Area Left="206" Top="67" Height="20" Width="10" >
			<Tooltip>HDG Sel Inrease</Tooltip>
			<Cursor Type="UpArrow"/>
			<Click>
				(L:HDG HOLD,degrees) 359 &lt; if{ (L:HDG HOLD,degrees) 1 + (&gt;L:HDG HOLD,degrees) } els{ 0 (&gt;L:HDG HOLD,degrees) }
				7 (&gt;L:Mercure_knob, number)
			</Click>
		</Area>


 

Seems if I use LINDA (or FSUIPC in general) to send "ipc.writeLvar("L:HDG HOLD",HDG)" both of them will recive the number, and as what it think it is, thus makes this problem, if I use mouse click on panel, it will know it's now on degrees and pass radians to HSI correctly.

After few hours of researching, I was able to make XML edit (in MN_Mercure, HSI_PILOT.xml and HSI_COPILOT.xml) to make it works for me :

	<Element>
		<Position X="125.5" Y="126.5"/>
		<Image Name="HSI_POINTER_HDG.bmp" Luminous="Yes">
			<Axis X="5.5" Y="86.5"/>
		</Image>
		<Rotate>
			<Value>!lua return dgrd(d360(varget("L:HDG HOLD","degrees") - rddg(varget("L:VG1_HDG","number"))))</Value>
		</Rotate>
	</Element>

 

But still,I would prefer just only make a better LINDA profile rather than have to edit the xml, and ideas?

 

Edited by C2615

Share this post


Link to post
Share on other sites

Here is full action.lua I got so far, for anyone who want a try, BTW the FD, AT and AP master are mostly using FSUIPC default control, so I don't included here:

-- EMPTY TEMPLATE -- 
-- Fill with what functions you need --


-- ## System functions ##

function InitVars ()

    -- uncomment to disable display
    -- AutopilotDisplayBlocked ()
end 

-- ## GEAR
function DM_GEAR_UP()
    ipc.writeLvar("L:GEAR_LEVER",0)
end

function DM_GEAR_OFF()
    ipc.writeLvar("L:GEAR_LEVER",1)
end

function DM_GEAR_DN()
    ipc.writeLvar("L:GEAR_LEVER",2)
end

-- ## AP ROLL

function DM_HDG_dec()
    local HDG = ipc.readLvar("L:HDG HOLD")
    HDG = HDG - 1
    if HDG < 0 then
        HDG = 359
    end
    ipc.writeLvar("L:HDG HOLD",HDG)
end

function DM_HDG_inc()
    local HDG = ipc.readLvar("L:HDG HOLD")
    HDG = HDG + 1
    if HDG > 359 then
        HDG = 000
    end
    ipc.writeLvar("L:HDG HOLD",HDG)
end

function DM_AP_LAND()
    ipc.writeLvar("L:AUTOPILOT_AUTOLAND",1)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_ILS()
    ipc.writeLvar("L:AUTOPILOT_ILS",1)
    ipc.writeLvar("L:AUTOPILOT_VOR",0)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_VOR()
    ipc.writeLvar("L:AUTOPILOT_VOR",1)
    ipc.writeLvar("L:AUTOPILOT_ILS",0)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_TURB()
    ipc.writeLvar("L:AUTOPILOT_TURB",1)
    ipc.writeLvar("L:AUTOPILOT_ILS",0)
    ipc.writeLvar("L:AUTOPILOT_VOR",0)
    ipc.writeLvar("L:AUTOPILOT_PSH",0)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_PSH()
    ipc.writeLvar("L:AUTOPILOT_PSH",1)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_RCLR()
    ipc.writeLvar("L:AUTOPILOT_AUTOLAND",0)
    ipc.writeLvar("L:AUTOPILOT_ILS",0)
    ipc.writeLvar("L:AUTOPILOT_VOR",0)
    ipc.writeLvar("L:AUTOPILOT_TURB",0)
    ipc.writeLvar("L:AUTOPILOT_PSH",0)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

-- ## AP PITCH
function DM_ALT_dec()
    local ALT = ipc.readLvar("L:ALT_HOLD_VAR")
    ALTN = ALT - 100
    if ALTN < 1 then
        ALTN = 0
    end
    ipc.writeLvar("L:ALT_HOLD_VAR",ALTN)
end

function DM_ALT_inc()
    local ALT = ipc.readLvar("L:ALT_HOLD_VAR")
    ALTN = ALT + 100
    if ALTN > 49800 then
        ALTN = 49900
    end
    ipc.writeLvar("L:ALT_HOLD_VAR",ALTN)
end


function DM_AP_IAS()
    ipc.writeLvar("L:AUTOPILOT_IAS",1)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
    ipc.writeLvar("L:AUTOPILOT_ALTH",0)
end

function DM_AP_ALTH()
    ipc.writeLvar("L:AUTOPILOT_ALTH",1)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
    ipc.writeLvar("L:AUTOPILOT_ALTS",0)
    ipc.writeLvar("L:AUTOPILOT_IAS",0)
end

function DM_AP_ALTS()
    ipc.writeLvar("L:AUTOPILOT_ALTS",1)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
    ipc.writeLvar("L:AUTOPILOT_ALTH",0)
end

function DM_AP_PCLR()
    ipc.writeLvar("L:AUTOPILOT_IAS",0)
    ipc.writeLvar("L:AUTOPILOT_ALTH",0)
    ipc.writeLvar("L:AUTOPILOT_ALTS",0)
    ipc.writeLvar("L:AUTOPILOT_GA",0)
end

function DM_AP_GA()
    ipc.writeLvar("L:AUTOPILOT_GA",1)
end

-- ## AP PANEL
function DM_AP_MAN()
    ipc.writeLvar("L:AP_MASTER",1)
end

function DM_AP_OFF()
    ipc.writeLvar("L:AP_MASTER",0)
end

 

Share this post


Link to post
Share on other sites

Hi @C2615 I can't find any reference to a HGJ Mercure aircraft. Do you have a link?

You don't say which Flt Sim you are using. This will help me provide a more targeted answer.

I would look at an alternative HDG Lvar for the HSI to cope with the radians. Also if you are working with MSFS 2020 then I would look for an Event (Hvar or .EVT) that set the HDG value.


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites
2 hours ago, ScotFlieger said:

Hi @C2615 I can't find any reference to a HGJ Mercure aircraft. Do you have a link?

You don't say which Flt Sim you are using. This will help me provide a more targeted answer.

I would look at an alternative HDG Lvar for the HSI to cope with the radians. Also if you are working with MSFS 2020 then I would look for an Event (Hvar or .EVT) that set the HDG value.

You can find free HGJ Mercure here:

https://simviation.com//hjg/aircraft2/dassault/dassault.htm

And here is how to use it in 64bit P3D, I now run it in v4.5HF3:
 
I don't have any SDKs, all Lvar was found using LINDA Console and Tracer

Share this post


Link to post
Share on other sites

I no longer have a licence for P3Dv4.5 so can not install the aircraft to investigate. However here are a few trips.

The LINDA Tracer is the best place to start. By setting up watches on likely Lvars you can see how they change when items in the cockpit are operated. Lvars can be both read and write but can also be read only allowing you to read current values.

Also check out possible Offsets by referring to the FSUIPC documentation. This is particularly the case when dealing with the AP. Additionally see what effect certain FSUIPC Controls have either on their own or with a parameter.

Your current functions are looking good to me. To test functions being developed, you can right click on the function name to immediately execute the, without having to assign them to a button.


Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...