Results 1 to 10 of 10
  1. #1
    New Member
    Join Date
    Jun 2016
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Carenado B200 - Simconnect inputs

    Dear all,

    I am currently working on a College project that involves restoring a Beechcraft B200 in working condition. We have interfaced our Mechanical switches from "Klixon" to work with Link2fs and arduino which has gone well so far (we can already start the aircraft) .

    I am quite new to the Link2fs and Arduino programming, however most of the sim connect inputs that we need are available in Link2fs.

    But, because we are using Carenado Beechcraft B200, with our simulator that has a lot of functionality in it, not all inputs that are modelled in the aircraft, are shown in Link2fs. As an example, we have a lot of different anti ice functions, Auto ignition left and right, and several more.

    I am aware there is an "Expert" version (which I am not), and I have been looking across the forum and found a few threads explaining you can add more inputs, but this must be done with the "Expert" version, as well as the aircraft software manufacturer (Carenado, in my case) has to allow it.

    Does any one, with previous experience in working with Carenado and Link2FS know where I should start looking and how to add more sim connect inputs?

    Regards,

    Samuel

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

    Re: Carenado B200 - Simconnect inputs

    Samuel,

    Link2FS is good for the basics and getting started.
    When dealing with more complicated payware aircraft with proprietary variables, LUA is the way to go.
    FSUIPC (registered) has the ability to use LUA scripts to interface via COM Port with Arduino.
    To find the names of the Variables that you wish to control (LUA Variables, LVars or LVariables), you need a program called LINDA.
    LINDA has a bunch of functions for other things, but we are interested in the LINDA Tracer function that can list the names of the LUA Variables. Once you know the names of the LVars you can read their state and manipulate them.

    Example:
    Code:
    if (red_string == "E16") then       --Master Switch On
    		
    		if (ipc.readLvar("Battery1Switch") == 0) then     -- if its off then we turn it on
    			
    			ipc.writeLvar("L:Battery1Switch", 1)
    			
    		end
    end
    FSUIPC has a LUA guide but the internet is short on working examples.
    The learning curve can be a little daunting, but the ARDUINO code that you use with Link2FS can be used with LUA. You just have to program LUA to "catch" the same instructions that you send to Link2FS and send back the same format that Link2FS sends to the Arduino.

    ~Fess
    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

  3. #3
    New Member
    Join Date
    Jun 2016
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Carenado B200 - Simconnect inputs

    Hello Fess,

    This looks very interesting! I shall test this program out with some of our switches when I am at College and report back how it went. If I have any questions, I will ask them on this thread.

    Thanks for pointing me to this program!

    Regards,

    Samuel

  4. #4
    New Member
    Join Date
    Jun 2016
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Carenado B200 - Simconnect inputs

    Fess,

    I have downloaded linda and a demo version of the latest FSUIPC. I synced the Carenado B200 with linda and FSX. When in the LINDA console under the tracer function, I can see control lines when I change the positions of switches, such as the navigation lights. I have read through the final part of the LINDA manual that explains the Tracer function.

    It explains that, because the standard FSX controls does not detect the added switches on payware aircraft, we need to use the Lua variables list (what you explained in your first post).

    However, this list is greyed out nor is there anything in it. In the manual it explains that I should press "Start all", for the LVARS to appear. Is it greyed out because I do not have a registered version of FSUIPC? If so, then I shall order it. Also, I have connected my Arduino Mega to COM5 of my computer, however LINDA is not detecting a Joystick / HID device. Am I forgetting something or is this purely because I need a registered FSUIPC to make it all work?

    Regards,

    Samuel

  5. #5
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    204
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Carenado B200 - Simconnect inputs

    As Fess says...

    "FSUIPC (registered) has the ability to use LUA scripts to interface via COM Port with Arduino."

    Regards.
    Horacio.

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

    Re: Carenado B200 - Simconnect inputs

    LINDA will not recognize the Arduino. You only use LINDA to find variable names.
    You can then use those variable names in a LUA script that you will have to write.
    The LUA script will have to be written with com instructions to interface with the Arduino.
    Here is how the communication works.

    FSX <-> FSUIPC <-> LUA <-> Arduino

    And yes, FSUIPC Registered.
    Get your survival gear together, its a big mountain to climb.

    ~Fess
    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

  7. #7
    New Member
    Join Date
    Jun 2016
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Carenado B200 - Simconnect inputs

    Fess,

    Ok. I have purchased a copy of FSUIPC registered and I now see all the LVars of the B200 in the tracer list. I have tested several switches that first didn't show any changes in the console, but now they do.

    I guess the main part now is to code in LUA, which I have never done before. Only basic arduino coding. I have searched for several LUA flight sim codes however haven't seen much yet. I will show you what I have coded when using Link2FS.

    First, is this how to interface lua with com instructions to arduino?

    Code:
    handle = com.open(5,115200,0) // Com 5 is on arduino mega and 115200 baud used in my arduino sketch
    This is a basic sketch of my external lighting:

    Code:
    void setup() {
      Serial.begin(115200); //begin serial at 115200 Baud
        
      pinMode(12, INPUT_PULLUP);
    
    }
    
    void loop() {
        //Navigation Lights
    
      if(digitalRead(12) == LOW){ //if switch on pin 12 is in "on" position
        Serial.println("C411"); //turn on
        
      }else{Serial.println("C410"); } //turn off
    
    }//End loop
    I understand I will have to change C411 and C410 to the correct LVar for it to work via Lua.

    How would I have to code this to make it work via Lua? Connecting the switch will not be difficult. I have in this example one side of the switch on pin 12, the other on common (GND).

    Regards,

    Samuel

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

    Re: Carenado B200 - Simconnect inputs

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

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

    Re: Carenado B200 - Simconnect inputs

    Samuel,


    Here is an example of my LUA code for a switch panel that works with the A2A Comanche.


    It is rough but functional. I am still new to LUA.
    There seem to be no tutorials on LUA with FSUIPC from a simple learning standpoint.
    My script uses a continuous "while" loop. There is a more efficient way to do it with an "event.com" function call.
    I have not been successful with that yet.
    Another user here, Tom_G_2010, I think has made a LUA script using the "event.com" function call.
    I messaged him today, hopefully we will hear back soon.


    ~Fess
    Attached Files Attached Files
    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

  10. #10
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jul 2014
    Location
    Sydney, Australia
    Posts
    9
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Carenado B200 - Simconnect inputs

    Here is some example lua code using the com event to connect to the com port...


    Code:
    MyComPort = com.open("COM4", 115200, 0)
    
    if MyComPort == 0 then
        ipc.display("Could not open Com Port for ARDUINO")
        ipc.sleep(5000)
        ipc.exit()
    end
    
    ipc.display("Connected to COM4:")
    ipc.sleep(5000)
    ipc.display("",0)
    
    
    -- ## Callbacks
    
    function GetSerialData(MyComPort, InputString, length)
        InputString = string.sub(InputString, 0, string.len(InputString)-2)  --  Drop cr & lf
    
        print (InputString)
    
    
        if InputString == "C410" then
            -- Code here to turn Nav Light Off
    
            ipc.control(66379, 0)
        end
    
        if InputString == "C411" then
            -- Code here to turn Nav Light On
    
            ipc.control(66379, 0)
        end
    
    end
    
    
    -- ## Events
    
    --  Com Port
          --  (handle, max, min, term, "function name")
    event.com (MyComPort, 20, 0, 10, "GetSerialData")