1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics 7-segment LED Clock

Discussion in 'Modding' started by Explicit, 27 Sep 2004.

  1. eutronix

    eutronix What's a Dremel?

    Joined:
    28 Nov 2005
    Posts:
    44
    Likes Received:
    0
    I finally got my C-max CME8000 circuit working. So now there is no need to use their radio module. It still needs error detection and rejection code but it mostly gives good results. Now I just need to get the alarm sound and controls working.

    Stu
     
  2. geogecko

    geogecko What's a Dremel?

    Joined:
    23 May 2007
    Posts:
    56
    Likes Received:
    0
    Cool. Would love to see more details of this project, if you are willing to share. I have two CME8000 modules sitting in my desk until I find time to start working on that project.

    I have really been interested in making an atomic version of this clock:

    http://www.youtube.com/watch?v=uKazTENcNWo
     
  3. eutronix

    eutronix What's a Dremel?

    Joined:
    28 Nov 2005
    Posts:
    44
    Likes Received:
    0

    It has a custom display we had made just for the project with several multicolored symbols and alphanumeric elements all in LEDs. It has a MAX6954 Maxim display driver IC and alarm with sampled audio using the OKI ML22Q58, and of course the C-max CME8000 for radio control. Eventually we will offer the displays for sale in a variety of colors if anyone is interested in making their own clock around them. I'll see about posting a picture soon.

    Stu
     
  4. geogecko

    geogecko What's a Dremel?

    Joined:
    23 May 2007
    Posts:
    56
    Likes Received:
    0
    Interesting. I am familiar with the MAX6954. I have thought about using the same chip, although it may be the MAX6952, if I remember correctly. One of them drives 128 discrete LEDs, but it has been a while since I looked at them.
     
  5. eutronix

    eutronix What's a Dremel?

    Joined:
    28 Nov 2005
    Posts:
    44
    Likes Received:
    0
    Well, the MAX6954 is capable of driving up to 128 discrete LEDs in one of its modes of operation. In our case, we drive 104 LEDs in our custom display. The MAX6955 is basically the same but uses the I2C interface instead of SPI. Your project should work well with it provided you don't need anymore than 128 LEDs. If you do though you can daisychain multiple MAX6954s to drive more.

    Stu

    [​IMG]
     
    Last edited: 31 Jul 2008
  6. Mike K8LH

    Mike K8LH What's a Dremel?

    Joined:
    17 Nov 2005
    Posts:
    36
    Likes Received:
    0
    Hi Guys,

    After more than a year I finally got around to prototyping that novelty single chip Charlieplexed Clock design and it seems to work well.

    The program was written using the free/Lite version of Sourceboost BoostC. The first version (listing below) implements the Clock function. Updated versions will include the Calendar and Timer functions.


    [​IMG]

    [​IMG]
    [​IMG]

    Please let me know if there's any interest and I'll setup a project page and post a link to it.

    Kind regards, Mike

    Code:
    /********************************************************************
     *                                                                  *
     *  Project: LED Clock                                              *
     *   Source: LED_Clock.c                                            *
     *   Author: Mike McLaren, K8LH                                     *
     *     Date: 21-Jul-08                                              *
     *  Revised: 04-Aug-08                                              *
     *                                                                  *
     *  16F88 Charlieplexed LED Clock Experiment                        *
     *                                                                  *
     *                                                                  *
     *      IDE: MPLAB 8.14 (tabs = 4)                                  *
     *     Lang: SourceBoost BoostC v6.87, Lite/Free version            *
     *                                                                  *
     *                                                                  *
     ********************************************************************/
    
    #include <system.h>
    
    #pragma DATA _CONFIG1, _CCP1_RB0&_LVP_OFF&_MCLR_OFF&_WDT_OFF&_HS_OSC
    #pragma DATA _CONFIG2, _IESO_OFF & _FCMEN_OFF
    
    #pragma CLOCK_FREQ 16000000      // I'm using a 16 MHz crystal
    
    //--< function prototypes >------------------------------------------
    //--< typedef and defines >------------------------------------------
    
    typedef unsigned char u08;
    typedef unsigned int u16;
    
    #define r08 const rom unsigned char
    
    #define spkr 1                  // spkr on RA1 pin
    #define smux 0                  // switch matrix on RA0
    
    #define setmode swflags.0       // set sw on RB0
    #define rtarrow swflags.1       // rt arrow on RB1
    #define uparrow swflags.2       // up arrow on RB2
    #define dnarrow swflags.3       // dn arrow on RB3
    
    //--< variables >----------------------------------------------------
    
    u08 clk[] = { 23,59,49 };       // clock array
    u08 set[] = { 00,00,00 };       // set/edit array
    u08 led = 0;                    // column 6 leds
    
    u08 data = 0;                   // isr, column segment data
    u08 colnbr = 0;                 // isr, led array index
    u08 colsel = 1;                 // isr, column select bit
    
    r08 segdata[] = { 0b00111111,   // "0"   -|-|F|E|D|C|B|A
                      0b00000110,   // "1"   -|-|-|-|-|C|B|-
                      0b01011011,   // "2"   -|G|-|E|D|-|B|A
                      0b01001111,   // "3"   -|G|-|-|D|C|B|A
                      0b01100110,   // "4"   -|G|F|-|-|C|B|-
                      0b01101101,   // "5"   -|G|F|-|D|C|-|A
                      0b01111101,   // "6"   -|G|F|E|D|C|-|A
                      0b00000111,   // "7"   -|-|-|-|-|C|B|A
                      0b01111111,   // "8"   -|G|F|E|D|C|B|A
                      0b01101111,   // "9"   -|G|F|-|D|C|B|A
                      0b01110111,   // "A"   -|G|F|E|-|C|B|A
                      0b01111100,   // "b"   -|G|F|E|D|C|-|-
                      0b00111001,   // "C"   -|-|F|E|D|-|-|A
                      0b01011110,   // "d"   -|G|-|E|D|C|B|-
                      0b01111001,   // "E"   -|G|F|E|D|-|-|A
                      0b01110001 }; // "F"   -|G|F|E|-|-|-|A
                        
    u08 rtcl = 0;                   // isr, 250 msec counter
    u08 rtch = 0;                   // isr, 1 second counter
    
    u08 sample = 0;                 // live/fresh switch bits
    u08 vcmask = 0;                 //
    u08 vcbit0 = 0;                 // vertical counter bit 0
    u08 vcbit1 = 0;                 // vertical counter bit 1
    u08 swlatch = 0;                // debounced switch state latch
    u08 swflags = 0;                // switch flag bits for Main
    
    u08 beepctr = 0;                //
    
    u08 group;                      //
    u08 limit;                      //
    
    
    //--< main >---------------------------------------------------------
    
    void main()
    { 
      ansel = 0;                    // a2d off, digital i/o
    //osccon = 0b01110000;          // set INTOSC to 8 MHz
    //while(!osccon.IOFS);          // wait 'til oscillator stable
      trisb = 0b11111111;           // set all pins to inputs
      trisa = 0b00000000;           // set all pins to outputs
      portb = 0b00000000;           // set all output latches to '0'
      porta = 0b00000000;           // set all output latches to '0'
    
    //  setup Timer 2 for 1 msec interrupts (16 MHz clock) for a display
    //  refresh rate of 142.8 Hz
    
      tmr2 = 0;                     // clear Timer 2 register
      t2con = 0b00000110;           // '0-------' unimplemented bit
                                    // '-0000---' TOUTPS<3:0>, postscale 1
                                    // '-----1--' TMR2ON, turn Timer 2 on
                                    // '------10' T2CKPS<1:0>, prescale 16
      pr2 = 250-1;                  // 250 x 4-usec 'ticks' = 1 msecs
      pir1 = 0;                     // clear peripheral interrupt flags
      pie1.TMR2IE = 1;              // set Timer 2 interrupt enable bit
      intcon = 0b11000000;          // '1-------' GIE, enable global ints
                                    // '-1------' PEIE, enable peripheral ints
                                    // '--0-----' T0IE, TMR0 ints disabled
                                    // '---0----' INTE, off
                                    // '----0---' GPIE, IOC disabled
                                    // '-----000' T0IF/INTF/GPIF flags
      while(1)
      {
        if(setmode)                 // if set switch 'on'
        { set[0] = clk[0];          // setup edit buffer
          set[1] = clk[1];          //
          set[2] = clk[2];          //
          group = 0;                // group = hours digits
          limit = 23;               // upper limit = 23
          while(setmode)            // while set switch "on"
          { if(rtarrow)             // if rt arrow
            { rtarrow = 0;          //
              if(group == 2)        // bump display group, 0..2
                group = 0;          //
              else                  //
                group++;            //
              if(group == 0)        // set group upper limit
                limit = 23;         //
              else                  //
                limit = 59;         //
            }
            if(uparrow)             // if up arrow
            { uparrow = 0;          //
              if(set[group] == limit)
                set[group] = 0;     //
              else                  //
                set[group]++;       //
              delay_ms(200);        // delay approx 1/4 sec
              swlatch.2 = 0;        // allow repeat operation
            }
            if(dnarrow)             // if dn arrow
            { dnarrow = 0;          //
              if(set[group] == 0)   //
                set[group] = limit; //
              else                  //
                set[group]--;       //
              delay_ms(200);        // delay approx 1/4 sec
              swlatch.3 = 0;        // allow repeat operation
            }
          }
          intcon.GIE = 0;           // suspend interrupts
          clk[0] = set[0];          // update clock hours
          clk[1] = set[1];          // update clock minutes
          clk[2] = set[2];          // update clock seconds
          rtcl = 25;                // reset RTC counters
          rtch = 0;                 //
          intcon.GIE = 1;           // resume interrupts
        }
      }
    }
    
    /********************************************************************
     *  interrupt service routine, 1 msec Timer 2 interrupts            *
     ********************************************************************/
     
    void interrupt()
    { pir1.TMR2IF = 0;              // clear timer 2 interrupt flag
     /*                                                                 *
      *  sample switches and update display                             *
      *                                                                 */
      trisb = 0xFF;                 // blank the display
      porta.0 = 0;                  // power the switch matrix
      sample = ~portb;              // sample "active low" switches
      porta.0 = 1;                  // turn off switch matrix
      portb = colsel;               // select new column (digit)
      if(data & colsel)             // if 'float' pin required
        data.7 = 1;                 // set the 'float' pin (RB7)
      data |= colsel;               // pick up column select bit
      trisb = ~data;                // display new column (digit)
      if(colsel.6)                  // if last column
      { colnbr = 0;                 // reset column number
        colsel = 1;                 // reset column select bit
      }
      else                          // else
      { colnbr++;                   // increment column number
        colsel <<= 1;               // shift column select bit
      }
     /*                                                                 *
      *  debounce "press" and "release" switch states                   *
      *                                                                 *
      *  a switch is "debounced" when it has been sampled at the same   *
      *  state 22 times spanning 21 msecs                               *
      *                                                                 */
      sample &= 0b00001111;         // switches are on RB3..RB0 pins
      vcmask = sample ^ swlatch;    // changes (press or release)
      vcbit0 &= vcmask;             // clear inactive vertical counters
      vcbit1 &= vcmask;             //
      vcmask &= colsel;             // use 'colsel' as 7 msec prescaler
      vcbit1 ^= (vcmask & vcbit0);  // inc bit 1 on active counter
      vcbit0 ^= vcmask;             // inc bit 0 on active counter
      vcmask = ~vcmask;             // check for timed-out counters
      vcmask |= vcbit0;             //
      vcmask |= vcbit1;             //
      vcmask = ~vcmask;             // any '1's are time-out counters
      swlatch ^= vcmask;            // update debounced switch state
      if(vcmask &= sample)          // get rid of "new release" bits
        beepctr = 32;               // task a "new press" beep
      swflags ^= vcmask;            // update switch flags for Main
     /*                                                                 *
      *  beep task produces a 500 Hz 'beep' with 1 msec interrupts      *
      *                                                                 */
      if(beepctr)                   // if beep task running
      { porta ^= 1 << spkr;         // toggle speaker pin
        beepctr--;                  // decrement msec counter
      }
     /*                                                                 *
      *  update RTC once per second (once every 1000 interrupt cycles)  *
      *                                                                 */
      rtcl++;                       // bump counter lo
      if(rtcl == 250)               // if 250 msec interval
      { rtcl = 0;                   // reset counter lo and
        rtch++;                     // bump counter hi
        if(rtch == 4)               // if 1 second interval
        { rtch = 0;                 // reset counter hi
          fsr = (u08) &clk[2];      // increment clock
          while(indf == 59)         //
          { indf = 0;               //
            fsr--;                  //
          }                         //
          indf++;                   //
          if(clk[0] == 24)          // if hours = 24
            clk[0] = 0;             // reset to 00
        }                           //
      }
     /*                                                                 *
      *  prep display data for next interrupt cycle                     *
      *                                                                 */
      fsr = (u08) &clk;             // clk[] array address
      if(setmode)                   // if set mode
        fsr = (u08) &set;           // use set[] array address
      fsr += (colnbr / 2);          // add display group, 0..2
      if(colsel.6)                  // if column 6
        data = led;                 // use discrete LED data
      else                          // else
      { if(colnbr.0)                // if odd column (ones)
          data = indf % 10;         // use ones digit, 0..9
        else                        // else
          data = indf / 10;         // use tens digit, 0..9
        data = segdata[data];       // segment data for next interrupt
        if(setmode)                 // if set mode and
          if(group == colnbr / 2)   // if this group and
            if(rtch.0)              // if 250 msec blink off period
              data = 0;             // display "off" next interrupt
      }
    }
    
     
    Last edited: 17 Aug 2008
  7. eutronix

    eutronix What's a Dremel?

    Joined:
    28 Nov 2005
    Posts:
    44
    Likes Received:
    0
    Nice clock. That's quite an elegant solution you've come up with! My clock uses 8 ICs to do basically the same thing. Do you plan on making (a) PCB(s) for it?

    Stu
     
  8. Mike K8LH

    Mike K8LH What's a Dremel?

    Joined:
    17 Nov 2005
    Posts:
    36
    Likes Received:
    0
    Hi Stu,

    No plans for a circuit board at this time (just too many choices for 7 segment displays) but if you or anyone else is interested, the project and updated software is posted here;

    K8LH Novelty Single Chip 24 Hour Clock/Calendar/Timer

    I might consider designing a PCB for the 2 chip version if anyone shows interest. The 2 chip design uses a standard multiplexed display and a serial-to-parallel sinking driver IC (MIC5821, or TPIC6C595, or A6821, etc.) to provide full brightness with PWM brightness control.

    Your clock design does sound very elegant and dramatic. Bravo!

    Have fun. Mike
     
    Last edited: 22 Aug 2008
  9. openadv

    openadv What's a Dremel?

    Joined:
    17 Sep 2008
    Posts:
    1
    Likes Received:
    0
    People - I've trawled this thread and come to the conclusion that I don't have the kit to do this and it's 20 years since my Electronics HNC. So why post well like another poster I'm keen to build a race clock for events. Commercial versions are in the £0000's which are to be honest out of reach for me. I can get the flip digit displays from a supplier in the US for quite a resonable price ($50 for 6" - say £50 after import and delivery) and I can build the case - however the controller illudes me.

    If anyone is interested please PM me. I'm happy to pay a project fee - ideally UK based but really not too fussed.

    needs to HH:MM:SS so 6 digit and like to make it double sided. Can supply more tech details on flip digits if required or see this website. http://www.flipdigitnumerals.com/index.htm. Firstly needs to be a 24 hour clock and then if poss a countdown clock. Look forward to hearing from anyone after an interesting project.
     
  10. dwt98

    dwt98 I own a Dremel :-)

    Joined:
    16 Mar 2008
    Posts:
    6
    Likes Received:
    0
    MM5314N clock chip

    I've been searching for information for a vfd clock using individual tubes. I have a scad of IV-11 tubes and would love to build a clock.

    I seems the problem is with the required power supplies, etc...most posts I find are three or four years old. I get the feeling interest is failing for vfd tube clocks because the price of the tubes is very low on ebay.

    Does anyone have a schematic, etc...that I could beg borrow or steal??...better yet if it includes the necessary programmed PIC.

    I'm 53 and studied two years EE in college before leaving for a career in telecom and I really don't want to learn PIC programming, compilation, burning the chips, etc...but I do love constructing and the building and assembly of the clocks.

    Does anyone have any thoughts on how to take a MM5314 clock chip which has 7 segment output and drive/convert for vfd tubes?

    I would also love to take one of my favorite nixie clock kits that uses a PIC processor and has BCD output and use it to drive the vfd tubes but have no idea how to do it.

    I have a few basic clock kits that use the mm5314N clock chip and six individual 7 seg red led displays. The 7 seg led itself is 14mm tall. I have one or two of these and tried to convert to numitron tubes but the clocks are still not what I want them to be but they work...

    Anyone interested in trading vfd info/schematic for 5314 clock chip led kit??

    Regardless, I enjoy reading the posts and wish I had stayed with EE 30+ years ago instead of going into telecom...hind sight is perfect :wallbash:

    Thanks for reading,
    DWT98
     
  11. richms

    richms What's a Dremel?

    Joined:
    24 Mar 2003
    Posts:
    39
    Likes Received:
    0
    There have being several made by people on the nixie yahoo group - http://groups.yahoo.com/group/NEONIXIE-L/ - quite a few things in the photos and files if you join the group.
     
  12. ROB 636

    ROB 636 Ski-Ba-Bop-Ba-Dop-Bop

    Joined:
    22 Feb 2008
    Posts:
    205
    Likes Received:
    0
    [​IMG]

    That is an awesome looking clock I wold like to have something like that.
     
    Last edited: 6 Oct 2008
  13. charlee78

    charlee78 What's a Dremel?

    Joined:
    22 Nov 2008
    Posts:
    7
    Likes Received:
    0
    Hi guys, I'm new here. I would like to build a clock for the car, is this possible?
     
  14. Guest-2808

    Guest-2808 Guest

    It's certainly possible, but you will have to make sure you use a separate battery backup for the time (I suggest using a Dallas RTC chip) and only power the display when the key is in the ignition. Otherwise, your battery will die overnight :)
     
  15. charlee78

    charlee78 What's a Dremel?

    Joined:
    22 Nov 2008
    Posts:
    7
    Likes Received:
    0
    Actually, I have a plug with a ground, switched 12v and constant 12v. I have a clock in the car right now, would it be easier to just change the leds?
    Oh, thanks for your time...
     
  16. Guest-2808

    Guest-2808 Guest

    The problem is that when the power is off the clock will loose the time, unless you have a separately powered clock chip.
     
  17. charlee78

    charlee78 What's a Dremel?

    Joined:
    22 Nov 2008
    Posts:
    7
    Likes Received:
    0
    For that, I was thinking about the constant 12V I have, and the switched 12V for the display only. The only problem I have is I don't know how to make it. Does anyone know where I could find a diagram with specs for this?
     
  18. charlee78

    charlee78 What's a Dremel?

    Joined:
    22 Nov 2008
    Posts:
    7
    Likes Received:
    0
  19. charlee78

    charlee78 What's a Dremel?

    Joined:
    22 Nov 2008
    Posts:
    7
    Likes Received:
    0
    Anyone??
     
  20. Stonewall78

    Stonewall78 What's a Dremel?

    Joined:
    21 Oct 2005
    Posts:
    90
    Likes Received:
    0
    Use a regulator a resister is an unreliable way to regulate voltage and is a waste of heat and power.
     

Share This Page