Hi,
I have been building an alphanumeric 1 digit display out a 16 segments led drive: STP16CP05.
The 16 segments display (42x55cm) is made out of fairy light segments hooked up to 16 relays driven by the STP16CP05.
Here is the code I use:
int sdiPin = 2;
int clkPin = 5;
int lePin = 4;
int oePin = 3;
//int glyph = 0;
byte alpha[26][16] = {
{0,1,0,1,0,0,0,0,1,0,1,1,1,1,1,0},
{1,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1},
{1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1},
{1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0},
{1,1,0,1,0,0,0,0,0,0,1,1,1,1,0,1},
{0,1,0,1,0,0,0,0,1,0,0,0,1,1,1,0},
{1,0,0,0,0,0,1,0,0,1,1,1,0,0,0,1},
{0,0,0,0,0,0,1,0,0,1,1,1,0,1,0,1},
{0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0},
{1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1},
{0,0,0,1,0,1,0,1,1,0,0,0,1,1,0,0},
{0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0},
{1,0,0,1,0,0,0,0,1,0,1,1,1,1,0,1},
{0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,0},
{1,0,0,1,1,0,0,0,1,0,1,1,1,1,0,1},
{0,1,0,0,1,0,0,0,1,0,1,1,1,1,1,0},
{1,1,0,1,0,0,0,0,0,0,1,1,1,0,1,1},
{0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0},
{1,0,0,1,0,0,0,0,1,0,0,0,1,1,0,1},
{0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0},
{0,0,1,1,1,0,0,0,1,0,0,0,1,1,0,0},
{0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,0},
{0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0},
{1,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1} };
//-----------------------------------------
void setup()
{
Serial.begin(9600);
Serial.println(":setup:");
pinMode(sdiPin, OUTPUT);
pinMode(clkPin, OUTPUT);
pinMode(lePin, OUTPUT);
pinMode(oePin, OUTPUT);
digitalWrite(sdiPin, LOW);
digitalWrite(clkPin, LOW);
digitalWrite(lePin, LOW);
digitalWrite(oePin, HIGH);
}
//-----------------------------------------
void loop()
{
delay(1000);
int i;
int glyph = 16;
Serial.println("-sdi-");
//for(i = 0; i < 16; i++)
while(i < 16)
{
delay(100); // pause inbetween data
digitalWrite(sdiPin, alpha[glyph][i]); // data out - SDI
Serial.print(alpha[glyph][i],BIN);
delayMicroseconds(8); // Tsetup_D
digitalWrite(clkPin, HIGH);
delayMicroseconds(13); // Twclk + Thold ---> 10+3
digitalWrite(clkPin, LOW);
i++;
}
Serial.println(" ");
//--
delay(5); // Tsetup_L
//--
digitalWrite(lePin, HIGH);
Serial.println("-le-");
delayMicroseconds(10); // Twlat
digitalWrite(lePin, LOW);
//--
delayMicroseconds(500); // Tsetup_3
//--
Serial.println("-oe-");
digitalWrite(oePin, LOW);
delay(2000); // display time
digitalWrite(oePin, HIGH);
//--
/*
glyph++;
if ( glyph > 26 ) { glyph = 0; }
*/
}
The STP16CP05 datasheet can be found here:
stm.com/stonline/products/literature/ds/12568/stp16cp05.pdf
Basically the problem I have is that it take a couple cycles for the system to actually settle and display the right glyph instead of lighting up random segments.
I have been checking and re-checking my code and the different timing to send the 16bits of data to the chip and can't find where the glitch is.
If anybody got any idea what could cause the problem or any experience with similar chip, I would really appreciate.
Thanks!