Welcome to Cockpitbuilders.com. Please login or sign up.

April 27, 2024, 03:42:17 PM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
454 Guests, 0 Users
Members
  • Total Members: 4,154
  • Latest: xyligo
Stats
  • Total Posts: 59,641
  • Total Topics: 7,853
  • Online today: 514
  • Online ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 454
Total: 454

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

flap indicator interface with Fs9

Started by Mach7, August 03, 2023, 04:23:14 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

ame

Morning in New Zealand. Sorry, I have a very busy day. I will get onto it as soon as I can. Probably something very simple. Sorry.

ame

Working on it. Confirmed it doesn't behave as expected when I simulate the code. Probably a thinko (it's like a typo, but it happens when you're thinking).

_alioth_


I can not test now, but it could be related to definitions inside the Case:

  case 'G': //Found the second identifier ("G" Flaps position)
      // Next three characters should be numeric
      flaps = "";
      flaps += getChar();
      flaps += getChar();
      flaps += getChar();
      // convert 3-character numeric string to a float
      // Expected range is 000 to 033
      float flaps_degrees = flaps.toFloat();
      // Convert degrees to PWM 0-255.
      // 33 degrees is full scale, so multiplier is 255/33=7.727
      int PWM_out = flaps_degrees*7.727;
...


I remember I have had problems with this in the past.
Try global definitions. Just in case.

_alioth_

I have tested in tinkercad simulator (no arduino here now) and it says some error related to definitions inside the case.

I have tested this code and seems to work as it should (but tinkercad is not the same as arduino so... ). I have added some Serial.prints inside the case just to test:

Quote/*
    This code is in the public domain
    For use with "Link2fs_Multi"
    Jimspage.co.nz (via archive.org)

*/

int CodeIn;// used on all serial reads

String flaps;
String fuel;    // Re-use this variable for all fuel gauges as we only do one at a time

// PWM pins for gauges. Must be one of 3, 5, 6, 9, 10, or 11 for Arduino Uno
// Flaps
int flaps_PWM_out_pin = 3;
// Fuel
int fuel_L_PWM_out_pin = 5; // Left fuel gauge
int fuel_C_PWM_out_pin = 6; // Centre fuel gauge
int fuel_R_PWM_out_pin = 9; // Right fuel gauge

// Variables for fuel gauges
// Can be reused for each gauge as we do one at a time.
int fuel_PWM_out;
float fuel_percent;
float fuel_lbs;

float flaps_degrees = 0;
int PWM_out = 0;

// Variables to support incremental update of gauges
unsigned long currentMillis; // store the current time

unsigned long previousMillis;
unsigned long period = 100; // 100millis = 0.1s, 10 updates per second

// Variables for flaps gauge
const int flaps_max_PWM_per_slot = 1; // Maximum amount we can move in 0.1s

int flaps_PWM_target; // Target PWM value, based on last flaps degrees
int flaps_PWM_current; // Current PWM value, can only move slowly

bool first_flaps_PWM_value; // Flag to see if we should go directly to target



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

  // Set up PWM pins.
  pinMode(flaps_PWM_out_pin, OUTPUT);
  pinMode(fuel_L_PWM_out_pin, OUTPUT);
  pinMode(fuel_C_PWM_out_pin, OUTPUT);
  pinMode(fuel_R_PWM_out_pin, OUTPUT);

  // Set PWM values to zero.
  analogWrite(flaps_PWM_out_pin, 0);
  analogWrite(fuel_L_PWM_out_pin, 0);
  analogWrite(fuel_C_PWM_out_pin, 0);
  analogWrite(fuel_R_PWM_out_pin, 0);

  flaps_PWM_target = 0;
  flaps_PWM_current = 0;
  first_flaps_PWM_value = true;
}


