Jump to content

Displaying Fuel Flow Gauge on an LCD


Kelevra9987

Recommended Posts

Hey Folks, since I am currently working on my own Cockpit where I want to Display the Fuel Flow Gauges of the A-10 on a 16x1 LCD Display and finaly got the Solution for this, I want to share this with you.

 

So, what do you need for this?

 

  • Arduino/Funduino Board
  • 16x1 / 16x2 Character LCD
  • Breadboard
  • Wires
  • Arduino IDE
  • Patience (a lot of it)

 

I have all of that!

 

Now you wire everything up like the Datasheet of your particular LCD describes.

Download the DCS-BIOS found here!

And read the User-Manual ofc.

 

Now the funny Part: Programming!

 

Since I want that to be open Source you can just Copy and paste it in your Sketch but don't forget to change the Pins to you Pin-Assignment found here:

 

LiquidCrystal lcd(2, 3, 4 , 5 , 6, 7);

 

#include <DcsBios.h>
#include <Servo.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4 , 5 , 6, 7);
DcsBios::ProtocolParser parser;

void setup() {
 Serial.begin(500000);
 lcd.begin(8,2);
 lcd.setCursor(0,0);
 lcd.print("Left Flo");
 lcd.setCursor(0,1);
 lcd.print("w: ");
}

void loop() {
 // feed incoming data to the parser
 while (Serial.available()) {
     parser.processChar(Serial.read());
 }
 
 // poll inputs
 DcsBios::PollingInput::pollInputs();
}

void sendDcsBiosMessage(const char* msg, const char* arg) {
 Serial.write(msg);
 Serial.write(' ');
 Serial.write(arg);
 Serial.write('\n');
}

void onDcsBiosWrite(unsigned int address, unsigned int value)
{
 if (address == 0x10ae)
 {
   unsigned int lEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueL = map(lEngFuelFlowValue, 0, 5000, 0, 5000);
   lcd.setCursor(3,1);
   lcd.print(valueL/1.3);
   lcd.setCursor(7,1);
   lcd.write("    ");
   if (valueL <= 9999)
   {
     lcd.setCursor(6,1);
     lcd.write("     ");
   }
   else
   {
     lcd.setCursor(7,1);
     lcd.write("    ");
   }
 }
}

 

 

As you may have noticed, this is only for one LCD and only one Engine. This is because my second Display hasnt Arrived yet and I couldn't programm it in. But thats only some small additions to the Sketch. As soon my second Display arrives and I have all set up I will Post the Updated Version of this Sketch ;)

 

A Very special Thanks to [FSF]Ian for his awesome Support and Patience with me. Without you I could not make this.

 

A little look at the Result is in the Attachments

 

Now Have fun building your very own Fuel Flow LCD.

See you in the Air :pilotfly::joystick:

20150727_215633.thumb.jpg.a0497cca7cd8880cd379b3774f7a6919.jpg


Edited by Kelevra9987

Modules: Well... all of 'em

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Motherboard: ASUS Maximus VIII Hero | CPU: i7-6700K @ 4.6GHz | RAM: 32GB Corsair Vengance LPX DDR4 | GPU: GTX TITAN X (Maxwell) | SSD1: 256GB NVMe SSD System | SSD2: 250GB Games | HDD 4TB WD Red

Link to comment
Share on other sites

So, one could put both of the meters on one display if needed?

Anything with a Rotary Wing is fun and challenging.

Use SRS radio.

Saitek X55 Modding

System Specs

 

Mixed Metals: i7 4790K@4.6, 32GB Kingston HyperX ram@2400Mhz, Gigabyte GA-Z97MX Gaming 5, ASUS Vega 64, 3xSamsung SSD drives, FSP Aurum 1000W PSU, Custom watercooling with EK blocks, Vive, Virpil MT 50, X55 throttle.

 

Link to comment
Share on other sites

It's possible, yes. My Plan is to use two Displays instead.

Modules: Well... all of 'em

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Motherboard: ASUS Maximus VIII Hero | CPU: i7-6700K @ 4.6GHz | RAM: 32GB Corsair Vengance LPX DDR4 | GPU: GTX TITAN X (Maxwell) | SSD1: 256GB NVMe SSD System | SSD2: 250GB Games | HDD 4TB WD Red

Link to comment
Share on other sites

Good job!

 

A few suggestions:

 

a) calling map(lEngFuelFlowValue, 0, 5000, 0, 5000) is a no-op: it won't change the value at all. The actual scaling happens in your print statement instead, where you divide by 1.3, so you end up with values from 0 to 50000.

 

You can do this instead for the same result:

void onDcsBiosWrite(unsigned int address, unsigned int value)
{
 if (address == 0x10ae)
 {
   unsigned int lEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueL = map(lEngFuelFlowValue, 0, 65535, 0, 50000);
   lcd.setCursor(3,1);
   lcd.print(valueL);
   lcd.setCursor(7,1);
   lcd.write("    ");
   if (valueL <= 9999)
   {
     lcd.setCursor(6,1);
     lcd.write("     ");
   }
   else
   {
     lcd.setCursor(7,1);
     lcd.write("    ");
   }
 }
}

 

b) The gauge in the A-10C pit actually reads "PPH x 100", so an indication of "50" on the scale would be 5000, not 50000 PPH. To get that, use map(lEngFuelFlowValue, 0, 65535, 0, 5000); instead.

 

c) There is a more convenient way to print the number right-aligned:

void onDcsBiosWrite(unsigned int address, unsigned int value)
{
 if (address == 0x10ae)
 {
   unsigned int lEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueL = map(lEngFuelFlowValue, 0, 65535, 0, 50000);

   char buffer[6]; // the size of the buffer must be one more than the largest number of digits we expect ("50000" has 5 digits)
   snprintf(buffer, sizeof(buffer), "%5d", valueL); // "%5d" means to pad with spaces until we have 5 characters. If you want leading zeroes instead, you can use "%05d".
   lcd.setCursor(7,1);
   lcd.print(buffer);
 
 }
}

 

 

EDIT:

So, one could put both of the meters on one display if needed?

 

Here's a version for both values on one display, using values from 0 to 5000 (also note that I didn't even try to compile any code in this post):

void onDcsBiosWrite(unsigned int address, unsigned int value)
{
 if (address == 0x10ae)
 {
   unsigned int lEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueL = map(lEngFuelFlowValue, 0, 65535, 0, 5000);

   char buffer[5];
   snprintf(buffer, sizeof(buffer), "%4d", valueL);
   lcd.setCursor(0,1);
   lcd.print(buffer);
 }

 if (address == 0x10b0)
 {
   unsigned int rEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueR = map(rEngFuelFlowValue, 0, 65535, 0, 5000);

   char buffer[5];
   snprintf(buffer, sizeof(buffer), "%4d", valueR);
   lcd.setCursor(6,1);
   lcd.print(buffer);
 }

}


Edited by [FSF]Ian
Link to comment
Share on other sites

I had an Error in the Scaling. Because 50x100 is 5000 not 50000 so it's a 4 Digit Buffer. Now it works like a charm. Thank you, Ian :)

 

The good thing is, that I can now apply this knowledge for more Indicators and Displays and so on.


Edited by Kelevra9987

Modules: Well... all of 'em

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Motherboard: ASUS Maximus VIII Hero | CPU: i7-6700K @ 4.6GHz | RAM: 32GB Corsair Vengance LPX DDR4 | GPU: GTX TITAN X (Maxwell) | SSD1: 256GB NVMe SSD System | SSD2: 250GB Games | HDD 4TB WD Red

Link to comment
Share on other sites

this is displaying numbers of the fuel flow. Will it be possible to get a small display to display the fuel panel like a small monitor, ie. display the panel as graphics instead of numbers?

 

Yes. It is already possible. You are programming an Arduino, so you are free to do whatever you want with the values you get. You will need to write the code to draw a fuel panel to the display.

 

The more interesting question is: is an Arduino powerful enough to write a reasonable number of frames per second to your display or do you need something faster like one of those ARM-powered TI Launchpads or a Raspberry Pi?

Link to comment
Share on other sites

  • 3 weeks later...

Finally Working on my Breadboard:

 

 

#include <DcsBios.h>
#include <Servo.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7,8,5,4,3,2);
LiquidCrystal lcd2(7,6,5,4,3,2);

DcsBios::ProtocolParser parser;

void setup()
{
 lcd.begin(8,2);
 lcd.setCursor(0,0);
 lcd.print(" Left:");
 lcd2.begin(8,2);
 lcd2.setCursor(0,0);
 lcd2.print(" Right:");
 Serial.begin(500000);
}

void loop() {
 // feed incoming data to the parser
 while (Serial.available()) {
     parser.processChar(Serial.read());
 }
 
 // poll inputs
 DcsBios::PollingInput::pollInputs();
}

void sendDcsBiosMessage(const char* msg, const char* arg) {
 Serial.write(msg);
 Serial.write(' ');
 Serial.write(arg);
 Serial.write('
');
}

void onDcsBiosWrite(unsigned int address, unsigned int value)
{
 if (address == 0x10ae)
 {
   unsigned int lEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueL = map(lEngFuelFlowValue, 0, 65535, 0, 5000);

   char buffer[5]; // the size of the buffer must be one more than the largest number of digits we expect ("50000" has 5 digits)
   snprintf(buffer, sizeof(buffer), "%4d", valueL); // "%5d" means to pad with spaces until we have 5 characters. If you want leading zeroes instead, you can use "%05d".
   lcd.setCursor(1,1);
   lcd.print(buffer);
 }
 
 if (address == 0x10b0)
 {
   unsigned int rEngFuelFlowValue = (value & 0xffff) >> 0;
   unsigned int valueR = map(rEngFuelFlowValue, 0, 65535, 0, 5000);

   char buffer[5]; // the size of the buffer must be one more than the largest number of digits we expect ("50000" has 5 digits)
   snprintf(buffer, sizeof(buffer), "%4d", valueR); // "%5d" means to pad with spaces until we have 5 characters. If you want leading zeroes instead, you can use "%05d".
   lcd2.setCursor(1,1);
   lcd2.print(buffer);
 }
}

Modules: Well... all of 'em

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Motherboard: ASUS Maximus VIII Hero | CPU: i7-6700K @ 4.6GHz | RAM: 32GB Corsair Vengance LPX DDR4 | GPU: GTX TITAN X (Maxwell) | SSD1: 256GB NVMe SSD System | SSD2: 250GB Games | HDD 4TB WD Red

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...