Jump to content
The simFlight Network Forums

How to map brake controls for Nanchang CJ-6 w/FSUIPC in PREPAR3D


Recommended Posts

Sir/Ma'am,

My Googling skills have failed me.  My search in the Forum and FAQs has yielded no fruit.  My comprehension of the FSUIPC User Guide and the Guide for Advanced Users is quite limited.  So... I must ask the community.

Has anyone been able to set up the wheel brakes for the Nanchang CJ-6 in PREPAR3D?  It's tricky bc one needs to actuate the brake handle (activating both brakes) and the deflect the rudder pedals (greater than 16 degrees left or right) to activate the differential steering used to control the aircraft movement on the ground.  I am able to set the brakes up as an axis in the FSUIPC Add-On menu, but I can't decipher how to add the brake handle on the control stick as a "Condition" or "Combination" (in either the Add-On menu or INI file).  Oh, and one still needs the rudder pedals to deflect the rudder as a primary flight control during flight conditions.

It's the same type of setup anyone "flying" the Migs, L-39s or Yaks would need to accomplish, so maybe someone has done that?  I'll take whatever help you have to offer.  

Thanks in advance!

- Josh

 

Here's what I currently have under Axes in my INI file (I think):

PollInterval=10
RangeRepeatRate=10
0=0R,256,D,7,8,0,0    -{ DIRECT: LeftBrake, RightBrake }-
1=0R,BR,1152,16383,65720,0    -{ DIRECT: LeftBrake, RightBrakeEntering=BRAKES_LEFT }-
2=0R,BR,-15803,-1161,65721,0    -{ Entering=BRAKES_RIGHT }-

Link to comment
Share on other sites

3 hours ago, Darth JBell said:

It's tricky bc one needs to actuate the brake handle (activating both brakes) and the deflect the rudder pedals (greater than 16 degrees left or right) to activate the differential steering used to control the aircraft movement on the ground.  I am able to set the brakes up as an axis in the FSUIPC Add-On menu, but I can't decipher how to add the brake handle on the control stick as a "Condition" or "Combination" (in either the Add-On menu or INI file).  Oh, and one still needs the rudder pedals to deflect the rudder as a primary flight control during flight conditions.

I am not sure I understand this - and I don't have this aircraft. Do you have a reference on how this works or can you provide further details? How is the "brake handle" recognised - is that an axis or button, and is any control logged when used, or maybe an lvar is changed? You will probably need to use lua if you want an axis condition. You would write the axis values to an FSUIPC offset, and have a lua script monitor these offsets, calibrate the value and send the appropriate control depending on the brake handle position, which would also need to be monitored.

There is a User Contribution for something similar, where a brake lever is used to control differential braking on a rudder axis - not the same I know, but shows the technique of how to send different controls on an axis depending on another lever: 

 

I can see if I can get hold of this aircraft and take a look, but this may take a while.

John

Link to comment
Share on other sites

6 hours ago, Darth JBell said:

Here's what I currently have under Axes in my INI file (I think):

PollInterval=10
RangeRepeatRate=10
0=0R,256,D,7,8,0,0    -{ DIRECT: LeftBrake, RightBrake }-
1=0R,BR,1152,16383,65720,0    -{ DIRECT: LeftBrake, RightBrakeEntering=BRAKES_LEFT }-
2=0R,BR,-15803,-1161,65721,0    -{ Entering=BRAKES_RIGHT }-

This seems rather strange, as you are sending the left/right brake controls on the R (rudder) axis, and are also repeatedly sending BRAKES_RIGHT or BRAKES_LEFT when the rudder is more than approx 2/3rds full left or full right.

Link to comment
Share on other sites

i have this aircraft now. I can see this brake lever, and it is documented as:

39 Brake grip on Rear Control Stick, Press and hold to set wheel brake active.

However, I cannot seem to 'press and hold' this - when I click it, it moves to the  right slightly, sends a BRAKES control, and then goes back to its original position.

