PDA

View Full Version : Toe brakes for Lock On v1.1


Revvin
13-04-2005, 07:23 PM
This question was asked in another forum so I'll post the solution here as I can attach images to my post to illustrate it.

Unfortunately Lock On v1.1 does not support analogue toe brake input so a very small .cms script can be used to provide the digital input required by the sim. The script looks like this:

[attachmentid=654]

The last two lines are to control the toe brakes and as you can see CMS Button 1 (imagine cms buttons as virtual buttons) will operate when the toe brakes are pushed approximately 3/4 of their total travel (the normal range of the toe brakes read from 0-255, CMS Button 1 will operate when the toe brake passes 220) Now all we need to do is tell Control Manager what command we want to execute when CMS Button 1 is operated. To do this we click on the CMS Controls tab in our control manager map file. If you have not added CMS capability to your map file click the 'Add' button http://www.ch-hangar.com/SiteFiles/Images/faq/cmaddbtn.jpg and select to add CMS controls in the pop up window that is displayed. Click on the CMS Controls tab and you'll see rows of the CMS Buttons that you can assign commands onto. As you're mouse moves over each one a tool tip will display telling you which button is which.

[attachmentid=655]

Select B5 and untick the 'Direct X Mode' tick box and either enter the letter w in the dialogue box or if you are using a .cmc file for your commands then select it from the list as you normally would (For help on using .cmc files have a look at the FAQ here (http://www.ch-hangar.com/content.php?content.2#cmcfiles). Repeat the process for button B6 in the CMS Controls tab and that's it your done! Download your profile to your controllers and you can then use the keycheck button http://www.ch-hangar.com/SiteFiles/Images/faq/cmkeycheckbtn.jpg to test you're toe brakes are functioning.

Outlaw
17-04-2005, 02:03 PM
Revvin,
I recently, posted this question over on Lock-ON Flaming Cliff forum, and decided to join this one after reading your very informative response. Thanks! :thumbsup:

Revvin
17-04-2005, 02:58 PM
You're most welcome Outlaw :salute:

Outlaw
30-04-2005, 02:04 AM
REVVIN,
I hate to be a problem, but I'm attempting to program my CH Pedals using the script method as you described above with no sucess at all. I using CH Manager ver. 3.60 and made the CMS script in the editor (it checked out okay)and programed button B5 & B6, downloaded to the controller. The rudder works fine but no brakes, I must me over looking something. Are there some adjustments in FC options I need to make? When programing butons B5 & B6 where should I place the "W" that operates the brakes in the increase or decrease area or both? :(

Revvin
30-04-2005, 11:53 AM
Are you're pedals device 3 in your profile? (click on an axis and look on the right of the screen under the 'DirectX Function' heading) Leave the left and right toe brake as the X and Y axis respectively by leaving the DirectX Mode box checked. Set buttons B5 and B6 to generate a 'w' or select the brake command in you're .cmc file and put it to the 'Normal Action' 'Press' box.

If you're pedals are not device three then you will need to edit the .cms script so for instance the first line of the script reads:

CMS.B5 = [JS3.A1 > 220]; // Wheel Brakes

If your pedals were device 2 then it would read:

CMS.B5 = [JS2.A1 > 220]; // Wheel Brakes

Outlaw
30-04-2005, 12:38 PM
Thanks Revvin!
My pedals are working great! :cheers:

DonULFonso
15-12-2005, 09:14 PM
Hm, why just set up a DIGITAL on/off brake if it's NP to emulate an ANALOGUE operation just as well ;) ?

Here's an example for the left toe-brake (you need to assign the key-stroke(s) to apply the brake to button B1 on teh CMS Controls tab of the CM's GUI):

SCRIPT

B1 = ( [ JS3.A1 >= 250 ] );
TIMER ( INTERVAL, D1, 1, 1 ) = ( [ JS3.A1 >= 200 ] ) AND ( [ JS3.A1 < 250 ] );
TIMER ( INTERVAL, D2, 1, 2 ) = ( [ JS3.A1 >= 150 ] ) AND ( [ JS3.A1 < 200 ] );
TIMER ( INTERVAL, D3, 1, 3 ) = ( [ JS3.A1 >= 100 ] ) AND ( [ JS3.A1 < 150 ] );
TIMER ( INTERVAL, D4, 1, 4 ) = ( [ JS3.A1 >= 50 ] ) AND ( [ JS3.A1 < 100 ] );

CMS.B1 = ( B1 OR D1 OR D2 OR D3 OR D4 );

ENDSCRIPT

The more you push it, the more you brake: there are 6 regions, starting with inactive brakes and then 'hammering' the brake-key(s) 4 times per second to 10 times per second the more you push the left toe-brake, until the max. position finally gives you full brakes by generating the held down braking-key :) .

