Hi Folks,
Having cracked the functionality of my RNAV, I am now reproducing the functionality of my Narco panel COM radios - these have a toggle switch enabling the pilot to change the active frequency rather than standby frequency. I have reproduced this but the quarter frequencies do not increment correctly.
I am effecting this by adding 0.025 decimal to the saved value of COM1 ACTIVE FREQUENCY
The functionality is there but the problem I am seeing is that XXX.X5 can end up as XXX.X6 and sometimes instead of XXX.X7 or XXX.X8 I can get XXX.X9 My guess is that this is becasuse FS stores quarter frequencies as BCD which effectively is a rounded second decimal place (but could be variously rounded up or down) and therefore when I add 0.025 XXX.X3 I get XXX.X55 which can then be rounded to XXX.X6 and so on. Setting the active frequency with the K:COM_RADIO_SET accepts the wrong value.
I rather assume that there is an elegant way of doing it with BCD maths (which I don't yet understand well). Any tips would be much appreciated.
Macros I am using are:
<Macro id="ConvertFrq" Name="ConvertFrq">
(L:COM1 ACTIVE FREQUENCY,MHz) 100 * near 10000 % d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * +
</Macro>
and
<Macro id="DecLarge" Name="DecLarge">
(A:COM1 ACTIVE FREQUENCY, MHz) 119 <
if{ 136 (A:COM1 ACTIVE FREQUENCY, MHz) 118 - + (>L:COM1 ACTIVE FREQUENCY,MHz) }
els{ (A:COM1 ACTIVE FREQUENCY, MHz) 1 - (>L:COM1 ACTIVE FREQUENCY,MHz) }
@ConvertFrq
</Macro>
<Macro id="DecSmall" Name="DecSmall">
(A:COM1 ACTIVE FREQUENCY, MHz) 118.5 <
if{ 136.975 (>L:COM1 ACTIVE FREQUENCY,MHz) }
els{ (A:COM1 ACTIVE FREQUENCY, MHz) 0.025 - (>L:COM1 ACTIVE FREQUENCY,MHz) }
@ConvertFrq
</Macro>
The outputs are then set using (>K:COM_RADIO_SET)
Having cracked the functionality of my RNAV, I am now reproducing the functionality of my Narco panel COM radios - these have a toggle switch enabling the pilot to change the active frequency rather than standby frequency. I have reproduced this but the quarter frequencies do not increment correctly.
I am effecting this by adding 0.025 decimal to the saved value of COM1 ACTIVE FREQUENCY
The functionality is there but the problem I am seeing is that XXX.X5 can end up as XXX.X6 and sometimes instead of XXX.X7 or XXX.X8 I can get XXX.X9 My guess is that this is becasuse FS stores quarter frequencies as BCD which effectively is a rounded second decimal place (but could be variously rounded up or down) and therefore when I add 0.025 XXX.X3 I get XXX.X55 which can then be rounded to XXX.X6 and so on. Setting the active frequency with the K:COM_RADIO_SET accepts the wrong value.
I rather assume that there is an elegant way of doing it with BCD maths (which I don't yet understand well). Any tips would be much appreciated.
Macros I am using are:
<Macro id="ConvertFrq" Name="ConvertFrq">
(L:COM1 ACTIVE FREQUENCY,MHz) 100 * near 10000 % d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * +
</Macro>
and
<Macro id="DecLarge" Name="DecLarge">
(A:COM1 ACTIVE FREQUENCY, MHz) 119 <
if{ 136 (A:COM1 ACTIVE FREQUENCY, MHz) 118 - + (>L:COM1 ACTIVE FREQUENCY,MHz) }
els{ (A:COM1 ACTIVE FREQUENCY, MHz) 1 - (>L:COM1 ACTIVE FREQUENCY,MHz) }
@ConvertFrq
</Macro>
<Macro id="DecSmall" Name="DecSmall">
(A:COM1 ACTIVE FREQUENCY, MHz) 118.5 <
if{ 136.975 (>L:COM1 ACTIVE FREQUENCY,MHz) }
els{ (A:COM1 ACTIVE FREQUENCY, MHz) 0.025 - (>L:COM1 ACTIVE FREQUENCY,MHz) }
@ConvertFrq
</Macro>
The outputs are then set using (>K:COM_RADIO_SET)