I presume the toe controls only control the rudder (i.e. only lateral movement, no movement on each pedal.

How is this supposed to work?

Does moving the tie pedals usually control the rudder, and when you want differential braking, you move the brake lever to the right (and hold it) and then use the rudder control for differential braking?

You can assign a button or key to the FS control BRAKES, on repeat. This will move the brake lever and keep it in position while the button/key is held.

If you then want to use the rudder pedals for differential braking (if the aircraft supports this), you would have to use a lua script to control both rudder and breaking.
You would write your rudder axis value to an FSUIPC offset, and then monitor this offset in a lua script. When the offset changes, your handling function will receive the axis value, You then decide if this is a rudder control or a brake control by looking at the state of the brake lever (you can also monitor this to determine if braking or steering).

As I now have this aircraft, I can help further, but I need to know how this works in the aircraft, and how you want to assign to reflect this.
It seems that if the brake lever is sending the BRAKES control, it isn't doing differential braking.

John

Link to comment
Share on other sites

Thanks for looking at this, Sir!  
 

It’s weird right?  So in the real aircraft 3 things are going on:  

- First, when one moves the rudder bar, the rudder deflects a proportional amount just like any other aircraft as the two are connected via cable. 

- Second, when one grasps the “bicycle” brake handle, air from the pneumatic system is sent to both wheel brakes in equal amounts when the rudder bar is centered (not deflected more than 16 degrees either direction).

- Finally, when one positions the rudder bar past neutral (anything greater than 16 degrees) with the brake handle also depressed, air from the pneumatic system is metered more toward the deflected side and less from the other side causing a differential braking condition for ground steering.

Here is an example:  if one wished to make a left turn onto the runway for takeoff, one would first put in left rudder bar deflection (something past 16 degrees of center), then apply a bit of pressure to the brake handle (maybe a couple of quick blips then release).  More air going to the left brake will cause the plane to turn left on the ground.  As soon as the plane starts turning, one would release the brake handle air pressure but probably keep the rudder bar deflected in case more turn was needed for the runway line up.  After a couple more blips of hand braking with the rudder bar deflected, one will take out the rudder bar deflection and brake handle application to let the nose wheel straighten out for the line up (it’s free castering).  After the nose wheel is straight one will then apply even braking (centered rudder bar) with the brake handle to come to a complete stop before engine run up for departure.  All the while, the rudder deflected with each rudder bar movement a proportional amount independently of the level of brake handle application.  
 

So weird…

Thanks again for looking.

P.S.  Yeah, that script in the INI file is just what populated when I tried to set up just the brake deflection with the Add-On menu in PREPAR3D.  I definitely didn’t get it right.  😢


 

 

Link to comment
Share on other sites

10 minutes ago, Darth JBell said:

It’s weird right?  So in the real aircraft 3 things are going on:  

- First, when one moves the rudder bar, the rudder deflects a proportional amount just like any other aircraft as the two are connected via cable. 

- Second, when one grasps the “bicycle” brake handle, air from the pneumatic system is sent to both wheel brakes in equal amounts when the rudder bar is centered (not deflected more than 16 degrees either direction).

- Finally, when one positions the rudder bar past neutral (anything greater than 16 degrees) with the brake handle also depressed, air from the pneumatic system is metered more toward the deflected side and less from the other side causing a differential braking condition for ground steering.

Ok, that should be possible via lua. How are you planning to control the "brake handle"? Do you want this assigned on a button or key press?
I will take a look and provide you a lua script to test, but it may take several days as I am pretty busy at the moment (well, always!).

John

 

Link to comment
Share on other sites

11 minutes ago, Darth JBell said:

I have a brake “handle” on my X56 HOTAS.  I’ll get the Joy Number and Button Number in just a sec.

No need. I will just use a spare button. You will have to update the scripts I provide for your controller letters, axes letters button numbers and offsets to use anyway.

This seems very similar to the Spitfire differential braking, except the control for that was on a brake lever which is an axis. Should be simpler on a button.

John

Link to comment
Share on other sites

Here are my joystick numbers

1 minute ago, John Dowson said:

No need. I will just use a spare button. You will have to update the scripts I provide for your controller letters, axes letters and button numbers anyway.

This seems very similar to the Spitfire differential braking, except the control for that was on a brake lever which is an axis. Should be simpler on a button.

John

Great, Sir!  Thank you.

Link to comment
Share on other sites

Can you try the following lua script. To use, first save this file to your FSUIPC6 installation folder (or your Lua library folder if you have set a different folder for lua files via the LuaPath ini parameter).

You then need to:

1. Have the lua file auto-started. To do this, add to your profile [Auto.xxx] section (or just [Auto] if using profiles-in-separate-files, in your profile file), e.g.:

Quote

[Auto.Nanchang]
1=Lua nanchangBrake

2. Assign your rudder axis with Send to FSUIPC Offset, and use control Offset Dword Set and offset xA010 (you can use a different offset, but if you do you also need to change the offset used in the script, local variable rudderAxisOffset)

3. Open the lua file you installed and set the following variables to specify the joystick & button you are using to control the brake lever:

Quote

local brakeLeverJoystickLetter = "S" -- the letter of the joystick that has the button used to control the brake lever
local brakeLeverButton = 0 -- the number of the button on the joystick that is used to control the brake lever

4. You can also set logging if you want to see what is happening by changing the enableLog value from false to true.

5. You can adjust the repeat rate for standard brakes by altering the brakesInterval value - increase for slower braking, decrease for faster braking

Let me know how it goes and if you need further tuning. I have commented the script so you should be able to tune for your needs.

John

nanchangBrake.lua

 

Link to comment
Share on other sites

Well, it's still not working.  😢

When it does run, it just acts like regular nosewheel steering.  There seems to be no bias toward the brake handle needing to be actuated.  In the .LUA script it references a letter (in addition to the assigned number) for the joystick to which the brake button is attached.  Is that what I'm doing wrong?  I only have the X56 HOTAS which shows up in my .INI as Joystick 2.  It's Button 5 for the brake handle.  Where would I find the "letter" to input.  The Script says Letter "S."

Thanks for looking into this mystery.  I know it's strange, and I appreciate your time.  

-Josh

 

P.S.  Attached is what I've got in my .INI and .LUA

 

 

 

FSUIPC6.ini nanchangBrake.lua

Link to comment
Share on other sites

3 hours ago, Darth JBell said:

When it does run, it just acts like regular nosewheel steering.

That is because you haven't set-up the brake lever button correctly.

3 hours ago, Darth JBell said:

In the .LUA script it references a letter (in addition to the assigned number) for the joystick to which the brake button is attached.  Is that what I'm doing wrong?  I only have the X56 HOTAS which shows up in my .INI as Joystick 2.  It's Button 5 for the brake handle.  Where would I find the "letter" to input.  The Script says Letter "S."

If you are not using the joy letters functionality (you should!),  then just set the brakeLeverJoystickLetter variable to the joystick number, i.e.
     local brakeLeverJoystickLetter = 2

I have modified in the attached to make it clear that you can use the joyletter or number.

John

nanchangBrake.lua

Link to comment
Share on other sites

No, sir.  Still nothing new.  The axis still acts like normal nosewheel steering.  Yes, the differential braking works (I guess it always did), and the hand brakes work in concert when the pedals are neutral, but it still steers on the ground with just rudder pedal deflection when no hand brakes are applied.   The plane would not do that in real life.  I even added joy letters (naming the control stick C) to see if that helped.

What are you thoughts?  Somehow we must remove the nosewheel steering functionality.    

Were you able to get your Chang to work?

- Josh

P.S.  Maybe I should've shared more of my purpose and background.  I'm hoping to develop this model in order to help others learn ground ops on the real life Nanchang CJ-6.  I'm not a programmer or a true Simmer; just a pilot hoping to learn new ways of teaching.  I bought DCS just so I could get the Yak (it works great with no mods just as in real life), and I got P3D just for the Chang.  I was disappointed with the model's functionality and set out to improve it with FSUIPC, but I may have gotten in over my head.  I truly appreciate your help.  If we can solve this mystery, we may be able to help all sorts of new Red Star pilot types learn how to taxi Migs, L-39s, L-29s, Yaks, Changs and other Eastern Bloc planes w/air systems.   

 

Link to comment
Share on other sites

5 hours ago, Darth JBell said:

The axis still acts like normal nosewheel steering. 

It should do when no braking is applied...

5 hours ago, Darth JBell said:

Yes, the differential braking works (I guess it always did)

No - the script controls differential braking, which activates when the brake lever is pressed and the rudder has > 16 degrees deflection. There is no differential braking without using the script, unless you have also assigned that directly to your rudder axis.

5 hours ago, Darth JBell said:

and the hand brakes work in concert when the pedals are neutral,

as it is supposed to...

5 hours ago, Darth JBell said:

but it still steers on the ground with just rudder pedal deflection when no hand brakes are applied. 

Of course, as it is being steered by the rudder. Are you saying that you do not want any rudder changes deflection to be sent when on the ground? Any rudder deflection will effect the steering when on the ground.

5 hours ago, Darth JBell said:

I even added joy letters (naming the control stick C) to see if that helped.

Why would that help? You can use the letter or the id/number, but the result would be the same.

Note that no steering controls are being sent - only rudder controls. It is this that is steering the aircraft when on the ground. You can prevent this, but then you would also see no rudder deflection when moving the rudder when on the ground. Try the attached script for this. i.e. rudder controls only sent when airborne.

Please look at the scripts and work out what is happening. If you understand them, you can modify them yourself to suit your needs.

John

nanchangBrake.lua

 

 

Link to comment
Share on other sites

Sir,

I definitely think we're getting close.  This last one is the best yet!  We still want the rudder to move though.  We just don't want it to perform a nosewheel steering sort of function on the ground. 

What if we change this portion of the script (or a different portion if I've got that wrong) to an airspeed value instead of having "onGround?"  Could we maybe do something like 20 knots/37 kph?  That way it could work with the funky braking requirements of the Chang on the ground but still be functional as a necessary control surface for takeoffs and landings.  

 function calculateBrakeValues()
  -- First check if on ground - if not, we can ignore
  onGround = ipc.readUW(0x0366)
  if onGround == 0 then -- airborne
    return
  end

What do you think?

-Josh

 

Link to comment
Share on other sites

4 hours ago, Darth JBell said:

We still want the rudder to move though.  We just don't want it to perform a nosewheel steering sort of function on the ground. 

But this is just not possible. If you move the rudder while moving on the ground, the aircraft will turn, but from the rudder effect not the nosewheel steering. There is no nosewheel steering on this aircraft (as far as I am aware). If it is steering too much via the rudder only (compared to real life), then this is an issue with the model. You may be able to adjust this by updating some of the model parameters, but I cannot help with this - you need to talk to the aircraft developers. 

4 hours ago, Darth JBell said:

What if we change this portion of the script (or a different portion if I've got that wrong) to an airspeed value instead of having "onGround?"  Could we maybe do something like 20 knots/37 kph?  That way it could work with the funky braking requirements of the Chang on the ground but still be functional as a necessary control surface for takeoffs and landings.  

What do you mean? If you changed that section of code to exit/return if ground speed was above 20 knots/37 kph, then no differential braking would be used above this speed.
You could do that, but I think what you would want is the rudder controls to also work, but it is not clear to me if you want the rudder to work when below this ground speed or above, and this is the section of code that determines when to send the rudder controls:

Quote

    -- Only send rudder controls if in airborne
  onGround = ipc.readUW(0x0366)
  if onGround == 0 then -- airborne
      ipc.control(rudderControl, value)
    if enableLog then
        ipc.log("rudderControl sent with value=" .. value)
    end
  end

So, please explain exactly what you would like the script to do. You can also try adapting it yourself...

Note the following restrictions due to the way the aircraft is modeled - to get these changed you need to talk to the aircraft developers:
   - the brake lever only moves when you send the BRAKES control, so when differential braking, the lever will not be in the correct position
   - how the aircraft steers on rudder control only when on the ground is up to the aircraft model

John

Link to comment
Share on other sites

Ok.  So it’s a developer thing which makes the aircraft move on the ground with nothing but rudder deflection.  FSUIPC can’t change this.  Got it.  
 

On 4/25/2024 at 3:58 AM, John Dowson said:

What do you mean? If you changed that section of code to exit/return if ground speed was above 20 knots/37 kph, then no differential braking would be used above this speed.
You could do that, but I think what you would want is the rudder controls to also work, but it is not clear to me if you want the rudder to work when below this ground speed or above, and this is the section of code that determines when to send the rudder controls:

Yes.  Let’s try this.  Since we can’t change the model to act like real life, let’s trick it into thinking it’s off the ground at a particular airspeed (our best guess of when the rudder will become effective; 20knots/37 kph)… So only rudder usage above this speed and no differential braking.  Below this speed, we’d have only differential braking and no rudder usage.  We could tweak it if it’s too high/low later.

I’ll ask Bear if they can update their model.

Thanks a bunch!

- Josh

Link to comment
Share on other sites

17 hours ago, Darth JBell said:

Yes.  Let’s try this.  Since we can’t change the model to act like real life, let’s trick it into thinking it’s off the ground at a particular airspeed (our best guess of when the rudder will become effective; 20knots/37 kph)… So only rudder usage above this speed and no differential braking.  Below this speed, we’d have only differential braking and no rudder usage.  We could tweak it if it’s too high/low later.

Please try the attached lua - I have added a new local variable for the effective ground speed:

Quote

-- rudderEffectiveSpeed: Rudder only effective when on ground above this
-- speed, and no differential braking above this speed. Rudder still sent when aircraft is static.
--     20 knots/37Km/h = 10.28 m/s = 673564/65536
local rudderEffectiveSpeed = 673564    

John

nanchangBrake.lua

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.