Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HSI bearing neeedle swaying

Featured Replies

Hi all FS9 XMLI noticed that on some RW HSI that the NAV & ADF bearing needles when tuned and active sway intermittently between up to + - 10 degrees of the bearing. Is it possible to simulate this and how?

Paul EGLD

  • Commercial Member

Hi PaulYes, it is, but you have to do it at the programming stage. I do something similar with pressure gauges because all pumps don't produce the same pressure at the same time (wear, cavitation etc). What I do is to create the gauge and ensure that it is working as expected, then finally make a call to a randomiser function ensuring that the random return is within reasonable limits for the type of display, add the randomiser to the FS output and feed the result to the needle. Another use of this method that I make is that in heavy iron, if you then check time of day you can increase the spread in the randomiser to increase peak load on the generators at mealtimes. If you then get a generator failure at peak times, you really do have to start load-shedding before you start losing the rest of them to overload conditions.

//**************************************************************************//Randomiser - where iMax is the upper limit and iActual is what you get//This version only gives a positive output; to get negative as well it will need modifying//**************************************************************************int GetRand(int iMax, int iActual){	long ltime=-1;	int stime=-1;		ltime=(long)time(NULL);	stime=(unsigned)ltime/2;	srand(stime);	iActual=(int)rand()%iMax;	return iActual;}

(Yes, I know you said XML and this is C, but you get the picture!).-Dai

  • Author
Hi PaulYes, it is, but you have to do it at the programming stage. I do something similar with pressure gauges because all pumps don't produce the same pressure at the same time (wear, cavitation etc). What I do is to create the gauge and ensure that it is working as expected, then finally make a call to a randomiser function ensuring that the random return is within reasonable limits for the type of display, add the randomiser to the FS output and feed the result to the needle. Another use of this method that I make is that in heavy iron, if you then check time of day you can increase the spread in the randomiser to increase peak load on the generators at mealtimes. If you then get a generator failure at peak times, you really do have to start load-shedding before you start losing the rest of them to overload conditions.
//**************************************************************************//Randomiser - where iMax is the upper limit and iActual is what you get//This version only gives a positive output; to get negative as well it will need modifying//**************************************************************************int GetRand(int iMax, int iActual){	long ltime=-1;	int stime=-1;		ltime=(long)time(NULL);	stime=(unsigned)ltime/2;	srand(stime);	iActual=(int)rand()%iMax;	return iActual;}

(Yes, I know you said XML and this is C, but you get the picture!).-Dai

Hi DaiYes that will work, I got the needle sway done but the radomiser code in C is way over my head. I need code to generate random numbers between -10 + 10 if possible or I can make it work with 0 to 20 with more code.Thanks

Paul EGLD

  • Commercial Member

I'm unclear as to why you pass iActual as a variable to this function. It makes no sense... especially since you return the value on the stack with the function itself.The call to srand() repeatedly shouldn't be necessary. It should be done once when the gauge loads.I use the PANEL_SERVICE_CONNECT_TO_WINDOW service call in the gauge's main callback:srand( (unsigned)time( NULL ) );To get a min value that's negative... simply subtract half of the max value from the result.

//**************************************************************************//Randomiser - where iMax is the upper limit and iActual is what you get//This version only gives a positive output; to get negative as well it will need modifying//**************************************************************************int GetRand(int iMax, bool go_negative = false){  int ret_val;  ret_val = (((double) rand() / (double) iMax) * iMax);  if (go_negative)  {	ret_val = ret_val - (iMax/2);  }	return ret_val;}

Ed Wilson

Mindstar Aviation
My Playland - I69

  • Moderator
Hi DaiYes that will work, I got the needle sway done but the radomiser code in C is way over my head. I need code to generate random numbers between -10 + 10 if possible or I can make it work with 0 to 20 with more code.Thanks
Here is one example of an XML pseudo-random number generator:
<Macro Name="XMLRandom">	(L:RandomSeed1,number) 0 == (L:RandomSeed2,number) 0 == ||		if{			(P:Absolute Time,seconds) abs d 2147483563 % (>L:RandomSeed1,number)			sqrt d d * * abs 2147483599 % (>L:RandomSeed2,number)		}	(L:RandomSeed1,number) 40014 * 2147483563 % (>L:RandomSeed1,number) 	(L:RandomSeed2,number) 40692 * 2147483399 % (>L:RandomSeed2,number) 	(L:RandomSeed1,number) (L:RandomSeed2,number) - 2147483563 / s1	l1 0 < if{ l1 ++ s1 }	l1</Macro><Update>	@XMLRandom (>L:RandomNumber,number)</Update>

from: http://forums1.avsim.net/index.php?showtop...;hl=random++xml

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

rand() returns a uniformly distributed random integer between 0 and RAND_MAX. On my 32-bit system RAND_MAX is defined in stdlib.h as ox7fff.To get a double between 0.0 and 1.0 use:

(double)(rand()) / RAND_MAX

To get a double between 0.0 and iMax use:

iMax * (double)(rand()) / RAND_MAX

Gerry Howard

  • Author
Here is one example of an XML pseudo-random number generator:
<Macro Name="XMLRandom">	(L:RandomSeed1,number) 0 == (L:RandomSeed2,number) 0 == ||		if{			(P:Absolute Time,seconds) abs d 2147483563 % (>L:RandomSeed1,number)			sqrt d d * * abs 2147483599 % (>L:RandomSeed2,number)		}	(L:RandomSeed1,number) 40014 * 2147483563 % (>L:RandomSeed1,number) 	(L:RandomSeed2,number) 40692 * 2147483399 % (>L:RandomSeed2,number) 	(L:RandomSeed1,number) (L:RandomSeed2,number) - 2147483563 / s1	l1 0 < if{ l1 ++ s1 }	l1</Macro><Update>	@XMLRandom (>L:RandomNumber,number)</Update>

from: http://forums1.avsim.net/index.php?showtop...;hl=random++xml

Thanks BillI can work with this code

Paul EGLD

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.