GABELS VHF NAV

přidáno: 2. 9. 2013 10:03, autor: Pavel Brodský   [ aktualizováno 2. 9. 2013 10:09 ]
   In this article you can read about our way of interfacing the VHF NAV radio to the FSX. I am pretty sure this method would work easily also with X-Plane with just minor changes to the script.

For full-res photos check the Photos section - Pedestal avionics album.

Gables radio
On the following picture you can see the inner structure of the NAV radio from Gabels. The radio consits of two identical halfs - left and right. Each half includes frequency drums (what you can see, the numbers), seven encoders and two rotary knobs - one for whole part and one for decimal part of frequency. When you turn the decimal knob you move the frequency drum and also the encoders. Using the frequency select switch you can determine which frequency will be active. Above the frequency drums are green light bulbs showing the active one - they are 5V.

NAV radio - hardware part is done!

Gables encoders
Here you can see a photo of one of our encoders. There are four of them for fraction part of frequency and three for whole part. On this example you can see the whole frequency encoder. Connecting this thing to your joystick card is pretty easy, the GND pin leads to your common ground, and the other pins are the buttons signal pins. When connected to (for example) Leo Bodnar card you can see this encoder in Windows as 10 buttons - only one of them is pressed at each time which determines the tuned frequency. In the radio there are much more encoders then what you need so we have used only: this one for whole part, two of them for decimal part - first number, and one special for decimal part - last number (which is five or zero). The exact wiring depends on your joystick card - just keep it simple, you only need individual button press combinations for each possible frequency, the rest is the matter of software. When working with the encoders pay special attention to them, they are fragile! Do not apply great force on them. Good thing is that they are very well heat resistant so soldering the wires on contacts is easy, the material surrounding the contact doesn't melt.

encoder of NAV radio

Joystick cards
I have chosen the MJ16 joystick cards manufactured by my friend in "micro" version which are the smallest joystick cards I have ever seen. You can find many information about them on google, they are not commercial product, people make them at home. They are cheap, easy and reliable. You can also use the Leo Bodnar cards which are similar and I think that the BU0836A could fit into the Gables unit. The Bodnar's BBI32 is too big and you would have to mount it outside of the radio box which I don't like.

On the following picture you can see some versions of the MJ16. We have used the smaller one:

MJ16 joystick cards build by my friend for our project. The smaller version will be used, one card in each NAV/COM radio

What to do if you connect multiple same units to your computer and you don't know which is which? Easy task for Windows register editing. I use the USBView utility (freeware, google it) which can display information about everything connected to your USB. Simply run the utility and then connect your joystick card - you will see which device has just appeared. Write down the manufacturer and products IDs - they are there every time, even if you made the card at home - part of USB protocol. Run your registry editor (Start -> Run -> regedit -> enter) and navigate to Joystics -> OEM. Here you can find the folder if your card (look for similar numbers as which you have seen in USBView. By editing the OEMName you can rename your joystick card to anything you wish. The name will stay there even when you connect the card to other USB port. 

 obrázek spíš pro mě, až zas nebudu vědět jak to přejmenovat...

Wiring
When connecting the encoders to the joystick card don't forget to use the frequency selector switch. You can wire your GND signal to this switch and the switch will connect the signal to only one of two sides at the time - means that you only need half as much inputs on your joystick card! Of course you could connect both sides at the same time to the card and the selector could be connected as a single switch which would bring the need of more complicated scripting to determine which side is active (actually, it would be easy one-line command). I just want to make things simple and easy, so my PC can never see what is tuned on the inactive frequency - because I don't need the PC to know it. Only the active side is connected to the joystick card. Your radio, your decision.

zapojování NAV rádia - obě desetinná místa frekvence "nadrátována"

Software interfacing
Here comes the challenge. You have the card connected to your PC and the encoders and you can make a table like:

button 1: whole part of my frequency is 108
button 2: whole part of my frequency is 109
and so far...

button 11: decimal part of my frequency is 00 or 05
button 12: decimal part of my frequency is 10 or 15
and so far...

button 21: last number of my frequency is 0
button 22: last number of my frequency is 5
that is all