void loop() {
  // Deal with incoming data from link2fs
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {
      EQUALS(); // The first identifier is "="
    }
    if (CodeIn == '<') {
      LESSTHAN(); // The first identifier is "<"
    }
    if (CodeIn == '?') {
      QUESTION(); // The first identifier is "?"
    }
    if (CodeIn == '/') {
      SLASH(); // The first identifier is "/" (Annunciators)
    }
  }

  // Other tasks
  // Currently we have to smooth the flaps output.
  // Fuel gauges don't need smoothing.
  currentMillis = millis(); // store the current time
  if (currentMillis - previousMillis >= period) { // check if 100ms passed
    // We're on a 100ms boundary
    previousMillis = currentMillis;  // update the time we were here
    if (flaps_PWM_target > flaps_PWM_current) {
      flaps_PWM_current += flaps_max_PWM_per_slot;
      if (flaps_PWM_current > flaps_PWM_target) flaps_PWM_current = flaps_PWM_target;
    }
    else if (flaps_PWM_target < flaps_PWM_current) {
      flaps_PWM_current -= flaps_max_PWM_per_slot;
      if (flaps_PWM_current < flaps_PWM_target) flaps_PWM_current = flaps_PWM_target;
    }
    else {
      // target and current are equal. Nothing to do.
    }
    analogWrite(flaps_PWM_out_pin, flaps_PWM_current);
  }

}


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


void EQUALS() {    // The first identifier was "="
  CodeIn = getChar(); // Get another character
  switch (CodeIn) { // Now lets find what to do with it
    case 'A'://Found the second identifier
      //Do something
      break;

    case 'B':
      //Do something
      break;

    case 'C':
      //Do something
      break;
  }
}


void LESSTHAN() {  // The first identifier was "<"
  CodeIn = getChar(); // Get another character
  switch (CodeIn) { // Now lets find what to do with it
    case 'A'://Found the second identifier
      //Do something
      break;

    case 'B':
      //Do something
      break;

    case 'G': //Found the second identifier ("G" Flaps position)
      // Next three characters should be numeric
      flaps = "";
      flaps += getChar();
      flaps += getChar();
      flaps += getChar();
      // convert 3-character numeric string to a float
      // Expected range is 000 to 033
      flaps_degrees = flaps.toFloat();
      // Convert degrees to PWM 0-255.
      // 33 degrees is full scale, so multiplier is 255/33=7.727
      PWM_out = flaps_degrees * 7.727;
      // Clip output to maximum if (for some reason) it's >255
      if (PWM_out > 255) PWM_out = 255;
      // New flaps PWM is calculated. Copy to other variables to
      // be handled by main loop on next 100ms boundary
      flaps_PWM_target = PWM_out;
      // If this is the first value we have received, go directly there.
      if (first_flaps_PWM_value) {
        flaps_PWM_current = flaps_PWM_target;
        first_flaps_PWM_value = false;
      }
      Serial.print("G");
      Serial.println (PWM_out);
      break;

    case 'X': // "X" left fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 9200 lbs (left)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 9200;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_PWM_out = ((fuel_lbs * 1.8) / 10000) + 75.0;
      // Clip output to maximum if (for some reason) it's >255
      if (fuel_PWM_out > 255) fuel_PWM_out = 255;
      // Drive the gauge
      analogWrite(fuel_L_PWM_out_pin, fuel_PWM_out);
      Serial.print("X");
      Serial.println (fuel_lbs);
      break;

    case 'Y': // "Y" centre fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 4400 lbs (centre)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 4400;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_PWM_out = ((fuel_lbs * 1.8) / 10000) + 75.0;
      // Clip output to maximum if (for some reason) it's >255
      if (fuel_PWM_out > 255) fuel_PWM_out = 255;
      // Drive the gauge
      analogWrite(fuel_C_PWM_out_pin, fuel_PWM_out);
      Serial.print("Y");
      Serial.println (fuel_PWM_out);
      break;

    case 'Z': // "Z" right fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 9200 lbs (left)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 9200;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_PWM_out = ((fuel_lbs * 1.8) / 10000) + 75.0;
      // Clip output to maximum if (for some reason) it's >255
      if (fuel_PWM_out > 255) fuel_PWM_out = 255;
      // Drive the gauge
      analogWrite(fuel_R_PWM_out_pin, fuel_PWM_out);
      Serial.print("Z");
      Serial.println (fuel_PWM_out);
      break;

  }

}

void QUESTION() {  // The first identifier was "?"
  CodeIn = getChar(); // Get another character
  switch (CodeIn) { // Now lets find what to do with it
    case 'A'://Found the second identifier
      //Do something
      break;

    case 'B':
      //Do something
      break;

    case 'C':
      //Do something
      break;
  }
}
void SLASH() {  // The first identifier was "/" (Annunciator)
  //Do something
}

ame

