Pages: 1 [2] 3 4 ... 6   Go Down
Author Topic: SureElectronics 3216 Led Matrix  (Read 14765 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

On the hardware side, make sure you use 4 signals from Arduino to the display. In used pins 6-9 in my setup (see the above source code, with the comments).
Also, make sure you plug in the ribbon cable into BR1 connector (inputs) and NOT BR2 (outputs).
As I said earlier, there is an extra cable from Arduino to the display (compared to the 24x16 display, which had CS hardcoded through the switch).
« Last Edit: December 19, 2010, 06:09:39 pm by florinc » 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

It works! Thanks.

Now I'll try to rewrite the plot function to select the correct chip. After this I have 2 3216 so I'll connect both and try to control 8 HT1632C.
Logged

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

Beautiful!
It would be nice to see westfw's original demo ported.
Logged

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

Great work guys! I will try the Arduino code tomorrow.

Here is my latest for the Parallax SX-48 micro-controller with the 3216 RG and SX/B (Basic like language). There is a picture and SX/B code. I had so many problems selecting the individual HT1632C chips like others did. This works but needs a lot of refinement. Perhaps it will help one of you Arduino developers.

http://forums.parallax.com/showthread.php?128037-Sure-Electronics-new-32x16-bi-color-display-3216-RG&p=962127#post962127
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'm very bad dealing with hex, bit in C.

I made an address, value mapping to help:
Code:
                               // x,y
  ht1632_senddata(1, 0x0, 0x8); // 0,0
  ht1632_senddata(1, 0x2, 0x8); // 1,0
  ht1632_senddata(1, 0x4, 0x8); // 2,0
  ht1632_senddata(1, 0x6, 0x8); // 3,0
  ht1632_senddata(1, 0x8, 0x8); // 4,0
  ht1632_senddata(1, 0xa, 0x8); // 5,0
  ht1632_senddata(1, 0xc, 0x8); // 6,0
  ht1632_senddata(1, 0xe, 0x8); // 7,0
  
  ht1632_senddata(1, 0x0, 0x8+0x4); // 0,1
  ht1632_senddata(1, 0x0, 0x8+0x4+0x2); // 0,2
  ht1632_senddata(1, 0x0, 0x8+0x4+0x2+0x1); // 0,3
  ht1632_senddata(1, 0x1, 0x8); // 0,4
  ht1632_senddata(1, 0x1, 0x8+0x4); // 0,5
  ht1632_senddata(1, 0x1, 0x8+0x4+0x2); // 0,6
  ht1632_senddata(1, 0x1, 0x8+0x4+0x2+0x1); // 0,7
  
  ht1632_senddata(1, 0x3+0x20, 0x1); // 1,7 RED
  ht1632_senddata(1, 0x5+0x20, 0x1); // 2,7 RED
  ht1632_senddata(1, 0x7+0x20, 0x1); // 3,7 RED
  ht1632_senddata(1, 0x9+0x20, 0x1); // 4,7 RED
  ht1632_senddata(1, 0xb+0x20, 0x1); // 5,7 RED
  ht1632_senddata(1, 0xd+0x20, 0x1); // 6,7 RED
  ht1632_senddata(1, 0xf+0x20, 0x1); // 7,7 RED

I didn't know how to write the plot function smiley-sad

Also, we can make this function like this:
Code:
void plot2(char x, char y, char val, char color)
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 setup a page on playground wiki to organize the things when it's finished:
http://www.arduino.cc/playground/Main/HT1632C
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 made it!  ;D
Code:
void plot2(char x, char y, char val, char color)
{
  char addr, bitval;
  unsigned int display;

  ASSERT(x >= 0);
  ASSERT(x <= X_MAX);
  ASSERT(y >= 0);
  ASSERT(y <= y_MAX);

  if (x<16 && y<8) {
    display = 1;
  } else if (x>=16 && y<8) {
    display = 2;
    x = x-16;
  } else if (x<16 && y>=8) {
    y = y-8;
    display = 3;
  } else if (x>=16 && y>=8) {
    x = x-16;
    y = y-8;
    display = 4;
  }
  addr = (x<<1) + (y>>2);  // compute which memory word this is in
  bitval = 8>>(y&3);  // compute which bit will need set
  if (color==2)
    addr = addr+0x20;
  if (val) {  // Modify the shadow memory
    ht1632_shadowram[addr] |= bitval;
  }
  else {
    ht1632_shadowram[addr] &= ~bitval;
  }
  // Now copy the new memory value to the display
  ht1632_senddata(display, addr, ht1632_shadowram[addr]);
  if (color==3)
    ht1632_senddata(display, addr+0x20, ht1632_shadowram[addr+0x20]);
}
Logged

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

Here is my (tested) version of the "original" ht1632_plot. The code below fills the screen, orderly, with green, then red, then orange, then black. (Needs to be added to the previously published functions.)

Code:
// possible values for a pixel;
#define BLACK  0
#define GREEN  1
#define RED    2
#define ORANGE 3


// our own copy of the "video" memory; 64 bytes for each of the 4 screen quarters;
byte ht1632_shadowram[64][4] = {0};


/*
 * plot a point on the display, with the upper left hand corner
 * being (0,0), and the lower right hand corner being (31, 15);
 * parameter "color" could have one of the 4 values:
 * black (off), red, green or yellow'
 */
void ht1632_plot (byte x, byte y, byte color)
{
  if (x<0 || x>X_MAX || y<0 || y>Y_MAX)
    return;
  
  if (color != BLACK && color != GREEN && color != RED && color != ORANGE)
    return;
  
  byte nChip = 1 + x/16 + (y>7?2:0) ;
  
  x = x % 16;
  y = y % 8;
  byte addr = (x<<1) + (y>>2);
  byte bitval = 8>>(y&3);  // compute which bit will need set
  switch (color)
  {
    case BLACK:
      // clear the bit in both planes;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case GREEN:
      // set the bit in the green plane and clear the bit in the red plane;
      ht1632_shadowram[addr][nChip-1] |= bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case RED:
      // clear the bit in green plane and set the bit in the red plane;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] |= bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case ORANGE:
      // set the bit in both the green and red planes;
      ht1632_shadowram[addr][nChip-1] |= bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] |= bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
  }
}

