AVR RGB MATRIX

Has anyone bought and succsessfully used one of the RGB backPacks?? I would reallyappreciate some help

Many Thanks

Andy :smiley:

I used the RGB Matrix & Backpack with an Arduino. http://www.arduino.cc also sold by sparkfun (http://www.sparkfun.com/commerce/produc ā€¦ cts_id=666)

Its pretty straight forward. Now, the trick is to make something interesting :wink:

Here is the Arduino code for it. (Cross posted on the arduino forums too)

// Simple program to test SPI with the RGB Matrix & Backpack from Sparkfun.
// Code is a combination of Heather Dewey-Hagborg, Arduino Forum user: Little-Scale, and Daniel Hirschmann
// Enjoy!

// The Backpack requires 125Khz SPI -> which is the slowest rate at which the Arduino's hardware SPI bus can communicate at. 
// We need to send SPI to the backpack in the following steps:
// 1) Activate ChipSelect; 
// 2) Wait 500microseconds;
// 3) Transfer 64bytes @ 125KHz (1 byte for each RGB LED in the matrix);
// 4) De-activate ChipSelect;
// 5) Wait 500microseconds
// Repeat however often you like!


#define CHIPSELECT 10//ss
#define SPICLOCK  13//sck
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO

char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
}

void setup()
{
  byte clr;
  pinMode(DATAOUT,OUTPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(CHIPSELECT,OUTPUT);
  digitalWrite(CHIPSELECT,HIGH); //disable device

  SPCR = B01010001;             //SPI Registers
  SPSR = SPSR & B11111110;      //make sure the speed is 125KHz

  /*
  SPCR bits:
   7: SPIEE - enables SPI interrupt when high
   6: SPE - enable SPI bus when high
   5: DORD - LSB first when high, MSB first when low
   4: MSTR - arduino is in master mode when high, slave when low
   3: CPOL - data clock idle when high if 1, idle when low if 0
   2: CPHA - data on falling edge of clock when high, rising edge when low
   1: SPR1 - set speed of SPI bus
   0: SPR0 - set speed of SPI bus (00 is fastest @ 4MHz, 11 is slowest @ 250KHz)
   */

  clr=SPSR;
  clr=SPDR;
  delay(10);
}

void loop()            
{
    delay(100);                   
    digitalWrite(CHIPSELECT,LOW); // enable the ChipSelect on the backpack
    delayMicroseconds(500);
    for (int i=0;i<8;i++) for (int j=0;j<8;j++)
    {
      spi_transfer(i);          //There are only 8 colours available to the matrix with the backpack, so this will present 1 colour per column on the matrix
    }
    digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
    delayMicroseconds(500);
}

Thats a great help :):slight_smile: cant wait to get it now lol

what does your code display?

many thanks

Andy

No problem :slight_smile:

It displays each column with one of the 8 colours that the backpack provides as default colour options.

Black (off), Red, Green, Blue, Amber, Light Blue, Purple, White (although the white is a little on the pink side)

~Daniel~

Ahh ok kool cant wait to try this out :slight_smile:

I have found a source for the same led matrix backpacks alot cheaper too he he he

Thanks for the help i will update and let you know how i get on :slight_smile:

great! If the source works out, would you mind sharing?

Thanks!

Oopps :frowning: my mistake i ment the RGB Matricies them selves :frowning: sorry to get your hopes up.

Hmmmm What to program mine to do

Ok now that i have got one finnally.

Can one of you lovely people :stuck_out_tongue: give me some help with actually displaying single pixels such as described on the PDF e.g. transfer 0x00 blah blaj

And could some one do a scrolling pattern for example red going up and down?

Im dumb please be nice

Thanks in advance.

Andy

is there no one out ther to help???

I have 2 of these RGB LED Matrix ā€œbackpacksā€ and can scroll text messages across them BUT also get this ghosting offset text message imaging. Has ANYONE seen this before?? I am getting no help on this.

I am using a Parallax SX-28 microcontroller using SX/B (BASIC like language).