Well, how about that?

I concur. I put a bunch of print statements in, to see what was happening: nothing.

Then I moved the variable definitions out: success!

This is why we test code before we post it to the internet.  :-[

Thanks Arturo.

ame

And here's why:
https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement

I've been doing this a while and I've never written anything that happened to cause that problem. I'll try not to do it again (I prefer making new mistakes).

_alioth_


new mistakes are always funnier, Ame!  :)


I would like to code some cleaner and efficient way to read the link2fs data.

But I would need to know if:
- ticking the box "include CR/LF" there is always a return at the end of each command.
- ticking the box "include comma's between" sends always a "," at the end of each command.

First one, then the other. Not both at the same time, if posible.

Can you help me with this Mach7?  you can see it in link2fs "to card" window or put some screenshots.

Thanks

Mach7

Hello guys, the program works perfectly!!

Thank you!!!!!!!!!!..

@Arturo...I thought I knew what you were talking about with respect to the fuel quantity indication and battery bus power...now seeing it it makes perfect sense to me what you were trying to tell me. Still not an issue for me in this application, but now I understand what you were saying..thanks.

I will put up some screen shots up today.

Also...and not a really big deal...but is there anyway to have the fuel needle(s) move a bit slower to there requested positions?

I notice that it may be beneficial, (to the instrument life itself) to have the needle move slowly to the requested fuel levels...that is to say in transient states the needle will move very fast, epecially when it returns to zero from a high fuel state..the needle "bounces" off its stops.

This may not be too big of an issue...just thinking that anything that moves a bit slower may increase the life of the instrument itself.

ame

Quote from: _alioth_ on August 24, 2023, 02:18:50 AMnew mistakes are always funnier, Ame!  :)


I would like to code some cleaner and efficient way to read the link2fs data.

But I would need to know if:
- ticking the box "include CR/LF" there is always a return at the end of each command.
- ticking the box "include comma's between" sends always a "," at the end of each command.

First one, then the other. Not both at the same time, if posible.

Can you help me with this Mach7?  you can see it in link2fs "to card" window or put some screenshots.

Thanks

I see where you're coming from, but nobody uses link2fs anymore, and the website is dead. Link2fs is based on FSConnect, from here:
https://www.dirks-software.ca/

One day FSConnect.dll will die too. However, I thought about using Python to access FSConnect.dll directly, then put a Python wrapper around it. Then it would be no longer necessary to use link2fs.

Furthermore, all the processing could be done in Python, thus leaving the Arduino to output a PWM value to a pin only.

ame

Quote from: Mach7 on August 24, 2023, 02:39:41 AMHello guys, the program works perfectly!!

Thank you!!!!!!!!!!..

@Arturo...I thought I knew what you were talking about with respect to the fuel quantity indication and battery bus power...now seeing it it makes perfect sense to me what you were trying to tell me. Still not an issue for me in this application, but now I understand what you were saying..thanks.

I will put up some screen shots up today.

Also...and not a really big deal...but is there anyway to have the fuel needle(s) move a bit slower to there requested positions?

I notice that it may be beneficial, (to the instrument life itself) to have the needle move slowly to the requested fuel levels...that is to say in transient states the needle will move very fast, epecially when it returns to zero from a high fuel state..the needle "bounces" off its stops.

This may not be too big of an issue...just thinking that anything that moves a bit slower may increase the life of the instrument itself.

Excellent. Glad it's working. Sorry about the rookie mistake.

Regarding damping the needles, a very common technique is to filter the target position with a simple running average:
new_position = (current_ position+target_position)/2
I'll code something up later (now it's bedtime in New Zealand), but that's what I'd do.

Mach7

Thanks again ame

And many thanks to both of you guys!!

Once I have it all connected up I will post a video!

Jim

Jason L

Any thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.

ame

Quote from: Jason L on August 24, 2023, 01:15:52 PMAny thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.
Does it support FS9?

Since it's all working now there's probably not much sense in reimplementing it.

Mach7

Hello guys, as promised a short video and a pic of the Arduino board setup...i still have to clean some wires up and situate the board...but for testing it is good for now.

Thanks again ame and Arturo for all the help.

It's nice to get away from those clunky OpenCockpit controlled dc servo motors..

As far as Mobiflight is concered...I looked into that, but as far as I can see there is no support for FS9.

