29 Radios & Autopilot Project: Toggle Between NAV1 MHz / kHz with the Encoder Switch in Mobiflight

In the previous video we managed to tune NAV1 MHz with an encoder. In this video we’ll do the same for NAV1 kHz, using the same encoder. And on top of that, we’ll use the encoder push button to toggle between tuning kHz or MHz.

But first some ‘breaking news’: the panel building is finished! It’s fully functional now and it looks like this:

radios & autopilot panel

Click the images to enlarge. Scroll down to watch the video.

Mobiflight  NAV1 kHz tune with encoder

To add NAV1 kHz to the Mobiflight software configuration, follow the exact same steps as in the previous video (LINK), with as the only changes:
– ‘On Left’ the event ID is ‘NAV1 RADIO FRACT DEC’
– ‘On Right’ the event ID is ‘NAV1 RADIO FRACT INC’

We have both NAV1 MHz and kHz tuning working now, but they change simultaneously! The challenge now is to toggle between MHz or kHz by pressing the push button of the encoder.

We’re going to solve this by using an FSUIPC memory location in which we store a ‘0’ or a ‘1’ and we’ll toggle between 0 and 1 every time the button is pressed. We’ll use the ‘Precondition’ tab in both the ‘Encoder NAV1 MHz’ and the ‘Encoder NAV1 kHz’ inputs to check if the memory location is ‘0’ or ‘1’. Mobiflight will now only change the value, MHz or kHz, of which the condition is true.

1. First we configure the push button of the NAV1 encoder in menu ‘Extra’ > ‘Setup’ > ‘Mobiflight Modules’ tab. I gave it the name ‘Button NAV1’.
2. Upload to the Arduino.
3. Save the config to disk.

Toggle NAV1 input

Now we create an Input that monitors the push button:
1. Go to the ‘Input’ tab and add a config, I named it ‘Toggle NAV1 MHz/kHz’.
2. Click the ‘Edit’ field and enter the parameters as shown in the image.

Explanation of the ‘Offset’.
FSUIPC stores the data that it reads from or writes to the flight sim in addresses, that for some reason are called ‘offsets’. In FSUIPC offsets in the range from 66C0 to 66FF are available to users to store their own data. We’ll use 66C0 to store our ‘0’ or ‘1’. See this PDF for all FSUIPC addresses.

Explanation of ‘Set Value’:
The value we want to store in address 66C0 when the button is pressed has to toggle from 0 to 1, or from 1 to 0. To accomplish this we use an ‘if’ statement: If the current value, read by $, is 1 then the new value becomes 0, else the new value becomes 1. This is written as: if($=1,0,1).

Toggle NAV1 output

The next thing to do is to create an output that we can use in the Preconditions we’re going to make:
1. Go to the ‘Ouput’ tab and add a config, I named it ‘Toggle NAV1 MHz/kHz’.
2. Click the ‘Edit’ field and enter the parameters as shown in the image. All we do is read the contents of our memory address 66C0. Remark: the image shows CC60, this was a mixup, it should be 66C0.

mobiflight precondition

We now return to the ‘Input’ tab where we’re going create Preconditions in the NAV1 kHz and -MHz inputs:
1. Select the Encoder NAV1 kHz input and go to the Precondition tab.
2. First click the tick mark at the top, next to ‘none’, and then fill in the parameters as shown.
3. Click ‘Apply’. The condition now shows at the top.
4. Click OK to exit.

mobiflight precondition

Do the same for Encoder NAV1 MHz, but this time use ‘1’ in the field named ‘If current value is’ (assuming you used ‘0’ for the kHz input).

Click Apply, then OK, then save the configuration to disk.

Now the push button of the NAV1 encoder toggles between tuning kHz or MHz, because when we press the button, memory location 66C0 changes its value from 0 to 1 or from 1 to 0 and this value is used as a precondition … only if the condition is true the input is active.

Encoders for NAV2, COM1 and COM2 are configured in exactly the same way.

8 thoughts on “29 Radios & Autopilot Project: Toggle Between NAV1 MHz / kHz with the Encoder Switch in Mobiflight

  1. This is awesome. I am building a small panel and I want to use a single rotary switch to change between the different radios and then the same rotary encoder for the radios. Is there a way it can be done?

    Like

  2. Hi Rudy, this is a great project – thanks for the info. Just one observation – there looks to be an inconsistency in the FSUIPC offset address shown in the video and screen-shots. I think perhaps the video (66C0) is correct, not the screen shots (CC60)?

    Like

  3. Hi Mr.Rudy, I’m making headway in building my panel, components are still coming.Last night I configured some encoders and they are working perfectly fine. I also named my first Arduino Mega “Rudy Mega” as a humble compliment to you. I noticed in the next videos you mentioned that you have used all of 66C0 offset and then you used 66C1 and 66C2 etc, my question is
    1. I know these free offsets range from 66C0 to 66FF
    How can we know what comes after 66C0? if we say that after 66C0 comes the next hexadecimal number 66C1 and so on up until 66FF. Am I correct?
    2. How many times can we use one offset, for example, how many times we can use 66C0, I guess 8 times? ( 8×8=64).
    3. Use of these offsets are aircraft specific? I mean if I use it for Cessna 172 can I use the same for A310.
    So far I have used 66C0 for I guess 3 or 4 encoders and they all work fine. I tried to google the answers but couldn’t find much
    Best Regards
    Muhammad

    Like

  4. Hi Muhammed,

    1. I know these free offsets range from 66C0 to 66FF How can we know what comes after 66C0? if we say that after 66C0 comes the next hexadecimal number 66C1 and so on up until 66FF. Am I correct?
    Yes, 66C1 is next, then 66C2 etc..

    2. How many times can we use one offset, for example, how many times we can use 66C0, I guess 8 times? ( 8×8=64).
    3. Use of these offsets are aircraft specific? I mean if I use it for Cessna 172 can I use the same for A310.
    So far I have used 66C0 for I guess 3 or 4 encoders and they all work fine.
    It is a memory location. The value you store in it is available wherever you read it out. There is no limit to how many times you use it. If you use it for multiple encoders it works fine, but when you start tuning another encoder and it reads this same memory, it means this encoder will have the value you left off with the previous encoder.

    Greetings, Rudy.

    Like

Leave a comment