void loop ()
{
  // green dots;
  for (int x = 0; x<32; x++)
  {
    for (int y = 0; y<16; y++)
    {
      ht1632_plot(x, y, GREEN);
      delay(20);
    }
  }

  // red dots;
  for (int x = 0; x<32; x++)
  {
    for (int y = 0; y<16; y++)
    {
      ht1632_plot(x, y, RED);
      delay(20);
    }
  }

  // orange dots;
  for (int x = 0; x<32; x++)
  {
    for (int y = 0; y<16; y++)
    {
      ht1632_plot(x, y, ORANGE);
      delay(20);
    }
  }

  // black dots;
  for (int x = 0; x<32; x++)
  {
    for (int y = 0; y<16; y++)
    {
      ht1632_plot(x, y, BLACK);
      delay(20);
    }
  }
}
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

your code is much better than mine.

I made it this way with char val as parameter to check if I need to clean the led when I call the function using val as 0:
Code:
void ht1632_plot (byte x, byte y, char val, byte color)
{
  if (x<0 || x>X_MAX || y<0 || y>Y_MAX)
    return;
  
  if (color != BLACK && color != GREEN && color != RED && color != ORANGE)
    return;
  
  byte nChip = 1 + x/16 + (y>7?2:0) ;
  
  x = x % 16;
  y = y % 8;
  byte addr = (x<<1) + (y>>2);
  byte bitval = 8>>(y&3);  // compute which bit will need set
  switch (color)
  {
    case BLACK:
      // clear the bit in both planes;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case GREEN:
      // set the bit in the green plane and clear the bit in the red plane;
      if (val) {
        ht1632_shadowram[addr][nChip-1] |= bitval;
      } else {
        ht1632_shadowram[addr][nChip-1] &= ~bitval;
      }
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case RED:
      // clear the bit in green plane and set the bit in the red plane;
      ht1632_shadowram[addr][nChip-1] &= ~bitval;
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      if (val) {
        ht1632_shadowram[addr][nChip-1] |= bitval;
      } else {
        ht1632_shadowram[addr][nChip-1] &= ~bitval;
      }
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
    case ORANGE:
      // set the bit in both the green and red planes;
      if (val) {
        ht1632_shadowram[addr][nChip-1] |= bitval;
      } else {
        ht1632_shadowram[addr][nChip-1] &= ~bitval;
      }
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      addr = addr + 32;
      if (val) {
        ht1632_shadowram[addr][nChip-1] |= bitval;
      } else {
        ht1632_shadowram[addr][nChip-1] &= ~bitval;
      }
      ht1632_senddata(nChip, addr, ht1632_shadowram[addr][nChip-1]);
      break;
  }
}

this way the code works with some samples I have here(bouncyline, cross, bres_line, randomwalk, ...).

