Jump to content

DCS-Bios + Arduino + MAX7219 = Caution Light Panel


ClayM

Recommended Posts

Attempting to get CLP working with these components. Can someone tell me is this is possible?

 

Seems like a good use for the MAX7219. Wired using matrix and with only one resistor makes wiring easy. i had previously used 7407 buffer/drivers with pin for pin input/output and an arduino mega2560. So i could just use standard DCS-BIOS code for each individual pin/led but it did not work very well. After a few minutes(or seconds) the CLP would display random LEDs turning on and off. So before i knew there were issues with running 500000 bps I tore it all apart. Which i now regret without trying 115200.

 

Anyways, as others on this forum, i am not a programmer. I have been using the LedControl.h library to try and get this to work. NO LUCK. Does anybody think it is worth going back to the 7407's even though it requires ten times the connections and individual resistors? But eliminates trying to write the code to get it to work. Personally it would be quicker for me to make 100 solder connections then write 1 line of code!!

 

Please tell me if I'm wrong but how much easier can you get then using MAX7219. Oh, except the code!! (which i think is the hardest part).

 

Let me know if you think the 7407's could work or is there something I don't understand about that.

 

Also, many thanks to Ian for the great software.It has encouraged me to keep going and not throw this big pile of mdf and gadgets in trash! (although the wife still thinks I'm nuts the kids really like to fly it). I think its educational for them in a way. Proves you can build whatever you want if you have the motivation.

 

Clay

Link to comment
Share on other sites

The code will be the easiest part, because I already wrote it for WarHog's CLP. We didn't get it to work but suspect it's a hardware issue.

 

The MAX7219 is definitely the way to go for the Caution Lights Panel. It's just so much less work. It saddens me when I see people go for the overcomplicated solution of one pin per LED just to avoid learning basic programming skills. Just because the DCS-BIOS Arduino library does not include a premade class for a specific situation does not mean it is impossible to do with DCS-BIOS.

 

How about we meet up on Skype or TeamSpeak and get this working? I'd love a chance to confirm that the sketch works.

 

I am not at my gaming rig right now, will post a link to the code later.

Link to comment
Share on other sites

Let me know when you plan to do this. I would very much like to be there and listen in on the trouble shooting session. It would be a good opportunity to listen and learn.

 

I just got a new batch of Pro Mini boards and 7219 chips so I can rebuild my circuit and then see if I can figure out what my issues are with this panel.


Edited by Warhog

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

Ian

 

Thanks for jumping in on this. Looking forward to future discussions!

 

WarHog

 

I used a matrix example from the Arduino website to test for function and everything seems to work as it should. Did you manage to get that far previously? Maybe you could show me your circuit diagram if you have one.

Although I have zero experience with the promini. Currently using 6 unos and 4 megas and a leonardo that is still using EOS Bus!

 

Thanks Again

 

Clay

Link to comment
Share on other sites

Ian

 

Thanks for jumping in on this. Looking forward to future discussions!

 

WarHog

 

I used a matrix example from the Arduino website to test for function and everything seems to work as it should. Did you manage to get that far previously? Maybe you could show me your circuit diagram if you have one.

Although I have zero experience with the promini. Currently using 6 unos and 4 megas and a leonardo that is still using EOS Bus!

 

Thanks Again

 

Clay

 

Hi Clay

 

My CLP is not be a good example to look at as I designed the circuit board for the LED matrix a bit differently then the code Ian wrote for this panel. I had actually built it before DCS-BIOS was a reality. As a result we (mostly Ian) had to make changes to the code to sync my matrix with the correct cell labels on the panel.

 

When we were testing mine we had issues with some of the cells lighting when they shouldn't have. But it went further then that. Ian wrote some quick tests for the 7219 and the bottom 3 sections of the panel (matrix) would not light at all. It appeared I had either a defective Pro Mini or MAX7219. Unfortunately I ran out of Arduino boards and couldn't look at this problem until now as I just received a new order. That's why I was interested in following your issues as now I can rebuild my circuit and retest me CLP.

 

Don't worry about what board we use, be it a Pro Mini or an UNO or whatever as they are all pretty much the same. I will try very hard to be there whenever you two decide to get together to figure out the problem. I have had good success with this 7219 IC with 7 seg displays but I have never used it in a matrix


Edited by Warhog

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

Here is the sketch. Note that it is a bit more complicated than it absolutely needs to be because it includes a layer of indirection so you can make it work with any conceivable LED matrix arrangement.

 

If you set the correct pin numbers in line 9 and you have your LED matrix wired up, every caution light in your virtual cockpit should correspond to one on your physical panel. You can then edit the "cl_row_map" and "cl_mask_map" arrays (lines 61 and 83) to get the locations right (the visual layout of the arrays in the code matches the physical layout of the CLP).

 

If it does not work out of the box, I can be available tomorrow or Friday night to troubleshoot things (from about 19:00 GMT).


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

Ian

 

Thanks ,

 

I'm glad to see I was on the right track with using the LedControl Library! Anyways I going to give it a shot and return with feedback.

 

Warhog,

 

Just to make it perfectly clear for others and not to confuse anyone you may want to change the reference to the ground traces GND on the LED Matrix PCB to be labeled to MAX7219 pin numbers (as these do not go to ground). Other than then that it is amazing work you have done!

Don't think I'll be posting pics of mine anytime soon. Mine panel is still at proof of concept stage.

 

Thanks

 

Clay

Link to comment
Share on other sites

Warhog,

 

Just to make it perfectly clear for others and not to confuse anyone you may want to change the reference to the ground traces GND on the LED Matrix PCB to be labeled to MAX7219 pin numbers (as these do not go to ground). Other than then that it is amazing work you have done!

Don't think I'll be posting pics of mine anytime soon. Mine panel is still at proof of concept stage.

 

Thanks

 

Clay

 

Thanks Clay, I see what you mean. I should have said "common cathode" so they know that its the LED's cathode that gets solder on to that part of the board and then indicate the "digit no" for each section of LEDs that gets connected to the 7219. Although I do have the digit no.'s illustrated on the last page. It always helps to have other people read your stuff and report back. Thanks.

 

 

Don't forget to post back how you make out with the CLP .

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

Okay guys

 

Since warhog seems to be very curious I tried the sketch out to see the results!

 

My setup

 

 

seg dp seg b seg d seg f

 

 

dig 0

 

dig 1

 

dig 2

 

dig 3

 

dig 4

 

dig 5

 

seg a seg c seg e seg g

 

dig 0

 

dig 1

 

dig 2

 

dig 3

 

dig 4

 

dig 5

 

(Stole this setup from Tigershark I think)

 

So

changed LedControl pins to match my setup.

 

changed row map for above setup.

 

changed mask map for above setup.

 

Seemed very simple and well laid out for easy changes to suit individual needs. Nice job Ian.

 

Set to 115200.

 

Ran DCS

 

The top four rows seem to work very well ( so 16 leds total. hmmm? 16).

They flash properly with the master caution and turn on and off with almost no delay.

 

However the rest seem to not function at all.

 

So I uploaded Ians original sketch just to see what would happen. Ran DCS and I did get some of the lower leds to turn on.

 

Ian

 

Any chance you may have time Saturday for a discussion?

 

Time zones pose a bit of problem. Warhogs not too far from me so hopefully he can make it.

 

Still farther then I have managed to get! I think its a good start.

 

Clay

Link to comment
Share on other sites

This is the same issue I was having. I thought it was my circuit deign but since you did yours independent of mine and experience the same problem, then maybe it not the hardware.

 

Saturday afternoon, any time after 12:00 is good for me. You two settle on a time and I'll be there.

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

Below are initialisation values I have used in successfully before in sequence. I generally set all registers to known values rather than just use defaults. Have you set the scan limit and decode mode.

 

NOOP, 0x00

// Decode mode - all off

DECMODE, 0x00

// Scan limit 0x00 - 0x07

SCANLIMIT, 0x07

// Intensity 0x00(LOW) - 0x0F(HIGH)

INTENSITY, 0x08

// Test display

TEST, 0x01

DelayMs(500);

TEST, 0x00

// Shutdown 0x00=OFF 0x01=ON

SHUTDOWN, 0x01

Link to comment
Share on other sites

bored at work so had a look at the sketch, could problem be at line 127:

 

unsigned char row = (address - 0x10d4) * 2;

 

maybe not multiply by 2.

 

We want to calculate the row on the physical caution lights panel in which the 16 data bits we received begin to apply. "address - 0x10d4" gives us the offset as a number of bytes. Each 8-bit byte covers two rows of 4 LEDs, hence multiply by 2.

 

But you made me look in the right place!

The error is on the next line, where I multiply by 16 (bits in a data word) when I should multiply by 4 (bits in a row) :music_whistling:

 

I have updated the sketch to correct that error (and also renamed the row variable to clp_row to make it clear it refers to rows on the physical CLP instead of the MAX7219).

Link to comment
Share on other sites

I could see start_index getting a wonky value and the '* 16' made me think you were indexing into unsigned shorts. I was getting freaked out by those while(1)'s in the setup routine, glad they are now gone.

Link to comment
Share on other sites

Thanks Ian

 

Give me a couple hours to get home from work and I will test.

 

These are the kind of things that get me really confused with the code. Its not that I haven't tried. So 0x10d4 is just the position of the 2 bits in the 16 bit string?? Correct??

 

Thanks Again

 

Clay

Link to comment
Share on other sites

Warhog,

 

Did you see the schematic that I posted earlier?

 

I haven't had a real good look at your circuit (but I will at some point)

 

and I may be missing something. I have a total of 14 wires between MAX7219 and arduino why do you need 3 14 pin plugs.

 

Clay

 

Sorry, 14 wires between max7219 and led panel!


Edited by ClayM
Correction
Link to comment
Share on other sites

Ian

 

2 things Id like to say. Sorry and Thank You!!

 

1: Sorry , new sketch you posted seems to do nothing. Here is what i did. Downloaded from github and changed the row map and mask map to much my own. Changed lc pin numbers to my own which i know are correct. also you have serial begin at 250000 ( i have been using 115200 with very good success ) so i changed .cmd file to match your sketch. Uploaded.

 

this resulted in no led outputs at all. ran dcs did some test and got nothing.

 

2: Uploaded your new sketch but only changed pin numbers in LedControl. Just in case i did some mistakes with any changes. so worst case scenario the wrong indicator lights up but we know we still function in some way.

 

same result. no output at all

 

3: Uploaded your previous version. CHANGED ONLY ONE ENTRY! . In class ( i think thats what its called ) updateCautionLights. changed row *16 to row* 4 like you mentioned above.

 

WORKS GREAT. Running at 115200 i get very quick response. no noticable delays at all. to test i did a ramp start all the way to takeoff with no issues. with all indicators off and pressing Signal Lights lamp test i can not press it fast enough to see any delays. Caution flashing works perfectly with all tested indicators. Currently tested using only CLP arduino with DCS and using mouse in game to activate switches. Tonight I will start up the rest of the pit and report back.

 

So it looks like Ian has solved this issue!

 

Turns out DCS-BIOS + Arduino + MAX7219 does equal CLP!

 

If anybody wants more detail on my setup or anything let me know. After 2 years of trying to get this to work I may be able to help others! (maybe)

 

Ian please let me know if you think i messed up your new version in someway. Or if you want me to try any changes you make I would gladly do so.

 

Thanks

 

Clay

Link to comment
Share on other sites

WORKS GREAT. Running at 115200 i get very quick response. no noticable delays at all. to test i did a ramp start all the way to takeoff with no issues. with all indicators off and pressing Signal Lights lamp test i can not press it fast enough to see any delays. Caution flashing works perfectly with all tested indicators.

 

That is great to hear! The CLP (and the signal lights test button) is the thing that can cause the greatest number of indicators to change rapidly in a way where latency issues are easily noticed by humans. It was what made me switch to a binary export protocol. It's a relief to know that this works well in the real world (i.e. not only is the data exported correctly and 30 samples per second are enough, but you also don't have noticeable jitter coming from buffering in the USB drivers for example).

 

