Hi all, I use the sketch below to read outputs from DCS World (Flight Sim) for 48 discrete LED's and then it will switch the corresponding LED on or off accordingly. It's important to note that the hardware is not set up as an array, each LED is hardwired with a pin to the Arduino Mega, and all LED's share a common ground.
Over USB it works brilliantly, however the intent is to use it with RS485 as experience has shown that using many USB devices slows down the devices so that there is a long lag between actuation and the LED lighting.
When I change the code over to RS485 and install the MAX487 chip, it seems that something is interfering with the way that the data is being processed, so what happens is that it will only light say half of the correct LED's at any time, and it flickers between the correct ones in banks of LED's
Here is a link to the video I did of the warning light panel working via RS485, after 10 seconds or so you can see the erratic actuation of the LED's
Caution light panel over RS485
Here is the sketch, as you can see it is pretty uncomplicated
//#define DCSBIOS_DEFAULT_SERIAL
#define DCSBIOS_RS485_SLAVE 33
#define TXENABLE_PIN 2
#include <Wire.h>
//#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
//ENG START CYCLEA-10C/CL_A1
DcsBios::LED clA1(0x10d4, 0x0001, 23);
//L-HYD PRESSA-10C/CL_A2
DcsBios::LED clA2(0x10d4, 0x0002, 25);
//R-HYD PRESSA-10C/CL_A3
DcsBios::LED clA3(0x10d4, 0x0004, 27);
//GUN UNSAFEA-10C/CL_A4
DcsBios::LED clA4(0x10d4, 0x0008, 29);
//ANTI-SKIDA-10C/CL_B1
DcsBios::LED clB1(0x10d4, 0x0010, 26);
//L-HYD RESA-10C/CL_B2
DcsBios::LED clB2(0x10d4, 0x0020, 24);
//R-HYD RESA-10C/CL_B3
DcsBios::LED clB3(0x10d4, 0x0040, 22);
//OXY LOWA-10C/CL_B4
DcsBios::LED clB4(0x10d4, 0x0080, 31);
//ELEV DISENGA-10C/CL_C1
DcsBios::LED clC1(0x10d4, 0x0100, 11);
//VOID1A-10C/CL_C2
DcsBios::LED clC2(0x10d4, 0x0200, 10);
//SEAT NOT ARMEDA-10C/CL_C3
DcsBios::LED clC3(0x10d4, 0x0400, 28);
//BLEED AIR LEAKA-10C/CL_C4
DcsBios::LED clC4(0x10d4, 0x0800, 33);
//AIL DISENGA-10C/CL_D1
DcsBios::LED clD1(0x10d4, 0x1000, 12);
//L-AIL TABA-10C/CL_D2
DcsBios::LED clD2(0x10d4, 0x2000, 9);
//R-AIL TABA-10C/CL_D3
DcsBios::LED clD3(0x10d4, 0x4000, 3);
//SERVICE AIR HOTA-10C/CL_D4
DcsBios::LED clD4(0x10d4, 0x8000, 35);
//PITCH SASA-10C/CL_E1
DcsBios::LED clE1(0x10d6, 0x0001, 13);
//L-ENG HOTA-10C/CL_E2
DcsBios::LED clE2(0x10d6, 0x0002, 5);
//R-ENG HOTA-10C/CL_E3
DcsBios::LED clE3(0x10d6, 0x0004, 30);
//WINDSHIELD HOTA-10C/CL_E4
DcsBios::LED clE4(0x10d6, 0x0008, 37);
//YAW SASA-10C/CL_F1
DcsBios::LED clF1(0x10d6, 0x0010, 4);
//L-ENG OIL PRESSA-10C/CL_F2
DcsBios::LED clF2(0x10d6, 0x0020, 6);
//R-ENG OIL PRESSA-10C/CL_F3
DcsBios::LED clF3(0x10d6, 0x0040, 32);
//CICUA-10C/CL_F4
DcsBios::LED clF4(0x10d6, 0x0080, 39);
//GCASA-10C/CL_G1
DcsBios::LED clG1(0x10d6, 0x0100, 38);
//L-MAIN PUMPA-10C/CL_G2
DcsBios::LED clG2(0x10d6, 0x0200, 36);
//R-MAIN PUMPA-10C/CL_G3
DcsBios::LED clG3(0x10d6, 0x0400, 34);
//VOID2A-10C/CL_G4
DcsBios::LED clG4(0x10d6, 0x0800, 41);
//LASTEA-10C/CL_H1
DcsBios::LED clH1(0x10d6, 0x1000, 40);
//L-WING PUMPA-10C/CL_H2
DcsBios::LED clH2(0x10d6, 0x2000, 44);
//R-WING PUMPA-10C/CL_H3
DcsBios::LED clH3(0x10d6, 0x4000, 42);
//HARSA-10C/CL_H4
DcsBios::LED clH4(0x10d6, 0x8000, 43);
//IFF MODE-4A-10C/CL_I1
DcsBios::LED clI1(0x10d8, 0x0001, 58);
//L-MAIN FUEL LOWA-10C/CL_I2
DcsBios::LED clI2(0x10d8, 0x0002, 58);
//R-MAIN FUEL LOWA-10C/CL_I3
DcsBios::LED clI3(0x10d8, 0x0004, 48);
//L-R TKS UNEQUALA-10C/CL_I4
DcsBios::LED clI4(0x10d8, 0x0008, 45);
//EACA-10C/CL_J1
DcsBios::LED clJ1(0x10d8, 0x0010, 59);
//L-FUEL PRESSA-10C/CL_J2
DcsBios::LED clJ2(0x10d8, 0x0020, 57);
//R-FUEL PRESSA-10C/CL_J3
DcsBios::LED clJ3(0x10d8, 0x0040, 50);
//NAVA-10C/CL_J4
DcsBios::LED clJ4(0x10d8, 0x0080, 47);
//STALL SYSA-10C/CL_K1
DcsBios::LED clK1(0x10d8, 0x0100, 7);
//L-CONVA-10C/CL_K2
DcsBios::LED clK2(0x10d8, 0x0200, 8);
//R-CONVA-10C/CL_K3
DcsBios::LED clK3(0x10d8, 0x0400, 46);
//CADCA-10C/CL_K4
DcsBios::LED clK4(0x10d8, 0x0800, 49);
//APU GENA-10C/CL_L1
DcsBios::LED clL1(0x10d8, 0x1000, 61);
//L-GENA-10C/CL_L2
DcsBios::LED clL2(0x10d8, 0x2000, 60);
//R-GENA-10C/CL_L3
DcsBios::LED clL3(0x10d8, 0x4000, 52);
//INST INVA-10C/CL_L4
DcsBios::LED clL4(0x10d8, 0x8000, 51);
void setup() {
DcsBios::setup();
}
void loop() {
DcsBios::loop();
}
I suspect that the way RS485 is handling the data is to blame, though I don't profess to be an expert. I can't change the hardware so the only thing I can think of is to somehow multiplex (which I think needs an array to function) or at least make the sketch read the and switch the LED's in a phased or scanned manner, maybe by breaking up the panel into smaller chunks that are read briefly. Maybe read only the first 8 for a couple of milseconds, illuminate them, then the next eight etc...? I hope that makes sense, I'm thinking about it as an engineer
So is there a way to do this?
cheers
Les