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. SideWeaver

    SideWeaver What's a Dremel?

    Joined:
    14 Feb 2006
    Posts:
    17
    Likes Received:
    0
    [​IMG]

    This is the circuit i want to build up. I've built this design based on research.

    I just am unsure of the right way to go with this. :confused: :wallbash:
     
  2. flymustang

    flymustang What's a Dremel?

    Joined:
    5 Feb 2006
    Posts:
    5
    Likes Received:
    0
    Chris,
    I got my powersupply from Pollin. I have tried without grounding the clock. It works peferctly fine.

    Pictures will follow later.
    I am still waiting for the aluminium profiles. :(

    Claus
     
  3. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    I use Proteus VSM myself to debug PIC projects.
    But your screen printout doesn't show all of the schematic so it doesn't make sense to me...

    Can you post the totality of your design?

    CD :)
     
  4. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    Hi Claus,

    Glad to hear your clock works without an earthed PSU.
    Probably it's because your closer to the Mainflingen DCF77 transmitter and have better DCF77 reception than in Belgium overhere.
    BTW, how far away is Glückstadt from Mainflingen?

    I would love to see pictures of your finished clock.

    Regards,
    Chris

    CD :)
     
  5. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    Hi Keith,
    Without a full schematic it's quite difficult to give you useful advise.

    I can tell you how I did it:
    - Interrupt on Timer0 overflow every 2 msecs.
    - During the interrupt service routine I do:
    - Update of the 24H-clock/calendar every two interrupts
    - Reception/decoding of the DCF77 signal/data every two interrupts
    - Update/multiplexing of the 6-digit display every interrupt
    (2msec=500Hz=83.2Hz for the whole 6-digit display)

    In the main routine I do:
    - Scanning of the keyboard/switches/push buttons
    - A/D conversion of the LDR value every 1.5 secs
    - Update of the hardware PWM registers for the automatic brightness control

    CD :)
     
  6. Mike K8LH

    Mike K8LH What's a Dremel?

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

    I don't program in C but if you provide more complete hardware info' I'll bet we can provide some pointers...

    My Clock project, like Chris', does most of the work in the ISR... I use 1-msec interrupts and scan 7 columns (6 display columns and 1 column of status and switch LEDs) for an overall scan or refresh rate of 142.85-Hz with a 14.3% LED duty cycle... The column drive lines are also used to drive and debounce the switches into a single pin... The switch code automatically sends a 50-msec short beep for audible feedback when it detects a new switch press and it provides a switch flag to the main program when the switch is released...

    Good luck with your project...

    Regards, Mike
     
    Last edited: 18 Feb 2006
  7. Mike K8LH

    Mike K8LH What's a Dremel?

    Joined:
    17 Nov 2005
    Posts:
    36
    Likes Received:
    0
    Chris (and gang),

    I just finished adding leap year capability to the Calendar code and will be testing it shortly... Other code modules are falling into place nicely (yippee!!!)... I'm about 90% done...

    The design has changed slightly as I plan to take advantage of 'long' switch presses (lower switch labels) for additional functionality;
    [​IMG]
    TRIM switch
    Press and hold the TRIM switch for at least 1.5 seconds and release (a short beep when the switch is pressed followed by two short beeps at 1.5 seconds) to enter TRIM mode (which replaces the oscillator trimmer capacitor hardware)... The switch LED will blink to let us know we're in TRIM mode and the right most digits on the display will show our current trim value... Turn the rotary encoder knob to adjust the TRIM value from +255 through 000 to -255... Press the TRIM switch again to save the new TRIM value to EEPROM... The TRIM ISR code is relatively simple;

    Code:
    ;
    ;  the Trim routine is used to adjust the RTC 1-second period
    ;  to within plus or minus 200-nsecs to make up for a crystal
    ;  that may be slightly off frequency...  it accomplishes this 
    ;  by adding or subtracting one 200-nsec count (1 Tcyc) from 
    ;  Timer 2 for the first 'CCTR' number of interrupt cycles 
    ;  each second...  Theoretical accuracy is 6.3-seconds/year,
    ;  not including crystal aging or temperature drift...
    ;
    ISR_Trim
    	movf	CCTR,W		; correction counter 0?		  |B0
    	bz	ISR_Switch	; yes, branch, else		  |B0
    	decf	CCTR,f		; decrement counter		  |B0
    	movf	CVAL,W		; get correction value FF or 01	  |B0
    	addwf	TMR2,f		; apply timer correction	  |B0
    ;
    LEVEL switch
    Another 'long' switch so enter and exit as above and it will flash to indicate we're in the 'long' switch state... Rotate the encoder knob to increase or decrease the display brightness...

    ZONE switch
    Another 'long' switch so enter and exit as above and it will flash to indicate we're in the 'long' switch state... Rotate the encoder knob to change the number of hours offset between Local and UTC time zones (-12 to +12)...

    Take care... Kind regards, Mike
     
    Last edited: 19 Feb 2006
  8. SideWeaver

    SideWeaver What's a Dremel?

    Joined:
    14 Feb 2006
    Posts:
    17
    Likes Received:
    0
    Ok, this is the specification i want to follow for the project.

    Specification
    For my Alarm Clock the following components will be used to display the time:

    Microprocessor
    PIC 16F876

    Time Display
    4x 7-Segment LED Displays[HH:MM]



    Controls
    Set Alarm/Set Clock
    Hour/Minute Buttons [1-9]
    Snooze/Cancel Alarm

    I want to integrate these functions onto a 4x4 matrix keypad

    ‘Wake up alarm’
    Buzzer

    Here is a picture of the circuit i believe to be the final circuit, if correct, as i am still learning :)

    // Edit - This is the picture generated from proteus.

    [​IMG]

    The one problem i have got is, i do not know how to wire this 4x4 Matrix Keypad to the PIC16F876 chip etc, and what type of output would be effective and simple enough alert for an alarm clock.

    Thanks for the responses :)
     
    Last edited: 18 Feb 2006
  9. Mike K8LH

    Mike K8LH What's a Dremel?

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

    (1) Is that a common anode or common cathode display?
    (2) Where are your column driver transistors?
    (3) Are you using direct segment drive from the Port B pins (20-ma current limit) or transistor drive for full brightness?

    I would suggest driving the keypad columns using the display column pins and connect the four keypad rows to four 'input' pins... You'll need pull-up or pull-down resistors on those inputs depending on the column driver pin configuration (active low or active high)... Read and save the state of those four input pins each time the display column changes and after every fourth column scan you'll have somewhat debounced switch data for all sixteen switches... Sorry, I can't help you with C code...

    Regards, Mike
     
  10. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    The crystal is also connected to the MCLR pin which I'm sure is unintentional ;) Don't forget the appropriate loading capacitors on your crystal to guarantee that it starts up.

    If this is a standard single LED per segment display then you can get away with just using driver transistors per digit as your ports can source/sink 25mA max.

    You should also have some current limiting resistors in there for your LEDs.

    The keypad seems possibly inappropriate for the project (the keypad will outsize the display!). Would you not be better off using up/down buttons for setting the time?
     
  11. SideWeaver

    SideWeaver What's a Dremel?

    Joined:
    14 Feb 2006
    Posts:
    17
    Likes Received:
    0
    Mike, ill answer your question's first :)

    The Displays are common cathode displays.

    Are column driver transistors essential and what component do I use them for?

    Concerning the 7-Segment Displays, they are directly connected to the PORTB pins.

    Sounds like sound advice

    SteveyG

    I realised my mistake there and I made that before :worried: and now I have resolved that, thanks. I am still learning microprocessor programming, with this being my project. What capacitors would I need for the crystal and how would they need to be wired up?

    With the keypad, yes I am unsure about it, I have logged it down as an idea; I just think that I wanted it in so I could learn how to integrate different things. As it is for educational purposes I could leave it in now. As you can see in the picture, I have labelled the different buttons for their respective functions.

    Thanks guys for the information, but what would you think should be my best course of action with this project? Many thanks again
     
  12. Mike K8LH

    Mike K8LH What's a Dremel?

    Joined:
    17 Nov 2005
    Posts:
    36
    Likes Received:
    0
    Chris (and gang),

    Food for thought -- just wanted to pass along another idea...

    I have ten 2.3-inch 8x8 LED display samples for a future project and I just changed the design to take advantage of what I've learned while working on the version 2 Clock...

    The version 2 Clock uses PWM driving the A6841 <OE> line as an inverse brightness control and I forced a 2% minimum PWM "ON" time (maximum brightness 98%) to provide a minimum 20-usec period at the very beginning of every interrupt cycle where the display is turned off and I reuse the RB1 and RB2 column driver pins temporarily as <CLK> and <DAT> lines to serially load the A6841...

    The technique works so well that I've decided to apply it to the 8x8 matrix design to reduce the interface requirements by using RB0 through RB7 as <DAT> pins during that same minimum 2% PWM "ON" period window (20-usecs or 100 instruction cycles) to load all eight A6841's at the same time... I also decided to put 500-ma regulators on each display board instead of using one big hot 8-amp regulator somewhere else... The modules are interchangable with a simple <DAT> address jumper change...

    Take care... Regards, Mike

    [​IMG]
     
    Last edited: 7 Mar 2006
  13. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    @SideWeaver:

    This is a printscreen of my blue LED clock Proteus design:
    [​IMG]

    You don't need to include an Xtal in the design, just specify the clock frequency in the PIC's properties (do not forget to specify the configuration bits and the path to your HEX-file either).

    The 7-segment displays can be connected directly to the PIC ports with serial resistors in the Proteus design; I do so myself in the design although in real life the displays are connected through ULN2803/UDN2981 drivers.
    The same for the LEDs: in reality they are all connected through transistors (and PWM'ed).

    The buzzer is for test/debugging purposes; in the real clock design it's a SAE800 3-tone gong.

    The 74LS138 3-to-8 decoder + 74LS14 inverters are there to simulate a 74238 (I couldn't find a 74238 in the part libraries).

    The section with the two trimpots in the left upper part of the design is to simulate the LDR resistor to port RA0.

    The DCF77 signal cannot be simulated in Proteus so I use a basic pattern generator connected to port RA4.

    As you see you have to simplify the Proteus design as much as possible (sometimes due to restrictions of Proteus itself) as long as the functionality of the design doesn't interfere in relation to the PIC code.

    Proteus is very useful for debugging/test purposes as long you're aware of its restrictions...

    CD :)
     
  14. SideWeaver

    SideWeaver What's a Dremel?

    Joined:
    14 Feb 2006
    Posts:
    17
    Likes Received:
    0
    Sound advice, looks helpful, but complex.

    As I am new to this, I don’t know if I would be confident enough to do it like that. How does the DCF77 operate? Also I am new to multiplexing, and I have never really seen it done like that due to my little experience.

    Looks very good, I just am unsure if at my level of knowledge, following a system like yours maybe a bit too much for me at this stage?
     
  15. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    Lots of examples of schematics and routines on how to interface a keyboard matrix to a PIC and MPX'ing displays are available (cf. Microchip's AN529 Application Note).

    CD :)
     
  16. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    I think simple schematics with basic functions like LED blinking and switch/pushbutton reading routines would be more appropriate at this stage.

    Once you're more experienced with PIC programming then start using Proteus VSM.

    DCF77:
    http://www.cis.udel.edu/~mills/ntp/dcf77.html
    http://www.hopf-time.com/en/dcf-info.htm

    CD :)
     
  17. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    Hi Mike,
    Glad to hear your code is progressing well.

    On the other hand, it's weird because I'm also busy with a new LED clock project with nine 2.3" 5*7 blue dot matrix displays...
    I'm actually using 8-bit 4094 shift registers in Proteus to test the code (the 6841 you mention seems to be a 8-bit shift register with output buffers).
    I have A6812 and MAX6921 20-bit shift registers available for the final schematic.

    Your idea of address jumpers and modular construction is great!
    Keep up the good work.

    CD :)
     
  18. SideWeaver

    SideWeaver What's a Dremel?

    Joined:
    14 Feb 2006
    Posts:
    17
    Likes Received:
    0
    #:) Thanks :) I have worked with Proteus on some examples i wqill keep giving it a shot, ill let you know how i get on :)
     
  19. eutronix

    eutronix What's a Dremel?

    Joined:
    28 Nov 2005
    Posts:
    44
    Likes Received:
    0
    Hi Chris,

    Have you ever considered using a voice synthesizer IC rather than a simple oscillator gong? Oki has a nice line with built in flash storage capable of up to CD quality (around 6 seconds worth). They do unfortunately require a $700 programmer to load the sounds! I'd certainly jump at the chance to play with them if not for the cost of the programmer.

    Also, the Kwality LEDs we got from India look great. If we can ever figure out how to do I2C or SPI communication to the driver IC, I'll post a picture of them in operation.

    Stu
     
  20. Turbokeu

    Turbokeu Minimodder

    Joined:
    30 Jul 2002
    Posts:
    347
    Likes Received:
    2
    Hello Stu,
    Quite a long time no see...

    Yes, I'm quite dissapointed with the quality sound of the SAE800 (makes me think on my Commodore64...)
    I thought about low-cost MP3 players as a sound device but this option has low priority.

    Wow, you finally ordered from Kwality LEDs! (I didn't yet)
    Are you satisfied? (ordering, quality, shipping, delays)
    Please post pictures!
    What did you finally order?

    CD :)
     

Share This Page