Results 1 to 4 of 4
-
11-21-2009, 10:11 PM #1
How do you set the altitude for AP?
I have been trying for two weeks to use an encoder to set the autopilot's altitude. Currently I have a Go-Flight AP which allows me to set the altitude and see it on LED displays.
I want to eventually get rid of the go-flight AP for a custom one. The first step is using an encoder to set the altitude. I have tried using parts of MEC scripts. Peter gave me some ideas and I have tried to use his info to build my script. It looks to me like it should work. It doesn't.
Using IPConsole I can see the altitude change ad the offset change with the Go-Flight dial. Not with my encoder. The encoder is working so the problem is in my scripts. Any help appreciated. Here is the latest code.
Var 3050, name AP_ALT, Link FSUIPC_INOUT, Offset $07D4, Length 4
{
L0 = &ROAP_ALT * -1 // turn clockwise to increase
IF L0 > 0
{
L0 = L0 + 100
}
ELSE
{
L0 = L0 -100
}
&AP_ALT = ROTATE 0, 80000, L0 // Increase or Decrease altitude
}
Var 3053, name ROAP_ALT, Link IOCARD_ENCODER, Input 43, Aceleration 6, Type 2
I tried // out the ROTATE function line. It didn't help.John
System:
ASUS P5Q SE/R
Intel Q9550 O/C to 3.4 GHz
4 GB 1066 DDR2 RAM
300 GB WD 10,000 RPM Raptor SATA Drive
GeForce 8800 GT 512 KB RAM
Matrox TH2Go with three 19" Sumsung 940 BX
IR Track 4
-
11-22-2009, 12:46 AM #2
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: How do you set the altitude for AP?
Hello, Peter.
As written, your script does nothing with inputs from the encoder.
You want to execute some SIOC commands as a result of changes to variable 3053 so
{
L0 = &ROAP_ALT * -1 // turn clockwise to increase
.
.
should be placed after that declaration.
Then you would have to make adjustments to deal with the fact that $7D4 is "Autopilot altitude value, as metres*65536". So to add 100 ft you need to convert that to metres and then multiply by 65536. It will take a lot of turns of your encoder to get there in fractions of a centimetre, as you are doing.
A better method is to let FS (or Peter Dowson) do the work for you via offset $3110. FS has a bunch of functions built-in which are available to application programmers as FS Controls. The FSUIPC package puts the list in your Modules folder. You'll see there two controls of immediate interest:
65892 AP_ALT_VAR_INC
65893 AP_ALT_VAR_DEC
These are two of the functions you want with their associated control numbers. FSUIPC will invoke those functions on your behalf if you stuff the appropriate control number into offset $3110. [You just need length 4 for your
AP_ALT functions as they do not need a parameter]
Those two give you 100ft increments/decrements. To get 1000ft steps, look at the FSUIPC guide for Advanced Users where you will find that Peter has augmented the FS list with "Additional 'FS' Controls" - including:
1016 Ap Alt Var Dec Fast (1000)
1017 Ap Alt Var Inc Fast (+1000)
So your script using this solution might be::
-----------------------------------------------------------
Var 3050, name FS_Controls, Link FSUIPC_OUT, Offset $3110, Length 4
Var 3053, name ROAP_ALT, Link IOCARD_ENCODER, Input 43, Aceleration 6, Type 2
{
IF &ROAP_ALT > 0
{
...IF &ROAP_ALT > 1
......{
.......&FS_Controls = 1017 // Ap Alt Var Inc Fast
.......}
...ELSE
......{
.......&FS_Controls = 65892 // AP_ALT_VAR_INC
......}
}
ELSE
{
...IF &ROAP_ALT < -1
......{
.......&FS_Controls = 1016 // Ap Alt Var Dec Fast
......}
...ELSE
......{
.......&FS_Controls = 65893 // AP_ALT_VAR_DEC
......}
}
&FS_Controls = DELAY 0 ,5 // Pause to allow FSUIPC to work
// Then clear the offset for the next time.
}
-----------------------------------------------------------
Some other observations:
L0 = &ROAP_ALT * -1 // turn clockwise to increase
&AP_ALT = ROTATE 0, 80000, L0 // Increase or Decrease altitude
G'night.
Jim
-
Post Thanks / Like - 1 Thanks, 0 Likes, 0 Dislikesjmig thanked for this post
-
11-22-2009, 04:58 AM #3
- Join Date
- Jan 2007
- Posts
- 496
Re: How do you set the altitude for AP?
I'm afraid I can't help with your script code (don't know it at all), but you should note that the A/P target altitude at offset 07D4 is in units of 1/65536ths of a metre. so you probably have some arithmetic to do at some place in the script.
[Ah, I see Jim's already clarified that point for you ... Tks!]
Pete
-
11-22-2009, 06:07 PM #4
Re: How do you set the altitude for AP?
Woooooohhhhhooooooooo! It works!!!
Thanks a Million to everyone who helped me. I may not be a programmer but, with help like this even I can get SIOC to do what I want it to do.
John
System:
ASUS P5Q SE/R
Intel Q9550 O/C to 3.4 GHz
4 GB 1066 DDR2 RAM
300 GB WD 10,000 RPM Raptor SATA Drive
GeForce 8800 GT 512 KB RAM
Matrox TH2Go with three 19" Sumsung 940 BX
IR Track 4
Similar Threads
-
altitude alerts in pm gc
By flyboy01 in forum PM Boeing GCReplies: 7Last Post: 03-28-2009, 07:31 AM -
Altitude MCP vs PMDG 737
By Delvos in forum OpenCockpits General DiscussionReplies: 0Last Post: 12-22-2008, 05:04 AM -
Altitude alert
By 737NUT in forum PM General Q & AReplies: 0Last Post: 02-02-2008, 10:04 AM -
RA altitude PFD
By Tom Stian Bjerk in forum PM General Q & AReplies: 4Last Post: 04-13-2006, 10:17 AM
Looking for Fun? Connect with Women Seeking Casual Encounters in Your Town
JH startup on Client PC