Jump to content

Recommended Posts

Posted

Hi

I am having an issue with loading the DCS Bios sketch for my recently constructed Caution light panel. The panel is wired in a matrix based on tigershark thread. The code is:

 

#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(2,4,3,1);//DIN,CLK,LOAD,# OF IC's

unsigned char cl_row_map[48] = {
 5, 5, 1, 1,
 5, 5, 1, 1,
 5, 5, 1, 1,
 3, 3, 7, 7,
 3, 3, 7, 7,
 3, 3, 7, 7,
 6, 6, 2, 2,
 6, 6, 2, 2,
 6, 6, 2, 2,
 0, 0, 4, 4,
 0, 0, 4, 4,
 0, 0, 4, 4,
 };
#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_B, SEG_G, SEG_G, SEG_B,
 SEG_C, SEG_E, SEG_E, SEG_C,
 SEG_DP, SEG_D, SEG_D, SEG_DP,
 SEG_B, SEG_G, SEG_G, SEG_B,
 SEG_C, SEG_E, SEG_E, SEG_C,
 SEG_DP, SEG_D, SEG_D, SEG_DP,
 SEG_B, SEG_G, SEG_G, SEG_B,
 SEG_C, SEG_E, SEG_E, SEG_C,
 SEG_DP, SEG_D, SEG_D, SEG_DP,
 SEG_B, SEG_G, SEG_G, SEG_B,
 SEG_C, SEG_E, SEG_E, SEG_C,
 SEG_DP, SEG_D, SEG_D, SEG_DP,
 };
 

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,8);//set the brightness
 lc.clearDisplay(0); //clear rthe display and get ready for new data
}
 
void updateCautionLights(unsigned int address, unsigned int data) {
   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);

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

 

I get an error message:

 

C:\Users\baker_000\Documents\Arduino\Caution_panel\Caution_panel.ino:3:24: fatal error: LedControl.h: No such file or directory

 

#include <LedControl.h>

 

^

 

compilation terminated.

 

exit status 1

Error compiling.

 

Can anyone advise on this error?

 

Thanks

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

Have you installed the LedControl library?

 

Go to arduino website. It has info there.

 

You then need to "install" the library in Arduino IDE.

 

Clay

Posted

Next step

 

Hi

 

I solved the above issue by loading the LED Control library; thank you. The sketch loaded ok onto my Uno and I connected to DCS world, ran the Cmd window and ran DCS world - Nothing fundamental happened in that no caution lights came on. I then reread 'http://forums.eagle.ru/showthread.ph...highlight=clay and realised that I had not set the mapping correctly; Now done.

 

However when studying the sketch my poor brain could not understand:

 

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

 

I am I correct in assuming that in the above example DIN is connected to Pin 2, CLK to Pin 4, Load to pin 3? I am not sure what # of IC's means and if that should then connect to Pin 1?

 

Sorry if this seems like a dense question.

 

Thanks

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

That comment is from an earlier version of the sketch, and someone (probably WarHog or myself) forgot to adapt or delete the comment when setting the correct pin numbers for their setup. The one-line command on the line that creates the LedControl instance is correct.

 

The lines should read:

//pin 2 is connected to the DataIn 
//pin 4 is connected to the CLK 
//pin 3 is connected to LOAD
LedControl lc=LedControl(2,4,3,1);//DIN,CLK,LOAD,# OF IC's

 

The last parameter specifies how many MAX7219 chips you have daisy-chained.

 

Here's the relevant part of the LedControl documentation:

http://playground.arduino.cc/Main/LedControl#Setup

Posted

Almost there

 

Hi Ian

 

thanks for the reply, that clarified everything. I managed to get the panel connected and working, albeit with the columns reversed. A quick alteration to the sketch and all the correct LEDs work - Hooray, pleased as punch!

 

One thing that I have noticed is that I get some of the non active (that is not lit on the caution panel in the Sim) flashing or coming on, but very very dim. Can anyone advise what might be causing this? I am not sure if its hardware or software related.

 