https://www.youtube.com/watch?v=khojFlD_xV4

Jim

ame


ame

Next step is the flaps input, right?

Only half-kidding. You said it was a linear pot hooked up to the flaps lever. Arduino has an analogue to digital converter (ADC) so can detect the position of the pot. Link2fs allows you to send commands back in to the simulator.

Would need to prototype it entirely before removing the current system you have which works, but I think it should be possible.

ame

Ok. I've improved the filtering on the flaps, so it should be less jerky. I've also added some smoothing to the fuel gauge so they don't jump at startup, but general movement won't be affected because the fuel gauges move so slowly.

Take a copy of the working code that you are happy with in case this code doesn't work, then you can go back to it if you need to. I did test it this time, but that is no guarantee...

Quote/*
    This code is in the public domain
    For use with "Link2fs_Multi"
    Jimspage.co.nz (via archive.org)

*/

int CodeIn;// used on all serial reads

String flaps;
String fuel;    // Re-use this variable for all fuel gauges as we only do one at a time

// PWM pins for gauges. Must be one of 3, 5, 6, 9, 10, or 11 for Arduino Uno
// Flaps
int flaps_PWM_out_pin = 3;
// Fuel
int fuel_L_PWM_out_pin = 5; // Left fuel gauge
int fuel_C_PWM_out_pin = 6; // Centre fuel gauge
int fuel_R_PWM_out_pin = 9; // Right fuel gauge

// Variables for fuel gauges
int fuel_L_PWM_out;
int fuel_C_PWM_out;
int fuel_R_PWM_out;
int fuel_PWM_out;
// Record last needle position for damping
int last_fuel_L_PWM_out;
int last_fuel_C_PWM_out;
int last_fuel_R_PWM_out;
// Can be reused for each gauge as we do one at a time.
float fuel_percent;
float fuel_lbs;

// Variables for flaps
float flaps_degrees;
float filtered_flaps_degrees;
int flaps_PWM_out;

     
// Variables to support incremental update of gauges
unsigned long currentMillis; // store the current time

unsigned long previousMillis;
unsigned long period = 100; // 100millis = 0.1s, 10 updates per second

// Variables for flaps gauge
// The gauge on the simulator travels from 0 to 33 degrees in about 35 seconds
// We should introduce fractional degrees for the physical gauge so that it
// moves smoothly between integer degree positions.
const float flaps_max_degrees_per_period=0.0943; // Maximum amount we can move in 0.1s

int flaps_PWM_target; // Target PWM value, based on last flaps degrees
int flaps_PWM_current; // Current PWM value, can only move slowly

bool first_flaps_value; // Flag to see if we should go directly to target



void setup()
{
  Serial.begin(115200);
 
  // Set up PWM pins.
  pinMode(flaps_PWM_out_pin, OUTPUT);
  pinMode(fuel_L_PWM_out_pin, OUTPUT);
  pinMode(fuel_C_PWM_out_pin, OUTPUT);
  pinMode(fuel_R_PWM_out_pin, OUTPUT);

  // Set PWM values to zero.
  analogWrite(flaps_PWM_out_pin, 0);
  analogWrite(fuel_L_PWM_out_pin, 0);
  analogWrite(fuel_C_PWM_out_pin, 0);
  analogWrite(fuel_R_PWM_out_pin, 0);
 
  first_flaps_value=true;
 
  last_fuel_L_PWM_out=0;
  last_fuel_C_PWM_out=0;
  last_fuel_R_PWM_out=0;

}