Can you post the complete working sketch you have (link to pastebin or something)? I'll run a diff against my latest version to see where I missed something.

Also, does it work at 250000 bps?

Link to comment
Share on other sites

The only significant difference I see between your latest version and mine (besides LedControl pin numbers, row/column maps and whitespace) is that my version updates the MAX7219 once after an update from DCS-BIOS has been received (on write access to address 0xfffe), while your version updates the MAX7219 up to three times per update (once for each data word that is received).

 

Are you maybe using a very old version of DCS-BIOS (older than v0.2.2, which was released on January 13)? Versions before v0.2.2 did not have the update counter at 0xfffe, so the sketch would wait forever for the "this update has ended, you now have lots of time to update stuff" signal.


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

After 2 years of trying to get CLP to work and i finally have it working perfectly thanks to you and you want me to change everything?

 

at one point i had 7 7407's wired up. Thats 98 connections alone.plus dealing with pin to pin code. and 48 resistors.

 

ok

 

i trust you

 

i'll do it

 

Clay

Link to comment
Share on other sites

Warhog,

 

Did you see the schematic that I posted earlier?

 

I haven't had a real good look at your circuit (but I will at some point)

 

and I may be missing something. I have a total of 14 wires between MAX7219 and arduino why do you need 3 14 pin plugs.

 

Clay

 

Sorry, 14 wires between max7219 and led panel!

 

I'm glad you finally are up and running. I haven't had a chance to test anything yet but I will this weekend.

 

Your circuit differs from mine as follows. You use 8 LEDs to create a row and connect each row of 8 to one digit using a total of 6 digits. I use 6 LEDs to create a row and connect each row to a total of 8 digits on the 7219. The. Current usage is less that way and the scan rate faster as there are only 6 LEDs in a row to worry about instead of 8. There should be no preceptable difference between the two circuits in terms of function. You also asked about the connector/plugs...Each connector represents 2 digits and 2 rows of 6 LEDs = 14 pins.

 

That's why I initially mentioned why my circuit would not work with Ian's sketch without modification.

 

Now that we have been talking about circuits I just realized that I calculated my current limiting resistor based on using all 8 segments of the 7219. Except I'm only using 6 . I wonder if that might be part of the problem I'm having. Maybe not as that would just make them all dim.

 

I'll try the new sketch this weekend and report back.

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

  • Recently Browsing   0 members

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