• 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.

FSXA Setting custom active frequency

Messages
1,749
Country
unitedstates
I have a DME that only has a active nav 2 frequency. I also have a nav 2 radio that uses stby/active with a swap button. So in my aircraft.cfg i have standby enabled so the nav 2 radio works with swap.

But for the DME i would like to directly tune the active which normally can't be done if you use the settings i mention above. So like in the past i have written custom knobs using Mhz or Khz and use the set events to update what you tune. I tested my new knob and i can tune the exact frequency range from 108 to 117. According to the wiki here i can set up a click button like i have posted below. But during testing i can't get my custom Lvar to set the active from clicking the knob or just using an update code like below. So i have tested with clicking event and update.

I am asking for help as i am now very tired and lost on why a simple set event will not set.

http://www.fsdeveloper.com/wiki/index.php?title=XML:_Decimal_To_BCD_Macro_-_Set_Nav/Com_Freq

Outside logic
Code:
    <Update>
    @Dec2Bcd((L:DME2_FREQ, MHZ)) (>K:NAV2_RADIO_SET)
    </Update>

Model.def
Code:
    (M:Event) 'LeftSingle' scmp 0 == if{ @Dec2Bcd((L:DME2_FREQ, MHZ)) (>K:NAV2_RADIO_SET) }
 
DG,

Modeldef file doesn't support macros. Just use:

Code:
(M:Event) 'LeftSingle' scmp 0 == if{ (L:DME2_FREQ,Frequency BCD16)  (>K:NAV2_RADIO_SET) }

Providing you have stored a frequency as the LVar (DME2_FREQ,Mhz).

There is no need at all to use the macro as FS provides a direct conversion.

Tom
 
If you want to have active/stby on Nav2 via aircraft.cfg and direct active in DME (2) there will be drawbacks IE Nav2 will follow DME but the previous NAV2 tuned will go into NAV2 Stby while DME will go active on tune. This shouldn't be done until the full frequency required is obtained via L:Var.

Code:
(M:Event) 'LeftSingle' scmp 0 == if{ (L:DME2_FREQ,Frequency BCD16)  (&gt;K:NAV2_STBY_SET) (&gt;K:NAV2_RADIO_SWAP) }
 
I realized this is for a macro. And i was only using the model def for a quick test and forgot it would not work. But i really want my custom knob to update the active as i tune.

Working!!!:p

What is weird i tried using this after i posted last night and it did not work.
I know see my mistake. I miss spelled frequency and i do not need to convert. Thanks for the help. I was tired....
Code:
<Update>
(L:DME2_FREQ, Mhz) (>L:DME2_FREQ, freqency BCD16)
(L:DME2_FREQ, freqency BCD16) (>K:NAV2_RADIO_SET)
</Update>
 
Last edited:
DG,

Exactly, You only need to express the var in the other unit:

Code:
Gauge 1
....
114.40 (>L:DME2_FREQ, Mhz)

Gauge 2, etc
....
(L:DME2_FREQ, Frequency BCD16) (>K:NAV2_RADIO_SET)

Tom
 
If you want to have active/stby on Nav2 via aircraft.cfg and direct active in DME (2) there will be drawbacks IE Nav2 will follow DME but the previous NAV2 tuned will go into NAV2 Stby while DME will go active on tune. This shouldn't be done until the full frequency required is obtained via L:Var.

Code:
(M:Event) 'LeftSingle' scmp 0 == if{ (L:DME2_FREQ,Frequency BCD16)  (&gt;K:NAV2_STBY_SET) (&gt;K:NAV2_RADIO_SWAP) }

This just causes the act/stby to swap as i tune. No need for the swap code added. But i did find 1 drawback. When i use the swap on the radio the DME does not update. I might have to make the radio swap button use a left click and left release so i can create an event during the swap to update the DME.
 
All working perfect. And i appreciate the help because when i tried to use my code i wrote last night and compared it to the ones taquilo wrote it was then i realized i had a miss spelled FREQUENCY.