Here's that same example but for both toe-brakes - and the lowest toebrake (i.e. the highest analogue value) scores:

SCRIPT

B1 = ( [ JS3.A1 >= 250 ] ) OR ( [ JS3.A2 >= 250 ] );
TIMER ( INTERVAL, D1, 1, 1 ) = ( [ JS3.A1 >= 200 ] AND [ JS3.A1 < 250 ] AND NOT [ JS3.A2 >= 250 ] ) OR ( [ JS3.A2 >= 200 ] AND [ JS3.A2 < 250 ] AND NOT [ JS3.A1 >= 250 ] );
TIMER ( INTERVAL, D2, 1, 2 ) = ( [ JS3.A1 >= 150 ] AND [ JS3.A1 < 200 ] AND NOT [ JS3.A2 >= 200 ] ) OR ( [ JS3.A2 >= 150 ] AND [ JS3.A2 < 200 ] AND NOT [ JS3.A1 >= 200 ] );
TIMER ( INTERVAL, D3, 1, 3 ) = ( [ JS3.A1 >= 100 ] AND [ JS3.A1 < 150 ] AND NOT [ JS3.A2 >= 150 ] ) OR ( [ JS3.A2 >= 100 ] AND [ JS3.A2 < 150 ] AND NOT [ JS3.A1 >= 150 ] );
TIMER ( INTERVAL, D4, 1, 4 ) = ( [ JS3.A1 >= 50 ] AND [ JS3.A1 < 100 ] AND NOT [ JS3.A2 >= 100 ] ) OR ( [ JS3.A2 >= 50 ] AND [ JS3.A2 < 100 ] AND NOT [ JS3.A1 >= 100 ] );

CMS.B1 = ( B1 OR D1 OR D2 OR D3 OR D4 );

ENDSCRIPT

Here's how it works: it works exactly like I described: the more you push the toebrake (any of them - the one that's pushed farther counts), the faster the "brake"-key gets generated (the key is continuously sent as being pressed and released immediately as long as any of the toebrakes is used), and when you push it through to its max. stop, then this key is sent as being held depressed.

The physical range of the toebrakes' axes is divided into 6 regions or bands, with a small region at min. and max. and larger regions of the same size between these extremes. Analog readout of DirectX-axes means RAW-values between 0 and 255 - divide a position's analog value through the axis' total to get the percentage that tells you the physical position along an axis' travel:

RAW min. RAW max. | value/total=relative | r e g i o n s
--------------------------+-----------------------+----------------------+---------------
( [ JS3.A1 >= 250 ] ) | 250 / 255 = 0,98 | 6. 98% - 100%
( [ JS3.A1 >= 200 ] ) AND ( [ JS3.A1 < 250 ] ) | 200 / 255 = 0,78 | 5. 78% - 98%
( [ JS3.A1 >= 150 ] ) AND ( [ JS3.A1 < 200 ] ) | 150 / 255 = 0,59 | 4. 98% - 59%
( [ JS3.A1 >= 100 ] ) AND ( [ JS3.A1 < 150 ] ) | 100 / 255 = 0,39 | 3. 59% - 98%
( [ JS3.A1 >= 50 ] ) AND ( [ JS3.A1 < 100 ] ) | 50 / 255 = 0,20 | 2. 20% - 59%
// ( [ JS3.A1 < 50 ] ) | 50 / 255 = 0,20 | 2. 0% - 20%

CH's CM can only read DirectX' RAW-values (yet?), no percentual references. TM's compiler prefers percentages:

r e g i o n s :
<-1->
<-2->
<-3->
<-4->
<-5->
<-6->
--+--+--+--+--+--+---
0 10 30 50 70 90 100

But for both, the max. value of the previous region is the start value of the next region.

We need at least one 'logical' button where we can assign the desired output to (we could as well define individual 'logical' buttons for each region, but why waste programmable positions?): in this case I've chosen CMS.B1, i.e. button 1 on the CMS Controls tab of the CM's GUI.

This 'button' actually is defined as any of a specified set of conditions' 'buttons', respectively bits and variables: simple bits "Bn" (without any prefix to indicate a physical controller or logical button) can be set up just like any other bit (any button actually is a bit: it's either digitally 'on' = TRUE or 'off' = FALSE), only that you cannot assign any output directly to it - but you can go the other way round: you can assign a logical button to a bit.

Another type of bit is the device variable "Dn" which can be used to set up e.g. a logical TIMER. To get a 'flashing' bit that's turning 'on'/'on' = TRUE/FALSE continuously as long as its conditions are matched = TRUE, we can use the INTERVAL type TIMER:

TIMER ( INTERVAL, D1, 1, 1 ) = whatever_condition(s);

