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

To set ADF frequency

Messages
61
Country
france
I want to create a frequency range selector that works in the following manner :

position 0 : from 100 to 190 khz
position 1 : from 190 to 420 Khz
position 2 : from 420 to 970 Khz
position 3 : from 970 to 1700 Khz

If the frequency is greater than 190 kHz when the switch is set to 0, it automatically returns to 100 kHz;
If the frequency is greater than 420 kHz when the switch is set to 1, it automatically returns to 191 kHz
And so on.

I have tried this code but it is not working either with EventID "ADF_SET" nor with "ADF_COMPLETE_SET"

Code:
<PartInfo> 
	<Name>00-NORD_ADF1_Plages_Frequences</Name> 
	<AnimLength>30</AnimLength> 
	<Animation> 
		<Parameter> 
			<Code> (L:ADF1_Plages_Frequences,enum) 10 *
			</Code> 
			<Lag>100</Lag> 
		</Parameter> 
	</Animation> 

	<MouseRect> 
		<Cursor>Hand</Cursor> 
		<MouseFlags>WheelUp+WheelDown+LeftSingle+RightSingle</MouseFlags> 			<TooltipText>Selecteur Plages de Frequences</TooltipText>		
	<CallbackCode> 
		<!-- DECREASE --> 
			(M:Event) 'RightSingle' scmp 0 == 
			if{ (L:ADF1_Plages_Frequences,enum) -- 0 max (&gt;L:ADF1_Plages_Frequences,enum) } 	

			(M:Event) 'WheelDown' scmp 0 == 
			if{ (L:ADF1_Plages_Frequences,enum) -- 0 max (&gt;L:ADF1_Plages_Frequences,enum) } 			
		
		<!-- INCREASE --> 	
			(M:Event) 'LeftSingle' scmp 0 == 
			if{ (L:ADF1_Plages_Frequences,enum) ++ 3 min (&gt;L:ADF1_Plages_Frequences,enum) } 
			(M:Event) 'WheelUp' scmp 0 == 
			if{ (L:ADF1_Plages_Frequences,enum) ++ 3 min (&gt;L:ADF1_Plages_Frequences,enum) } 
			

	<!-- EVALUATE SWITCH POSITION AND TAKE ACTION --> 
	[COLOR="Red"](L:ADF1_Plages_Frequences,enum) 0 == 
        (A:ADF ACTIVE FREQUENCY:1, KHz) 190 &gt; and
	if{ 100 (&gt;K:ADF_SET) }[/COLOR]
	
		</CallbackCode>
 </MouseRect> 

</PartInfo>




Could you help me ?
 
Last edited:
You need to translate your KHz frequency to BCD format before passing it to the ADF_COMPLETE_SET event. Evaluate your "Band Switch" to set the base band frequency, then convert the base freq to BCD format:

Code:
        (* SET THE FREQUENCY BAND *)
        (L:ADF1_Plages_Frequences,enum)) 0 ==
            if{ 100 (>L:ADF_Band,enum) }
        (L:ADF1_Plages_Frequences,enum)) 1 ==
            if{ 190 (>L:ADF_Band,enum) }
        (L:ADF1_Plages_Frequences,enum)) 2 ==
            if{ 420 (>L:ADF_Band,enum) }
        (L:ADF1_Plages_Frequences,enum)) 3 ==
            if{ 870 (>L:ADF_Band,enum) }            
        
        (* UPDATE ADF FREQUENCY *)
        (L:ADF_Band,enum)
        10000 * s0 10 %
        s2 l0 10 / flr 10 % 16 * l2 +
        s2 l0 100 / flr 10 % 256 * l2 +
        s2 l0 1000 / flr 10 % 4096 * l2 +
        s2 l0 10000 / flr 10 % 65536 * l2 +
        s2 l0 100000 / flr 10 % 1048576 * l2 +
        s2 l0 1000000 / flr 10 % 16777216 * l2 +
        s2 l0 10000000 / flr 10 % 268435456 * l2 +
        s2 (>K:ADF_COMPLETE_SET)

Alternatively, if you have an <Update> section in your gauge, you can use this @Macro instead:
http://www.fsdeveloper.com/wiki/index.php?title=XML:_Set_ADF_Frequency

Code:
        (* SET THE FREQUENCY BAND *)
        (L:ADF1_Plages_Frequences,enum)) 0 ==
            if{ @SetADF(100) }
        (L:ADF1_Plages_Frequences,enum)) 1 ==
            if{ @SetADF(190) }
        (L:ADF1_Plages_Frequences,enum)) 2 ==
            if{ @SetADF(420) } 
        (L:ADF1_Plages_Frequences,enum)) 3 ==
            if{ @SetADF(870) }
 
Last edited:
Thank you for your answer. Your code works perfectly to display 100-190-420-870.
But in addition, I would prohibit exceed 190 when
HTML:
(L:ADF1_Plages_Frequences,enum) 0 ==
I have tried this code but it doesn't work
Code:
(L:ADF1_Plages_Frequences,enum)) 0 ==
[COLOR="RoyalBlue"](A:ADF ACTIVE FREQUENCY:1, Khz) 190 &gt; and[/COLOR]
     if{ 100 (&gt;L:ADF_Band,enum) }
 
