Saturday, August 25, 2007

4 digits working



The schematic is correct but the ICs are different. I didn't want to create the parts. The 7805 is ULN2803A. The displays are Kingbright SA56-21EWA and the CA are 3 &8. V1 is a 74HC238.

This is to drive the display with just 7 lines from the CPU. Each of the segment are driven by the
74HC238 3 to 7 decoder. You select the correct digit with the U4,U10,U17, and U18 control lines. This is different then most examples for a 7 segment display drivers. They would take 7 +4= 11 control lines. I would have rather do it that but this is an existing display drive. No chance to change this time..


Working too slow will have to recoded. I duplicated the same code for each display. Not very efficient but does debug the look up table. The display is dimmer because and can't get to the display routines fast enought.

interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
display_u18(u18_value);
display_u17(u17_value);
display_u10(u10_value);
display_u4(u4_value);
a_counter();
check_keypad();
TCNT0=255; /*set for 300us timeout Olimex 6mhz*/
}

display working




Got the display U18 running thru all display values O-F,U,r,- . Using Olimex Atmel mega16 board. Added Molex 14 pin connect in place of ribbon cable. The Olimex has a Jtag interface. I am using the Olimex Atmel USB to Jtag emulator. It interfaces to Atmel's AVR Studio 4 nicely.
I am using the CodeVision AVR C complier. Both programs make a very nice development enviroment.

void display_u18(int n)

{ u18_buffer = U17SegmentTable[n];
if ( (u18_buffer & 0x80) ==0x80)
{ /* state 0*/
PORTA=0x00;
U18 =1;
delay_us(50);
}
else
{
U18=0;
delay_us(50);
}
if ( (u18_buffer & 0x40) ==0x40)
{ /* state 1*/
PORTA=0x01;
U18 =1;
delay_us(50);
}
else
{
U18=0;
delay_us(50);
}

... State 7.
This is the table to light the segments for U17 U18

const unsigned char U17SegmentTable[20]=
{ 0xFC, /*0 */ 0x60, /*1 */ 0xD9, /*2 */ 0xF1, /*3 */ 0x65, /*4 */ 0xB5, /*5 */ 0xBD, /*6 */ 0xE0, /*7 */ 0xFD, /*8 */ 0xF5, /*9 */ 0xED, /*A */ 0x3D, /*B */ 0x9C, /*C */ 0x79, /*D */ 0x9D, /*E */ 0x8D, /*F */ 0x7D, /*U */ 0x09, /*r */ 0x01, /*- */ 0x02 /*dp*/ };

U4 & U10 are different because the display is inverted.. Nice touch to save a few via holes.
const unsigned char U4SegmentTable[20]= { 0xFC, /*0 */ 0x0C, /*1 */ 0xD9, /*2 */ 0x9D, /*3 */ 0x2D, /*4 */ 0xB5, /*5 */ 0xF5, /*6 */ 0x1C, /*7 */ 0xFD, /*8 */ 0xBD, /*9 */ 0x7D, /*A */ 0xE5, /*B */ oxFo/*C */ 0xCD, /*D */ 0xF3, /*E */ 0x71, /*F */ 0xEC, /*U */ 0x41, /*r */ 0x01, /*- */ 0x02 /*dp*/ };

Interrupt Timer 0 routine:

interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
display_u18(u18_value);
a_counter(); lights the led display on,off,flash
check_keypad(); check the key depression.
TCNT0=255; /*set for 1us timeout Olimex 6mhz*/
}

In the main program

for (i=0;i<19;i++)
{ u18_value =i;
}

Next task is to get all 4 digits operating.