void loop() {
  // Deal with incoming data from link2fs
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {EQUALS();} // The first identifier is "="
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
    if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
  }

  // Other tasks
  // Smooth the needle output.
  // For flaps, we calculate intermediate flaps positions and then move the needle.
  // For fuel, we calculate the PWM output, and apply a running average filter.
  currentMillis = millis(); // store the current time
  if (currentMillis - previousMillis >= period) { // check if 100ms passed
    // We're on a 100ms boundary
    previousMillis = currentMillis;   // update the time we were here

    // flaps_degrees is updated elsewhere when new data arrives.
    // Filter the gauge needle position slowly over time.

    if (flaps_degrees > filtered_flaps_degrees) {
      filtered_flaps_degrees += flaps_max_degrees_per_period;
      if (filtered_flaps_degrees > flaps_degrees) filtered_flaps_degrees=flaps_degrees;
    }
    else if (flaps_degrees < filtered_flaps_degrees) {
      filtered_flaps_degrees -= flaps_max_degrees_per_period;
      if (filtered_flaps_degrees < flaps_degrees) filtered_flaps_degrees=flaps_degrees;
    }
    else {
      // target and current are equal. Nothing to do.
    }
   
    // Convert degrees to PWM 0-255.
    // 33 degrees is full scale, so multiplier is 255/33=7.727
    // If this is the first value we have received, go directly there.
    if (first_flaps_value) {
      filtered_flaps_degrees=flaps_degrees;
      first_flaps_value=false;
    }
   
    flaps_PWM_out = filtered_flaps_degrees*7.727;
   
    analogWrite(flaps_PWM_out_pin, flaps_PWM_out);
   
    // Now update the fuel gauges. Just a simple digital filter.
    // Yes, this should be done as an array...

    fuel_PWM_out = ((3.0*last_fuel_L_PWM_out) + fuel_L_PWM_out)/4.0;
    last_fuel_L_PWM_out = fuel_PWM_out;
    analogWrite(fuel_L_PWM_out_pin, fuel_PWM_out);

    // Lighter filter on centre gauge
    fuel_PWM_out = ((2.0*last_fuel_C_PWM_out) + fuel_C_PWM_out)/3.0;
    last_fuel_C_PWM_out = fuel_PWM_out;
    analogWrite(fuel_C_PWM_out_pin, fuel_PWM_out);

    fuel_PWM_out = ((3.0*last_fuel_R_PWM_out) + fuel_R_PWM_out)/4.0;
    last_fuel_R_PWM_out = fuel_PWM_out;
    analogWrite(fuel_R_PWM_out_pin, fuel_PWM_out);

  }

}


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


void EQUALS(){      // The first identifier was "="
  CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
  }
}


void LESSTHAN(){    // The first identifier was "<"
  CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'G': //Found the second identifier ("G" Flaps position)
      // Next three characters should be numeric
      flaps = "";
      flaps += getChar();
      flaps += getChar();
      flaps += getChar();
      // convert 3-character numeric string to a float
      // Expected range is 000 to 033
      flaps_degrees = flaps.toFloat();
      // Moving the needle will be done in the main loop.
    break;
   
    case 'X': // "X" left fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 9200 lbs (left)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 9200;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_L_PWM_out = ((fuel_lbs * 1.8)/10000.0)+75.0;
      // Clip output to maximum if (for some reason) it's >255
      if(fuel_L_PWM_out > 255) fuel_L_PWM_out=255;
      // Moving the needle will be done in the main loop.
    break;

    case 'Y': // "Y" centre fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 4400 lbs (centre)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 4400;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_C_PWM_out = ((fuel_lbs * 1.8)/10000.0)+75.0;
      // Clip output to maximum if (for some reason) it's >255
      if(fuel_C_PWM_out > 255) fuel_C_PWM_out=255;
      // Moving the needle will be done in the main loop.
    break;

    case 'Z': // "Z" right fuel gauge
      // Next three characters should be numeric
      fuel = "";
      fuel += getChar();
      fuel += getChar();
      fuel += getChar();
      // convert 3-character numeric string to a float
      // It's a percentage of full, where full is 9200 lbs (left)
      // Expected range is 000 to 100
      fuel_percent = fuel.toFloat();
      fuel_lbs = fuel_percent * 9200;
      // Convert lbs to PWM 0-255.
      // 0 lbs on gauge is PWM 75
      // 10,000 lbs on gauge is 255
      // So PWM is (1.8 x (lbs/100)) + 75
      fuel_R_PWM_out = ((fuel_lbs * 1.8)/10000.0)+75.0;
      // Clip output to maximum if (for some reason) it's >255
      if(fuel_R_PWM_out > 255) fuel_R_PWM_out=255;
      // Moving the needle will be done in the main loop.
    break;
   
  }
 
}

void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}

ame

Incidentally, I am testing with this:
https://wokwi.com/

You can simulate the Arduino, which means you can compile code and edit it in the browser, and you can simulate serial input and output for testing.

Saves having something hooked up on the bench.

Mach7

Thanks for the updated code ame!