The 1st parameter specifies the type "INTERVAL", the 2nd parameter the name "D1", and then you need to specify 2 numeric values to specify the period of time that it is to be TRUE respectively FALSE while 'flashing' (you set the rate of the 'flash', so to say, or rather its frequency). These values are in character times, which by default is 50ms; the bits and values I've used thus simply mean the following 'on'/'off'-times and the resulting 'frequency' [Hz], i.e. number of 'flashes' or impulses per second:

on off | period 'on' | period 'off' | period 1 cycle | Hz
-----------------------------+-----------------+------------------+----------------------+------
TIMER ( INTERVAL, D1, 1, 1 ) | 1 * 50ms = 50ms | 1 * 50ms = 50ms | 50ms + 50ms = 100ms | 10
TIMER ( INTERVAL, D2, 1, 2 ) | 1 * 50ms = 50ms | 2 * 50ms = 100ms | 50ms + 100ms = 150ms | 6.7
TIMER ( INTERVAL, D3, 1, 3 ) | 1 * 50ms = 50ms | 3 * 50ms = 150ms | 50ms + 150ms = 200ms | 5
TIMER ( INTERVAL, D4, 1, 4 ) | 1 * 50ms = 50ms | 4 * 50ms = 200ms | 50ms + 200ms = 250ms | 4

The condition(s) for each device variable to be TRUE simply say that the tpebrake that's reporting the higher RAW-values, i.e. that's pushed farther down, is the one that's to be read: you basically check where one toebrake is and verify that the other toebrake's not pushed farther.

In a last step we then can simply set up our logical button 1 "CMS.B1" to be TRUE if either the bit 1 "B1" OR any of the device variables "D1" to "D4" are TRUE:

CMS.B1 = ( B1 OR D1 OR D2 OR D3 OR D4 );

Whenever any of these conditions is TRUE, then the logical button 1 will generate its assigned output, the "brake"-key(s).

This script may come a bit late ;) , probably - but I've got an excuse :rolleyes: , Your Honour: I didn't have any CH Products back then :blush: ... and it's better late than never, huh?!

