Results 1 to 4 of 4
  1. #1
    10+ Posting Member
    Join Date
    Apr 2015
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Arduino uno + Link2fs Radio issue with A2A ADF

    Hello everyone, first of all i want to thanks to Jimmy for such amazing work.

    Well i finished the construction of the radio project posted at Jimmy's page and everything works fine but the ADF is not working.

    The problem is when i put the rotary switch into ADF position the LCD show the actual freq in the airplane's radio but it doesn't change when i move the encoder; the most weird thing is when i move the knob directly in the cockpit, the ADF freq change in the plane's radio and in the LCD of the homemade radio.

    Any solutions for this?..


    P.D: The plane i fly is the Cessna 172 from A2A.

  2. #2
    150+ Forum Groupie
    Join Date
    Nov 2013
    Evansville, Indiana
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino uno + Link2fs Radio issue with A2A ADF

    On the A2A Comanche, the ADF has an Active and Stand-by just like the Coms and Navs.
    On my home built radio, for the Comanche, the selector will change the ADF standby freq but my radio display shows the Active. If I press the button to swap freqs then my display changes.
    Link2FS doesn't address ADF Stand-by.

    It kind of acts like 737 COM freqs where active and standby are swapped.

    I will only ever be, half the Geek that I wished I was.

  3. #3
    300+ Forum Addict Tom_G_2010's Avatar
    Join Date
    Mar 2011
    Central Mass
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino uno + Link2fs Radio issue with A2A ADF

    I may be removing the ADF and DME from my Sim Pit in the future to fit a GPS in but in the interim I've been pondering how to resolve that same ADF issue.

    There are actually a hand full of functions on the A2A avionics that Link2FSMulti doesn't support. However, A2A does provide a list of LVars that could be triggered in a Lua script. So, "borrowing" some ideas from others I am setting up an Arduino Uno to act as a secondary USB serial port to pass commands off to a Lua script that monitors its com port. I may also try this by adding a Serial/USB converter to my existing Mega to avoid the nees for another Arduino card.

    I have it partially working on my test bench so I'm not quite ready to post the code yet. But, I will be sure to do so when it's fully baked. At present using the Uno I am linking it to my avionics Arduino using the I2C connection. With that, anytime I want to send a command to the Lua script rather than Link2FSMulti all I do is address it to the I2C bus rather than the Serial bus. The command then gets picked up by a lua script that is listening to the second arduino and triggers the appropriate LVar.

    Regarding the ADF I have the same issue. My ADF hardware is only setup for a single frequency display and does not have a button available that I could use as a swap function. The fix for this is on my task list but I haven't had a chance to work on the ADF yet so I don't have any code to offer but here's my crazy idea.

    • I plan to work the swap button fuction via the lua portal and the approriate LVar to toggle it.
    • Upon initialization I will send a default ADF freq to the radio, trigger the swap and then send it again so that both the hot and the standby are on the same freq.
    • Following that I will modify the rotary encoder code for my ADF frequency selector so that with each click it also triggers an ADF swap and a second send of the freq change. That way with each click of the roatry encoder the standby freq will change and immediately swap then the old freq, now the standby, will update as well.

    It's a bit crude and I am concerned about timing and the speed of encoder rotation verses the swap action so I'm not 100% certain it will work but, given that I plan to remove my ADF in the future I don't want to invest time and money into building a hot/standby version at this time.

    Maybe that sparks some other ideas for folks for further discussion. As I said above as my Lua Portal idea gets a little more firm and tested I'll be sure to share the details. PC: Intel Core i7 Haswell @ 3.8GHz, 8Gb Ram, Win 7 64Bit, dual SSDs, GeFroce 780 SIM: FSX w/Aclrtn Pk, FSUIPC4, ASN, UTX, GEX, REX 4

  4. #4
    75+ Posting Member

    BushPilotWannabe's Avatar
    Join Date
    Jan 2014
    Alberta, Canada
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino uno + Link2fs Radio issue with A2A ADF

    Like all good things this code is based on and inspired by and his

    // global ADF variables
    int adfActive[4];
    int adfDigits[4] = {200, 60, 6};
    int adfHolding[4];

    // replaces ADF input in void EQUALS()
    case 'I': // "ADF"
    intData = 0 ;
    adfActive[0] = int((getChar()-48 *1000);
    adfActive[0] += int((getChar()-48 *100) ;
    adfActive[1] = int((getChar()-48 *10) ;
    adfActive[2] = int(getChar()-48 ) ;
    getChar(); // ignor the decimal point and tenths digit

    // add this to void INPUTPINS() after "if (pinStateSTR != oldpinStateSTR){"
    if (pinNo==11) sudoKingCollinsEncoder = ((digitalRead(11) * (-1)) + (digitalRead(12) * (1)));
    if (pinNo==12) sudoKingCollinsEncoder = ((digitalRead(11) * (-1)) + (digitalRead(12) * (1)));

    /* For we mortals without KING/COLLINS/HONEYWELL switches and must scrape along with a single encoder for the ADF and two pushbuttons to mimic
    use of an outer knob, inner knob pushed in, and an inner knob pulled out; I code the output of the ADF encoder as 14 for ccw and 17 for cw rotation.
    Eventually one button on the yoke will raise these code values to indicate outer knob rotation and another pushbutton to lower the code values and
    indicate inner knob 'out' rotation. Inner knob 'in' is the default rotation. Until then I am stuck with a on/off/on toggle switch or two pushbuttons.

    switch (decoded_encoder_output){
    case 13: {ADF_UNITS(+1); break;} // dec ADF units
    case 14: {ADF_TENS(+10); break;} // dec ADF 10s
    case 15: {ADF_HUNDREDS(+100); break;} // dec ADF 100's
    case 16: {ADF_UNITS(-1); break;} // inc ADF units
    case 17: {ADF_TENS(-10); break;} // inc ADF 10's
    case 18: {ADF_HUNDREDS(-100); break;} // inc ADF 100's

    // Changes the units digit and calls the function to display this to the ADF standby display.
    // This is longer than it could be but limiting wrap around is not the norm.
    void ADF_UNITS(int addend){
    int temp;
    adfDigits[2] += addend;
    temp = adfDigits[2];
    if (adfDigits[2] > 9) temp = 0;
    if (adfDigits[2] < 0) temp = 9;
    adfDigits[2] = temp;
    UPLOAD4CharFreq(adfDigits[0]+adfDigits[1]+adfDigits[2], "","");

    // same as above
    void ADF_TENS(int addend){
    int temp;
    adfDigits[1] += addend;
    temp = adfDigits[1];
    if (adfDigits[1] > 90) temp = 0;
    if (adfDigits[1] < 0) temp = 90;
    adfDigits[1] = temp;
    UPLOAD4CharFreq(adfDigits[0]+adfDigits[1]+adfDigits[2], "","");

    // ditto
    void ADF_HUNDREDS(int addend){
    int temp;
    adfDigits[0] += addend;
    temp = adfDigits[0];
    if (adfDigits[0] > 1799) temp = 100;
    if (adfDigits[0] < 100) temp = 1700;
    adfDigits[0] = temp;
    UPLOAD4CharFreq(adfDigits[0]+adfDigits[1]+adfDigits[2], "","");

    /* My do-all output to display or serial USB.
    The command and tagAlong variables will accept empty strings
    String command input is usually Jim's simConnect input. eg. "A33" It can be a leading zero "0" or empty """" and no spaces are printed.
    The String tagAlong is added to display four digits and upload five digits as per the "A33xxxxx" format.
    void UPLOAD4CharFreq(int rawFreq,String command, String tagAlong){
    if (rawFreq <1000) {Serial.println(command + '0' + String(rawFreq) + tagAlong);}
    Serial.println(command + String(rawFreq) + tagAlong);

    // switch (pushbuttons){ // another switch case. This one is for transfer and mode/channel pushbuttons.
    // two legs of a three way swap. the adfActive array is reloaded during download of the new ADF active frequency.

    case 12: {if (flagValue > 0){
    for (int a=0; a<3; a++) adfHolding[a] = adfActive[a];
    UPLOAD4CharFreq(adfDigits[0]+adfDigits[1]+adfDigits[2], "A33","0"); // adfActive is reloaded during void EQUALS().
    for (int a=0; a<3; a++) adfDigits[a] = adfHolding[a];
    Last edited by BushPilotWannabe; 01-19-2016 at 07:56 PM. Reason: replace happy face with 8 )
    ---CYXD ----- TWR --- GND ------ Closed
    ILS-- NDB -- 119.1 -- 121.9 ---- 11/2013

Tags for this Thread