Success in increments is still success!

 

Thanks

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

Hi

Could it be light bleeding over from adjacent indicators? Or does this also happen with LEDs that are surrounded by other inactive LEDs?

its the Led itself that is lighting up, but probably about a quarter of the normal brightness!

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

That shouldn't happen. So to help diagnose this, can you post some close up pictures of your panel so I can see how you put it together. Can I assume you used the correct iset resistor as well as including the 2 capacitors that are needed for the Max7219? Have you tried another 7219 to see if it's the IC that's causing the problem?

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

Posted

Hi

please see the pictures attached. The 7219 chip is one of the modules you can buy from China, which comes in kit form; I soldered it myself so not pre-assembled.

 

The matrix follows tigershark schematic and I have soldered a common wire between Anode and Cathode wires on each LED. I have done this in two blocks with a linking wire.

 

With hindsite I would have used 2 led for each indicator and when I have completed all my panels I may revisit this one and use two leds.

 

Thanks for your help.

 

Neal

959350507_IMG_01251.thumb.JPG.bf27b3c6a98e5ecabed028b2b243b3d9.JPG

1535203964_IMG_01261.thumb.JPG.30826ce07a3f54e4c2b1fa2a6f53d2ca.JPG

1209085123_IMG_01271.thumb.JPG.a8a136e0e71e9278e8ac2527968ef7e8.JPG

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

Everything looks ok as far as I can trace the wires from your pictures. Try this code and tell me if it makes a difference. I adjusted it for your pins so all you need to do is a straight copy and paste. Other than that, I would check everywhere for possible shorts or connections that appear to be connected but in fact are not connected. But try the code first.

 

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

LedControl lc=LedControl(2,4,3,1);//DIN,CLK,LOAD,# OF IC's

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,8);//set the brightness
 lc.clearDisplay(0); //clear rthe display and get ready for new data
}
 
void updateCautionLights(unsigned int address, unsigned int data) {
   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);

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

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

Posted

Hi John

 

tried the new sketch, no change. One of my led's was not working so i have swapped that out, not sure if that could have been affecting anything. I have gone through and checked joints and remade a few dodgy looking ones. The dim leds were on te same row as the non functioning one.

 

I will check on dcs pc tomorrow.

 

thanks for the assistance.

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Posted

Success

 

Hi

 

I am please to say that after replacing the failed led, the issue of the leds lighting up dimly dissappeared. It appears that when one of the Leds within the matrix fails it creates some kind of electrical feedback to the other leds in that ROW. It did not appear to have the same effect in the column.

 

Thank you for your support, I now have a fully functioning CLP: YIPPEEEE!

 

Best wishes

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

  • 7 years later...
Posted

Hello, sorry to post on an open topic. I am looking to use the code above caution lights panel of the A10 adapted to the ECM panel of the F16. I am currently testing on a 2-row, 8-column matrix with the following code (Final 4x8 matrix). I am not at all comfortable with the programming language, I updated the mapping of digit 0 and 1 and segments according to pinout. The second code part corresponding to the update function, I do not understand it. Is it possible to adapt for the ecm light F16 ? Could someone help me? Thanks

Quote
/*
  Tell DCS-BIOS to use a serial connection and use the default Arduino Serial
  library. This will work on the vast majority of Arduino-compatible boards,
  but you can get corrupted data if you have too many or too slow outputs
  (e.g. when you have multiple character displays), because the receive
  buffer can fill up if the sketch spends too much time updating them.
 
  If you can, use the IRQ Serial connection instead.
*/
#define DCSBIOS_DEFAULT_SERIAL
 
#include "DcsBios.h"
#include "LedControl.h"
 
/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn
 pin 11 is connected to the CLK
 pin 10 is connected to LOAD
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);//DIN,CLK,CS
/* paste code snippets from the reference documentation here */
 
unsigned char c1_row_map[16] ={
 
  0, 1,
  0, 1,
  0, 1,
  0, 1,
  0, 1,
  0, 1,
  0, 1,
  0, 1,
};
 