I will upload it when I get back from work..i will be on the road for 4 days starting tomorrow, so will be able to update you on Monday.

Again...I really appreciate your time, knowledge and commitment.

Thank you!!

Jim


ame

Quote from: Jason L on August 24, 2023, 01:15:52 PMAny thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.
On a related note, how can we encourage more people to build things? This is "cockpitbuilders.com" after all. Or is everyone on the mobiflight site these days?

I have enjoyed this little foray into link2fs, and in some ways I'm disappointed that it's gone. MSFS now has "Simconnect", which can be utilised in a number of ways, but that's no good for FS9.

_alioth_

Quote from: ame on August 24, 2023, 08:09:54 PM
Quote from: Jason L on August 24, 2023, 01:15:52 PMAny thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.
On a related note, how can we encourage more people to build things? This is "cockpitbuilders.com" after all. Or is everyone on the mobiflight site these days?

I have enjoyed this little foray into link2fs, and in some ways I'm disappointed that it's gone. MSFS now has "Simconnect", which can be utilised in a number of ways, but that's no good for FS9.

Yes... and I the freedom you have using custom arduino code is unlimited. The only limit is your imagination.

You can not interface real complex things with mobiflight.

I really like the arduino/teensy code size. My problem was always the comunication with p3d.

Xplane is great with teensy, because teensy has native support to share variables with xplane:
https://www.pjrc.com/teensy/td_flightsim.html
I would rellay like to have something similar in p3d/msfs.

I know simconnect, but I never find the strength, and I don't even know if I would have the skills to program c++ plugins to  do the communication with arduino.

So, I am using lua scripts with FSUIPC.
The Lua script in fsuipc talks with simconnect. So you read variables and send values to arduino and the reverse.
The advantage over link2fs is you can control poll rate, read Lvars, and take control over variables.
For example, level gauge has only 100 steps in link2fs, but with the script I can read the lbs and send from 0 to 1000, or the lbs, or whatever I want.

But I would like to have something more "comercial grade", a plugin, dll, exe... not editable por third parties.

Arturo.

Jason L

Will try not to read too much into your comment but the assumption that if you use MobiFlight you aren't building a cockpit seems a bit of a stretch.  It is by no means plug and play.  One could ask the same of Prosim then too, one should be just building everything from scratch?  I've got a combination of OEM and vendor-built parts in my 737, fully interfaced OEM ACP's using MobiFlight with FSUIPC and Prosim.  Written scripts in SIOC for some of my OpenCockpits stuff.  You can make your own firmware for MobiFlight to support more advanced features of the arduino.  It's all open source and there is a large community to help support your endeavors.  To me, that is cockpit building.
I like this site and the historical information that it provides, but it isn't a significantly active source for new information anymore.  Many have turned to places like, yes, as you mentioned MobiFlight's discord server, Prosim's forums, whatsapp groups etc.

Off my soap box now.

Quote from: ame on August 24, 2023, 08:09:54 PM
Quote from: Jason L on August 24, 2023, 01:15:52 PMAny thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.
On a related note, how can we encourage more people to build things? This is "cockpitbuilders.com" after all. Or is everyone on the mobiflight site these days?

I have enjoyed this little foray into link2fs, and in some ways I'm disappointed that it's gone. MSFS now has "Simconnect", which can be utilised in a number of ways, but that's no good for FS9.

Jason L

You can get the registered copy of FSUIPC for FS9 for free now, with that, yes mobiflight will work.  You can use it strictly with FSUIPC offsets then.

Quote from: ame on August 24, 2023, 01:26:08 PM
Quote from: Jason L on August 24, 2023, 01:15:52 PMAny thoughts of using mobiflight as your interface instead of link2fs?  Actively supported with multiple flavors of arduinos and works really well.
Does it support FS9?

Since it's all working now there's probably not much sense in reimplementing it.

ame

Quote from: Jason L on August 25, 2023, 05:49:10 AMWill try not to read too much into your comment but the assumption that if you use MobiFlight you aren't building a cockpit seems a bit of a stretch.
Ah, sorry, that was not my intention at all. I meant "where are all the cockpit builders?". We've been helping Mach7 here, but there are no other similar threads (building something) on this site. So, where else are people doing it and writing about it?

Mach7

Hello guys...back from work and will try the new code out and get back to you!!!!

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate