I keep getting these random artifacts chacters. Would anyone have any insight as to what is causing this and how to stop it?
I am using this code to test the setup before I write my program: http://arduino.cc/en/Tutorial/ShftOut12
My modifications are:
• setting the baudrate is set to 38400, as anything lower will cause flickering, due to the way I am testing this.
• Changing the pin out variables names to something I understand better
#define DATASER 11 //BIT3 //SER DS Serial data input //White Wire from 595 Pin 14 to: Arduino Pin 11 PB3
#define CLOCKSHCP 12 //BIT4 //_RCLK Shift register clock pin //Blue Wire from 595 Pin 11 Brown to: Arduino Pin 12 PB4
#define LATCHSTCP 8 //BIT0 //_SRCLK SS Storage register clock pin //Red Wire from 595 Pin 12 to: Arduino Pin8 PB0
To display the letters, I copy and paste this into the serial monitor, many times over and over, to create a long string of numbers.
// H = 1315141711
// E = 2625242322
// L = 353332
// O = 414243454647
// HELO = 131517112625242322353332414243454647
Thanks for your response! I had experimented with capacitors earlier, starting with .1uF, but couldn't see them having any affect. I re-added two .1uF mylar caps to the power and gnd pins like so:
You have /OE tied low permanently? Pin 8 is the real ground pin so you might consider how the cap is placed. I stagger them across the top of a chip from power to ground pin. Is that grounded cap leg on pin 13 (/OE) or 12 (STCP)?
Are you sure they are random? In the photos where you display only one letter at a time, the "artifact" segment number is the same as the letter number. For example, when letter 1 is on, the artifact is segment 1; when letter 2 is on, the artifact is segment 2, and so on. Is this a coincidence?
Instead of using the example arduino program, I wrote my own little program to test. I can now successfully write out HELO. Using a delay, I've also found that characters need to refresh at about 80HZ to avoid flickering.
#define BIT7 0x80 // 1000 0000
#define BIT6 0x40 // 0100 0000
#define BIT5 0x20 // 0010 0000
#define BIT4 0x10 // 0001 0000
#define BIT3 0x08 // 0000 1000
#define BIT2 0x04 // 0000 0100
#define BIT1 0x02 // 0000 0010
#define BIT0 0x01 // 0000 0001
#define DATASER BIT3 //SER DS Serial data input //White Wire from 595 Pin 14 to: Arduino Pin 11 PB3
#define CLOCKSHCP BIT4 //_RCLK Shift register clock pin //Blue Wire from 595 Pin 11 Brown to: Arduino Pin 12 PB4
#define LATCHSTCP BIT0 //_SRCLK SS Storage register clock pin //Red Wire from 595 Pin 12 to: Arduino Pin8 PB0
#define PB_PIN (*((uint8_t*)0x23))
#define PB_DDR (*((uint8_t*)0x24))
#define PB_DATA (*((uint8_t*)0x25))
void ShiftReg595_init()
{
PB_DDR |= ( LATCHSTCP | DATASER | CLOCKSHCP );
PB_DATA |= ( LATCHSTCP | DATASER | CLOCKSHCP );
}
// _2_
// 3|_4_|1
// 5|___|7 .8
// 6
int main()
{
ShiftReg595_init();
while(1)
{
shiftDATA( BIT1 , B10111010); // BIT1 is Display 1, Letter H
HardDelay(3);
shiftDATA( BIT2 , B01111100); // BIT2 is Display 2, Letter E
HardDelay(3);
shiftDATA( BIT3 , B00101100); // BIT3 is Display 3, Letter L
HardDelay(3);
shiftDATA( BIT4 , B11101110); // BIT4 is Display 4, Letter O
HardDelay(3);
}
return 0;
}
void shiftDATA( uint8_t display , uint8_t value )
{
uint16_t value16 = ((display << 8) | (value));
PB_DATA &= ~LATCHSTCP;
for (uint8_t i = 0; i <= 16; i++)
{
PB_DATA |= CLOCKSHCP;
WriteData( DATASER , !!(value16 & (1 << (15 - i))));
PB_DATA &= ~CLOCKSHCP;
}
PB_DATA |= LATCHSTCP;
}
void WriteData( uint8_t mask, uint8_t val )
{
if (val == 0) { PB_DATA &= ~mask; } else { PB_DATA |= mask; }
}
/**********************************************************************************
* Hard Delay Function
*********************************************************************************/
void HardDelay(uint32_t i)
{ //Delay Thousands of a second
volatile uint32_t msecs;
uint16_t N = 499; //469 is accurate
//499 is accurate with respect to watchdog in room conditions
for ( msecs = 0 ; msecs < i * N ; msecs++ ) {}
return;
}