Pages: [1] 2 3 ... 6   Go Down
Author Topic: SureElectronics 3216 Led Matrix  (Read 14756 times)
0 Members and 1 Guest are viewing this topic.
São Paulo/SP/Brazil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 305
Brazilian Arduino Team
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you buy a P4 32X16 RG Bicolor LED Dot Matrix Unit Board SPI Like from sureelectronics, you'll note that it does not work with any existing arduino code.

In this thread we'll discuss and try to make a working library and all hardware connections.

westfw said in http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225239439/354:
Quote
This board uses the same HT3216 driver chip as the other boards that have been under discussion here, so it is no more "true SPI" that those (and no less.  When I wrote the first sample code, the main reason for avoiding existing SPI libraries is that the chip commands were of unusual lengths (not a multiple of 8 bits.)  (The "sample" code in Sure's documentation only seems to use the HW SPI support for some of the early initialization of the display.)

The 32x16  has FOUR of the HT3216 controllers, with each one driving the LEDs (red and green) in only two of the 8x8 arrays, so the mapping to dots is going to be significantly different.  And you have to figure out which one to write to, and how.  And deal with the multiple colors somehow.  The existing code between the "draw a dot" logic and above the "send a command to an HT1632" is probably pretty useless.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also their 5 mm LED "P7" 3216 RG display uses the same code as the smaller 3 mm LED "P4" 3216 RG display.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6792
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
these use the new HT1632C not the older HT1632 Led Driver chips. The RC Master command ($18) is used differently now
How so?  The wording in the datasheet has been changed slightly, but it looks like the actual functionality is identical...
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's right about the datasheet. A couple of the commands were combined into one with a new name. The user just needs to be aware that the code is not the same as the obsolete HT1632C. It also provides more output LED current. I will try to post my SX/B code (still in development) later tonight.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See the Parallax forum for the latest link to my software:

http://forums.parallax.com/showthread.php?128037-Sure-Electronics-new-32x16-bi-color-display-3216-RG

You can open the *.sxb file with any text editor such as Notepad.
Logged

São Paulo/SP/Brazil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 305
Brazilian Arduino Team
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
See the Parallax forum for the latest link to my software:

http://forums.parallax.com/showthread.php?128037-Sure-Electronics-new-32x16-bi-c...

You can open the *.sxb file with any text editor such as Notepad.

I'll try to make an arduino code from this.

Thank you!
Logged

São Paulo/SP/Brazil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 305
Brazilian Arduino Team
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I found the trick in http://forums.parallax.com/showthread.php?117423-Electronics-I-O-(outputs-to-common-anode-RGB-LED-matrix)-question/page4:

The HT1632_CMD_MSTMD in HT1632 sets the IC to master mode. But in the new HT1632C it sets it to slave, so to set master mode on the new HT1632C you have to change HT1632_CMD_MSTMD to HT1632_CMD_RCCLK in initialization code of all this 0832, 2416 arduino codes/libraries already available.

I'm without my arduino stuff here(I'm traveling) so I can't test it. I'll try it tomorrow.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. To be a little more specific with the differences between the HT1632 (used in the 2416 and 0832) and the new HT1632C (4 used in the 3216 RG) as far as coding goes is:

The MSTMD command is used ($14) but all that is needed is now the RC MasterMode (which has the same value as the HT1632 RCCLK command of $18).
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One obvious difference is that 32x16 display requires an extra signal (CLK, pin2), compared to 24x16 display.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its actually worse that just a just the extra CLK pin 2.

There is a CS pin 1 and CLK pin 2. The CS and CLK pins use pins from the micro-controller so that when CS is an active LOW (/CS) and the CLK pin is clocked by the micro-controller, 1 of 4 active low CS pins are cycled out of the 74HC164 shift register on the 3216 RG display. These 1 of 4 active low CS pins are fed into each of the 4 quadrant HT1632C active low CS inputs as /CS1, /CS2, /CS3, and /CS4.  

The hard part is getting the clock cycling correct on the CLK pin and then applying the CS pin to enable to the correct HT1632C on the 3216 RG display. I haven't quite got this part working correctly yet.
« Last Edit: December 19, 2010, 02:48:39 pm by gilmoret » Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having problems with selecting the chip that is supposed to receive the data/command. Basically, all commands/data I send go to all chips at once.
Logged

São Paulo/SP/Brazil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 305
Brazilian Arduino Team
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am having problems with selecting the chip that is supposed to receive the data/command. Basically, all commands/data I send go to all chips at once.
I'm with the same problem here.

I didn't understand the datasheet. If I have more than one HT1632C how do I select the chip I want to control? Cycle the CLK pin? I tried to do this then I went to this problem(all commands/data goes to all chips).
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working.
I use the ChipSelect() from Sure's datasheet.
Most of the functions from the original code need to be enclosed between ChipSelect(chipNo) and ChipSelect(0). ChipSelect(0) would be equivalent to the old ht1632_chipfree().
I will put together a demo (with code).
Currently, I am just filling the memory with bits, using this piece of code:
Code:
void plot2 (int chipNo, byte addr, byte val)
{
   ht1632_shadowram[addr] = val;
   // Now copy the new memory value to the display
   ht1632_senddata(chipNo, addr, ht1632_shadowram[addr]);
}


static void ht1632_senddata (byte chipNo, byte address, byte data)
{
  ChipSelect(chipNo);
  ht1632_writebits(HT1632_ID_WR, 1<<2);  // send ID: WRITE to RAM
  ht1632_writebits(address, 1<<6); // Send address
  ht1632_writebits(data, 1<<3); // send 4 bits of data
  ChipSelect(0);
}


void loop ()
{
 for (int k=1; k<5; k++)
 {
   for (byte addr=0; addr<64; addr++)
   {
     for (int val=0; val<16; val++)
     {
       plot2 (k, addr, val);
       delay(20);
     }
   }
 }
  cls();
}


Logged

São Paulo/SP/Brazil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 305
Brazilian Arduino Team
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll appreciate the code!  ;D

I tried to rewrite the chipselect function too but without success.
Logged

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are the modified Sure functions I am using:
Code:

//**************************************************************************************************
//Function Name: OutputA_74164
//Function Feature: enable pin A of 74164 to output 0 or 1
//Input Argument: x: if x=1, 74164 outputs high. If x?1, 74164 outputs low.
//Output Argument: void
//**************************************************************************************************
void OutputA_74164(unsigned char x) //Input a digital level to 74164
{
  // chip select;
  if(x==1)
  {
    digitalWrite(ht1632_cs, 1);
  }
  else
  {
    digitalWrite(ht1632_cs, 0);
  }
}


//**************************************************************************************************
//Function Name: OutputA_74164
//Function Feature: enable pin A of 74164 to output 0 or 1
//Input Argument: x: if x=1, 74164 outputs high. If x?1, 74164 outputs low.
//Output Argument: void
//**************************************************************************************************
void OutputA_74164(unsigned char x) //Input a digital level to 74164
{
  // chip select;
  if(x==1)
  {
    digitalWrite(ht1632_cs, 1);
  }
  else
  {
    digitalWrite(ht1632_cs, 0);
  }
}


//**************************************************************************************************
//Function Name: ChipSelect
//Function Feature: enable HT1632C
//Input Argument: select: HT1632C to be selected
// If select=0, select none.
// If s<0, select all.
//Output Argument: void
//**************************************************************************************************
void ChipSelect(int select)
{
  unsigned char tmp = 0;
  if(select<0) //Enable all HT1632Cs
  {
    OutputA_74164(0);
    CLK_DELAY;
    for(tmp=0; tmp<CHIP_MAX; tmp++)
    {
      OutputCLK_Pulse();
    }
  }
  else if(select==0) //Disable all HT1632Cs
  {
    OutputA_74164(1);
    CLK_DELAY;
    for(tmp=0; tmp<CHIP_MAX; tmp++)
    {
      OutputCLK_Pulse();
    }
  }
  else
  {
    OutputA_74164(1);
    CLK_DELAY;
    for(tmp=0; tmp<CHIP_MAX; tmp++)
    {
      OutputCLK_Pulse();
    }
    OutputA_74164(0);
    CLK_DELAY;
    OutputCLK_Pulse();
    CLK_DELAY;
    OutputA_74164(1);
    CLK_DELAY;
    tmp = 1;
    for( ; tmp<select; tmp++)
    {
      OutputCLK_Pulse();
    }
  }
}


And here the definitions for pins (etc):
Code:
static const byte ht1632_data = 6;  // Data pin (pin 7 of display connector)
static const byte ht1632_wrclk = 7; // Write clock pin (pin 5 of display connector)
static const byte ht1632_cs = 8;    // Chip Select (pin 1 of display connnector)
static const byte ht1632_clk = 9; // clock pin (pin 2 of display connector)


void ht1632_setup()
{
  pinMode(ht1632_cs, OUTPUT);
  digitalWrite(ht1632_cs, HIGH);
  pinMode(ht1632_wrclk, OUTPUT);
  pinMode(ht1632_data, OUTPUT);
  pinMode(ht1632_clk, OUTPUT);

  ht1632_sendcmd(0, HT1632_CMD_SYSDIS);  // Disable system
  ht1632_sendcmd(0, HT1632_CMD_COMS00);
  ht1632_sendcmd(0, HT1632_CMD_MSTMD);       /* Master Mode */
  ht1632_sendcmd(0, HT1632_CMD_RCCLK);
  ht1632_sendcmd(0, HT1632_CMD_SYSON);       /* System on */
  ht1632_sendcmd(0, HT1632_CMD_LEDON);       /* LEDs on */
  for (byte i=0; i<96; i++)
  {
    ht1632_senddata(1, i, 0);  // clear the display!
    ht1632_senddata(2, i, 0);  // clear the display!
    ht1632_senddata(3, i, 0);  // clear the display!
    ht1632_senddata(4, i, 0);  // clear the display!
  }
}


Logged

Pages: [1] 2 3 ... 6   Go Up
Jump to: