Jump to content

DCS-Bios + Arduino + MAX7219 = Caution Light Panel


ClayM

Recommended Posts

Thanks Ian. The baudrate change worked really well.

 

About the capacitors and the resistors I allready knew about that. I had bought a small Arduino LED kit with the LED driver. So this time I tested it with the 8x8 matrix that came with it.

Worked fine except for the unorgized leds but thats because I didn't take time to change the arrayorder in the sketch. Going to test this with some real leds in a 4x12 matrix later when I have some more leds for it.

Also going test this with my Mega as a master(I2C) and the Uno as a slave with the 7219 connected to the Uno.

 

If I will be going for building a pit for myself in some distanced future I might going to have my Arduino mega as a master and smaller Arduinos as slaves. If the Mega isn't up for it I might go for something faster like a Intel Galileo or something like that.

For the near future its pretty much only going to be prototype testing on breadboards

__________________

Intel i7-7700K @ 5.1GHz, Gigabyte Z170XP SLI

32 GB Corsair Vengeance @ 2666 Mhz (Stock 2400 Mhz), Gigabyte GTX 1080 Windfoce OC , PSU 650W Seasonic

EK Watercooling (Open loop)

Windows 10 Pro x64

Thrustmaster HOTAS Warthog + MFG Crosswind + Thrustmaster MFD

Link to comment
Share on other sites

  • 2 weeks later...

Snowman, I just checked that link you posted and its to a GitHub page for a Caution Panel sketch that Ian revised for me some time ago. My LED matrix is very different from the typical layout so please use the sketch that Clay posted in "Pastebin" earlier in this thread. My sketch will not work for you no matter how much you try and revise it.

 

I should have pointed that out earlier but I just now noticed where that sketch originated from.

 

John

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

  • 6 years later...

Hello Gents!

 

Started my Hog Pit 2 years ago and have had I great support from here. Warhog- your Arduino data has been a lifesaver 🙂

Currently started working on my CLP. Basics for my plan are to use 2x 3V LED per Indicator controlled by Uno and 7219.

Can you please help me out with the following-

1. Since there is 4x indicators in a row and 12 in a Column. Can I wire each row in linear (8 LEDs), thus creating 12 rows?

2. Secondly, what would be the resistor needed per row then?

3. Are you guys willing to share pictures of your actual wiring scheme?

 

With very best regards,

Chuck

"Dropping Warheads on Foreheads"

ESTHOGPROJECT
Since 2019

 

Link to comment
Share on other sites

1. You have to use an 8 by 8 matrix. If you have a look into the code you can see, that the CLP is split into two halfs. In the case below it's 8 by 6 LEDs (top is 4 by 6 and below is another 4 by 6 matrix). So all 48LEDs can be used on one Max7219 chip. Original code is from here: https://gist.github.com/jboecker/1f37b5c0b44aec0d3f80

 

Below is my adaption for the CLP.

Spoiler
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <LedControl.h>

//pin 10 is connected to the DataIn 
//pin 11 is connected to the CLK 
//pin 12 is connected to LOAD
LedControl lc=LedControl(10,11,12,1);//DIN,CLK,LOAD,# OF IC's

// variables to dimm by the LCP "SIGNAL LTS" switch (BRT / DIM)
byte BRT = 11;  // normal brightnes
byte DIM = 3; // dimmed
byte BOOT = 11;  // LED brightnes after panel booting
unsigned long boottime = 125;

unsigned char cl_row_map[48] = {
  0, 0, 0, 0,
  1, 1, 1, 1,
  2, 2, 2, 2,
  3, 3, 3, 3,
  4, 4, 4, 4,
  5, 5, 5, 5,
  0, 0, 0, 0,
  1, 1, 1, 1,
  2, 2, 2, 2,
  3, 3, 3, 3,
  4, 4, 4, 4,
  5, 5, 5, 5,
  };
#define SEG_DP (1<<7)
#define SEG_A (1<<6)
#define SEG_B (1<<5)
#define SEG_C (1<<4)
#define SEG_D (1<<3)
#define SEG_E (1<<2)
#define SEG_F (1<<1)
#define SEG_G (1<<0)
unsigned char cl_mask_map[48]= {
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_DP, SEG_B, SEG_D, SEG_F,
  SEG_A, SEG_C, SEG_E, SEG_G,
  SEG_A, SEG_C, SEG_E, SEG_G,
  SEG_A, SEG_C, SEG_E, SEG_G,
  SEG_A, SEG_C, SEG_E, SEG_G,
  SEG_A, SEG_C, SEG_E, SEG_G,
  SEG_A, SEG_C, SEG_E, SEG_G
  };
  

unsigned char max7219_rows[8];

