• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 SOLVED - Radio frequency set-up problems

Messages
258
Country
ireland
Hi,

In my FS2004 Cessna 172 XML radio stack I set up the standby comms frequency using the knob and then transfer that frequency into the active frequency using the transfer button.

I set up the whole number of the frequency in one LVAR on the outside of the knob and the decimal part in multiples of 25 in another LVAR on the inside of the knob. I merge both LVARS together into another LVAR and display this as the standby frequency in the window.

Then when I want to use that frequency I use a complicated formula which I found on the web some time ago.

Bill Leaming put the formula up on FlightSim in 2005 (nearly a decade ago - doesn't time fly!)

This then becomes the active frequency which is used for radio contact.

Most of the time this procedure works fine. On the odd occasion it doesn't.

For instance, on my latest flight from KOWD to KFMH it really fouled up badly.

The frequencies in KOWD worked fine - 119.950, 121.800 and 126.000.

For Providence, I set up a standby frequency of 128.700, pressed the transfer button and it went across as 128.690.

For Cape, I set up a standby frequency of 118.200, pressed the transfer button and it went across as 118.190.

For Otis, I set up a standby frequency of 121.000, pressed the transfer button and it went across as 120.990.

Having landed, I tried them all again. 118.200 and 121.00 worked fine (!) while 128.700 still fouled up!

Just before I sent this I tried 128.700 once again and this time it worked!

I know the frequency looks ok in the standby window, when it transfers to the active it corrupts.

Obviously there is some problem problem with the stability of my code (surprise, shock, horror!!)

I set up the standby frequency with

(L:Rad1Dec,number) 0.001 * (L:Rad1Whole,number) + (>L:Rad1Freq,number)

and I use the transfer button to set up the active frequency with

(L:Rad1Freq, number) s1 100 * 10000 % int d 10 % r
10 / int d 10 % r 10 / int d 10 % r 10 / int 16
* + 16 * + 16 * + (>K:COM_RADIO_SET)


I have no idea really what all the numbers are doing (though Bill explained it in 2005)- I know it works the vast majority of the time and fails just a few times.

I supect that it is (L:Rad1Freq, number) causing the problems although I have displayed its contents to 7 places of decimal and it looks fine.

Can anyone see how I can ensure that it always works.

Thanks

Walter
 
Messages
1,564
Country
thailand
Walter,

Have you tried this way... let the sim handle the units conversion for you. Suppose you want 120.5 Mhz frequency. Then do the following two-step process:

Code:
120.5 0.00001 + (>L:Com2Frequency, Mhz)
(L:Com2Frequency, Frequency BCD16) (>K:COM2_RADIO_SET)
[edit] 0.00001 is added to avoid rounding issues as described by Tom in response #5, below.

Same approach can be applied to ADF and to Transponder.

Code:
ADF:
379 (>L:ADF_Freq, khz)
(L:ADF_Freq, Frequency ADF BCD32) (>K:ADF_COMPLETE_SET)

XPNDR:
1234 (>L:XPDR_Code, enum)
(L:XPDR_Code, Bco16) (>K:XPNDR_SET)

[edit] Anyway, these are a somewhat shorter way to set the radios, but putting the Horner formula into a macro is rather succinct as well ... The Horner method shown by Roman in response #4 is also described in Bill Leaming's wiki, both incorporating the "100.001" to avoid rounding issues.

Apologies for my initial response that did not include the 0.00001 factor.


Bob
 
Last edited:
Messages
258
Country
ireland
Thanks Bob,

the coding is certainly shorter!

I tried it out and again most of the time it works, but then it fails.

I tried setting up 118.200 on standby, pressed transfer and most of the time it comes out properly in the active window, but it fails sometimes and goes to 118.190.

I tried some of the other frequencies that failed sometimes before, and they have being successfully transferred without corrupting so far.

Walter
 
Messages
440
Country
us-wisconsin
Walter,

I believe this may help you.. ( REF - http://www.fsdeveloper.com/forum/threads/xml-math-oddity.75567/#post-222735 )

Not sure why you're multiplying by 0.001 when using 25 KHZ spacing.

One of 2 ways you could maybe try -

Code:
(L:Rad1Dec,number) int  0.01 * (L:Rad1Whole,number) + (>L:Rad1Freq,number)

Or, I use this Horner method because of rounding errors and having a dual mode radio, TACAN/Civilian.

Code:
100.001 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * +

Notice the first value "100.001" rather than "100".
 
Messages
258
Country
ireland
Thanks Bob.

I have changed all my settings to the edited method.

I got everything working on the ground (and that should also apply in the air... but...) except the ADF which works fine with the code before the edit.

I now have to fly the same route and see what happens...

There are definitely a lot less lines of code in the gauge now!

Spokes2112, I was pretty certain that a rounding error was causing my problem, but I just couldn't see where, and why it should work some of the time. Surprisingly enough, that old set of code has done me fine for about three years now, with only the odd foul-up. The 0.001 seemed to work fine. Since I have now spent the afternoon and evening changing everything to Bob's recommendations I don't think I will go back with this radio gauge. This is for the Cessna 172 radio stack - I have a radio pedestal set up in XML for the B737 using the old code so when I get back to flying jets again I will re-examine the code in that gauge with your recommendations in mind.

Thanks

Walter.
 
Messages
258
Country
ireland
Bob,

I just completed the flight from Norwood to Falmouth again.

The new comms worked well right up to contacting the airport at Falmouth - then it corrupted the frequency again!

I re-input the frequency into the standby, transferred it, and it worked perfectly!!!

There must be a loose connection somewhere in my Bendix King :(

Thanks for the help

Walter
 
Messages
1,564
Country
thailand
Walter,

Definitely is a floating point issue.

Check this thread and see how to make proper corrections:

http://www.fsdeveloper.com/forum/threads/incrementing-active-frequency.425561/#post-633255

Tom

Walter, I'm sure either Roman's or Tom's approaches (quoted above) will take care of it.

May I ask again to make sure I understand your last response ... you say that even when you entered the frequency as Hz, (as opposed to the usual MHz) the following failed?

Code:
128700000 (>L:Com2Frequency, hz)
(L:Com2Frequency, Frequency BCD16) (>K:COM2_RADIO_SET)

Bob

and please note that I edited my response#2 above
 
Last edited:
Messages
258
Country
ireland
Bob,

The gauge covers the whole of the Bendix King Radio stack, including the 2 Comms radios, 2 Nav radios, an ADF, a transponder and a DME. The AP is coded separately.

It would be huge (and confusing) to display all the code here, but I will show the relevant bits and hope that you can see my error.

The Update Frequency is 18.

Rad1Whole is manufactured using the outside ring of the radio knob, Rad1Dec from the centre of the knob:

Code:
    <Area Left="104" Right="156" Top="100" Bottom="125">
     <Cursor Type="Grab"/>
      <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
        (M:Event) 'LeftSingle' scmp 0 ==
             (M:Event) 'WheelUp' scmp 0 == or
              if{ (L:Rad1Whole,number) 137 &lt;
                        if{ (L:Rad1Whole,number) ++ (&gt;L:Rad1Whole,number) }
                           els{ 118 (&gt;L:Rad1Whole,number) }
                  (L:COM1KnobCount,number) ++ 8 % (&gt;L:COM1KnobCount,number)
                  1 (&gt;L:DSD_XML_SOUND_04, number) }
        (M:Event) 'RightSingle' scmp 0 ==
            (M:Event) 'WheelDown' scmp 0 == or
              if{ (L:Rad1Whole,number) 118 &gt;
                        if{ (L:Rad1Whole,number) -- (&gt;L:Rad1Whole,number) }
                           els{ 137 (&gt;L:Rad1Whole,number) }
                    (L:COM1KnobCount,number) -- d 0 &lt; 8 * + (&gt;L:COM1KnobCount,number)
                    1 (&gt;L:DSD_XML_SOUND_04, number) }
      </Click>
    </Area>

    <Area Left="104" Right="156" Top="127" Bottom="148">
     <Cursor Type="Grab"/>
      <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
        (M:Event) 'LeftSingle' scmp 0 ==
             (M:Event) 'WheelUp' scmp 0 == or
              if{ (L:Rad1Dec,number) 975 &lt;
                 if{ (L:Rad1Dec,number) 25 + (&gt;L:Rad1Dec,number) }
                          els{ 0 (&gt;L:Rad1Dec,number) }
                 (L:COM1KnobCount,number) ++ 8 % (&gt;L:COM1KnobCount,number)
                 1 (&gt;L:DSD_XML_SOUND_04, number) }
        (M:Event) 'RightSingle' scmp 0 ==
            (M:Event) 'WheelDown' scmp 0 == or
              if{ (L:Rad1Dec,number) 0 &gt;
                        if{ (L:Rad1Dec,number) 25 - (&gt;L:Rad1Dec,number) }
                          els{ 975 (&gt;L:Rad1Dec,number) }
                   (L:COM1KnobCount,number) -- d 0 &lt; 8 * + (&gt;L:COM1KnobCount,number)
                   1 (&gt;L:DSD_XML_SOUND_04, number) }
      </Click>
    </Area>

While within the gauge I have:

Code:
<Element>
<Select>
  <Value>
    (L:Rad1Whole,number) 1000 * (L:Rad1Dec,number) + 1000 * (&gt;L:Rad1Freq,hz)
  </Value>
</Select>
</Element>


Rad1Whole would have held 121, Rad1Dec would have held 0, therefore Rad1Freq should have held 121000000.

Rad1Freq is diplayed properly in the Standby Window using:

Code:
    <Element>
        <Position X="84" Y="80"/>
    <Text X="67" Y="27" Bright="Yes" Length="7" Font="Quartz" Color="Red" BackgroundColor="Black" Adjust="Left" VerticalAdjust="Center">
    <String>%((L:Rad1Freq,Mhz))%!7.3f!</String>
    </Text>
    </Element>


My actual code on the mouse-click for the transfer button is:


Code:
(L:Rad1Freq, Frequency BCD16) (&gt;K:COM_RADIO_SET)


First time it didn't work - it came out in the Active Window as 120.99, with no comms available obviously - tried the 121.00 again and it worked!

The thing works 99.9% of the time.

Walter
 
Last edited:
Messages
1,564
Country
thailand
ok ... I'll look thru this tomorrow. I know I will learn something and together, we might get it right as long as Bill or Roman or Tom, et.al., are still reading this :p
 
Messages
258
Country
ireland
... and just to make a solution more difficult...

I just flew the same flight - with no changes to the gauges since the last flight - and all frequencies worked perfectly!

Walter
 
Messages
495
Country
austria
For setting COM - freq i use this K:

COM_RADIO_FRACT_DEC
COM_RADIO_FRACT_INC
COM_RADIO_SET
COM_RADIO_WHOLE_DEC
COM_RADIO_WHOLE_INC
COM_STBY_RADIO_FRACT_DECREASE
COM_STBY_RADIO_FRACT_INCREASE
COM_STBY_RADIO_SET
COM_STBY_RADIO_SWAP
COM_STBY_RADIO_WHOLE_DECREASE
COM_STBY_RADIO_WHOLE_INCREASE

Same with Nay - freq

Edi
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
Walter,

First advice, work directly with Mhz units instead of number, it's a lot easier:

Code:
...
if{ (L:Rad1Whole,Mhz) 137 &lt;
    if{ (L:Rad1Whole,Mhz) ++ (&gt;L:Rad1Whole,Mhz) }
els{ 118 (&gt;L:Rad1Whole,Mhz) }
...
...
if{ (L:Rad1Dec,Mhz) 0.975 &lt;
if{ (L:Rad1Dec,Mhz) 0.25 + (&gt;L:Rad1Dec,Mhz) }
els{ 0 (&gt;L:Rad1Dec,Mhz) }
...

Then

Code:
<Element>
  <Select>
    <Value>
       (L:Rad1Whole,Mhz) (L:Rad1Dec,Mhz) + 0.00001 + (>L:Rad1Freq,Mhz)
    </Value>
  </Select>
</Element>

And then transfer button (your code):

Code:
(L:Rad1Freq, Frequency BCD16) (&gt;K:COM_RADIO_SET)

Tom
 
Messages
258
Country
ireland
Just to say thanks to those who made my radio stack very predictable and accurate.

I finally settled on units of hz but I added .1 hz as I combined the whole and decimals, as suggested by Tom.

I have had a few flights since, and not one failure to convert the standby to the active frequency.

Many thanks...

Walter
 
Top