Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 56
  1. #1
    25+ Posting Member
    Join Date
    Feb 2010
    Location
    KFLL
    Posts
    57
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Looking for assistance with writing FSUIPC offsets

    Am seeking clarity in writing sketches with Mega/Uno and Link2FS using FSUIPC codes in/out.


    Am still not understanding what goes where.


    I am using the Link2FS Multi FS9 v3a.


    I've got the entire list of FSUIPC offsets and am looking to gain a clearer understanding of what goes where in the coding and within FSUIPC.


    Thank you in advance for the assistance.


    Jay
    KFLL

  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: Looking for assistance with writing FSUIPC offsets

    Jay,

    What are your project goals?

    Radio Stack?

    MCP?

    Motion Platform?



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

  3. #3
    25+ Posting Member
    Join Date
    Feb 2010
    Location
    KFLL
    Posts
    57
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    The long term plan is to have a complete B727-200 flight deck with original equipment including MIP, radios, ADFs, VORs, autopilot, etc. I have many of these components from B727s already.

    The short term plan is to gain a better understanding of the Arduino/Link2FS interface for some operations and Open Cockpit/SIOC software for others.

    Learning both programming codes has been challenging.

    For the time-being, my project is with FS9 and the Dreamfleet 727. There will be an upgrade to FSX at some point down the road.

    Thus far, and with grateful thanks to similar enthusiasts here, I have the landing gear panel and handle fully operational as well as the leading edge flaps indicators, which I'm in the process of tweaking.

    I have 2 Arduino Mega 2560 boards and 1 Arduino Uno. I also have several stepper motors, servos and a bunch of jumper wires...all looking to be played with!

    My latest projects are to complete the flap position indicators (which will be a master and slave arrangement by piggy-backing on the wiring) as well as the engine gauges (EPR, N1, Fuel Flow, N2, EGT).

    I have a limited working knowledge of my registered version of FSUIPC and right now, am looking for assistance with codes. In the case of the engine gauges, I'm confident that I'll be able to adjust the coding to suit each gauge's individual operating characteristics.


    Jay
    KFLL

  4. #4
    25+ Posting Member
    Join Date
    May 2014
    Location
    Bulgaria and United Kingdom
    Posts
    56
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    Hi Jay,
    You said, what you need to extract is N1, N2 and EPR. Here are the exact settings you got to do within Link2Fs FSUIPC section.



    First column is a free text to remind you what are you extracting. Second column is the most important one – it is the number of FSUIPC Offset you taken from the list of offsets. What you extracting from the memory is in a binary format and is called row result. It is not something ready to be used right away. That is why in the next column called Type you set the format of the variable. Some of the flight sim data is very basic – it vary btw. 0 and 1
    Or up to 255. For that sort of data is enough to set type to Byte. Other data vary btw. –32000 to +32000, then you set Type to Int32, Short - for data 0-16000, etc. etc. When it goes as high as 64000 and only on the positive side , then set variable type to Long. Or just try out different setting until you get workable result.
    Unfortunately, that is not ready to be used just yet. Imagine the following – you extracting N1 in the example above. N1 will vary between 0-100 percent of the maximum. You set the variable type as Short, so the row binary result is going to vary between 0 - for 0 percent N1 up to 16384 for 100 percent N1. In order to transfer
    0-16384 in percent RPM, you apply formula *100/16384
    And finally - you tick the Card 1 column to make Link2Fs send the data to Arduino Card 1. If the letter next to the column says #a , the code Link2Fs is going to send to Arduino is : #a000 up to #a100 . If the letter is #d, the code going to be #d000 up to #d100
    What you need to do next within the Arduino sketch is to capture that codes , take away ‘#a’ part and assign the numbers to a variable .

  5. Likes xflight38 liked this post
  6. #5
    25+ Posting Member
    Join Date
    May 2014
    Location
    Bulgaria and United Kingdom
    Posts
    56
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    Hi again,
    As I said above – step two is to extract the data coming from Link2Fs within Arduino card. Every time you writing sketch , you don’t have to start from scratch – that is going to be pretty confusing. You’ve got to prepare and use a standard ‘empty’ template instead. Here is an example of ‘empty’ template prepared to be used with Link2Fs for almost every task you trying to accomplish. The following sketch is not extracting and not inputting anything at all, it is just must have structure and you need to use/follow it in every sketch you writing:

    int CodeIn;// for extractions



    void setup(){

    Serial.begin(115200);

    }




    void loop() {


    {INPUTS();}

    if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '#') {EXPERT();}
    if (CodeIn == '=') {EQUALS();}
    if (CodeIn == '<') {LESSTHAN();}
    if (CodeIn == '?') {QUESTION();}
    if (CodeIn == '/') {SLASH();}
    }
    }


    char getChar()// Get a character from the serial buffer(Dont touch)
    {
    while(Serial.available() == 0); // wait for data (Dont touch)
    return((char)Serial.read());// (Dont touch) Thanks Doug
    }


    void EXPERT(){
    CodeIn = getChar();
    switch(CodeIn) {


    } }


    void EQUALS(){ }
    void LESSTHAN(){ }
    void QUESTION(){ }
    void SLASH(){ }


    void INPUTS() { }
    Then you modify the template according to extractions you need to do. This time I made the additions for you. Those modifications made the Arduino to read N1, N2 and EPR for engine one coming from Link2FS and assign those to variables called engOneN1 , engOneN2, engOneEPR accordingly:




    int CodeIn;// for extractions


    String engOneN1String, engOneN1StringOld; int engOneN1;
    String engOneN2String, engOneN2StringOld; int engOneN2;
    String engOneEPRString, engOneEPRStringOld; int engOneEPR;
    String dotKickOut;


    void setup(){

    Serial.begin(115200);

    }




    void loop() {


    {INPUTS();}

    if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '#') {EXPERT();}
    if (CodeIn == '=') {EQUALS();}
    if (CodeIn == '<') {LESSTHAN();}
    if (CodeIn == '?') {QUESTION();}
    if (CodeIn == '/') {SLASH();}
    }
    }


    char getChar()// Get a character from the serial buffer(Dont touch)
    {
    while(Serial.available() == 0); // wait for data (Dont touch)
    return((char)Serial.read());// (Dont touch) Thanks Doug
    }


    void EXPERT(){
    CodeIn = getChar();
    switch(CodeIn) {

    case 'a':
    delay (5);
    engOneN1String = "";
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());

    if (engOneN1String != engOneN1StringOld){
    engOneN1 = engOneN1String.toInt();

    engOneN1StringOld = engOneN1String; }
    break;


    case 'b':
    delay (5);
    engOneN2String = "";
    engOneN2String += char(Serial.read());
    engOneN2String += char(Serial.read());
    engOneN2String += char(Serial.read());

    if (engOneN2String != engOneN2StringOld){
    engOneN2 = engOneN2String.toInt();

    engOneN2StringOld = engOneN2String; }
    break;


    case 'c':
    delay (5);
    engOneEPRString = "";
    engOneEPRString += char(Serial.read());
    dotKickOut= ""; dotKickOut += char(Serial.read());
    engOneEPRString += char(Serial.read());
    engOneEPRString += char(Serial.read());

    if (engOneEPRString != engOneEPRStringOld){
    engOneEPR = engOneEPRString.toInt();

    engOneEPRStringOld = engOneEPRString; }
    break;

    } }




    void EQUALS(){ }
    void LESSTHAN(){ }
    void QUESTION(){ }
    void SLASH(){ }


    void INPUTS() { }
    The next step is to use those variables to display them on LCD or drive motors , etc, etc.

  7. Likes Fess_ter liked this post
  8. #6
    25+ Posting Member
    Join Date
    May 2014
    Location
    Bulgaria and United Kingdom
    Posts
    56
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    Step 3 – now we have ‘the numbers’ for left engine N1, N2 and EPR extracted and assigned to variables inside Arduino. Next thing we need to do is to use those numbers and drive some analogue gauge needles.
    There are two different approaches to drive needles – first one is using Hobby Servo’s and second is to use Steppers. The choice depends heavily on the range of the needle we need to drive. If that range is within 180 degree, then Servo is the easiest way to accomplish the task and if the range is well beyond 180 degrees or we are not good at precision mechanics, then Steppers are our next choice. I strongly suggest to a beginner with Link2FS to try Servo approach first –it is the easiest way to make flight sim move something via Link2FS and Arduino.
    There are some servo libraries ready available for download and use. VarSpeedServo Library is a pretty good one :
    https://github.com/netlabtoolkit/VarSpeedServo

    When you download and extract it, you need to have a folder called VarSpeedServo with 3 files in it : VarSpeedServo.h , VarSpeedServo.cpp and VarSpeedServo.h
    Copy and paste the entire folder within Arduino/libraries folder.
    Now modify the Arduino sketch from the example above to make the library work for you ( using the data from your variables and drive servos ). I made the modification for you and now your Arduino sketch is ready to use the data for left engine N1 extracted in the variable called engOneN1 and drive a servo called engOneN1Servo :


    #include VarSpeedServo.h // put triangle brackets on both sides of //'VarSpeedServo.h'
    // here i tell the Air Line Operator (Arduino), there is a 'pilot'
    //called VarSpeedServo, ready to fly an airplane on my behalf


    VarSpeedServo engOneN1Servo;
    // and now i tell the pilot , the name of the 'plane' (Servo) he is going to fly.
    // It is called 'engOneN1Servo and i assign it to him



    int CodeIn;// for extractions


    String engOneN1String, engOneN1StringOld; int engOneN1;
    String engOneN2String, engOneN2StringOld; int engOneN2;
    String engOneEPRString, engOneEPRStringOld; int engOneEPR;
    String dotKickOut;

    void setup(){

    Serial.begin(115200);

    engOneN1Servo.attach(2);
    // Here i tell the pilot , i left the airplane on apron 2 ( attached the servo on Arduino pin 2)

    }



    void loop() {

    {INPUTS();}


    if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '#') {EXPERT();}
    if (CodeIn == '=') {EQUALS();}
    if (CodeIn == '<') {LESSTHAN();}
    if (CodeIn == '?') {QUESTION();}
    if (CodeIn == '/') {SLASH();}
    }
    }

    char getChar()// Get a character from the serial buffer(Dont touch)
    {
    while(Serial.available() == 0); // wait for data (Dont touch)
    return((char)Serial.read());// (Dont touch) Thanks Doug
    }


    void EXPERT(){
    CodeIn = getChar();
    switch(CodeIn) {

    case 'a':
    delay (5);
    engOneN1String = "";
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());

    if (engOneN1String != engOneN1StringOld){
    engOneN1 = engOneN1String.toInt();

    engOneN1 = map(engOneN1, 0, 100, 0, 180);
    engOneN1Servo.slowmove(engOneN1,10);

    //here i give to the airplane
    // with the name engOneN1Servo departure clearance , tell them to use
    // departure procedure called engOneN1 and not to exceed 10 knots below certain //altitude
    // In other words - tell servo it is cleared to move , tell if it wants to know where to move, to use
    // for data variable with name engOneN1 and not to excced speed of 10. Bye bye

    engOneN1StringOld = engOneN1String; }
    break;

    case 'b':
    delay (5);
    engOneN2String = "";
    engOneN2String += char(Serial.read());
    engOneN2String += char(Serial.read());
    engOneN2String += char(Serial.read());

    if (engOneN2String != engOneN2StringOld){
    engOneN2 = engOneN2String.toInt();

    engOneN2StringOld = engOneN2String; }
    break;

    case 'c':
    delay (5);
    engOneEPRString = "";
    engOneEPRString += char(Serial.read());
    dotKickOut= ""; dotKickOut += char(Serial.read());
    engOneEPRString += char(Serial.read());
    engOneEPRString += char(Serial.read());

    if (engOneEPRString != engOneEPRStringOld){
    engOneEPR = engOneEPRString.toInt();

    engOneEPRStringOld = engOneEPRString; }
    break;
    } }


    void EQUALS(){ }
    void LESSTHAN(){ }
    void QUESTION(){ }
    void SLASH(){ }




    void INPUTS() { }

  9. #7
    25+ Posting Member
    Join Date
    Feb 2010
    Location
    KFLL
    Posts
    57
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    Trakon--



    WOW!

    This is EXACTLY the explanation I was seeking. Clear, concise, easy to read and it makes perfect sense!


    You're a genius and I can't thank you enough for taking the time to thoroughly explain the process. I, as well as many of our fellow enthusiasts, will make projects work thanks to you and your generosity.


    I'm sure I will have questions along the way but this is an incredible start.



    Again, thank you. I truly appreicate you.




    Jay
    KFLL

  10. #8
    25+ Posting Member
    Join Date
    Feb 2010
    Location
    KFLL
    Posts
    57
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    I've copied and pasted your coding; making a few adjustments along the way.
    I'm using stepper motors instead of servos (as I need more than 180 degrees movement.


    1 int CodeIn; // Used for all serial reads
    2 int engOneN1StepperPosition; // Tracks current step count for stepper motor
    3 int engOneN1StepperPin1 = 8; // Blue - 28BYJ48 pin 1
    4 int engOneN1StepperPin2 = 9; // Pink - 28BYJ48 pin 2
    5 int engOneN1StepperPin3 = 10; // Yellow - 28BYJ48 pin 3
    6 int engOneN1StepperPin4 = 11; // Orange - 28BYJ48 pin 4
    7 int engOneN1StepperLookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};
    8 int engOneN1StepperDelay = 1500;
    9
    10 void setup() {
    11 pinMode(engOneN1StepperPin1, OUTPUT);
    12 pinMode(engOneN1StepperPin2, OUTPUT);
    13 pinMode(engOneN1StepperPin3, OUTPUT);
    14 pinMode(engOneN1StepperPin4, OUTPUT);
    15 Serial.begin(115200);
    16 engOneN1StepperPosition = 512; //Sets motor position to worst-case scenario location
    17 Serial.println("Gauge reset and configured.");
    18
    19 String engOneN1String, engOneN1StringOld; int engOneN1;
    20 String engOneN2String, engOneN2StringOld; int engOneN2;
    21 String engOneEPRString, engOneEPRStringOld; int engOneEPR;
    22 String dotKickOut;
    23
    24 void loop() {
    25 {
    26 INPUTS();
    27 while (Serial.available()) {
    28 CodeIn = getChar();
    29 if (CodeIn == '#') {
    30 EXPERT();
    31 }
    32 if (CodeIn == '=') {
    33 EQUALS();
    34 }
    35 if (CodeIn == '<') {
    36 LESSTHAN();
    37 }
    38 if (CodeIn == '?') {
    39 QUESTION();
    40 }
    41 if (CodeIn == '/') {
    42 SLASH();
    43 }
    44 }
    45 }
    46 char getChar()// Get a character from the serial buffer (Don't touch)
    47 {
    48 while (Serial.available() == 0); // Wait for data (Don't touch)
    49 return ((char)Serial.read()); // (Don't touch) Thanks Doug
    50 }
    51 void EXPERT() {
    52 CodeIn = getChar();
    53 switch(CodeIn) {
    54
    55 case 'a':
    56 delay (5);
    57 engOneN1String = "";
    58 engOneN1String += char(Serial.read());
    59 engOneN1String += char(Serial.read());
    60 engOneN1String += char(Serial.read());
    61 engOneN1String += char(Serial.read());
    62
    63 if (engOneN1String != engOneN1StringOld) {
    64 engOneN1 = engOneN1String.toInt();
    65 engOneN1StringOld = engOneN1String;
    66 engOneN1 = map(engOneN1, 0, 100, 0, 180);
    67 engOneN1Stepper.slowmove(engOneN1,10);
    68 // I give to the airplane with the name "engOneN1Stepper" his departure clearance, tell him to use the
    69 // departure procedure called "engOneN1" and not to exceed 10 knots below a certain altitude.
    70 // In other words, tell the stepper that it is cleared to move; tell if it wants to know where to move, to use
    71 // for data variable with name "engOneN1" and not to excced speed of 10.
    72 }
    73 break;
    74
    75 case 'b':
    76 delay (5);
    77 engOneN2String = "";
    78 engOneN2String += char(Serial.read());
    79 engOneN2String += char(Serial.read());
    80 engOneN2String += char(Serial.read());
    81 engOneN2String += char(Serial.read());
    82
    83 if (engOneN2String != engOneN2StringOld) {
    84 engOneN2 = engOneN2String.toInt();
    85 engOneN2StringOld = engOneN2String;
    86 }
    87 break;
    88
    89 case 'c':
    90 delay (5);
    91 engOneEPRString = "";
    92 engOneEPRString += char(Serial.read());
    93 dotKickOut = ""; dotKickOut += char(Serial.read());
    94 engOneEPRString += char(Serial.read());
    95 engOneEPRString += char(Serial.read());
    96 engOneEPRString += char(Serial.read());
    97 engOneEPRString += char(Serial.read());
    98
    99 if (engOneEPRString != engOneEPRStringOld) {
    100 engOneEPR = engOneEPRString.toInt();
    101 engOneEPRStringOld = engOneEPRString; }
    102 break;
    103 } }
    104
    105 void EQUALS() { }
    106 void LESSTHAN() { }
    107 void QUESTION() { }
    108 void SLASH() { }
    109 void INPUTS() { }



    The errors I'm getting in compiling:

    sketch_apr12a.ino: In function 'void setup()':

    sketch_apr12a.ino:24:15: error: a function-definition is not allowed here before '{' token

    sketch_apr12a.ino:109:21: error: expected '}' at end of input

    Error compiling.

    I've added and subtracted the { and } as a test....no success.


    What have I overlooked?

    Thank you for the advice.


    Jay
    KFLL

  11. #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: Looking for assistance with writing FSUIPC offsets

    In the above code...

    void setup() has no closed bracket } line 23

    void loop() has 2 open brackets { line 24 and 25

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

  12. #10
    25+ Posting Member
    Join Date
    Feb 2010
    Location
    KFLL
    Posts
    57
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Looking for assistance with writing FSUIPC offsets

    Thanks, Fess!
    That fixed it but now, I'm getting different errors:

    int CodeIn; // Used for all serial reads
    int engOneN1StepperPosition; // Tracks current step count for stepper motor
    int engOneN1StepperPin1 = 8; // Blue - 28BYJ48 pin 1
    int engOneN1StepperPin2 = 9; // Pink - 28BYJ48 pin 2
    int engOneN1StepperPin3 = 10; // Yellow - 28BYJ48 pin 3
    int engOneN1StepperPin4 = 11; // Orange - 28BYJ48 pin 4
    int engOneN1StepperLookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};
    int engOneN1StepperDelay = 1500;

    void setup() {
    pinMode(engOneN1StepperPin1, OUTPUT);
    pinMode(engOneN1StepperPin2, OUTPUT);
    pinMode(engOneN1StepperPin3, OUTPUT);
    pinMode(engOneN1StepperPin4, OUTPUT);
    Serial.begin(115200);
    engOneN1StepperPosition = 512; //Sets motor position to worst-case scenario location
    Serial.println("Gauge reset and configured.");
    String engOneN1String, engOneN1StringOld; int engOneN1;
    }
    void loop()
    {
    INPUTS();
    if(Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '#') {EXPERT();}
    if (CodeIn == '=') {EQUALS();}
    if (CodeIn == '<') {LESSTHAN();}
    if (CodeIn == '?') {QUESTION();}
    if (CodeIn == '/') {SLASH();}
    }
    }
    char getChar()// Get a character from the serial buffer (Don't touch)
    {
    while(Serial.available() == 0); // Wait for data (Don't touch)
    return((char)Serial.read()); // (Don't touch) Thanks Doug
    }
    void EXPERT(){
    CodeIn = getChar();
    switch(CodeIn){
    case 'b':
    delay (5);
    43 engOneN1String = "";
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());
    engOneN1String += char(Serial.read());


    49 if (engOneN1String != engOneN1StringOld){
    50 engOneN1 = engOneN1String.toInt();

    52 engOneN1StringOld = engOneN1String;
    }
    break;
    }
    }

    void EQUALS() { }
    void LESSTHAN() { }
    void QUESTION() { }
    void SLASH() { }
    void INPUTS() { }




    Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"
    sketch_apr12b.ino: In function 'void EXPERT()':
    sketch_apr12b.ino:43:7: error: 'engOneN1String' was not declared in this scope
    sketch_apr12b.ino:49:29: error: 'engOneN1StringOld' was not declared in this scope
    sketch_apr12b.ino:50:9: error: 'engOneN1' was not declared in this scope
    sketch_apr12b.ino:52:9: error: 'engOneN1StringOld' was not declared in this scope
    Error compiling.

    Any ideas or clues?


    On a similar subject....
    Even if I can get this script to work, I'm thinking that it won't drive the stepper motor.
    I'm thinking I should (probably) have a 'return, return map' function going as well.

    Thoughts?


    Jay
    KFLL
    Last edited by EAL727Capt; 04-12-2015 at 04:01 PM.

Page 1 of 6 12345 ... LastLast