void setup() {
  DcsBios::setup();
  memset(max7219_rows, 0xff, sizeof(max7219_rows));
  lc.shutdown(0,false); //turn on the display
  lc.setIntensity(0,BOOT);//set the brightness
  bootsequence(); // let's light up some LEDs  :-)
  lc.shutdown(0,true); //turn off the display
}
  
void updateCautionLights(unsigned int address, unsigned int data) {
    lc.shutdown(0,false); //turn on the display
    unsigned char clp_row = (address - 0x10d4) * 2;
    unsigned char start_index = clp_row * 4;
    unsigned char column = 0;
    unsigned char i;

    bool is_on;
    for (i=0; i<16; i++) {
        is_on = data & 0x01;
        // set caution light state (clp_row, column, is_on)
        if (is_on) {
          max7219_rows[cl_row_map[start_index+i]] |= cl_mask_map[start_index+i];
        } else {
          max7219_rows[cl_row_map[start_index+i]] &= ~(cl_mask_map[start_index+i]);
        }
        data >>= 1;
        column++;
        if (column == 4) {
           clp_row++;
           column = 0;
        }
    }

}

void onClpData1Change(unsigned int newValue) {
    updateCautionLights(0x10d4, newValue);
}
DcsBios::IntegerBuffer clpData1(0x10d4, 0xffff, 0, onClpData1Change);

void onClpData2Change(unsigned int newValue) {
    updateCautionLights(0x10d6, newValue);
}
DcsBios::IntegerBuffer clpData2(0x10d6, 0xffff, 0, onClpData2Change);

void onClpData3Change(unsigned int newValue) {
    updateCautionLights(0x10d8, newValue);
}
DcsBios::IntegerBuffer clpData3(0x10d8, 0xffff, 0, onClpData3Change);

// dimm the whole CLP matrix by the LCP "SIGNAL LTS" switch
void onLcpSignalLightsChange(unsigned int newValue) {
    if (newValue == 1) lc.setIntensity(0,BRT);
    else lc.setIntensity(0,DIM);
}
DcsBios::IntegerBuffer lcpSignalLightsBuffer(0x1144, 0x0200, 9, onLcpSignalLightsChange);

void loop() {
  DcsBios::loop();

  // update MAX7219
  unsigned char i;
  for (i=0; i<8; i++) {
    lc.setRow(0, i, max7219_rows[i]);
  }
}

void bootsequence()
//---------Boot sequence of the display ----------
  {
  delay(boottime);
  lc.setRow(0,0,B10101010);
  delay(2 * boottime);
  lc.clearDisplay(0);
  lc.setRow(0,1,B10101010);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,2,B10101010);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,3,B10101010);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,4,B10101010);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,5,B10101010);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,0,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,1,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,2,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,3,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,4,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  lc.setRow(0,5,B01010101);
  delay(boottime);
  lc.clearDisplay(0);
  delay(boottime);
  lc.setColumn(0,0,B11111100);
  lc.setColumn(0,1,B11111100);
  delay(boottime);
  lc.setColumn(0,2,B11111100);
  lc.setColumn(0,3,B11111100);
  delay(boottime);
  lc.setColumn(0,4,B11111100);
  lc.setColumn(0,5,B11111100);
  delay(boottime);
  lc.setColumn(0,6,B11111100);
  lc.setColumn(0,7,B11111100);
  delay(8 * boottime);
  lc.clearDisplay(0);
  } // -------End of display Boot sequence

 

 

2. You only need one resistor for the 7219 chip to limit the current. Have a look into the data sheet or the LedControl documentation, it`s according to the forward voltage / current of your LEDs.

 

3. For a shematic look there:

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 weeks later...

Keep in mind that the MAX7219 needs 2 capacitors on the VCC/GND line.   Check the data sheet for the MAX7219 (attached) for the specifics.  (see page 10 under "Supply Bypassing and Wiring")  Without these capacitors the MAX7219 will occasionally act up and output random garbage.  Also take note that both GND pins (pin 4 and pin 9) on the 7219 must be connected to a ground.  Read the data sheet to avoid possible issues.

MAX7219.pdf

  • Like 2

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

  • 4 months later...

Hello Everybody,

I have an issue with my CLP for which I used the code from FsFlan on page 1. (Thanks for the code btw, this safes some work)

 it is also build with a Max7219 and a Arduino nano. both share ground but have their own power.

the problem I've been having is that after roughly 5 minutes the display turns itself off (meaning all annunciator lights go off for no reason)

what I have to do is reset the Arduino nano with the little button. this fixes the problem for a few minutes again.

 cycling the power of the Max7219 doesn't make a difference.

 

anybody an idea what could be going on?

 

thank you in advance.

Bob

Link to comment
Share on other sites

  • Recently Browsing   0 members

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