Showing posts with label 7-Segment. Show all posts
Showing posts with label 7-Segment. Show all posts

Friday, May 21, 2010

DIY LED Watch vs Panerai PAM 127

I have completed a prototype of my LED Watch. I will post the detail about how to make it later. The watch case and strap are missing :)
Features:
- Programmable (via ICSP)
- Vintage 7-segment LEDs with slim sigments
- Powered from a coin cell 3.7V Li-ion rechargeable battery
- Built-in USB battery charger

Size comparison between the DIY LED Watch size and a 1 Thai Baht coin.


On my wrist with help of transparent tape :).
DIY Led Watch

The LED Watch prototype is on the left. Panerai PAM 127 or the "Fiddy" is on the right. In case that you are wondering about the strap, it is custom made from a Louis Vuitton bag.
DIY LED Watch, Panerai PAM127

Please comeback and check out for the making of DIY LED Watch later.

Monday, April 13, 2009

Classic LED 7-Segment Displays

Just recently I have been addicted to old LED displays as they are small and bright and I love the classic look. We can see them in vintage calculators and vintage led watches. However these displays consume significant amount of power, so they are not used in watches and calculators anymore. As they are replaced by LCD, these LED 7-Segment displays are not in production anymore and difficult to obtain.

Now, I have 2 models of the classic LED 7-Segment as shown in the picture below: HP 5082-7414 from HP is on the left. It’s a 4-digit Red LED 7-Segment very nice for wristwatch. The one on the right is an 2-digit Red LED 7-Segment from an unknown maker. It can be used in a wristwatch too (with a little bit bigger case).

LED 7-Segment Display HP 5082-7414

Based on my inspection, I have made symbols for these displays with Eagle 5.4.0 free version. The displays are common cathode and the symbols are below

LED 7-Segment Display HP 5082-7414 schematic

The PCB footprints are as the following (DIP 12)

LED 7-Segment Display HP 5082-7414 PCB footprint

I have made simple clocks using these displays and PIC16F887. The real thing looks much better than the photo. The displays are bright red and sun light viewable. Very COOL!!! They are on my computer desk and I love to see them very often.
bubble-7-segment-clock

LED 7-Segment Display HP 5082-7414 clock

LED 7-Segment Display HP 5082-7414 digital clock

Each clock consumes about 0.25W (50mA, 5V) when the PIC16F887 operates at 250kHz (display refresh rate is about 61Hz). The amount of consumed current can be reduced significantly if I use some current limit resistors. But the displays will be dimmer than without resistors. I will try to use PWM for reducing the power consumption as I don’t want to put 8 resistors into my design. The schematic/PCB and firmware including source code in MikroC will be made public once I have complete all of the designs. I will even have kits for sell if my time permitted.

Sunday, December 21, 2008

6 Digits LED 7-Segment Multiplexing

In the post 'LED 7-Segment Multiplexing', I have explained about the concept and benefits of multiplexing. Multiplexing implementation is very similar to driving Led Dot Matrix. I use Timer0 interrupt for switching through each digit. Timer0 or TMR0 is an 8-bit timer which overflows every 256 (0xFF) counts. It's known that the refresh rate above 50Hz would be enough for human's eyes to see the display without recognizing the flickering. If I set TMR0 with 1:8 Prescaler, the multiplexing frequency will be

4MHz(internal OSC.)/4(working OSC)/8(prescaler)/256(max counts of TMR0)/6(number of digits) = 81.3 Hz which is good for a display.

Just an example, I have implemented (in Proteus) a 999999-second counter by using 6 Digits LED 7-Segment Multiplexing technique. There are 2 main components in the project, PIC16F627A or PIC16F628 and 6 x LED7-segment display. The schematic shows below. The crystal is 32.768KHz as usual. There is a 10KOhm pull up resistor at RA4 pin as this pin is an open-drain pin as I described in "Open-Drain RA4 pin on PIC Microcontroller".

7-Segment LED Multiplexing PIC16F627A or PIC16F628
The source code in MikroC is listed below: (.hex is also available, please feel free to contact me)
//PIC16F627A
//4MHz Internal OSC
//MUX by the MUC itself with Interrupt
//TMR0 .. check the prescelar+delay in scan routine as they are related
//punkky@gmail.com
unsigned short number [10] = {
    0x5F0x060x9b0x8f0xC60xCd, 0xDD0x07,
    0xDf, 0xCf
};
unsigned short digit [6];
unsigned short counter;
unsigned short shift_register;
unsigned short x1;
unsigned short x2;
unsigned short x3;
unsigned short x4;
unsigned short x5;
unsigned short x6;
unsigned short tick;
void interrupt ()
{
    if (INTCON.T0IF)
    {
        //Scan digits with TMR0
        INTCON.T0IF = 0;
        if (counter == 5)
        {
            PORTA = number [digit [counter]];
            Delay_us (500);
            shift_register = 0x01;
            PORTB = ~shift_register;
            PORTA = 0x00;
            counter = 0;
        } else
        {
            PORTA = number [digit [counter]];
            Delay_us (500);
            shift_register = shift_register << 1;
            PORTB = ~shift_register;
            PORTA = 0x00;
            counter ++;
        }
    }
    if (PIR1.TMR1IF)
    {
        TMR1H = 0x80;
        PIR1.TMR1IF = 0;
        tick = 1;
        //update current time
        x6 ++;
        if (x6 > 9)
        {
            x6 = 0;
            x5 ++;
            if (x5 > 9)
            {
                x5 = 0;
                x4 ++;
                if (x4 > 9)
                {
                    x4 = 0;
                    x3 ++;
                    if (x3 > 9)
                    {
                        x3 = 0;
                        x2 ++;
                        if (x2 > 9)
                        {
                            x2 = 0;
                            x1 ++;
                            if (x1 > 9)
                            {
                                x1 = 0;
                            }
                        }
                    }
                }
            }
        }
    }
}
void main ()
{
    //Digital I/O for PORTA
    CMCON = 0x07;
    TRISA = 0x00;
    PORTA = 0x00;
    TRISB = 0x00;
    PORTB = 0x00;
    //Internal Clock 4MHz
    PCON.OSCF = 1;
    counter = 0;
    // Enable TMR0
    OPTION_REG.T0CS = 0;
    // Enable Prescaler
    OPTION_REG.PSA = 0;
    // PS0,1,2 = 010 = 3
    // 3 means 1:8 prescaler
    // 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:128, 1:256
    OPTION_REG.PS2 = 0;
    OPTION_REG.PS1 = 1;
    OPTION_REG.PS0 = 0;
    INTCON.T0IF = 0;
    INTCON.T0IE = 1;
    INTCON.GIE = 1;
    INTCON.PEIE = 1;
    T1CON = 0x0F;
    TMR1H = 0x80;
    TMR1L = 0x00;
    // Enable TMR1 interrupt
    PIE1.TMR1IE = 1;
    shift_register = 0x01;
    x1 = 0;
    x2 = 0;
    x3 = 0;
    x4 = 0;
    x5 = 0;
    x6 = 0;
    while (1)
    {
        if (tick)
        {
            tick = 0;
            //update digits
            digit [0] = x1;
            digit [1] = x2;
            digit [2] = x3;
            digit [3] = x4;
            digit [4] = x5;
            digit [5] = x6;
        }
    }
}

Tuesday, December 2, 2008

LED 7-Segment Multiplexing

In my first Digital Clock, I use 6 pcs. of CD4543,BCD to 7-Segment decoder, to drive 6 digit LED 7-Segment display for the sake of simplicity of the software. However, the hardware needs many components. As you can see in the post, the PCB of the clock is quite big and containing a lot of solder points. To reduce the number of components, I will integrate the function of CD4543 into the firmware. One digit requires 7 connections (wires) for all segments and 1 connection for common cathode (or anode). If I connect 6 digits to the MCU without any modification, I will need 7-segment x 6 digit = 42 connections . That means I need to use MCU with atleast 42 I/O pins. As you know, it is a waste for using a lot of MCU pins just for display. The required pins can be reduced dramatically by using a technique called Multiplexing.

