levon Posted February 28, 2009 Report Share Posted February 28, 2009 I'm starting to design a new project, basicaly a 8x8 matrix. But I'm a little confused as to what way to go about it.I want to have a single coloured 8x8 led matrix and I will be programming in C.It will have a core, 1 4xDIN module (28 buttons, 2 encoders) 2-4 pots connected directly to j5 of the core. And 1 4xDOUT. For the core I will have 8 red/green leds connected to the first two multiplexers.For the third and fouth multiplexers I wanted to use as a 8x8 led matrix, using J5 of the DOUT board for the anodes of the matrix, and J6 for the cathodes. I found a diagram on using this for the midibox 64e with led rings.Now I'm not sure if I should try to used the blm driver, the 64e software, SID or code it myself, as the availlable drivers have features that I don't require, and I don't know asm to customize them.Are there any C examples of an 8x8 matrix already?Is C fast enough to do a matrix?I'm having a bit of trouble getting my head around how the matrix works, but I would basicaly like to be able to control each led in the matrix individualy.Also, would I be able to control the brightness of the LEDs individualy by flashing them very quicky at different intervals in the led matrix?Thanks Quote Link to comment Share on other sites More sharing options...
lucem Posted February 28, 2009 Report Share Posted February 28, 2009 You might want to take a look at the MBSID source, matrix handling is in there :) Quote Link to comment Share on other sites More sharing options...
TK. Posted February 28, 2009 Report Share Posted February 28, 2009 This is a C based example, which demonstrates the usage of the assembly based BLM driver for MIOS8:http://svnmios.midibox.org/listing.php?repname=svn.mios&path=%2Ftrunk%2Fapps%2Fexamples%2Fbutton_duoled_matrix%2FThis C based module (which is only provided for MIOS32, but could also be ported to MIOS) is an example how to handle a 8x8 button/LED matrix:http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fmodules%2Fblm8x8%2Fif you remove all functions which are related to button handling, you will get the code for which you asked for (or the other way around: BLM8X8_PrepareCol() is the only relevant function for your usecase)Is C fast enough to do a matrix?Definitely yes, as the DOUT register handling itself is handled by MIOS, and it's already speed optimized so that you don't need to take care about the low level stuff. Just hook the code which periodically changes the DOUT values into SRIO_ServicePrepare() - this function is called each mS before MIOS updates the DOUT registers.Also, would I be able to control the brightness of the LEDs individualy by flashing them very quicky at different intervals in the led matrix?No, because a really satisfying PWM requires a much higher update frequency - details: see this article:http://www.midibox.org/forum/index.php/topic,10915.0.htmlMeanwhile I developed a simple way to generate PWM, an example code can be found underhttp://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fbootloader%2Fmain.c(MIOS32 only, search for PWM)But it only works if the LED is directly connected to an IO pin. It won't work for LEDs connected to the SRIO chain due to the slower update frequency (1kHz instead of 10 kHz), and it especially won't work for multiplexed LEDs, since it reduces the update frequency (e.g. 8x8 matrix: 125 Hz instead of 1kHz)Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
levon Posted March 2, 2009 Author Report Share Posted March 2, 2009 Thanks TK, you rock.Ill have a look into the BLM code. since im using just a single led 8x8 matrix, i can do this with just 2 Shift Registers. J5 and J6 of the DINx4 board.Is there much difference between the Mios32 and MIOS? how much code will need changing?Looks like ill skip the dimming LEDs, but would it be possible to flash them, say once a second? Quote Link to comment Share on other sites More sharing options...
TK. Posted March 2, 2009 Report Share Posted March 2, 2009 Is there much difference between the Mios32 and MIOS? how much code will need changing?The code isn't compatible (e.g. due to different function names and different variable types), but the concept is the same for PIC based MIOS.Looks like ill skip the dimming LEDs, but would it be possible to flash them, say once a second?Sure - use a 16bit variable (unsigned short) as a counter. Increment it on each SRIO_ServicePrepare() invocation (each mS), and set it back to 0 once it reaches 1000 (== 1 second). Now you could apply an inversion mask to each DOUT bit which should flash whenever the counter is > 500, this gives you a 1:1 flash ratio.Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
julienvoirin Posted March 3, 2009 Report Share Posted March 3, 2009 Looks like ill skip the dimming LEDs, but would it be possible to flash them, say once a second?easier : clockbox muxed with BLM(rainbow) can do thatjust make a command line like (beats counts 0 1 2 3 then return to zero) when beats = 0 or 1, then Led ON, else LED off, default BPM is set to 120i've started to code this but i do not remember if it is published in the topic Quote Link to comment Share on other sites More sharing options...
levon Posted March 12, 2009 Author Report Share Posted March 12, 2009 Can the BLM driver be used with the AC-Sim? ive been trying to get it working, with no luck. Also it seems that DOUT_SetPin(); doesnt work with AC-sim.anyway...Im building the matrix next week and just wanted to make sure Im doing it right before i start.The Cathodes of the LEDs will be connected verticaly in colums 1,2,3,4,5,6,7,8. these will be connected to J5 of a DOUT module ( pins 0-7)The Anodes of the LEDs, will be connected horizontaly in rows 1-8 and connected to J6 of a Dout (pins 0-7)Im just not sure as http://www.ucapps.de/mbhp/button_duoled_matrix.pdfm has some of the buttons connected to the Dout Cathodes.If I set it up like that in an 8x8 rather than a 4x16, will the scrambling discribed in this link be a problem, or can it be changed in software?im fairly sure it will all be fine, but i just wanted to check so im not wasting time.thanks Quote Link to comment Share on other sites More sharing options...
stryd_one Posted March 12, 2009 Report Share Posted March 12, 2009 AC-Sim is really intended for algorithm testing and such, not really for CS stuff so much.... but you can always add functions for anything that's missing :) Quote Link to comment Share on other sites More sharing options...
julienvoirin Posted March 12, 2009 Report Share Posted March 12, 2009 If I set it up like that in an 8x8 rather than a 4x16, will the scrambling discribed in this link be a problem, or can it be changed in software?if you look at the Rainbow topic i made, you will see a schematic to build your own Matrix. And you look in the last version of the software (v1.8 ), you will see there is a possibility to do 4x16 or 8x8 thanks to an algo developped by bugfight. It is called DESCRAMBLING. Quote Link to comment Share on other sites More sharing options...
levon Posted March 22, 2009 Author Report Share Posted March 22, 2009 Thanks julienvoirin, looking though your code has helped, just need to build my 8x8 matrix so i can test it :P Quote Link to comment Share on other sites More sharing options...
julienvoirin Posted March 22, 2009 Report Share Posted March 22, 2009 just need to build my 8x8 matrixi advise you to do a RGB matrix even if you use only 1 colour. It would be ready for future enhancemnts. And i also advise you to get sparkfun kit as it is easy to solder and buttons are good ; LEDs can be found in ebay china for 25 euros/100pcs.(topbright88)Kommon KATHODfollow the TK's schematic with my pen additions and you are in. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.