Sign in to follow this  
dragonflightdesign

Differential braking

Recommended Posts

It's been mentioned in a few posts recently that if you use differential braking, you lose access to the KEY_BRAKE (i.e. slam everything on) function. I thought that if you still had access to the key_event then you could possibly get round the problem by using the differential braking as a sort of override function. It turns out you can. The following code uses differential braking to simulate the KEY_BRAKE event. Why bother? This was part of a POC for an antiskid unit; if the antiskid was turned off, I needed to allow direct braking again. The key_event fires off multiple times a second, so the release_timer does two things; it smooths out the key_event and also acts as a delay in releasing brake pressure. I always found the FS native release of pressure to be way too slow; irritatingly slow, in fact.Much of this code doesn't need to be in sub-routines; the sub-routines do more work in the antiskid unit than is shown here. Watch out for the line wraps.-Dai//***************************************************************************void ManualBrake(ID32 event){ if (event==KEY_PARKING_BRAKES || event==KEY_BRAKES || event==KEY_BRAKES_LEFT || event==KEY_BRAKES_RIGHT) { release_timer=currtick18.var_value.n+9; if(release_timer>65536)release_timer-=65536; }}//***************************************************************************//Manual brake operationvoid Brakes(){ lookup_var(&acft_on_gnd); if(acft_on_gnd.var_value.n) { lookup_var(&park_brake); lookup_var(&left_brake); lookup_var(&right_brake); lookup_var(&currtick18); } if(acft_on_gnd.var_value.n) { if(currtick18.var_value.n!=release_timer && release_timer!=-1) { trigger_key_event(KEY_AXIS_LEFT_BRAKE_SET,16383); trigger_key_event(KEY_AXIS_RIGHT_BRAKE_SET,16383); } else { trigger_key_event(KEY_AXIS_LEFT_BRAKE_SET,-16383); trigger_key_event(KEY_AXIS_RIGHT_BRAKE_SET,-16383); release_timer=-1; } } else { release_timer=-1; trigger_key_event(KEY_AXIS_LEFT_BRAKE_SET,-16383); trigger_key_event(KEY_AXIS_RIGHT_BRAKE_SET,-16383); } return;}//---------------------------------------------------------------------------void FSAPI EventHandler (ID32 event, UINT32 evdata, PVOID userdata){ ManualBrake(event);}//-------------------------------------------------------------------------------void FSAPI dfdblind_update (PGAUGEHDR pgauge, int service_id, UINT32 extra_data){ switch(service_id) { case PANEL_SERVICE_CONNECT_TO_WINDOW: register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler,0); break; case PANEL_SERVICE_PRE_UPDATE://Antiskid unit Brakes(); case PANEL_SERVICE_DISCONNECT: unregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler,0); break;

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

>It's been mentioned in a few posts recently that if you use>differential braking, you lose access to the KEY_BRAKE (i.e.>slam everything on) function. I thought that if you still had>access to the key_event then you could possibly get round the>problem by using the differential braking as a sort of>override function. It turns out you can. The following code>uses differential braking to simulate the KEY_BRAKE event. Why>bother? This was part of a POC for an antiskid unit; if the>antiskid was turned off, I needed to allow direct braking>again. The key_event fires off multiple times a second, so the>release_timer does two things; it smooths out the key_event>and also acts as a delay in releasing brake pressure. I always>found the FS native release of pressure to be way too slow;>irritatingly slow, in fact.Hi Dai,It is possible to have full control of braking action using XML gauges as well. Now, I think the important thing is to control brake pressure like FS does, but more efficiently. Add incremental pressure as long as a brake key is pressed/braking condition is met; and release pressure as per aircraft manufacturer's specifications. To add/release brake pressure, simple use a set of 2/3rd order polinomials, instead of issuing 16383/-16383 which only gives Full/none braking action.Just my 2 cents :-)Tom

Share this post


Link to post
Share on other sites

Hi TomI agree; as it stands, what I've written is pretty useless because all it does is duplicate the KEY_BRAKES event. It's a framework that can be extended for differential braking but the important point is that if you use F11 and F12, you won't lose the braking demanded by the joystick trigger (default) or the period key (parking brake). That was my intention in figuring it out; the code is a simple Proof Of Concept and nothing more.-Dai

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