18 May 2014

Fidgety Phidgets

This is a bit technical post, and I make this post, only to record it for benefit of a future pit builder using the same techniques as I.

While all the ‘Inputs’ in the bit are being handled by either Leo Bodnar’s cards, or by Teensey ++2.00 micro-controller boards. For my purposes, these means have proved to be quite adequate.

While Arduino boards could also be used for ‘Output’ purposes, but, long time ago, I chose to go with Phidget boards.

Alan Dyre had developed a nifty tool called “FS2Phidgets”, which cleanly interfaces the Phidget boards with FSX/FSUIPC. It took some learning, but after that this board/tool is a breeze to use.

Glenn “Tripod” Weston, has provided a masterpiece of an interface tool called as ‘SuperScript’. This LUA script interfaces the VRS SuperBug with FSUIPC and provides total control over all data communication with the airplane.

The SuperScript provides ‘Memory Offsets’ used by FSUIPC, which could be read/written to, to interface the state of all cockpit annunciators, with any other driver board.

While programming the “FS Variable” file for the FS2Phidgets, I came across two idiosyncrasies of the script, which I thought need to be mentioned.

The SuperScript defines memory offsets (in HEX) as, for example, “0x66CA”. However, if the same format is used to declare the offset in FSVariable, it leads to unpredictable results. I found that if the preceeding “0x” was deleted, (use only 66CA, from above example), then the offsets worked flawlessly.

The second issue I faced was in declaring the length of the memory offset. All the output scripts provided by Tripod are one Byte (8 bits) long, except three which are two byte’s long (Caution Panel and Left/Right Annunciator Panels). This was done, to accommodate more than 8 bit assignments in these panel groups.

While declaring FSVariables in FS2P, if I declared the length of offset as ‘Two’ bytes, then the results were very unpredictable. It took me all of full day, to finally figure my way out of this. I realized that FS2P is not able to correctly convert the HEX to decimal, when using two byte long FS Variables.

Out of the three 2 byte groups that Tripod has provided, the Left/Right Annunciator Panel groups, actually use only 8 bits, while the rest of the bits are kept for future use. However, the Caution Panel group uses 10 bits of address space. I split these two bytes into two single bytes offsets, and  accordingly changed bit addresses of the included parameters.

To illustrate, the Caution Panel reads the Offset 0x66C0, and, it’s a 16 bit Unsigned Word. The offset is two bytes long and declares variables from Bit0 till Bit9 (10 bits), while the remaining six bits are kept free for future use.

I declared the FS2P FSVariables in Offset 66C0 from Bit0 till Bit7 (8 bits) and then declared the next memory offset (i.e. 66C1) and declared the Bit8 & Bit9 of the original offset and Bit0 & Bit1 of the new offset, and voila, everything fit into place.


I know this is boring, but, am sure, will help someone someday.

3 comments:

  1. Very Nice Explanation Mickey, You are quite right that should help somebody who comes across this same issue.
    0x preceding a number is the way to identify HEX numbers vs DECIMAL numbers, I would say that the FSVariables in FS2P just presumes all the entries are going to be HEX and you just do not require the preceding 0x.

    It's a Shame they also assumed all entries were going to be only 8 BITS wide, this is never the case when dealing with many of the different Offsets in FSUIPC, some of the standard Offsets are 4 BITS wide.
    However your Solution was spot on and it's great that you managed to work that out. Fortunately you are only looking at the individual BITS for signalling so this solution worked, It would be much more of a problem if you actually required to deal with the whole 16BIT value, I would probably advise the Author of this shortcoming if he is still developing that software.

    Great work....Thankyou for taking the time to do these Logs.

    Tripod.

    ReplyDelete
  2. Hi Mickey, I'm Antonio (Arinc429). Thanks for your explanation. I finally bought a phidgets board. I'm currently programming all LED outputs. I note that the last FS2phidget version doesn't work on my computer. (windows 7 x64). I only can run it under 4.3.65, not newer, but it seems to be all ok. Which version are you using on fs2phidghet? Thank you.

    ReplyDelete
  3. Hi Antonio,

    I'm using ver 4.3.66 which is a patch over 4.3.65; and it is working quite satisfactorily for me.

    Alan Dyre had also provided me with a test version 4.3.87 for compatibility with newer Phidget drivers, but for various reasons, that didn't work too well on my computer.

    ReplyDelete