PDA

View Full Version : PF Script Help


Papa_K
20-07-2005, 03:33 AM
The following is my current script for PF 4.01m:

script
// Left or Right Toe Brakes
if([js3.a1>js3.a2])then
cms.a1=js3.a1;
else
cms.a1=js3.a2;
endif
// Deadband (10) for Toe Brakes
if([cms.a1<10])then
cms.a1=0;
else
cms.a1=(255*(cms.a1-10))/245;
endif
//Repeat keys for manual gear
TIMER (Interval, D1, 2, 1)=js1.b13;
cms.b1=D1;
TIMER (Interval, D2, 2, 1)=js1.b15;
cms.b2=D2;
//Rudder Auto-trim using Button 4 on Throttle
IF (NOT js2.b4) THEN // If Throttle Button 4 is released then
cms.a2 = js3.a3 + a2; // add the offset to the rudder pedals
ENDIF
//
SEQUENCE
WAIT (js2.b4); // Wait until Throttle Button 4 clicks
a2 = js3.a3 - 128; // Calculate the Z offset and save it
ENDSEQUENCE
//
IF (js2.b2 AND js2.b4) THEN // Reset rudder axis
a2 = 0; // With Shift + Throttle Button 4
ENDIF
//
endScript

First, I can't take credit for any of it...it's all from other people's scripts.

My question is about the portion at the bottom: The script will set the rudder axis fine, and reset with a shift (js2.b2) + js2.b4. But, it does this (reset) even if the two buttons aren't hit at the same time. I can hit and release js2.b2, and then hit js2.b4 and the axis resets. (I'm trying to avoid inadvertent resets.)

How do I get the rudder axis to reset ONLY if js2.b2 and js2.b4 are hit at the same time?

Any help will be greatly appreciated.

Papa_K

Bob Church
20-07-2005, 05:15 AM
Hi Papa_K,

I haven't run it, I still don't have the CM running, but as far as I know the logic should be good. I think the likely culprit is this:

SEQUENCE
Â*WAIT (js2.b4); Â* Â* // Wait until Throttle Button 4 clicks
Â*a2 = js3.a3 - 128; // Calculate the Z offset and save it
ENDSEQUENCE

If js3.a3 is centered, it will be generating a value of 128 and since it looks to be the Z axis on the Pedals, then it probably is centered. That being the case, a2 will be reset to 0 on a press of js2.b4 by itself. I'm not sure what you'd want to do instead, but maybe that will explain the reset for you.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Papa_K
21-07-2005, 01:20 AM
And of course you're right...

Don't need the last part to reset the axis, so what the heck was I thinking?

Thanks.

Papa_K

Bob Church
21-07-2005, 02:30 AM
Hi Papa_K,

>> Don't need the last part to reset the axis, so what the heck was I thinking? <<

I kind of wondered too but I didn't recognize the trim code at first. It made more sense when that happened. :) The interlock is a good idea, but I'd think the best way would be to interlock the WAIT in the sequence itself:

sequence
Â*wait( js2.b2 AND js2.b4 ); Â* Â* // Wait until Throttle Button 4 clicks
Â*a2 = js3.a3 - 128; Â* Â* Â* Â* Â* Â* // Calculate the Z offset and save it
endSequence

Then you'd need shift just to set the trim at all, even if it was back to 0 trim with the pedals centered. Or maybe just require that the trim be held for a fairly long time and avoid shifting at all:

timer( ONDELAY, d1, 10 ) = js2.b4;
sequence
Â*wait( d1 );
Â*a2 = js3.a3 - 128;
endSequence

Which would make you hold the button for about a half-second before anything happened. You could adjust that longer if you needed it. Anyway, it would probably be enough to get you around accidental "bumping" of the button..

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Dirk98
20-08-2005, 08:37 AM
Guys, would you be so kind to comment in details on how this AUTOTRIM CMS is supposed to work in Pacific Fighters, outside of CMS interface so to say? What is meant by AUTOTRIM relative to PF?

Unfortunately I don't know programming, but I collect chunks of CMS lines from different scripts with detailed comments to understand what they are intended for and use them for other tasks when applicable. This one sounds interesting but I cant dig it yet.

Thank you.

Dirk98
20-08-2005, 09:23 AM
I'm also interested in this one because I'm trying to use joystick trim functions for Strike Fighters. There's no trimming in that game unlike PF for example where you can assign trimming to buttons or axes in the game interface.

Bu I understand with CMS programming one can shift current values of js1.a1 or js1.a2 (Fighterstick) with clicks on js2.b19-12 (ProThr).

Sorry if it is not very pertinent to the above piece of fine programming.

Anyway could you please post here the final working version of Rudder Autotrim part.

Dirk98
20-08-2005, 09:30 AM
Also, what is "a2" generally and in this particular situation (script for PF):

IF (NOT js2.b4) THEN // If Throttle Button 4 is released then
cms.a2 = js3.a3 + a2; // add the offset to the rudder pedals

Bob Church
20-08-2005, 12:23 PM
Hi Dirk,

The trim sample is in the Users Guide back in the CMS samples section. Basically, you hold the stick itself in a position that gives you level flight (presumably somewhere off stick center). Once you're there, you press and hold a button and that locks the values coming from the stick while the button is down and records them. While the button is down, you move the stick back to center, then release the button. Once the button is released, the recorded values are combined with the stick values to produce the values that you had where you pressed the button, but they'll be delivered when the stick is at center.

For example, stick center is normally at 128 for X and Y. Suppose you need a little forward and left trim, so you move the stick to where it's flying level and the values are 100 and 100. Since the stick by itself will produce 128 and 128 at center, the corrections are the difference, -28 and -28. When you click the button, the 100/100 value is locked down and the -28/-28 corrections are calculated. You move the stick back to center and release the button, the script starts generating the stick values with the -28s added and so at center the modified values are producing 100/100, the value that you "marked" when you pressed the button.

The "a2" value is "Axis 2". The "CMS" part says it's one of the CMS controls, so CMS.A2 is CMS Axis 2. For other controls, the nomenclature is similar. The controller on the first tab (excluding the "Program Settings" tab) in the map is "JS1", the controller on the second tab is "JS2", etc. The X axis is "A1", the Y axis is "A2", the Z axis is "A3", etc. so if you put a FighterStick on the first tab, a Pro Throttle on the second tab, and Pro Pedals on the third tab, you can reference the Pro Throttle Z axis (the throttle handle) as "JS2.A3". Buttons work similarly. Assuming the same setup as just described, the Trigger on the FighterStick would be "JS1.B1" since it's Button 1 on the controller on the first tab.

Anyway, have a look at the sample and see if that helps clear it up a little.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Dirk98
20-08-2005, 07:06 PM
Thanks Bob!