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

FSX Third NAV Radio XML

cheangjc

Resource contributor
Messages
111
Country
singapore
Hi,

I decided to share the code that I created for the third NAV Radio with the help of the wealth of information on the fsdeveloper forums.

Code:
(L:AB_RD_SCH_CMP, bool) 1 ==
if{
	(C:fs9gps:NearestVorItemsNumber, number) (> L:AB_RD_SCH_Max, number)
	
	:01
	
	(L:AB_RD_SCH_Item, number) (>C:fs9gps:NearestVorCurrentLine, enum)
	(L:AB_RD_SCH_Item, number) (>C:fs9gps:NearestVorSelectedVor, enum)
	
	(C:fs9gps:NearestVorCurrentFrequency, mhz) (L:YOUR_VOR2fq, number) - abs 0.01 <
	if{
		(C:fs9gps:NearestVorSelectedVorType) (> L:AB_RD_VOR2_Type, number)
		(A:PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees)
		(A:PLANE LONGITUDE, degrees) (>C:fs9gps:GeoCalcLongitude1, degrees)	
		(C:fs9gps:NearestVorSelectedVorLatitude, degrees) (>L:AB_RD_VOR2Lat, degrees)
		(C:fs9gps:NearestVorSelectedVorLongitude, degrees) (>L:AB_RD_VOR2Lon, degrees)	
		(L:AB_RD_VOR2Lat, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees) 
		(L:AB_RD_VOR2Lon, degrees) (>C:fs9gps:GeoCalcLongitude2, degrees) 
		(C:fs9gps:NearestVorCurrentIdent, string) 0 symb ord (> L:AB_RD_VOR2_0, number)
		(C:fs9gps:NearestVorCurrentIdent, string) 1 symb ord (> L:AB_RD_VOR2_1, number)
		(C:fs9gps:NearestVorCurrentIdent, string) 2 symb ord (> L:AB_RD_VOR2_2, number)
		(L:AB_RD_SCH_Max, number) 1 + (> L:AB_RD_SCH_Item, number)
		0 (> L:AB_RD_VOR2_INVL, bool)
	}
	els{
		(L:AB_RD_SCH_Item, number) 1 + (> L:AB_RD_SCH_Item, number) 	
		
		(L:AB_RD_SCH_Item, number) (L:AB_RD_SCH_Max, number) <
		if{
			g01 }
		els{
			1 (> L:AB_RD_VOR2_INVL, bool)
			0 (> L:AB_RD_VOR2_DIST, number)
			0 (> L:AB_RD_VOR2_BRG, number)
			0 (> L:AB_RD_VOR2_0, number)
			0 (> L:AB_RD_VOR2_1, number)
			0 (> L:AB_RD_VOR2_2, number) }						
	}
	
	0 (> L:AB_RD_SCH_Item, number)
	0 (> L:AB_RD_SCH_CMP, bool)	

}
els{
	50 (>C:fs9gps:NearestVorMaximumItems, enum) 
	(A:PLANE ALTITUDE, feet) 100 / 25 * 195 min (>C:fs9gps:NearestVorMaximumDistance, nmiles)		
	(A:PLANE LATITUDE, degrees) (>C:fs9gps:NearestVorCurrentLatitude, degrees) 
	(A:PLANE LONGITUDE, degrees) (>C:fs9gps:NearestVorCurrentLongitude, degrees)
	
	(L:AB_RD_VOR2_INVL, bool) 0 ==
	if{
	(C:fs9gps:GeoCalcDistance, nmiles) (> L:AB_RD_VOR2_DIST, number)
	(C:fs9gps:GeoCalcBearing, degrees) (> L:AB_RD_VOR2_BRG, number)  }

	(L:AB_RD_CN, number) 1 + (> L:AB_RD_CN, number)
	
	(L:AB_RD_CN, number) 19 >=
	(C:fs9gps:NearestVorItemsNumber, number) 0 != &&
	if{
		1 (> L:AB_RD_SCH_CMP, bool)
		0 (> L:AB_RD_CN, number)	}
	
}

Code:
[B][U]INPUTS[/U][/B]
VOR2 Frequency Input: L:YOUR_VOR2fq, number

[B][U]OUTPUTS[/U][/B]
Coordinates:
L:AB_RD_VOR2Lat, degrees
L:AB_RD_VOR2Lon, degrees 

3 LETTER VOR IDENT - ASCII CHARACTER CODING:
L:AB_RD_VOR2_0, number
L:AB_RD_VOR2_1, number
L:AB_RD_VOR2_2, number

Distance to VOR2:
L:AB_RD_VOR2_DIST, number

Bearing to VOR2:
L:AB_RD_VOR2_BRG, number

VOR2 Invalid/No Signal (VOR2 Invalid = 1, VOR2 Reciving Normal = 0) :
L:AB_RD_VOR2_INVL, bool

VOR2 Type (UNKNOWN = 0, VOR = 1, VOR_DME = 2, DME = 3, TACAN = 4, VORTAC = 5, ILS = 6, VOT = 7):
L:AB_RD_VOR2_Type, number

Code:
Notes:
1. There is a timer counter combined with a FS9GPS wait for response to ensure the GPS Module have all the time it needs to scan the VOR.
2. The VOR Reciving distance varies with altitude using data that I collected. 195nm is roughly the absolute Max Distance (at any height) a VOR Receiver can receive according to my data. 
3. Three letter Code IDENT is specifically adaptated to transfer to C++ the string. I know there are modules out there that parse a String Value for storage to access into C++ Module, I prefer to keep it simple here. If you only use XML for displays, search FSDeveloper Forums for XML String Storing and Loading.

Hopefully it helps anybody searching for a code sample :)
 
Last edited:
Messages
118
Country
israel
works perfect.
but I dont know how to reset output values where VOR is out of range or another unactive VOR freq is tuned
 
Messages
118
Country
israel
Thanks!

what I needs to to If I want to tune only DME station VORDME or LOCDME or juse stand alone DME
 

cheangjc

Resource contributor
Messages
111
Country
singapore
Thanks!

what I needs to to If I want to tune only DME station VORDME or LOCDME or juse stand alone DME

All you need to do is to read L:AB_RD_VOR2_Type as listed in the apendix. If the type of navaid tuned is not the one you want, just ignore the signal and treat it as invalid. (Note, there usually should not be two same freq in too close proximity together)
 

cheangjc

Resource contributor
Messages
111
Country
singapore
I tried to revice DME located on ILS system and there is no signal :(

You can't use this code to receive ILS/LOC signals. This code is exclusive to VOR/DME. Instead, you should configure all ILS radios to use the default and VOR using this.
 
Top