Here is what it takes to make a comm/nav radio use stby/active mode while having a DME that uses a direct active mode.

Aircraft.cfg = set to standby
First aircraft load value = Convert the active nav2 freq to the Lvar value [outside logic]
Custom Lvars for knobs = set up in Mhz [model.def]
Radio swap code = Left click and Left release with a custom Lvar so you can update the custom DME Lvar when you use the radio swap button. [model.def] & [outside logic]
Custom Lvar value sent to nav2 active frequency = (L:DME2_FREQ, freqency BCD16) (>K:NAV2_RADIO_SET) [model.def]
 
Last edited:
I got a new issue. The custom knob i set up is acting like a carry over. This would be fine but for some reason when the decimal goes from .10 to .15 the radio stack active freq shows .14 and then keep increasing with .01 short. .14 .19 .24 and so on....But when i reduce the value the active freq shows a perfect value.

I really would like to create the 2 knobs so there is no carry over. Does anyone have a sample or tips on how to get this to work. The outer whole knob is working perfect. But the inner fract knob will not work.


I want to just cycle 0.05 and not effect the whole number!!!
Code:
FRACT KNOB
  
      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 - 107.95 max (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 117.95 == if{ 107.95 (>L:DME2_FREQ, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 + 117.95 min (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 107.95 == if{ 117.95 (>L:DME2_FREQ, MHZ) }

    (L:DME2_FREQ,Frequency BCD16) (>K:NAV2_RADIO_SET)

WHOLE KNOB

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) -- 107 max (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 117 == if{ 107 (>L:DME2_FREQ, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) ++ 117 min (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 107 == if{ 117 (>L:DME2_FREQ, MHZ) }

    (L:DME2_FREQ,Frequency BCD16) (>K:NAV2_RADIO_SET)
 
Last edited:
Oh so i need to add 0.00001 + to both directions?
Code:
      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 - 0.00001 + 107.95 max (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 117.95 == if{ 107.95 (>L:DME2_FREQ, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 + 0.00001 + 117.95 min (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 107.95 == if{ 117.95 (>L:DME2_FREQ, MHZ) }

Update: That worked. i still need to tweak a value because i have to move the wheel 2 times when i go from 108.00 to 117.95.

Any tips on making it so there is no carryover?
 
Using 107.95 or 108.00 for the minimum value both have drawbacks. I am going to stay with 108.00 which means when tuning up from 117.95 it jumps to 108.05. When tuning down it does not skip 108.00

I managed to fix it by only having 1 value at 107.95 and the others at 108.00 :stirthepo
Code:
 (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 - 0.00001 + 108.00 max (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 117.95 == if{ 107.95 (>L:DME2_FREQ, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ, MHZ) 0.05 + 0.00001 + 117.95 min (>L:DME2_FREQ, MHZ) }
      (L:DME2_FREQ, MHZ) 108.00 == if{ 117.95 (>L:DME2_FREQ, MHZ) }

But my next goal is to code the knobs so they have no carryover. Not sure if this can be done. Does anyone know?
 
Last edited:
The fract part knob changes the fract freq from 0.00 to 0.95.

(L:Fract_FREQ, MHZ) 0.05 - (>L:Fract_FREQ, MHZ)
(L:Fract_FREQ, MHZ) 0 &lt;
if{
0.95 (>L:Fract_FREQ, MHZ)
}

(L:Fract_FREQ, MHZ) 0.05 + (>L:Fract_FREQ, MHZ)
(L:Fract_FREQ, MHZ) 0.95 &gt;
if{
0 (>L:Fract_FREQ, MHZ)
}



The whole part knob changes the whole freq from 108 to 117.

so you have selected
111 (&gt;L:Whole FREQ,MHz)
0.55 (&gt;L:Fract FREQ,MHz)

(L:Whole FREQ,MHz) (L:Fract FREQt,MHz) + 0.00001 + (>L:DME2_Frq,MHz)


Proper var name will used by yourself!
 
Thanks EduHir for this method. This does in fact work as no carryover. But I still have 1 small drawback. The first load aircraft to set the freq value from the current Nav2 freq shows up but when you turn either knob it starts over at 108.00 or 117.00. And if i use no first load it shows as 0.00. Then works from there. So basically the drawback is after first load. I need to find a solution. But either way i am happy with for now.
 
Use an init routine!

You have to read the (A:freq_var,MHz) into your ( L:vars,MHz)

But probably you need an delay counter until the panel is proper loaded!
There is thread where Rob Barentregt discuss this!


PS:
Code:
  (A:NAV2 STANDBY FREQUENCY,MHz) 0.000001 + (&gt;L:Radio_NAV2_Stdby_Frq,MHz)
  (L:Radio_NAV2_Stdby_Frq,MHz) int (&gt;L:Radio_NAV2_Stdby_CT_Frq,MHz)
  (L:Radio_NAV2_Stdby_Frq,MHz) 1 % (&gt;L:Radio_NAV2_Stdby_Fract_Frq,MHz)
 
Last edited:
You only have this posted once. Was this suppose to be in the code twice?

Code:
(&gt;L:Radio_NAV2_Stdby_CT_Frq,MHz)
 
This setup works pretty good with a minor drawback. Which is the first time you tune it changes the active to 108.00 and tunes from there. The other drawback is when you use the swap on the radio the DME and radio active frequency does update the code after swap but when you use the DME knobs the freq starts from the standby frequency and tunes from there. Feel free to test as i have tried many tests myself and can't make it perfect. But this is ok for now.

The real issue is the DME2_FREQ is getting updated and looks perfect but the knobs always seem to have another hidden value.

UPDATE_DME...... is a Lvar added to the radio swap button. This makes it so the active freq is only converted to the DME freq when you swap codes.
The 108 &lt; does the same conversion but just for first load. This entry below is in the DME XML and no need to put code in another first load xml.
Code:
<Element>
   <Select>
     <Value>
    (L:UPDATE_DME, bool) 1 == (L:DME2_FREQ, MHZ) 108 &lt; or if{ (A:NAV2 ACTIVE FREQUENCY, MHZ) (>L:DME2_FREQ, MHZ) }
     </Value>
   </Select>
</Element>


Code:
Fract knob
 
      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ_FRACT, MHZ) 0.05 - (>L:DME2_FREQ_FRACT, MHZ) }
      (L:DME2_FREQ_FRACT, MHZ) 0 &lt; if{ 0.95 (>L:DME2_FREQ_FRACT, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ_FRACT, MHZ) 0.05 + (>L:DME2_FREQ_FRACT, MHZ) }
      (L:DME2_FREQ_FRACT, MHZ) 0.95 &gt; if{ 0 (>L:DME2_FREQ_FRACT, MHZ) }

    (L:DME2_FREQ_FRACT, MHZ) (L:DME2_FREQ_WHOLE, MHZ) + 0.00001 + (>L:DME2_FREQ, MHZ)
    (L:DME2_FREQ,Frequency BCD16) (>K:NAV2_RADIO_SET)


Whole knob

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:DME2_FREQ_WHOLE, MHZ) 1 - (>L:DME2_FREQ_WHOLE, MHZ) }
      (L:DME2_FREQ_WHOLE, MHZ) 108 &lt; if{ 117 (>L:DME2_FREQ_WHOLE, MHZ) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:DME2_FREQ_WHOLE, MHZ) 1 + (>L:DME2_FREQ_WHOLE, MHZ) }
      (L:DME2_FREQ_WHOLE, MHZ) 117 &gt; if{ 108 (>L:DME2_FREQ_WHOLE, MHZ) }

    (L:DME2_FREQ_FRACT, MHZ) (L:DME2_FREQ_WHOLE, MHZ) + 0.00001 + (>L:DME2_FREQ, MHZ)
    (L:DME2_FREQ,Frequency BCD16) (>K:NAV2_RADIO_SET)
 
First, these code example are from a working nav and com panel.

second, the update routine looks a little bit broken.
Do you set ( L:UPDATE_DME, bool) to 0?
And check the above mentioned thread.

you also have to set the (L:DME2_FREQ_WHOLE, MHZ) and (L:DME2_FREQ_FRACT, MHZ)!


Code:
  (A:NAV2 STANDBY FREQUENCY,MHz) 0.000001 +  (>L:DME2_FREQ, MHZ)
  (>L:DME2_FREQ, MHZ) int (>L:DME2_FREQ_WHOLE, MHZ)
  (>L:DME2_FREQ, MHZ) 1 %  (>L:DME2_FREQ_FRACT, MHZ)

Code:
  but the knobs always seem to have another hidden value.

In this case use a debug tool and check the values of the vars.
 
Hey DG!

Am I right in the assumption, that
  • you have a DME where you can dial in a frequency and this freq is simultaneously the NAV2 active freq?
  • any change of the NAV2 active freq on the Nav panel would instantly change the DME freq as well?
If so, I would approach it like this *

  1. In both your DME part knobs:
    Code:
    (M:Event) 'WheelDown' scmp 0 ==
          if{ 1 (>L:DME_changed_freq,bool)
          <!-- your decrementing code here -->
          }
    (M:Event) 'WheelUp' scmp 0 ==
          if{ 1 (>L:DME_changed_freq,bool)
          <!-- your incrementing code here --> 
          }
  2. In a small update section:
    Code:
    (L:DME2_FREQ_FRACT, MHZ) (L:DME2_FREQ_WHOLE, MHZ) + 0.00001 + 
    (>L:DME2_FREQ, MHZ)
    
    (L:DME2_FREQ, MHZ) (A:NAV2 ACTIVE FREQUENCY, MHZ) !=
    if{
      (L:DME_changed_freq,bool)
        if{ (A:NAV2 STANDBY FREQUENCY, MHZ) (>L:Nav2_stby_buffer,MHZ)
            (L:DME2_FREQ,Frequency BCD16) (>K:NAV2_RADIO_SET)
            (L:Nav2_stby_buffer,Frequency BCD16) (>K:NAV2_STBY_SET)
            0 (>L:DME_changed_freq,bool) 
           }
        els{ (A:NAV2 ACTIVE FREQUENCY, MHZ) 0.000001 + d 
             int (>L:DME2_FREQ_WHOLE, MHZ)
             1 % (>L:DME2_FREQ_FRACT, MHZ)
           }
    }

Note:
  • Intention is to update your NAV2 freq on the Nav panel whenever you turn the DME knobs and vice visa (this should also eliminate your first load issue)
  • the Nav2_stby_buffer is used to save the STANDBY freq before you play with the active freq and restore it after you're done. (See Roman's post #3)
  • DME_changed_freq is the little helper, that tells the update code whether you changed the NAV freq from the DME or from the Nav panel.
  • Please don't nail me on the variable names or units, I didn't test it. But I'm sure you got the idea behind it.


(*) Disclaimer: I haven't worked with the whole Nav and Com stuff yet, so sorry if I misunderstood the problem.
 
EduHir this time everything is working perfect. Thanks for your help and everyone else who also helped.:D

Yes the ( L:UPDATE_DME, bool) sets to zero when you release the swap button.

I kept the model.def exactly the same and used your new code with my old code. But we want to use the active not the standby. Because the swap already updates the active and our custom Lvar is updated by the active or first load.

So there are 2 updates.
1. First load if custom Lvar is below 108 borrow the current active.
2. If swap is used on the radio borrow the current active.
Code:
<Element>
   <Select>
     <Value>
    (L:UPDATE_DME, bool) 1 == (L:DME2_FREQ, MHZ) 108 &lt; or
if{
(A:NAV2 ACTIVE FREQUENCY, MHZ) 0.000001 + (>L:DME2_FREQ, MHZ)
(>L:DME2_FREQ, MHZ) int (>L:DME2_FREQ_WHOLE, MHZ)
(>L:DME2_FREQ, MHZ) 1 % (>L:DME2_FREQ_FRACT, MHZ)
}
     </Value>
   </Select>
</Element>
 
Back
Top