Jump to content
The simFlight Network Forums

Attn: Pete please - Setting Bits in pmsystems offset


Recommended Posts

Dear Pete,

I spent a _lot_ of time READING threads in severals forums with my search for 'enlightenment' concerning to interact with PM's pmsystems.

I've purchased their GC, MCP, CDU and pmsystems package for Boeing as well as (of course!) a key for your wonderful FSUIPC and WideFS. Thanks for the latter, Pete, it's _SO_ worthwhile an investment that I was really thinking about voluntarely 'renewing' my license these days. What you think? Christmas is near, you know...

OK, my question...

I was happy to learn from experimenting with available switches on my SAITEK Yoke & additional lever unit that it's true what you write in your documentation for FSUIPC advanced users: basicly _everything_ is programmable by using the appropriate offset.

I mean _WITHOUT_ buying expensive additional hardware, just by means of a spare switch on any joystick...

Now my problem: seems that I've missed school when they told us how to set and clear certain bits at certain addresses ('offsets') of FS via the FSUIPC Interface. I managed to switch on the 737 BATT (0x5628) and the APU (0x050F) by sending a '0', '1' or '2' as parameter because a BYTE is expected as parameter, but I failed to switch on a certain fuel pump as this needs to set certain BITS at 0x56B1. Can you help me with this problem _AND_ give me a hint where to find a nice tutorial about this kind of simple bit-manipulating stuff (lessons on masking bits and conditional operations are welcome, too !) because I _hate_ to ask questions and _love_ to be able to help myself... :-)

Thanks, Pete, in advance for your efforts!

Peter (Switzerland)

Thanks in advance for your help, Pete, and excuse my please, I'm 59 and _pharmacist_(Did you know pharamcists are ALL stupid as it comes to binary logic?) :mrgreen:

:-)

Link to comment
Share on other sites

... I failed to switch on a certain fuel pump as this needs to set certain BITS at 0x56B1. Can you help me with this problem _AND_ give me a hint where to find a nice tutorial about this kind of simple bit-manipulating stuff

Not sure where you'd find out about bits except in an elementary book about computers -- look up binary numbers and logic. Try Wikipaedia first.

But it is easy in any case. Look:

In decimal each higher digit is worth 10 of the previous one -- 1, 10, 100, 1000 etc. Right? Each one ten times the previous.

In BINARY, each is only worth 2 of the previous. So in binary

1 is same as decimal 1

10 is same as decimal 2

100 is same as decimal 4

...

10000000 is same as decimal 128 (work it out).

Now each of those binary digit positions is a "bit" and each "bit" can be 1 or 0 only -- it can't be more than 1 because that would make 2 and that's the next higher digit position. Right?

There are 8 bits in a BYTE. We number the lowest bit, worth 1, as "bit 0", and so on, until the top bit in a byte (the 8th) is "bit 7".

The worth of a bit in a byte is as follows:

Bit 0 = 1

bit 1 = 2

Bit 2 = 4

...

Bit 7 = 128

You will also see that for any bit number, n, the value is 2^n ("2 to the power n", or 2 multiplied by itself n times).

bit 2 = 2 x 2 = 4

bit 3 = 2 x 2 x 2 = 8

etc.

Now I think you should be able to work out the parameter values for single bits, knowing the bit number. Right?

If you want to set or change multiple bits, just add the values of the separate bits together. So, for example, Bit 0 and Bit 2 = 1 + 4 = 5.

Regards

Pete

Link to comment
Share on other sites

Thanks a lot, Pete, for answering THAT quickly.

And: what a wonderful lesson about binary <--> decimal... !

It seems that unfortunately I expressed myself badly.

My problem is less about not understanding the binary system, but not knowing how to set a certain bit at a certain PM offset WITHOUT changing the rest of the bits at that offset. I suppose the FS control 'Offset Byte Set' is not suitable for that purpose. But which one instead: 'Offset Byte Setbits'? And which parameter to use in order to determine which bit shall be toggled?

Example:

Offset 0x56B1 Bits 0...5 concerns the fuel switches of the B737 OHP (=pmsystems).

Setting Bit 0 to '1' would switch on the FWD 1 Pump. Sending a '1' to Bit 1 of the mentioned offset by means of the above mentioned 'Offset Byte Set' control switches the FWD 2 pump on but resets FWD 1 pump to 'Off' etc. etc.

So what I mean is: how can I set (and clear) certain bits at a given PM offset without influencing the rest of the bunch?

Do I have to buy and read one the books you mentioned in your post reply or is there a simple 'recipe' you could give me?

Regards,

Peter

Link to comment
Share on other sites

My problem is less about not understanding the binary system, but not knowing how to set a certain bit at a certain PM offset WITHOUT changing the rest of the bits at that offset. I suppose the FS control 'Offset Byte Set' is not suitable for that purpose. But which one instead: 'Offset Byte Setbits'?

