Jump to content
The simFlight Network Forums

Momentary push switches with offsets PMDG737


Recommended Posts

 

Hi everyone, (sorry this is repost) think previous post was deleted and now got lost some where.

I'm very new to the forum, so please forgive me if I open a can of worms here and this have already been discussed to death. 

I've read some of the pass posts and topics of buttons, and Pete wonderful guide on (advanced Users guide) Adding offset conditions, but still struggling to try and achieve what I  would like to do, maybe its all in there and I have just miss read or understood something. 

Basically I have several toggle switches and they are wired to a game controller, its actually a desktop aviator card with 36 connections. when I flip a toggle switch one way, the response is computer picks up is a 1/2sec button press so in other words a momentary push switch. (yes the toggle switch is a momentary push switch 

So following the guides and advanced users guide 

  

I've come up with the following three lines of script. 

[Buttons.pmdg737]
1=P0,11,C1005,3842                    -joy 0 button 11, toggle flag, 256 * joystick 15 + button 2   
2=CP(F+15,2)0,11,69633,0           - condition ( joystick 15,2)physical control, pmdg offset 69633, set 0
3=CP(F-15,2)0,11,69633,1            - condition ( joystick 15,2)physical control, pmdg offset 69633, set 1 

  

Issues i have is : flipping switch one way turn switch from off to on. But subiquent flipping of switch will have pmdg cycle the respective element off then back to on. 

 

what i really need is an if statement or case select to test position? If such a thing exists.  

  

maybe someone solved this problem 10 years ago and I just haven't come across it yet. 

  

Many thanks for reading. 

  

Norm 

 0
Link to comment
Share on other sites

Please tell me what you actually want to do, first. You seem to be making it much more complex that you should need to. For example, why have button operations dependent on another switch or button?

Momentary buttons are quite normal and should present no problems.

If you state the actual problem you are trying to solve, rather than present a "solution" to something I don't understand, I could help.

Pete

 

Link to comment
Share on other sites

Hi Pete thank you for your reply.

what I would like to achieve I think is straight forward I hope. if you imagine the aircraft is cold and dark with everything off the Battery switch would stay be in the off position, I would then like to flip a physical switch to make the FSX move the battery to the ON position. So far I have got that to work, but when I flip the switch to the off position it then moves the switch remains in the On position (well actually it seems to toggle between the off and on)

 

the physical switch acts like a momentary push switch instead of a continuous switch, because the I/O card the switch is connected to is basically a game controller.

 

many thanks in advance Norman

Link to comment
Share on other sites

6 hours ago, Normana said:

I would then like to flip a physical switch to make the FSX move the battery to the ON position. So far I have got that to work, but when I flip the switch to the off position it then moves the switch remains in the On position (well actually it seems to toggle between the off and on)

Okay. So how have you actually programmed this?  The Toggle Master Battery control will do just that -- turn it of if on, and vice versa. It sounds like your device is sending the press twice -- but then, how does it turn it on?

Pete

 

Link to comment
Share on other sites

Hi pete thanks for the speedy reply, because the 737ng from pmdg ( i think ) doesnt work with the generic aircraft controls "toggle master battery" i decided i could maybe make it work with the offsets and fsupic. 

 

So i used the code above from first post and droped that straight into the config file.

But yes exactly as you pointed out - I have turned if off then on with the button press, but thats where i became stuck. Is there some way i could add a test to the script? 

Like an if then else statement?  is something like this even possible? Or is there an easier solution? 

 

Many thanks for all your help. (Hopefully in not being completely daft here) 

 

norman

Link to comment
Share on other sites

33 minutes ago, Normana said:

So i used the code above from first post and droped that straight into the config file.

Sorry, I don't understand the "code above".  What did you intend by it?  You seem to be making a simple thign very complicated. Why all the conditional stuff?

37 minutes ago, Normana said:

Is there some way i could add a test to the script? 

Have you tried FSUIPC logging at all?

38 minutes ago, Normana said:

Like an if then else statement?  is something like this even possible? Or is there an easier solution? 

Sorry, I really can't see why there's a problem in the first place! Why not simply assign to what you want to do?

Pete

 

Link to comment
Share on other sites

Hi Pete

 

I took a little video of the problem im having maybe, will explain better.... maybe im just way off the mark with this one and you'll be able to see what im doing right away is the wrong approach.

 

Im really grateful for all your assistance... cheers Norman

Link to comment
Share on other sites

Rather than a video, why didn't you simply say you need to make a button send Battery Off and Battery On on alternate presses?

The PMDG aircraft have their own "custom control" numbers (NOT "offsets" -- calling them offsets simply confuses things completly. Offsets are references to data in memory. There are a large number of offsets added for PMDG 737NGX and 777X aircraft, and they are listed in documenrs found in your FSUIPC Documents folder. Offsets contain data which is used to feed displays and so on. The PMDG offsets control nothing. 

All the PMDG custom controls are extensions to the normally assignable FS controls, and the latter are, mostly, ignored by PMDH -- as you found with "Toggle Master Battery".

It's a little odd that the battery switch on your panel is spring-loaded to off. On the real aircraft it's either on (down) or off (up). So I assume what you want is for the identified button to send "battery on" and "battery off" on alternate pressings.

If you know the correct custom controls for Battery on and battery off, then in FSUIPC this is easily done using the button's "flag".  Here is som text from the Advanced User's manual (page 24):

Quote

 

Each time any button is pressed (goes from off to on) FSUIPC4 toggles its flag. This makes the buttons flag a sort of “latching” switch. You can test it in any parenthesised condition by preceding the condition by F, thus:

N=CP(F+j2,b2) …

This says the rest of this parameter is obeyed if the Flag associated with j2,b2 is set. A condition (F–j2,b2) tests for the
Flag being clear. Note that the actual current state of the button j2,b2 is not relevant. All that matters is whether it last
left its Flag set or clear.

 

Since the button flag changes on each press, you can use the same j, b button identification as the button you are using. So, if it is joystick 0 button 14:

1=CP(F-0,14)0,14,<custom control number1>,<parameter1>
2=CP(F+0,14)0,14,<custom control number2>,<parameter2>

All you need to do is find the correct custom control numbers and parameters for Battery On and Battery OFf. I don't have or use any PMDG aircraft so I can't help you there, but from the video it seemed like you found them.

Pete

 

Link to comment
Share on other sites

On 8/22/2016 at 11:04 PM, Normana said:

Basically I have several toggle switches and they are wired to a game controller, its actually a desktop aviator card with 36 connections. when I flip a toggle switch one way, the response is computer picks up is a 1/2sec button press so in other words a momentary push switch. (yes the toggle switch is a momentary push switch 

Thinking about this a bit whilst walking the dog, I realised I still may be misunderstanding you. Looking right back, I am now wondering if your description above is really correct and complete?

A normal toggle switch is a latching switch with (usually) on or two poles and one or two "throws" -- like a light switch. When switched on two contacts are joined, when off they are separated. The closing of the contacts would be detected by your game controller which sends a button press indication. Since you say it is "momentary" I assume the controller sends a button down and a button up.

In the video you seemed to be showing that the switch is spring-loaded to "off". Is this correct? Was this your choice of switch, or is it out of your control, because it is certainly the wrong type of switch for this action.

However, that shouldn't stop it being used as a toggle in the way I said above.

What remains to confuse me then is that you seem to be saying, in the video, that whilst holding it, against the spring, doesn't cause any new events, just releasing is causes the button press again! Is that right? Same button number detected when pressed down, and when released? Is the toggle switch perhaps wired with the 'off' position and the 'on' position both connected to the same place on the controller, thus giving two identical button presses with one press and release? If so, why?

I think a better way of showing me what is going on would be to enable Button/Key logging in FSUIPC, then operate the button once down and release, and let me see the resulting log.

Of course, the button flag method I showed in my previous message can easily be used to ignore every other identical button press, and then you could use another button flag condition to determine whether to send "battery on" or "battery off". (If the PMDG aircraft supported Battery toggle instead then this would obviate the need for this extra condition).

Pete

 

 

 

Link to comment
Share on other sites

Hi Pete,

 

thanks for your info, i'll have a play around tonight with all the stuff you have given me one i put the child in bed and the wife allows me to get the laptop out. 

 

Sorry for any confusion i was causing, clearly this is my lack of understanding about how it all works behind the scenes. Will try this stuff and let you know how it all works out. 

 

Thanks once again

norman

Link to comment
Share on other sites

  • 2 weeks later...

Firstly many thanks to Pete for the help he provided... Sorry for late reply I was in germany for a Cargolux China assessment (sadly never got though the DLR testing) - aww well at least i have a job.

but its fine here is the three line of code i have working the switch i wired up to a desktop aviator card

[Buttons.pmdg737]

1=CP(F-1,0)1,0,C69634,1     -{Custom control: <69634>}- pmdg guarded battery switch 

2=CP(F+1,0)1,0,C69634,0     - actual battery switch

3=CP(F-1,0)1,0,C69633,0

 

many thanks once again :-)

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.