Jump to content
The simFlight Network Forums

Setting NAV/COM frequency


Recommended Posts

Hello Pete,

I am working on interfacing old real Gabels radio head to FSX (both COM and NAV radios) and I have following idea. The radio can do a closed loops for each digit of frequency -> when connected to joystick card every single digit can be recognised as a button press. For example when I tune 1 on the third place in my frequency (111,60) I have press of some key. When I tune 2 on the second place of my freq (112,60) I have a different key press. Can I interface it to FSX via FSUIPC somehow? I was thinking about assigning control to each of the "buttons" with Nav 1 Radio Set and parameter like **1,** or **2,** - which would just set the third number of frequency and the rest would be left unmodified. Is something like that possible with FSUIPC? I hope you know what I mean, it is quite hard to explain...

 

Thank you for your help,

Pavel Brodsky

DC-9 project (www.dc-9.eu)

 

Link to comment
Share on other sites

I am working on interfacing old real Gabels radio head to FSX (both COM and NAV radios) and I have following idea. The radio can do a closed loops for each digit of frequency -> when connected to joystick card every single digit can be recognised as a button press. For example when I tune 1 on the third place in my frequency (111,60) I have press of some key. When I tune 2 on the second place of my freq (112,60) I have a different key press. Can I interface it to FSX via FSUIPC somehow? I was thinking about assigning control to each of the "buttons" with Nav 1 Radio Set and parameter like **1,** or **2,** - which would just set the third number of frequency and the rest would be left unmodified. Is something like that possible with FSUIPC?

 

The normal assignments are direct to FS controls, and FS doesn't offer such things. You could do it with a Lua plug in which reads the frequency, changes the appropriate digit and writes it back again. There's no way without doing a bit of programming like that.

 

Pete

Link to comment
Share on other sites

  • 3 weeks later...

Hello Pete,

I am back with this after some time. I have now a joystick card connected to button presses as follows:

 

button 1 = last number of decimal is 5 (fsuipc 0)

button 2 = last number of decimal is 0 (fsuipc 1)

 

button 9 = pre-last number of decimal is 3

button 10 = pre-last number of decimal is 2

button 11 = pre-last number of decimal is 5

button 12 = pre-last number of decimal is 4

button 13 = pre-last number of decimal is 1

button 14 = pre-last number of decimal is 0

button 17 = pre-last number of decimal is 6

button 18 = pre-last number of decimal is 7

button 19 = pre-last number of decimal is 8

button 20 = pre-last number of decimal is 9

 

button 25 = whole is 108 (fsuipc 24)

button 26 = whole is 109 (fsuipc 25)

button 41 = whole is 110

button 42 = whole is 111

button 43 = whole is 112

button 44 = whole is 113

button 45 = whole is 114

button 46 = whole is 115

button 47 = whole is 116

button 48 = whole is 117

 

button 35 = DME test

button 36 = DME ON/OFF

 
So for example frequency 113.45 is coded with button press: 44 + 12 + 1
 
Now I am trying to make LUA script to determine the frequency which is currently set and send it to FS.
 
while 1 do
joy = 1

wholeeight = ipc.testbuttonflag(joy,24)
wholenine = ipc.testbuttonflag(joy,25)
wholeten = ipc.testbuttonflag(joy,40)
wholeeleven = ipc.testbuttonflag(joy,41)
wholetwelve = ipc.testbuttonflag(joy,42)
wholethirteen = ipc.testbuttonflag(joy,43)
wholefourteen = ipc.testbuttonflag(joy,44)
wholefifteen = ipc.testbuttonflag(joy,45)
wholesixteen = ipc.testbuttonflag(joy,46)
wholeseventeen = ipc.testbuttonflag(joy,47)

decimalzero = ipc.testbuttonflag(joy,13)
decimalone = ipc.testbuttonflag(joy,12)
decimaltwo = ipc.testbuttonflag(joy,9)
decimalthree = ipc.testbuttonflag(joy,8)
decimalfour = ipc.testbuttonflag(joy,11)
decimalfive = ipc.testbuttonflag(joy,10)
decimalsix = ipc.testbuttonflag(joy,16)
decimalseven = ipc.testbuttonflag(joy,17)
decimaleight = ipc.testbuttonflag(joy,18)
decimalnine = ipc.testbuttonflag(joy,19)

