PDA

View Full Version : Il2 1946 Bombsight controls on FS throttle axis



stathem
26th August 2008, 10:44 PM
Hello there.

I'm new to the CM software, and new to the site, so first of all thanks for all the tips I've learnt whilst lurking.

I got a Fighterstick last Friday and am in the process of getting everything sorted out.

I know I should take the time and learn it myself but there's something I really wanted to acheive with the throttle wheel on the fighterstick.

As the thread title implies, I fly level bombers a fair bit in Il2 1946. I wanted to to map the FS throttle axis (I have a X-52 throttle) to increase and decrease sight angle, height, and speed.

After a bit of searching round the Help and here at these forums, I managed to get it done with

CMS.B3 = [JS1.A3 < 50];
CMS.B4 = [JS1.A3 > 200];

and mapping the commands on B3 and 4 with the approriate responses for the three modes.

However, as I'm sure you're aware, it gives a very fast increase, which makes it difficult to fine tune it when close to the required speed or altitude.

So what I wanted to do was to have it press B3 (or whatever) only once per second or so when JS1.A3 is between say 50 and 100.

This is where I'm up to with that code;

sequence
while ([JS1.A3 < 100] and [JS1.A3 > 50]);
CMS.B1 = true;
delay (20);
endsequence

but it doesn't seem to be working as planned (obviously being new to this I'm winging it)

B1 in this case is set to NULL (appropriate keypress)

Can anyone help me out with where I'm going wrong here?

Many thanks.

Bob Church
27th August 2008, 01:31 AM
Hi stathem,

Well, you're not too far off, really. You just need to turn cms.b1 OFF, otherwise it just stays on forever. Something like this would probably do it:


script
sequence
while ([ js1.a3 > 50 ]) AND ([ js1.a3 < 100 ]);
cms.b1 = TRUE;
delay( 1 );
cms.b1 = FALSE;
delay( 19 );
endIf
endIf
endScript

Then it's just pulsed once per second which I think it what you're trying to do. A timer might be an easier way:


script
timer( INTERVAL, d1, 1, 19 ) = ([ js1.a3 > 50 ]) AND ([ js1.a3 < 100 ]);
cms.b1 = d1;
endScript

which essentially does the same thing, really. The only advantage would be that, with the SEQUENCE it's going to run out that last second before it responds. The timer should shut down right away. You would have to use cms.b1 to send the character.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

stathem
27th August 2008, 10:58 PM
Hi Bob.

Many thanks, that works a treat. One of the iterations I tried was to set the button true then false, but I didn't (and probably wouldn't have thought to) set the delay between turning it off and on.

I've gone with the sequence, and with three bands in the end. I haven't quite got my head around the way timers work yet, once I understnad them I might switch to that way.

Anyway, the final code, in case it helps anyone else is



script
CMS.B3 = [JS1.A3 < 25];
CMS.B4 = [JS1.A3 > 230];

sequence
while ([JS1.A3 < 50] and [JS1.A3 > 25]);
CMS.B1 = true;
delay (1);
CMS.B1 = false;
delay (9);
endsequence

sequence
while ([JS1.A3 < 230] and [JS1.A3 > 205]);
CMS.B2 = true;
delay (1);
CMS.B2 = false;
delay (9);
endsequence

sequence
while ([JS1.A3 < 90] and [JS1.A3 > 50]);
CMS.B1 = true;
delay (1);
CMS.B1 = false;
delay (19);
endsequence

sequence
while ([JS1.A3 < 205] and [JS1.A3 > 170]);
CMS.B2 = true;
delay (1);
CMS.B2 = false;
delay (19);
endsequence

endScript


Thanks again for the speedy response,

All the best.

Bob Church
28th August 2008, 12:38 AM
Hi stathem,

>> Many thanks, that works a treat. <<

Great! And you're quite welcome!

>> One of the iterations I tried was to set the button true then false, but I didn't (and probably wouldn't have thought to) set the delay between turning it off and on. <<

It's not obvious at first, but the CMS file doesn't do anything the script doesn't tell it to do. The delay sets a 1-character time TRUE and then a 19-character time OFF, so the cms.b1 gets pushed and released like you want. As it was, it was just holding the key down after the first pass.

>> I've gone with the sequence, and with three bands in the end. I haven't quite got my head around the way timers work yet, once I understnad them I might switch to that way. <<

The SEQUENCE is fine, but they can be tricky. I think you can't do an "IF" within a SEQUENCE and if you put an IF around a SEQUENCE then the sequence will not execute at all if the IF comes up FALSE. I usually avoid them unless they're obviously the thing to used, and even then I'll just set or clear a bit in the sequence and actually work with it in an IF outside of the SEQUENCE. It's just easier than remembering the rules. :)

The INTERVAL timer takes care of that, you give it one of the "dn" bits (d1 in this case) and that tracks the output. So long as the input (everything to the right of the "=" ) evaluates to TRUE, the timer just runs continuously. The first number (1) is the "On" time, and the second (19) is the "Off" time. The output shows up on d1 and you just pass it along to cms.b1, that cycles off and on as a result.

Also (if you really want to get into it), you can do arithmetic on the js1.a3 value and use the result in place of the "19". It makes the whole thing adjustable. It might not be any use in your case but, for example, if your:


delay( 19 );

line were written:


delay(( js1.a3 / 10 ) + 1 );

then js1.a3 would vary the off time between 1 and 26. The same thing would work with the timer, too. The "+1" at the end is there because I don't remember for sure if a "0" would work there or not, it might not be necessary.

Anyway, I'm glad you got it running! It's a lot to try to figure out, but it gets easier. If you need any help, just come on back and ask!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com