now I need to figure out how to display characters and scrolling. but I'll try it tomorrow. it's too late in Brazil(02:00 am)! smiley

Thank you florinc!
« Last Edit: December 19, 2010, 11:05:51 pm by trunet » Logged

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

Guys,

Forgive me but I am not up to par with Arduino and C programming as much as I would like to be. I see that you both have provided "VOID subroutines" (if thats what there called) (as I am a BASIC programmer but can read and try to understand C type and Arduino code). How do I take what you have provided and make it complete to run? It looks like there are missing sections. If that's intentional for now, that's ok but I would like to be able to run the code you have provided on my Arduino Duemilanvove which I upgraded with a 328 chip.

Also, on the Parallax site I used to be known as 'T&E Engineer' so most of the HT1632C discoveries were from me with my custom RGB board (24x16) I designed using the HT1632C for each color. Parallax redid their website and I am known now as my name 'Tim Gilmore'.

Great work and I hope to get this moving forward and use the Arduino as it has way more memory then the obsolete Parallax SX-48 having only 4K so (4)  arrays of 64 bytes would seem not to work.

I have under taken a project for my church to create a text display with 2 sets of 4 of these larger P7 displays (3216 RG) so I hope the Arduino can support this effort. I was going to use the Sure Electronics 3264 older display but they have made them obsolete so I have start from the begining with the new bi-color 3216 RG displays (just a whole lot more of them then just the original (2) 3264 displays).

I see this is really taking off and I would like to contribute anyway I can on this effort and hopefully learn more about C and the Arduino.

Thanks again and let me know about runing your Arduino code.

Tim Gilmore
Logged

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

Tim,
I uploaded my demo code here: http://code.google.com/p/wiseclock2/downloads/detail?name=HT1632.zip&can=2&q=
It is still work in progress, with ht1632_plot() function working correctly.
I also posted a video of the test:

Logged

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

florinc,

I tried your code and it did nothing that I could see. I am using the latest Arduino 021 environment. I connected the pins as follows:

ht1632_data = 6;  // Data pin (pin 7 of display connector)
ht1632_wrclk = 7; // Write clock pin (pin 5 of display connector)
ht1632_cs = 8;    // Chip Select (pin 1 of display connnector)
ht1632_clk = 9; // clock pin (pin 2 of display connector)
 and POWER 5V to (pin 16 of the display connector)
 and POWER GND to (pin 15 of the display connector)

I am using USB for power to my Arduino Duemilanove w/328 also.

I did a 'Verify/Compile' command in the Arduino 021 environment displaying a Binary sketch size: 3950 bytes and also did a 'Upload' and the RX TX LEDS on the Arduino were turning on and off as they should during the upload but nothing was displayed.

I also used 2 different known working connectors and neither work in this setup with the display being blank.

From what I can tell from your code, it looks like the Void demo_filler() routine should be running in a loop.

Is there anything I am missing here?

Thanks again!
« Last Edit: December 20, 2010, 08:02:08 am by gilmoret » Logged

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

Tim,
Check the connections/wires. I assume you use the ribbon cable that comes with the display. One end of the cable goes into BR1 connector (the other connector won't work). Plug the wires from Arduino into the other connector, making sure they correspond to the right pins on the display.
If you don't get it working, I will send you a photo of my setup when I get home.

Yes, demo_filler() is called in the loop(). It produces the effect you see in the video.
« Last Edit: December 20, 2010, 09:43:50 am by florinc » Logged

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

florinc,

Here are links that show a working display with the Parallax SX-48 and same wires and cable as used with the Arduino setup. I tried to get good pictures so you can see the wires and the pin connections.

http://i204.photobucket.com/albums/bb95/tdg8934/IMG_1101.jpg

http://i204.photobucket.com/albums/bb95/tdg8934/IMG_1102.jpg

Everything looks correct and I was able to download and run the BLINK.pde as an example on my Arduino with no problems so we know that the Arduino works, the cables and wires are good, so this means there is something else I'm missing in the setup or the code.

Thanks for your help!
« Last Edit: December 20, 2010, 11:23:15 am by gilmoret » 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

florinc... I make your code to work with dual display(8 chips and 64/16). I have to modify the plot function:
Code:
 if (x>=32) {
    nChip = 3 + x/16 + (y>7?2:0);
  } else {
    nChip = 1 + x/16 + (y>7?2:0);
  }

Video showing bouncy line here:

I posted the video in 720p, give a second to youtube make the higher resolutions videos available.
Logged

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