lastzero = ipc.testbuttonflag(joy,1)
lastfive = ipc.testbuttonflag(joy,0)

frequencywhole = (wholeeight * 800) + (wholenine * 900) + (wholeten * 1000) + (wholeeleven * 1100) + (wholetwelve * 1200) + (wholethirteen * 1300) + (wholefourteen * 1400) + (wholefifteen * 1500) + (wholesixteen * 1600)+ (wholeseventeen * 1700)

frequencydecimal = (decimalzero * 0) + (decimalone * 10) + (decimaltwo * 20) + (decimalthree * 30) + (decimalfour * 40) + (decimalfive * 50) + (decimalsix * 60) + (decimalseven * 70) + (decimaleight * 80) + (decimalnine * 90) + (lastzero * 0) + (lastzero * 5)

frequency = frequencywhole + frequencydecimal

ipc.writeDD(0350,frequency)
ipc.sleep(500)
end

Questions to the code: I know that LUA can handle button numbers 0 - 31. Any ideas what can I do with numbers greater > 31? It would be very useful to handle them as some external applications in windows can without problems...

 

I am not sure if I have chosen correctly the ipc.writeDD to do the task - right?

 

The frequency is in the format suitable for offset 0350, I hope I did at least this correctly  :razz:

 

 

Sorry it the code is unnecessarily complicated, still newbie with LUA.

 

Thank you again for your time!

Pavel

 

Link to comment
Share on other sites

One possible solution for the high button numbers: I have a small utility which can trigger keyboard commands when all those buttons are pressed. So we can emulate keystrokes like (for example ctrl + alt + shift + Q) and let LUA read them instead of joystick buttons directly...?

 

Pavel

Link to comment
Share on other sites

Questions to the code: I know that LUA can handle button numbers 0 - 31. Any ideas what can I do with numbers greater > 31? It would be very useful to handle them as some external applications in windows can without problems...

 

The joystick interface being used in the Lua functions you are using  only recognises 32 buttons. The later 64-button capabilities of DirectX were too late for FS and FSUIPC cannot risk using a later version.

 

The HID facilities built into the Lua COM library would be a better way altogether for you. Please check it out. If doesn't use DirectX, but a direct USB link, much as a joystick driver might.There's a HIDdemo.lua example in the Lua stuff installed in your FSUIPC Documents folder.

 

I am not sure if I have chosen correctly the ipc.writeDD to do the task - right?

 

Offset 0350 is clearly documented as being 2 bytes, so 2 x 8 = 16 bits. "writeDD" is clearly documented as writing a 64 bit signed integer. So how do you work out getting 64 bits into 16? Look through the list of functions for the 16-bit unsigned value (wrteUW).

 

The frequency is in the format suitable for offset 0350, I hope I did at least this correctly  :razz:

 

It doesn't look anywhere near correct. The representation is hexadcimal (what's known as "BCD" -- binary coded decimal). Try using FSInterrogate and viewing the sort of values there. You seem to be trying to concoct something in decimal. For hex the multipliers would be values like 4096 (1st digit) , 256 (2nd), 16 (3rd) and 1 (4th). Don't forget the first digit (1) is omitted).

 

Pete

Link to comment
Share on other sites

To HIDdemo: so you think that I should write every button which number is higher than 31 to individual FSUIPC offset and then read those offsets when evaluating which buttons are pressed? Do i understand it right?

 

Pavel

Link to comment
Share on other sites

To HIDdemo: so you think that I should write every button which number is higher than 31 to individual FSUIPC offset and then read those offsets when evaluating which buttons are pressed? Do i understand it right?

 

Why not simply interpret ALL of the buttons you are using, in the Lua plug-in, and action them there? There's no point writing stuff to an offset just to read it back. All your plug-in wants to do is set values for NAV/COM frequencies based on buttons being pressed. Right? Make it all self contained.

 

Pete

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.