New Way to Control Train Brakes from the Keyboard

Discussion of rolling-stock creation & re-painting.

New Way to Control Train Brakes from the Keyboard

Unread postby wacampbell » Mon Jan 05, 2015 6:34 pm

I have been spending time lately doing a lot of switching on the RW&A. When I do switching operations I spend a lot of time out of the cab, controlling the locomotive via keyboard and watching the F4 HUD display. I find it a bit frustrating controlling the brakes with the keyboard - finding just the right position for apply, release etc without accidentally throwing it into emergency. So I worked out an alternate way to use the keyboard for controlling the brakes. It doesn’t change mouse operation at all.

I treat the brake control as if it is 'spring loaded'. To apply the brakes, press the apostrophe ( ' ) key as usual. The brake pipe pressure drops so long as you hold the key down. When you release the key, the brake lever moves to 'hold' and the brake pressure remains where you set it. Pressing semicolon ( ; ) releases the brakes ( charges the brake pipe ) so long as you hold down the key. When you release the semicolon, the brake lever moves to 'running' position.

Similarly with the engine brake , hold right bracket ] down to apply the engine brake. Releasing the key moves the lever to 'hold'. Pressing left bracket [ moves the engine brake lever to release and when you lift the key it returns to 'hold'.

I also added a 'snap' action to the reverse lever so the w and s keys quickly snap from forward to reverse.

The emergency brake is activated with the backspace key so you can't accidentally move to emergency during routine switching.

I find the controls much more intuitive now, and I am able to operate the loco without looking at the gauges or HUD display. I am pretty familiar with prototype brake control and fully admit that this is a major simplification. But the notion of 'apply pressure' / 'release pressure' feels a lot more like the prototype than the default keyboard handling.

I have attached a copy of my files in case you might want to try it out. The package contains modified files for the RS-1 loco that comes with the RWA route. The modified loco will appear as 'ALCo RS-1 RWA WAC' in the scenario editor, or you can rename the file to overwrite the default RS-1 loco.

RWA_RS-1_WAC.zip




For the techno types out there, here’s how I implemented this feature. I’ll describe only the TrainBrakeControl. The EngineBrakeControl was handled in a similar manner.

To make this work I needed to put the keyboard processing under control of the Engine Script. But normally the Engine Script can’t read the keyboard state. So I added two new control values to the Engine Blueprint, these control values are made to mirror the state of the the semicolon and apostrophe keys on the keyboard. The Engine Script queries these control values to learn the state of the keys and set the actual Train Brake Control accordingly. In most locomotives these keys are connected directly to the TrainBrakeControl. My change essentially disconnects them from TrainBrakeControl, routing their signal through the Engine Script instead.

To go into it in more detail, refer to the block diagram below.
New Loco Brakes.jpg


INPUT MAPPER - IM_Expert_RWA_WAC.bin is a copy of the standard RWA mapper, IM_Expert_RWA.bin, with the brake keys remapped as follows:

Key_Apostophe, ButtonDown maps to IncreaseControlStart, ApplyBrake
Key_Apostophe, ButtonUp maps to DecreaseControlStart, ApplyBrake
Key_SemiColon, ButtonDown maps to IncreaseControlStart, ReleaseBrake
Key_SemiColon, ButtonUp maps to DecreaseControlStart, ReleaseBrake

ENGINE BLUEPRINT - Alco_RS-1_001_WAC.bin - has two new entries in the ControlValues section for ApplyBrake, and ReleaseBrake. These controls have a value range between 0 and 0.2 to represent the key up and down states. This limited range improves the response time of the control. These control values are meant to mirror the state of the keyboard semicolon and apostrophe keys.

I also modified the notch settings of the TrainBrakeControl to implement only Release, Run, Hold, FullService, and Emergency.
And I directed ExpertRemapper to the new input mapper.

ENGINE SCRIPT - The final component is the modified engine script, RS-1_EngineScript_WAC.lua The work is done in the OnControlValueChange function by these lines:

Code: Select all
   --- TRAIN BRAKE CONTROLS
   if name == "ApplyBrake" then
      if  value > 0.1 then
         --- When Apostrophe is pressed, TrainBrakeControl sets to FullService
         Call( "*:SetControlValue", "TrainBrakeControl", 0, 0.6 ) 
      else
         --- When Apostrophe is released, TrainBrakeControl sets to Hold
         Call( "*:SetControlValue", "TrainBrakeControl", 0, 0.4 ) 
      end
   elseif name == "ReleaseBrake" then
      if  value > 0.1 then
         --- When SemiColon is pressed, TrainBrakeControl sets to Release
         Call( "*:SetControlValue", "TrainBrakeControl", 0, 0 )   
      else
         --- When SemiColon is released, TrainBrakeControl moves to Running
         Call( "*:SetControlValue", "TrainBrakeControl", 0, 0.2 )
      end


As an example, lets follow the control flow when the player presses the Apostrophe key to apply the brakes:
- user presses Apostrophe key
- input mapper translates Apostrophe Down to ApplyBrakes IncreaseControlStart
- in the engine blueprint, the ApplyBrake control value begins to increase from 0 and quickly reaches 0.2
- this triggers the OnControlValueChange function in the engine script.
- when OnControlValueChange detects that ApplyBrake value has increased past 0.1 ( the half way point ) it considers the key pressed, and sets the TrainBrakeControl to 0.6, which is the FullService notch


I hope you like this method of brake control and please take what you need from this to implement it in your own locos.



Wayne
You do not have the required permissions to view the files attached to this post.
Last edited by wacampbell on Tue Jan 06, 2015 9:06 am, edited 3 times in total.
Wayne Campbell
wacampbell
 
Posts: 510
Joined: Tue Sep 27, 2011 12:45 pm
Location: BC, Canada

Re: New Way to Control Train Brakes from the Keyboard

Unread postby Chacal » Mon Jan 05, 2015 8:02 pm

Done like a pro.
This is quite clever, I wouldn't have thought of that.
This circumvents the flaws of using the keyboard (not notched and no visual clue about amount of release).
I will try this, at least until I get a Saitek throttle quadrant.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6492
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: New Way to Control Train Brakes from the Keyboard

Unread postby Kali » Tue Jan 06, 2015 7:04 am

If you want a simpler way of doing it using one up/down control, you can have a three position control ( -1/0/1 ) with only one notch, like the PBL brakes for some european stock ( the 66 for example ). PBL brakes control pipe pressure using a single + or - pressure notch, so it might be worth having a quick look at those implementations too given they're doing the same thing a little more explicitly.
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea


Return to Rolling-Stock Design

Who is online

Users browsing this forum: No registered users and 2 guests