:( :( I thought that, having grasped what the term "bits" meant, and how they are numbered and converted, all that would be easy? The names of the added FSUIPC controls for offsets are surely clear enough? What is the problem?

Take a look. There are three types of operation provided which affect only selected bits:

SetBits, which, interestingly enough, SETS bits to 1

ClrBits which clears selected bits, i.e. sets them to 0

ToggleBits which toggles selected bits. i.e. changes 1 to 0 and 0 to 1.

Don't you think those names rather suggest the actions they perform?

And which parameter to use in order to determine which bit shall be toggled?

It was to help you work that out that I went to all that detail last time. The value of the parameter gives the value computed by adding the values of all the bits you want to change! Why did you think I explained it all in such detail? It seems to have all been a waste of time! :( :cry: :? :cry:

So what I mean is: how can I set (and clear) certain bits at a given PM offset without influencing the rest of the bunch?

Do I have to buy and read one the books you mentioned in your post reply or is there a simple 'recipe' you could give me?

:roll: :roll: :roll: I went into great detail as to how you can select one or more bits to change. I really cannot see how I could explain in any more detail or at any lower level. That previous reply was rock-bottom basics. You said you understood that and really didn't need it, but evidently you do need it and don't understand! :-(

To change bit 0 use parameter 1, because bit 0 is worth 1.

To change bit 1 use parameter 2, because bit 1 is worth 2

...

To change bit 7 use parameter 128 because bit 7 is worth 128

To change several bits just add their "worth" up to compute the correct parameter.

Please please please go back and read the previous reply. You seem to have missed most of it! I seem to be wasting a lot of my time otherwise.

Pete

Link to comment
Share on other sites

Hi

No, you only need to use the available options/giveaways of FSUIPC !

Use Offset Byte SetBit to set and Offset Bit ClrBit to reset.

e.g.

56B1 Bit0 for FwdPump1

Offset Byte SetBit, Value = 1 (2^0), to switch ON

Offset Byte ClrBit, Value = 1 (2^0), to switch OFF

56B1 Bit1 for FwdPump2

Offset Byte SetBit, Value = 2 (2^1), to switch ON

Offset Byte ClrBit, Value = 2 (2^1), to switch OFF

To do both at the same time you would use Value = 3 ((2^0) + (2^1)) Bit0 + Bit1

To set e.g. Bit0 and Bit7 at the same time you would use Value = 128 ((2^0) + (2^7)) Bit0 + Bit7

With SetBit and ClrBit you can select ONE or MULTIPLE bits, depends of the value you use.

Link to comment
Share on other sites

Thanks Pete, I've no more questions.

Using the 'try and fail' method I had stumbled into 'Offset Byte SetBits' and 'Offset Byte ClrBits' in the meantime and - well that's it.

Thanks Thomas for your SHORT AND DIRECT hint what to do. THAT'S what I was after. Simple and clear. Would it be suitable to ask YOU for help instead in the future? Maybe it could even be in German then as I think I've heard you're German like me. :)

Thanks again Pete for your patience. Hope I didn't bother you too much after all...

Regards,

Peter

P.S. Somebody may close or even delete this thread now.

Link to comment
Share on other sites

Thanks Thomas for your SHORT AND DIRECT hint what to do. THAT'S what I was after. Simple and clear. Would it be suitable to ask YOU for help instead in the future?

So you didn't want to learn how to do it for yourself, but only to have someone do it for you? Is'nt that a bit short-sighted?

I did take a lot of trouble trying to make the tutorial on bit numbering relevant and to the point, but you simply ignored it and asked the same questions again. Very upsetting.

So, please remind me not to reply to you next time, and I expect Thomas will do the work for you.

Regards

Pete

Link to comment
Share on other sites

So you didn't want to learn how to do it for yourself, but only to have someone do it for you? Is'nt that a bit short-sighted?

I did take a lot of trouble trying to make the tutorial on bit numbering relevant and to the point, but you simply ignored it and asked the same questions again. Very upsetting.

So, please remind me not to reply to you next time, and I expect Thomas will do the work for you.

Regards

Pete

Hi Pete and Peter

The best way is ever learning by doing!

-- If you never burned your fingers on a hotplate you will not understand what is "HOT" --

Questions are ever welcome and answered by Pete, Other (and me is also Others) as long it is visible there is a will of trying things but running into problems.

FSUIPC is a technical tool that allows you to program/read/write values to/from FS, in many cases very complex internal manipulated so that it is really handy useable for customers. But it is ever needed to study the manuals to understand the key of this tool and the way to use it correct.

The SDK of FSUIPC describes the most things as well for beginners.

I think I can say this for Pete as well that is not the way only to ask every step/code to get things to work. And of course there is no time to do this, for me because of my work for Project Magenta and I "think" as well for Pete because his extensive activities on FSUIPC4 / 3 (without his work we would all stay a bit in the rain).

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.