Please help.

Well I found out that my problem with the ghosting was because of the microcontroller running faster than 125 KHz or so. I had it set to 4 MHz. However, now the scanning is so slow that it is nowhereā€™s near being ā€œsmoothā€ - refresh is very observable.

I set the DEVICE and FREQ as below:

DEVICE SX28, OSC128KHZ, TURBO, STACKX, OPTIONX

FREQ 128_000

Now what?

Danielh,

When you wrote your AVR program, it appears that you set the program at 125 KHz. However, a friend on the Parallax website stated:

Unless you use the SpeedMult parameter with SHIFTIN/SHIFTOUT, the SHIFT functions in SX/B are set at ~83khz (slow enough for Stamps). And to the best of my knowledge, the SHIFT timing is frequency independent (that is, the time between bits is recalcuating based on device frequency so that the time between bits is always ~6us). That said, slowing things down to 128_000 would probably slow down SHIFTIN/SHIFTOUT, but I donā€™t think you were anywhere near 125khz to begin with.

I am more confused now than ever on this issue.

May i suggest using the arduino :slight_smile: it is more than capable or providing the correct speed.

Still need help with writing sprites thou :slight_smile:

Iā€™m using the arduino decimila with the RG (not B) Matrix backpack, but I cannot get this code to work. I changed the spi_transfer to spi_transfer(1) to show all red, but it is showing sparatic red dots on the matrix. Any ideas?

Hey,

Thanks for the code Daniel, I have my RGB matrix up and running, looks great. So many program ideas to tinker with!

Cheers

Nick

Iā€™m using the arduino decimila with the RG (not B) Matrix backpack, but I cannot get this code to work. I changed the spi_transfer to spi_transfer(1) to show all red, but it is showing sparatic red dots on the matrix. Any ideas?

Could anyone answer to that? Because even if I change the spi_transfer to spi_transfer(1) it does absolutely nothing!

I donā€™t see why this wouldnā€™t work with the RGB matrix. Make sure you have the line to set the speed correctly:

SPSR = SPSR & B11111110; //make sure the clock speed is 125KHz

If not I guess maybe the RG matrix needs the data sent in a different way to thr RGB one. Have you tried using the example code on the sparkfun site? (on the page for the RG matrix)?

There is an exemple code written in C for WinAvr. Iā€™m using Arduino so itā€™s different and I donā€™t understand it.

Anyway I didnā€™t forget to use this line ```
SPSR = SPSR & B11111110;

I found that with the following code I got a LOT of flickering and colored spots in the corner

  SPCR = B01010001;             //SPI Registers 
  SPSR = SPSR & B11111110;      //make sure the speed is 125KHz 

  /* 
  SPCR bits: 
   7: SPIEE - enables SPI interrupt when high 
   6: SPE - enable SPI bus when high 
   5: DORD - LSB first when high, MSB first when low 
   4: MSTR - arduino is in master mode when high, slave when low 
   3: CPOL - data clock idle when high if 1, idle when low if 0 
   2: CPHA - data on falling edge of clock when high, rising edge when low 
   1: SPR1 - set speed of SPI bus 
   0: SPR0 - set speed of SPI bus (00 is fastest @ 4MHz, 11 is slowest @ 250KHz) 
   */ 

  clr=SPSR; 
  clr=SPDR;

I pulled this from an example sketch and it gives me a more solid lookā€¦ I havenā€™t been really getting in to animation so I donā€™t know if it will be smoother.

	//SPI Bus setup
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);	//Enable SPI HW, Master Mode, divide clock by 16	//SPI Bus setup

[/code]

it is Embedded mp3 module , it can be

controlled by MCU via RS232

It provide stable performance , with VS1003 Mp3 decoder . see from this link

http://www.tendaelectronics.com/?action ā€¦ 10,427|427

Hope you will like it , because engineers like new things .Any question , pls let me know

Best regards

Lynn

Tenda Electronics

Tel:0086-20-22100510

www.tendaelectronics.com

tendaelectronics@gmail.com