Get rid of the last parentheses:

(L:ADF1_Plages_Frequences,enum))

Hope this helps,
 
I've tried this code and it doesn't work.

Code:
(L:ADF1_Plages_Frequences,enum)) 0 ==
	(A:ADF FREQUENCY:1; Khz)) [COLOR="Navy"]190.5 &lt; and[/COLOR]
	      if{ 100 (&gt;L:ADF_Band,enum) }

What I want to do is to make impossible a setting greater than 190 when
(L:ADF1_Plages_Frequences,enum)) 0 == is selected.

And to make impossible a setting lower than 190.1 or greater than 420 when
(L:ADF1_Plages_Frequences,enum)) 1 == is selected.

And so on...
 
You are approaching this goal incorrectly...

The approach to take is what I've done with the ADF radio in my 737-200:

1. Band Switch to select ADF tuning band.
2. Tuning knob(s) that will only tune between the band limits selected.

In other words, you need to control the tuning limits in the knob(s) mouse areas, not the band selector!
 
HTML:
2. Tuning knob(s) that will only tune between the band limits selected
I have no idee of how this can be done.
Would you be so kind as to provide me the code used for your 737-200 ?

Here is my code for the tuning knob.

Code:
<PartInfo>
    <Name>00-NORD_ADF1_Frequence</Name>
    <AnimLength>360</AnimLength>
    <Animation>
      <Parameter>
        <Code>(A:ADF ACTIVE FREQUENCY:1, KHz) 10 / 10 % 36 * dnor</Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipID>TOOLTIPTEXT_ADF1_FREQ</TooltipID>
      <MouseFlags>WheelUp+WheelDown+LeftDrag+LeftSingle</MouseFlags>
      <CallbackJumpDragging>
        <XMovement>
          <Delta>5</Delta>
          <EventIdInc>ADF1_WHOLE_DEC</EventIdInc>
          <EventIdDec>ADF1_WHOLE_INC</EventIdDec>
        </XMovement>
      </CallbackJumpDragging>
    </MouseRect>
  </PartInfo>

Thanks for your help
 
Essentially, you will need to use <CallbackCode> rather than <CallbackJumpDragging> so that you can include conditions and limits to your tuning knob(s).

Notice that there are four separate "band" and "limit" conditions that must be true, so that only one will be used depending on which of the "bands" is selected. The limits are defined as the minimum and maximum frequencies within each "bank". So, once you've reached the maximum for a selected band, it will simply stop tuning! With Band 0 selected for example, you cannot tune below 100.0 KHz, and cannot tune above 189.5 KHz.

I've set this up to use either left/right clicking or the mousewheel. You would have to script another, similar section for the K:ADF_100_INC and K:ADF_100_DEC tuning of course.
Code:
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
      <CallbackCode>
		(* Band 0 *)
		(L:ADF1_Plages_Frequences,enum) 0 ==
		(A:ADF ACTIVE FREQUENCY:1,KHz) 100.0 &gt;= and
		(A:ADF ACTIVE FREQUENCY:1,KHz) 189.5 &lt;= and
		if{
			(M:Event) 'RightSingle'  scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'LeftSingle'   scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
			(M:Event) 'WheelUp'      scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'WheelDown'    scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
		}
		
		(* Band 1 *)
		(L:ADF1_Plages_Frequences,enum) 1 ==
		(A:ADF ACTIVE FREQUENCY:1,KHz) 190.0 &gt;= and
		(A:ADF ACTIVE FREQUENCY:1,KHz) 419.5 &lt;= and
		if{
			(M:Event) 'RightSingle'  scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'LeftSingle'   scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
			(M:Event) 'WheelUp'      scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'WheelDown'    scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
		}
		
		(* Band 2 *)
		(L:ADF1_Plages_Frequences,enum) 2 ==
		(A:ADF ACTIVE FREQUENCY:1,KHz) 420.0 &gt;= and
		(A:ADF ACTIVE FREQUENCY:1,KHz) 879.5 &lt;= and
		if{
			(M:Event) 'RightSingle'  scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'LeftSingle'   scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
			(M:Event) 'WheelUp'      scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'WheelDown'    scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
		}
		
		(* Band 3 *)
		(L:ADF1_Plages_Frequences,enum) 3 ==
		(A:ADF ACTIVE FREQUENCY:1,KHz) 870.0 &gt;= and
		(A:ADF ACTIVE FREQUENCY:1,KHz) 1750.0 &lt;= and
		if{
			(M:Event) 'RightSingle'  scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'LeftSingle'   scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
			(M:Event) 'WheelUp'      scmi 0 == if{ (>K:ADF1_WHOLE_INC) }
			(M:Event) 'WheelDown'    scmi 0 == if{ (>K:ADF1_WHOLE_DEC) }
		}				
      </CallbackCode>
 
Back
Top