Multiplexing

Multiplexing technique is based on the idea of Persistence of vision of the human eyes. The sample schematic of 3 digits multiplexing is shown below. Segment a-g of each digit are connected together. Each digit is switched on-off by controlling signal at Digit 1, Digit 2 and Digit 3. For example, if Digit 1 is '1' , Digit 1 will be on. If Digit 1 is '0', Digit 1 will be off. People will see all 3 digits display in the same time if each digit switch on and off fast enough.


Led 7-Segment multiplexing
By using multiplexing technique the number of required connections for 6 digits display is reduced from 42 pins to 7-Segment+6 digits = 13 pins Wow!! I can drive 6 digits 7-segment display by using just a PIC16F627A.
Next time, I will post the program for LED 7-Segment Multiplexing

--- Updated 21 Dec 2008 --
The program for LED 7-Segment Multiplexing is now posted at 6 Digits LED 7-Segment Multiplexing

Tuesday, November 18, 2008

PCB for 7-Segment PIC Digital Clock

I have designed a single-sided PCB for the PIC Digital Clock. Because the autorouter is not good for routing single-sided PCB so I have to route by hand. It was my first hand routed PCB design and it was a time consuming task. I haven't tested the PCB yet. Use it by your own risk. I will produce this PCB and test it later.

As I don't have server to upload the Eagle file, please contact me if you want the file or PDF version of the image below.

PCB for 7-Segment PIC Digital Clock

Components side of the PCB. The red lines are jumpers.
Component placement on the PCB of 7-Segment PIC Digital Clock

Thursday, November 6, 2008

10-Second Counter

I have made a 10-Second Counter by using a PIC16F627a and a CD4543 BCD to 7-Segment decoder. This circuit and source code are just a demonstration of using MCU to drive an LED 7-Segment Display via CD4543. The 7-Segment displays from 0 to 9 and the number will roll over to 0 again. The interval between change is 1 second. So, this circuit counts 10 seconds between the roll over. I use TIMER1 module and 32.768KHz crystal to make 1 second timebase (see Clock with 32.768KHz Crystal for more info ).

The schematic of the 10-Second counter
Schematic of 10-Second counter
Project setting of MikroC for using internal oscillator of the PIC16f627a.
Setting MikroC for Internal Oscillator

The firmware is written in MikroC and you can find it below.

//PIC16F627A
//4MHz Internal OSC
// One Digit Counter
// 06/11/2008
//Punkky
unsigned short counter;
unsigned short tick;
void interrupt ()
{

        PIR1.TMR1IF = 0;        // clears TMR1IF
        TMR1H = 0x80;
        tick = 1;
}

void main(){
        CMCON = 0x07;   //Digital I/O for PORTA
  TRISA = 0x00;
  PORTA = 0x00;
  TRISB = 0x00;
  PORTB = 0x00
  T1CON = 0x0F
         
  // Prescaler 1:1   external clock 
  PIE1.TMR1IE = 1;  // enable interupt to start the clock 
  INTCON = 0xC0;   // Set GIE, PEIE 
  TMR1L = 0x00
  TMR1H = 0x80
  PCON.OSCF = 1//Internal Clock 4MHz
  //PCON.OSCF = 0; //Internal Clock 48KHz doesn't work well
  counter = 0;
  tick = 0;
  PORTA.F0 = 1// Enable 4345 BCD to 7-Segment
  while(1){
    if(tick){
       tick = 0;
       counter++;
       PORTB = counter;
       if(counter>9){
       counter = 0;
    }
   }
  }
}

Friday, June 13, 2008

Making a Digital Clock

Please check the update at === Digital Clock Updated Version ===

--- Original Version ---
As I am a WIS so I built a clock as my first microcontroller project.

The clock is controlled by PIC16F628A from the PIC book . The idea was making a digital clock with hour, minute and second display. I just wanted to learn about microcontroller so the accuracy of the clock was not an issue (yet). However, I was trying to make it the most accurate as possible by using Timer1 Module of the PIC.

Timer1 Module (TMR1 Register)

The Timer1 Module is a 16 bit counter. It counts from 0x0000 to 0xFFFF and rolls over to 0x0000. The TMR1 interrupt is generated on overflow of the TMR1 register. More information about TMR1 is available in the data sheet of the PIC. In my clock, the PIC is running with 20MHz crystal so the internal clock is 5MHz. So, the duration between each TMR1 increment is 1/5000000 = 0.2 µs . That means TMR1 will overflow every 0.2 µs x 65536 = 0.0131072 s. If I count number of overflows to 77 times, I will get 1.0061744 s which is close to 1 second but the clock will gain about 6ms every second. The result will be a fast running clock (gaining about 9 min/day) .

To get a better accuracy, I make TMR1 counts to 62500 and set prescaler of the TMR1 to 1:8 (How these 62500 and 1:8 come? I did guess and test) . From these settings, the TMR1 will overflow every 1/5000000 x 8 x 62500 = 0.1 s. Counting number of overflows to 10 will yield 1 second. Just perfect huh!

Making Timer1 counts to 62500
It's easy. Just make it starts counting at 65536-62500 = 3036 = 0x0BDC by setting: (MikroC compiler)

TMR1L = 0xDC; //Write TMR1L first to reduce timing error.
TMR1H = 0x0B;

Setting TMR0 requires 2 clock cycles but I have no idea about how many cycles required for setting TMR1L. If 2 cycles were required for setting TMR1L, I should set TMR1L to 0xDC+2 = 0xDE so my clock will run more accurate. The frequency drift in the crystal is also a source of inaccuracy of the clock. The time drift from crystal can be calculated by using data from data sheet of the crystal. Normally, it says 20ppm (Part-Per-Million). That means the crystal will produce error about 20 s. in 1,000,000 s. or about 1.7 s./day.

Making prescaler 1:8
T1CON register contains TMR1 setting information. I set prescaler to 1:8 by

T1CON = 0x31;

Driving 7-segment leds
I don't multiplex the 7-segment leds, so I have to use 6 pieces of CD4543B to drive each 7-segment from BCD output of the PIC. As an outcome of non-multiplexing leds, I can get very bright display. Nearly all of the digital clock projects I have found on the Internet used 7447 or 4511 as the BCD 7-Segment decoders. I use CD4543B because it displays 6 and 9 with tails (nicer looking). However, I have seen some of 7447 and 4511 that also display 6 and 9 with tails but the data sheets of these ICs show 6 and 9 without tails.
number 9 without tailnumber 6 without tail6 and 9 without tails... I just don't like them :)






The schematic of the clock is very simple as shown in the image below (power supply of CD4345B doesn't show).
Schematic of the 7-segment Digital Clock
The working digital clock on protoboards.
Working digital clock on protoboards
Working digital clock on protoboards Missing things
- Buttons for setting time : The time is set by hard code in the program :) . Yeah, it's a very bad idea. But, I had a plan to get the time from GPS module so I didn't bother making those buttons. Now, my GPS clock is up and running.

- Alarm function: it's not alarm clock so there is no alarm function.

- Date: umm.. my GPS clock has it.

Wednesday, June 4, 2008

Smallest 7-Segment Display

I have been looking for a small 7-Segment display for awhile. TDSG Series from VISHAY are among the smallest 7-Segment Displays I can find on the Internet. The character height is only 7mm. They are available at Mouser with mouser part # 78-TDSO1160 for common cathode and # 78-TDSO1150 for common anode. The price for one unit is $1.27. Actually, I found another small 7-Segment display, 7S-1 Super Tiny 7-Segment ($2.99). But, it is a vintage display (New Old Stock) so the reliability is questionable.