Results 1 to 7 of 7
  1. #1
    10+ Posting Member
    Join Date
    Sep 2014
    Location
    uk
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    FSX default A320 FCU: Nano v3

    Greetings one and all. Please help if you can. I'm building a A320 type FCU using a modified version of Fess original code. Using 3 Max7219 displays for SPD hdg Alt and vs with 4 rotary encoders. I also use 4 momentary switches to control AP; LOC; APPR and ATTR buttons
    Problem is this.
    I am using an Arduino Nano v3 which has 12 Digital pins and analog pins A0-A12 etc. Digital pins 2-9 used for encoders. Analogue pins will be used for buttons. In the code when pins 23-53 is referenced the Max7219 displays work correctly in fsx. However the rotary encoders don't work. On the other hand when digital pins 2-61 is referenced the encoders work correctly within fsx but the MAX displays remain blank.
    I am testing on the default FSX A320. Any help with the pins and coding with regards to the nano welcomr

  2. #2
    75+ Posting Member anzabon's Avatar
    Join Date
    Apr 2014
    Location
    Moon Base
    Posts
    75
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: FSX default A320 FCU: Nano v3

    Hi, there's already a freeware that supports Arduino in connection with FSUIPC perfectly - including switches, pushbuttons, rotaries and 7-segment displays: MobiFlight. You'll find it on ther website: www.mobiflight.de
    But it works with Arduino Mega 2560 only, not with Nano or other Arduino boards because of the number of pins available.
    Maybe that input helps...

    Regards, Bon

  3. #3
    10+ Posting Member
    Join Date
    Sep 2014
    Location
    uk
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: FSX default A320 FCU: Nano v3

    Thanks for your response Bon. I will check it out.

  4. #4
    150+ Forum Groupie


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

    Re: FSX default A320 FCU: Nano v3

    I've moved this Fess_ter's from Boeing Style MCP/Autopilot panel

    Hi there. I have modified the code at the appropriate section of the code for the nano anolog output pins as inputs pins. eg.

    pinMode(A0,INPUT)" etc.
    ........
    "if(current_pin ==A0)
    if (digital read(A0)==LOW) etc
    …............
    Problem. Getting no input or output when button when wired up. 1 wire to pin 1 wire to ground.

    I'm sure I will work it out eventually but help any with coding with reference to the nano appreciated. Thanks in advance. Still slowly learning slowly but surely.

    Try this then change "A0" to "14" I'm using IDE Version 1.6.5 earlier versions may allow swapping "A0" and "14" for Arduino UNOs, Nanos & ProMinis. Long term memory not so good. Short term memory is even worse.

    void setup() {
    pinMode(13,OUTPUT);
    pinMode(A0, INPUT_PULLUP);
    }

    void loop() {
    if (digitalRead(A0) == HIGH) digitalWrite(13,HIGH);
    else digitalWrite(13, LOW);
    }

    "if(current_pin ==A0)"
    If you have not defined "A0" as a variable, "A0" is a designator not the contents.
    Try
    if (current_pin == digitalRead(14))
    or
    int (or whatever) A0;
    A0 = digitalRead(14);
    if (current_pin == A0) ................

    When getting started with Link2fs and learning Arduino's version of C+, I spent more time in the Arduino Playground than butchering Jim's Multi Radio Project. And when you think it has all come together you spend a day chasing a missing "=".

    Hugh
    ---CYXD ----- TWR --- GND ------ Closed
    ILS-- NDB -- 119.1 -- 121.9 ---- 11/2013

  5. #5
    10+ Posting Member
    Join Date
    Sep 2014
    Location
    uk
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: FSX default A320 FCU: Nano v3

    Thanks one and all for your helpful tips.
    Using your ideas along with some experimentation I now have the 3 Max 7219 displays, the 4 rotary encoders and 4 inputs buttons integrated and working within FSX.

    To recap the project.
    A simple A320-style FCU using an Arduino Nano along with some modification of Fester's original Boeing-style MCP coding.

    Using the Nano's 17 available pins is used the following configuration (thanks Fesster for this info).

    *Digital Pins 10,11,12 for the 3 Max7219 to display SPD, HDG, ALT & VS respectively
    *Digital Pins 2-9 for the 4 rotary encoders used. Pins combination (2-3: 4-5: 6-7: 8-9) respectively.
    *Analog Pins A0; A1; A2; A3 as inputs to operate the LOC; Autopilot ; Autothrottle, Approach buttons respectively.
    *Analog pins A4; A5; A6; A7 as outputs for the respective LED annunciators, hopefully.

    Here are the appropriate sections of Fester's original code that I modified taking your suggestions into account.
    _______________________________________________________________________________
    ***************
    void setup() section changes
    ***************
    for (current_pin = 2; current_pin <= 9; current_pin++) // Get pins 2-9 ready as inputs
    {
    pinMode(current_pin, INPUT_PULLUP); // By setting the pins as INPUT_PULLUP it makes them all "HIGH" etc.etc.


    pinMode(2, INPUT_PULLUP); // A0-A3 INPUTS (A4-A7 as Outputs are for LED annunciators)
    pinMode(A0, INPUT_PULLUP); // Analog pin A0 is for (LOC)
    pinMode(A1, INPUT_PULLUP); // Analog pin A1 is for (AP)
    pinMode(A2, INPUT_PULLUP); // Analog pin A2 is for (ATTR)
    pinMode(A3, INPUT_PULLUP); // Analog pin A3 is for (APPR)
    pinMode(A4, OUTPUT); // Analog pin A4 is for (LOC LED)
    pinMode(A5, OUTPUT); // Analog pin A5 is for (AP LED)
    pinMode(A6, OUTPUT); // Analog pin A6 is for (ATTR LED)
    pinMode(A7, OUTPUT); // Analog pin A7 is for (APPR LED)
    ______________________________________________________
    ***************
    SECTION changes
    ***************
    void INPUTPINS() // All of the Encoders, Buttons and Switches are checked for changes



    all_pins_state = ""; //
    for (int current_pin = 2; current_pin <=17; current_pin++) // going to cycle thru all input pins 2 - 17
    ___________________________________________________________________________________________

    After implimenting these few changes in Fester's original Boeing the A320 FCU functions I required are now working.
    Minor caveat: I still need to test if the leds built into the momentary buttons used will work. But so far so good.
    Thanks again.

  6. #6
    150+ Forum Groupie


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

    Re: FSX default A320 FCU: Nano v3

    Are you double tasking pin2? Encoder #1 and pinMode(2, INPUT_PULLUP);.

    Nano pins A6 and A7 are analog input only. Suggest check out http://tronixstuff.com/2011/01/11/tu...tiple-buttons/ and use analog pins A0 to A3 for your led outputs and A7 for your pushbutton inputs. You still have pin A6 for another input. If you scan both pins A6 and A7 on every loop, add one or two analogRead(x)'; before the scan that you want to use for input data input. This is required to settle the internal circuits.

    Analog inputs are high res 0 to 1023. You can make them low res digital inputs by

    /*
    WARNING! NANO and PROMINI Microcontroller boards. YOU DO NOT WANT TO SHORT +5V POWER PIN TO GROUND AT ANY TIME.
    CAUSES BAD SMELL, SMOKE, AND REPLACEMENT OF A DIODE LOCATED BELOW THE USB CONNECTOR.
    I don't know if the input/output pins are protected for over current. Check the data sheet.

    Use external 10k ohm (or greater) pullup resistor for the analog input
    Connect the analog input through a normally open pushbutton or toggle switch to ground.
    Placing a 1k ohm resistor between the switch and ground in this circuit may prevent an accidental short. It is not
    electronically necessary.

    Arduino recognizes HIGH = 1 exclusively. Arduino recoginzes LOW = 0 exclusively. Think digitalValue in place of digitalRead.
    */

    long delayTimer;

    void setup() {
    Serial.begin(115200);
    }

    void loop() {
    TEST();
    }

    void TEST(){
    unsigned int sample = 0;
    byte digitalValue = 1;

    if (millis() > delayTimer){
    analogRead(0); // delete if using only one analog input -- add another if the pin is unresponsive when scanning more than one analog pin.
    sample = analogRead(0);
    if (sample < 154) digitalValue = 0; // digital LOW is anything less than 15% of VCC -- digital HIGH is the default
    if (digitalValue == LOW) Serial.println("LOW");
    if (digitalValue == HIGH) Serial.println("HIGH");
    delayTimer = (millis() + 300); // slows the output and will not freeze the Arduino compiler by flooding the serial terminal
    }// close if millis()
    }// end TEST()
    ---CYXD ----- TWR --- GND ------ Closed
    ILS-- NDB -- 119.1 -- 121.9 ---- 11/2013

  7. #7
    10+ Posting Member
    Join Date
    Sep 2014
    Location
    uk
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: FSX default A320 FCU: Nano v3

    Thanks for your observation and advice.To be honest I'm fairly new to arduino and programming as such. Learning with the help of this forum. Regarding the modified version of Fess_ters original code I have used it is aattached to this post for perusal. It appears to be doing the job based on my initial testing. However I am open to advice to improve it and my learning along the way. The 5 buttons from 1 analogue pin looks inviting. Will explore that route
    Attached Files Attached Files