Now you need something to decode your buttons and send the frequency to Flight Sim. If you are using FSX and registered version of FSUIPC you can do a LUA script to do the task. Or you can (as I did) use other utility. I have chosen HIDMacros which can recognise many joysticks with unlimited number of buttons on each of them (note that FSUIPC is limited to 32 buttons per joystick). In HIDMacros I have assigned a function to each of my buttons to call the procedure of NAV1 frequency set. The code of the procedure follows at the end of this article (VBScript).

Other ways how to interface
As the radio is designed to provide tuned frequency "as is", you don't have to follow my way of interfacing. You can design you own PCB to connect to the original diodes and decode the binary coded frequency from them and use your own software to set the FS frequency. Great example of this approach is on L1011 project website. This access has its own advantages - you don't have to touch the encoders and you can use many of the original wires. The disadvantage is that you have to develop your own PCB (printed circuit board) and maybe even your own software. I found it easier and faster to do it as I did.

HIDMacros code
This is my code calculating the frequency from pushed buttons. Note that I have used the FSX event function (yep, Simconnect) so this thing is not FS2004 or X-Plane compatible. If you wanted to use X-Plane the only change to the code would be not to send it as FSX event but as X-Plane dataref - see HIDMacros documentation.


Textové pole

Sub NAV1set
Dim wsh
Set wsh = CreateObject("Wscript.Shell")


wholeeight = HIDMacros.IsButtonPressed("NAV1", 25)/(-128)
wholenine = HIDMacros.IsButtonPressed("NAV1", 26)/(-128)
wholeten = HIDMacros.IsButtonPressed("NAV1", 41)/(-128)
wholeeleven = HIDMacros.IsButtonPressed("NAV1", 42)/(-128)
wholetwelve = HIDMacros.IsButtonPressed("NAV1", 43)/(-128)
wholethirteen = HIDMacros.IsButtonPressed("NAV1", 44)/(-128)
wholefourteen = HIDMacros.IsButtonPressed("NAV1", 45)/(-128)
wholefifteen = HIDMacros.IsButtonPressed("NAV1", 46)/(-128)
wholesixteen = HIDMacros.IsButtonPressed("NAV1", 47)/(-128)
wholeseventeen = HIDMacros.IsButtonPressed("NAV1", 48)/(-128)


decimalzero = HIDMacros.IsButtonPressed("NAV1", 14)/(-128)
decimalone = HIDMacros.IsButtonPressed("NAV1", 13)/(-128)
decimaltwo = HIDMacros.IsButtonPressed("NAV1", 10)/(-128)
decimalthree = HIDMacros.IsButtonPressed("NAV1", 9)/(-128)
decimalfour = HIDMacros.IsButtonPressed("NAV1", 12)/(-128)
decimalfive = HIDMacros.IsButtonPressed("NAV1", 11)/(-128)
decimalsix = HIDMacros.IsButtonPressed("NAV1", 17)/(-128)
decimalseven = HIDMacros.IsButtonPressed("NAV1", 18)/(-128)
decimaleight = HIDMacros.IsButtonPressed("NAV1", 19)/(-128)
decimalnine = HIDMacros.IsButtonPressed("NAV1", 20)/(-128)

lastzero = HIDMacros.IsButtonPressed("NAV1", 2)/(-128)
lastfive = HIDMacros.IsButtonPressed("NAV1", 1)/(-128)

frequencywhole = wholeeight * 108 + wholenine * 109 + wholeten * 110 + wholeeleven * 111 + wholetwelve * 112 + wholethirteen * 113 + (wholefourteen * 114) + wholefifteen * 115 + wholesixteen * 116 + wholeseventeen * 117
frequencydecimal = decimalone * 0.1 + decimaltwo * 0.2 + decimalthree * 0.3 + decimalfour * 0.4 + decimalfive * 0.5 + decimalsix * 0.6 + decimalseven * 0.7 + decimaleight * 0.8 + decimalnine * 0.9 + lastfive * 0.05
frequency = (frequencywhole + frequencydecimal)*100

HIDMacros.FSXEvent "NAV1_RADIO_SET", "&h"&frequency
'HIDMacros.Debug(frequency)
end sub

Video of my result
(sorry for the Czech-only comments)

VHF NAV video


Comments