(This script - a (much) more readable version of it, but anyway - is where this thread about emulating "as if analogue" operation for digital controls and setting up "multi-speed" generation of digital keystrokes (http://www.ch-hangar.com/forum/index.php?showtopic=2709) will be leading to, BTW...)

ruggbutt
15-12-2005, 11:20 PM
I'm using ULF's script and it's fantastic. In Lock On you either get full brakes on or off. There's no inbetween. ULF script turns the brakes on/off several times a second and it actually feels like pressure sensitive braking. The farther the pedal goes down the better the brakes work.

It's the next best thing to having the devs for Lock On assign brakes to an axis and give us the real thing.

Bob Church
16-12-2005, 06:14 AM
Hi RuggButt,

A bit simpler method that you can try is to use the axis itself to vary the timer. Also to enable the timer. Something like:


script
TIMER( INTERVAL, D1, 1, (8 - (js1.a1 / 32 ))) = [ js1.a1 > 20 ];
cms.b1 = d1 or [ js1.a1 > 240 ];
endScript


That sets up about 8 rates as the pedal is depressed, eventually at 240 it just stays on continuously. The " > 20 " comparison starts the timer with the pedal itself. You can play with the numbers a bit to tweak it. Anyway, it avoids having to write the individual timers separately and gives much the same result.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

DonULFonso
16-12-2005, 07:14 AM
THX, Bob :thumbsup: !

I know you know (and you know I know) I always 'forget' :blush: that the CM can calculate (but I hope I'll learn it some day :rolleyes: ).

Some questions, though, if you don't mind:

How do you now verify which of the toebrakes is being pushed farther :unsure: ? I've got a serious allergy against maths :o , you know, so any attempt to figure this out myself could cause serious damage to my (mental) health :blink: ! Al I could think of would be a simple IF...THEN...ELSE... to use either or...

And how would I set up different regions, like a smaller first and last one and larger ones for the rest?

DonULFonso
16-12-2005, 07:15 PM
Bob, could you please explain this

(8 - (js1.a1 / 32 )))

for a mathematical illiterate like me :rolleyes: ?

Why "8 -" :huh: , why "/ 32" :unsure: ? I know that we've got a total of 256, yes - but not what you've made with it :blush: ... I understand that "8" is your max. "pause" to set the slowest "frequency"... and I assume that "/ 32" sets up these 8 regions you've mentioned (256 / 32 = guess what? 8, what a surprise... for me :D )... right?

TIA :D

P.S.: The PP usually are js3, not js1 (yep, I am learning ;) ).

DonULFonso
16-12-2005, 09:16 PM
Disregard, figured it out. THX for this solution :thumbsup: !

DonULFonso
20-12-2005, 10:16 AM
A do-it-yourself solution:


script
A1 = 8; // steps (including deadzone and endzone)
A2 = 2; // factor (to slow down / scale output)
TIMER ( INTERVAL, D1, 1, ( (A1 - (JS3.A1 / (256/A1))) * A2) ) = [JS3.A1 > (256/A1) ];
CMS.B1 = D1 OR [JS3.A1 > ((256/A1)*(A1-1))];
endScript

Simply modify the values of A1 and/or A2:

A1 secifies the total number of steps you want your left toebrake to have (including a 'blank' deadzone at its start without any output, and the endzone to generate the key as being held down); all steps' zones will be of an equal size.

A2 specifies a factor to scale the frequency of the flashing keypresses. A factor of 1 results in the maximum pause between each flash being (1 + steps)*50ms, with the pause getting 1 character time (50ms) shorter with each step; a factor of 2 results in the maximum pause between each flash being ((1 + steps)*2)*50ms, with the pause getting 2 character times (100ms) shorter with each step, etc.

DonULFonso
20-12-2005, 04:03 PM
A do-it-yourself solution, part deux:

script
Â*Â* A1 = 8; // steps (including deadzone and endzone)
Â*Â* A2 = 2; // factor (to slow down output)
IF ([JS3.A1 > JS3.A2]) THEN
Â*Â* A3 = JS3.A1;
Â*Â* ELSE
Â*Â* A3 = JS3.A2;
ENDIF
TIMER ( INTERVAL, D1, 1, ( (A1 - (A3 / (256/A1))) * A2) ) = [A3 >Â*Â*(256/A1)Â*Â*Â*Â*Â*Â*Â*Â*];
Â*Â*Â*Â*Â*Â* CMS.B1 =Â*Â* D1Â*Â*Â*Â*Â*Â*Â*Â*ORÂ*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â* Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*[A3 > ((256/A1)*(A1-1))];
endScript

Same as above, but this time for both toebrakes: the toebrake that's pushed more scores.

DonULFonso
21-12-2005, 11:23 AM
A do-it-yourself solution, part trois:


script

A1 = 8; // steps (between deadzone and endzone)
A2 = 2; // factor (to slow down / scale output)
// A3 toebrakes (the one pushed more counts)
A4 = 5; // deadzone (no output)
A5 = 5; // endzone (held down output)

IF ([JS3.A1 > JS3.A2]) THEN
A3 = JS3.A1;
ELSE
A3 = JS3.A2;
ENDIF

TIMER ( INTERVAL, D1, 1, ((A1*A2) - ( ((A3*100)-(256*A4)) / (((256*100)-(256*(A4+A5)))/A1) /100 *A2)) ) = [A3 > (256/A1) ];
CMS.B1 = D1 OR [A3 > ((256/A1)*(A1-1))];

endScript

Same as above, i.e. for both toebrakes (with the one that's pushed more scoring), but this time with a custom dead- and endzone:

Simply modify the values of A4 and/or A5:

A4 specifies the size of the 'blank' deadzone without any output at the startof the toebrakes' travel in percents;

A5 specifies the size of the endzone to generate the key as being held down in percents;

all remaining zones between this deadzone and this endzone will be of an equal size.

Trailryder
13-01-2006, 05:12 AM
Hey all,
Can I use Dons "A do-it-yourself solution, part trois" script "as is" to have toe brakes in Pacific Fighters, just adding it to a current .map I'm using of Revvins?

531_Ghost
13-01-2006, 06:06 PM
Don't see why not. Or you could use Bobs (http://www.ch-hangar.com/forum/index.php?s=&showtopic=1886&view=findpost&p=17367).

:cheers:

DonULFonso
13-01-2006, 07:22 PM
Use the stick's x-axis ;) ? Well, why not :rolleyes: ...

Seriously, "my" solution is 'just' an improved and enhanced version of Bob's basic but raw example - without his tip I wouldn't have come up with this version that's a.) optimized for toebraking (read: you can use either of the two toebrakes) and b.) allows for easy (to understand ;) ) customization (just specify how many regions = speeds you want and the script automatically takes care of everything).

531_Ghost
13-01-2006, 07:34 PM
Just illustrating an example Ulf. I would hope that someone would be able to figure out what JS1, 2, 3, 4, 5... are. As well axis assignments. :D Then again...

Trailryder
13-01-2006, 10:51 PM
Thanks guys.

I'll try to figure out how to do that before asking. If I can figure it out myself I'll remember it better, but if not, I'll be back.

Trailryder
15-01-2006, 08:49 PM
Let's see, JS1,2,3 etc. I assume is the same as CM Device 1,2,3 etc.. which are FS,PT and PP in my case. JS stands for joystick. "Axis" are physical movements of a device and not mere "activations" like those from a button? Tho what I'm finding is that with the right programming, you make one take on the functions of the other. There-in lies the stupification factor. lol


Just illustrating an example Ulf. I would hope that someone would be able to figure out what JS1, 2, 3, 4, 5... are. As well axis assignments. :D Then again...
[/b]