• 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 ADF Radio Coding

Messages
358
Country
ca-ontario
I am currently building a 3D ADF radio like the one in the picture below:

KR86_ADF_Receiver-2.jpg


I've searched in the usual places but cannot find any sources for code (or coding hints) with regard to animating and tuning the digit drums and selection knobs. I do have working code for the matching drum type transponder unit and I have looked at trying to convert the code myself but as it has to be in 'BCD32' format it is way beyond my coding skills.

Does anyone have any working 3D code for this type of ADF radio they would be willing to share or any pointers to get me going in the right direction?

It's just the drums and tuning knobs I need code for as I believe the ADF compass card, pointer and HDG knob have stock code available for them.

Thanks for any assistance.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
You don't have to use BCD32. "Hz" will do just fine as a unit for the A: var. Tuning is done with the appropriate K: vars.

As for the drums, each one's animation can be controlled by taking modulo for 1s 10s and 100s of the active frequency (I think).
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
That is correct, and quite frankly is one major advantage of using XML script rather than C code. In C one must use BCD32.
 
Last edited:

Heretic

Resource contributor
Messages
6,830
Country
germany
Shouldn't the emboldening and the underscore be for the "must" instead of the "use", Bill? :D
 
Messages
358
Country
ca-ontario
I've got the tuning side of the radio working very nicely now but I've run into issues on the gauge side. For some reason the needle only works if the signal is coming from the right side of the aircraft (i.e. the 12 o'clock to 6 o'clock position on the gauge face) and I'm not sure it's even pointing at the right heading when compared to a 2D RMI gauge in a pop-up window I'm using for testing/comparison. The needle is animated through 360° in a CW direction starting at the 12 o'clock position. If the signal is coming from the left side of the aircraft the needle points straight up and if I circle the aircraft it will eventually start tracking the NDB when it is on the right side again.

This is the code I'm using for the needle:

Code:
<PartInfo>
     <Name>Mallard_ADF_needle</Name>
     <AnimLength>360</AnimLength>
     <Animation>
     <Parameter>
          <Code>
           (A:ADF radial:1, degrees)
          </Code>
     </Parameter>
     </Animation>
    </PartInfo>

I'm also having issues with the HDG knob and compass card as I can't seem to get those to play together and the compass card doesn't move at all. I'm obviously making a stupid mistake somewhere but can't seem to find it. This is the code I'm using for both the knob and the compass card and the card is animated through 360° in a CCW direction while the knob is animated through 360° in a CW direction (KF'd at 0-90-180-270-360 in both cases):

Code:
<PartInfo>
        <Name>Mallard_ADF_card</Name>
     <AnimLength>360</AnimLength>
        <Animation>
            <Parameter>
                <Code>
                (L:ADF_card, enum) 10 *
                </Code>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <TooltipText>ADF Card</TooltipText>
            <CallbackCode>
                (L:ADF_card, enum) ! (&gt;L:ADF_card, enum)
            </CallbackCode>
        </MouseRect>
    </PartInfo>

Looking at the 2D gauge in my pop-up window I can see that the compass card on that RMI head is actually working like a gyro compass with no need for a HDG knob to manually adjust the compass card and while I could code the card that way (using the code from my gyro compass) it wouldn't be right for this type of radio so I'm reluctant to do it that way.

Any suggestions on what I'm doing wrong with the needle and compass card/knob?
 

tgibson

Resource contributor
Messages
11,338
Country
us-california
It appears to me your variable (L:ADF_card, enum) only has the values of 0 and 1 (true/false), starting with false. If you want it to rotate, you would need to add one (or another number) to that variable at each click, not negate it. And rotating cards often have a left click (CW) and right click (CCW) mouserect.
 
Messages
358
Country
ca-ontario
Thanks for that Tom. I now have it all working perfectly thanks to help from Roman (Spokes2112).

We even tied the needle into a set of conditions so that it will only move if:

a) The radio power knob is ON.

b) The ADF radio is receiving a signal (i.e. it is tuned to a correct freq.).

and

c) The avionics circuit is ON and it has power from either the battery or generator.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
This is the code I'm using for the needle:
You need to "normalize" the A:variable Larry.
Code:
(A:ADF1 Radial,degrees) dnor
I like to add check conditions so that the ADF needle will "park" in the East position when no signal is present, or power is not available:
Code:
          (A:ELECTRICAL MASTER BATTERY,bool)
          (A:AVIONICS MASTER SWITCH,bool)
          and
          if{
              (A:ADF SIGNAL:1, number) 255 &gt;
              if{ (A:ADF1 Radial,degrees) dnor }
 
              (A:ADF SIGNAL:1, number) 256 &lt;
              if{ 90 }
          }
          els{ 90 }
 
Last edited:

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
That is correct, and quite frankly is one major advantage of using XML script rather than C code. In C one must use BCD32.

Not necessarily. If you are using execute_calculator_code, aircraft_varget, or simconnect you can use Hertz.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
True enough Jon, but then you are really using XML then... :duck:
 
Top