#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 c1_mask_map[16] = {
 
SEG_DP, SEG_DP,
SEG_G, SEG_G,
SEG_F, SEG_F,
SEG_E, SEG_E,
SEG_C, SEG_C,
SEG_D, SEG_D,
SEG_B, SEG_B,
SEG_A, SEG_A,
 
};
 
unsigned char max7219_rows[2];


 
void setup() {
  DcsBios::setup();
 
  memset(max7219_rows, 0xff, sizeof(max7219_rows));
     The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}
 
void updateEcmLights (unsigned int address, unsigned int data){
unsigned char clp_row = (address-0x10d4) *2;
unsigned char stard_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
       if (column == 4) {
          clp_row++;
          column = 0;
       }
   }
 
}
void onClpData1Change(unsigned int newValue) {
   updateEcmLights(0x448, newValue);
}
DcsBios::IntegerBuffer clpData1(0x4480, 0xffff, 0, onClpData1Change);
 
void onClpData2Change(unsigned int newValue) {
   updateEcmLights(0x448a, newValue);
}
DcsBios::IntegerBuffer clpData2(0x448a, 0xffff, 0, onClpData2Change);
 
void loop() {
 DcsBios::loop();
 
 // update MAX7219
 unsigned char i;
 for (i=0; i<8; i++) {
   lc.setRow(0, i, max7219_rows[i]);
 }

 

 

Posted

Hi Zorg,

I'll have a look in the evening if help is possible.

Regards, Vinc 

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted (edited)

Hi Vinc, thank you in advance for your help. I have code that works with an 8x8 matrix but this requires me to double the number of LEDs. If a solution is possible from the A10 deposit code, it is unexpected and good for optimization. Thanks again to everyone who makes the interface accessible - I will work on a post as soon as possible to present the progress of the panels.

Edited by Zorg.
Posted (edited)

Hi Zorg,

First I have to say, that I have the F-16 module just to check some scripting but have no clue how the ECM panel works or the inner data structure. I cannot find a LED matrix for the ECM panel within the DcsBios reference tool that is comparable to the A-10 coding.

If you want to do your own 2 col and 8 row matrix, in my opinion you should change the coding somehow to the following pattern

unsigned char c1_row_map[16] ={
 
 0, 0, 0, 0,
 1, 1, 1, 1,
 0, 0, 0, 0,
 1, 1, 1, 1,
};
 
#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 c1_mask_map[16] = {
 
 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,
};
 
unsigned char max7219_rows[8];

 

Furthermore, I think that you cannot change the A-10 command "updateCautionLights" into "updateEcmLights" without knowing the correct commands and addresses for the F-16 module. For example, the hex code 0x10d4 is for the A-10 CLP.

void updateEcmLights (unsigned int address, unsigned int data){
unsigned char clp_row = (address-0x10d4) *2;
unsigned char stard_index = clp_row * 4;
unsigned char column = 0;
unsigned char i;

 

Same for the A-10 commands "ClpData1" and "ClpData2" where no F-16 equivalent is within your code.

void onClpData1Change(unsigned int newValue) {
   updateEcmLights(0x448, newValue);
}
DcsBios::IntegerBuffer clpData1(0x4480, 0xffff, 0, onClpData1Change);
 
void onClpData2Change(unsigned int newValue) {
   updateEcmLights(0x448a, newValue);
}
DcsBios::IntegerBuffer clpData2(0x448a, 0xffff, 0, onClpData2Change);

 

So in the end, the problem cannot be solved without further knowledge on the F-16 EMC panels inner data structure.

Sorry for that!

 

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

After several tests, it was simpler than I thought, I just used the led.control.h library + the Digit 0 and Digit 1 interface on the seven segments - converting newValue to Bool. It works. Phew

Thanks again for taking a look anyway.

  • Like 1
Posted

Yes, that's the easy way to talk to a smaller matrix 👍

Congratulations!

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

  • Recently Browsing   0 members

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