1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

K8LH Novelty Single Chip Clock

Discussion in 'Electronic Projects' started by Mike - K8LH, Aug 8, 2008.

Thread Status:
Not open for further replies.
  1. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Hi Guys,

    After designing this single chip Charlieplexed 24 hour Clock/Calendar/Timer well over a year ago, I finally found some time to prototype it and it seems to work pretty well.

    [​IMG]

    The Charlieplexed display uses direct I/O drive on the segment lines and this limits 'peak' and 'average' current and display brightness. I'm using relatively efficient displays but the display is by no means "full brightness".

    Software was written using the free/Lite version of Sourceboost BoostC.

    I'm using a four push button "diamond" configuration to control everything. The buttons are fully debounced (both press and release cycles) and there's a short switch press beep through the piezo speaker for positive feedback. The Left button is used to toggle between "display" mode and "set" mode. The <up arrow>, <down arrow>, and <right arrow> buttons perform different tasks depending on whether you're in "display" mode or "set" mode.

    In "display" mode, pressing the <up arrow> or <down arrow> buttons cycles the display between the 'Clock', 'Timer', 'Calendar, or 'Display Off'. Use the <right arrow> button to toggle a function associated with the current display on or off. For example, pushing the <right arrow> button while displaying the 'Clock' will toggle the display between local time and UTC. Pushing the <right arrow> while displaying the 'Timer' will toggle the Timer on and off (the red timer LED indicates Timer on/off status). Currently there is no <right arrow> function for the Calendar display.

    Press the "set" button to enter "set" mode to edit the current display data (Clock, Timer, or Calendar). The left most display group (Hours/Months) will flash at a 2 Hz rate. Use the <up arrow> and <down arrow> buttons to increment or decrement the display group. The group values will roll over from upper limit to lower limit, or vice versa. Use the <right arrow> button to move to the next display group to the right. When you're at the right most display group, pressing <right arrow> again will move you back to the left most hours/months display group. When finished editing press the "set" button to copy the edited data back to the source (Clock, Timer, or Calendar).

    Check for source code updates here; LED_Clock.c

    The displays are non-multiplexed common anode type. The NPN transistors are 2N3904. The NPN base resistors are missing on this prototype but should be between 500 and 1000 ohms.

    Regards, Mike
     

    Attached Files:

    Last edited: Aug 12, 2008
    • Like Like x 2
  2. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    Do you really need the base resistors? At nominal voltages MCU pins drive LEDs pretty well.
     
  3. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Are you confusing the NPN base resistors with something else?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. BeeBop

    BeeBop Active Member

    Joined:
    Dec 22, 2005
    Messages:
    1,281
    Likes:
    23
    Location:
    Vancouver Canada

    Mike, this sets the standard for what a project should look like. Nicely done, nicely documented, with all of the parts in place.

    Well done! :D :D :D
     
  6. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    I'm pleased with how well the project turned out but I can't say that I presented it or documented it very well (not a proper schematic, no BOM, etc.).

    If I had time I would try to do a more professional presentation like Bill (Blueroom) does in his manuals.

    Mike
     
    Last edited: Aug 9, 2008
  7. sananh

    sananh New Member

    Joined:
    Oct 13, 2007
    Messages:
    6
    Likes:
    0
    Good looking Clock

    Hi all.

    Digital clock looking good, I would like to build one just for fun. Could someone look at my drawing and tell me if anything is missing. Also please tell me how to connect timer relay, I'm not sure how to connect it. Disregard arrow keypad I forgot to put in my drawing.

    Below are parts that I'm planning on using. If someone has part# for seven-seg display please share. Thanks

    Quantity Description
    1 16F88
    7 BJT_NPN, 2N3904
    6 SEVEN_SEG_DECIMAL_COM_A_GREEN
    5 LED_green
    1 CRYSTAL, 16MHz
    1 Small speaker
    1 RELAY, 9001-05
    2 22pf caps
    1 680 omhs resistor
     

    Attached Files:

  8. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Hi sananh,

    Your schematic is incorrect. Charlieplexed or N(N-1) type multiplexing is very different from standard multiplexing. Please see attached drawing below. Yes I know it looks like a wiring nightmare (grin)...

    As for RA2 relay control output, that is up to you. RA2 is an active high output which can drive an NPN or N-channel MOSFET transistor as a sinking driver to activate a 5v or 12v relay. You wire relay output pins in series with AC or DC voltage source and the load. !!! Please be careful !!!

    Best wishes. Mike
     

    Attached Files:

    Last edited: Aug 26, 2008
  9. sananh

    sananh New Member

    Joined:
    Oct 13, 2007
    Messages:
    6
    Likes:
    0
    My was waaay off. Thanks for a schematic, I'll give a try. If I run into a problem I will post.
     
  10. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I am a little confused. The schematic shows base current limiting resistors on the 2N2222A transistors that power CA (common annode) digit pins. The wired board does not.

    My 7 seg displays are too dim with base current limiting resistor of 100R. The base current is 3.6mA without a resistor. Do you think it is OK to run without the resistors or should I start looking at even smaller values? They are so dim you have to view them in a room with the lights off with a 1K base resistor.

    I am thinking the since the pic can easily handle the 3.6mA there is no downside to not using resistors here.

    EDIT: The value of 3.6 mA was taken with the display muxtiplexing. That means the current while it is flowing is about 3.6*6 or 21.6mA which is much closer to the 25mA max. I need to do an actual measurement but will wait till morning. But I am less comfortable about not using a resistor. Back to bed :)

    These are displays are surplus units from electronic goldmine and I can not find a real datasheet on them. I have found this
     
    Last edited: Aug 25, 2008
  11. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Hi 3v0,

    I'm not using base resistors on the 2N3904 transistors or current limiting resistors on the LED segments on this prototype.

    The 0.4 inch Fairchild displays I'm using provide decent brightness in a well lighted room but you can tell they're not full brightness. Some 0.56 inch Fairchild displays that I tried were noticeably dimmer. So, getting good results with this novelty one chip design depends a lot on your choice of displays.

    I would be happy to post a much better 2 chip Clock design, if anyone is interested. It uses standard multiplexed display wiring and provides full brightness with PWM brightness control using an 8 bit serial-to-parallel sinking driver IC like the TPIC6C595, MIC5821, or A6821 (or an 8 bit serial-to-parallel constant current sinking driver like the A6275).

    Mike
     

    Attached Files:

  12. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Thanks mike. I was not actualy building this clock:eek: But it looked like a good context for asking the question.
     
  13. Space Varmint

    Space Varmint New Member

    Joined:
    Jul 10, 2008
    Messages:
    1,487
    Likes:
    11
    Location:
    Tucker GA...USA
    This one is software adjustable in case it runs slightly fast or slow.
     

    Attached Files:

  14. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,085
    Likes:
    327
    Location:
    Brisbane Australia
    What a horrible piece of code and it uses Timer0. If you do a search Mike (the OP) posted a very good method to adjust for crystal inaccuracies in software.

    Mike.
     
  15. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Personally I'm one of those types who tries to match the crystal frequency to the task at hand. Using the generic 4MHz or multiples thereof for everything always baffled me, after all crystals are about the same price and there are many common frequencies available. 19.6608MHz is a handy for both RTC & UART stuff.
     
  16. wy6k

    wy6k New Member

    Joined:
    Aug 30, 2008
    Messages:
    12
    Likes:
    0
    Location:
    Charleston, SC
    Just use current limiting resistors on the segment lines and connect the transistor collectors to 12 volts and you can have whatever brightness you want.

    If you want to keep it a one power supply project, use 12 volts as the power supply and generate the 5v with a voltage regulator (7805).

    Mike
     
  17. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Hi Mike, WY6K,

    Keeping in mind the 5v PIC pins, an NPN/PNP pair or N-FET/P-FET pair for the high side drivers does indeed work well with traditional multiplexed displays but it's a bit problematic for Charlieplexed displays.

    Regards, Mike, K8LH
     
  18. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,641
    Likes:
    109
    Location:
    Michigan, USA
    Unfortunately, that's about all that crystal frequency is good for (grin).

    Using wierd crystal frequencies always baffled me but if you can show me how to accomplish any operation in exact 1 usec increments using one of those crystal frequencies then you'll have a convert (grin)...
     
  19. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,085
    Likes:
    327
    Location:
    Brisbane Australia
    I can see how a 19.6608MHz crystal is good for serial communications but how is it any better for a real time clock? :confused:

    Mike.
     
    Last edited: Sep 10, 2008
  20. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,295
    Likes:
    647
    Location:
    Derbyshire, UK
    I can't see how it's any better for serial either, it works 100% perfectly with a 20MHz or 4MHz crystal - so how does getting an exact frequency match give any improvement?.
     
  21. wy6k

    wy6k New Member

    Joined:
    Aug 30, 2008
    Messages:
    12
    Likes:
    0
    Location:
    Charleston, SC
    Ahhh. I see that now. In that case, you need another set of column transistors and invert the logic on the n-1 line? (I'm not really familiar with Charlieplexing, but I think I get it). MPU output drives base of NPN which pulls down the base of the PNP with it's emitter connected to 12 volts. Right?
     
Thread Status:
Not open for further replies.

Share This Page