• Power supply design

    FoxHood11/06/2024 at 18:26 0 comments

    The old approach was messy, based on flawed ideas like a 9V being a good choice and no way to automatically conserve energy. So, time to bring it up a notch.

    I originally considered a back-up capacitor/battery that can power logic while the leds only turn on when USB is plugged in, but with consumption expected to be around 7mA and the experience I’ve built up dealing with them: I’m opting for a Li-Ion cell instead than can power the entire clock for a while.

    Depending on the cell chosen it should be possible to power the clock for anywhere from ~4 days with a small 800mAh Pouch/14500 cell to ~18 days with a 3000mAh 18650 cell.

    Primer:

    Lithium-Ion batteries are a double-edged blade. They store significant amounts of energy, but this also renders them a little bit volatile. As in they can turn into an incendiary device if badly treated. The short list of rules are:

    • Do not let them overcharge (4.25v>)
    • Do not let them discharge too deeply (<3V)
    • Do not overload them beyond their ratings (depends on cell)

    Bit intimidating, but not that hard once you figure out how to manage power effectively. In this project I went for a three layered approach to handling power:  Charger, Protection and Power-Saving.

    Charger:

    A good charging IC can handle safely charging the battery, avoid overcharging it, provide protection to the charger’s power-source and power the load.

    I went for a TI BQ21040 charger in this implementation. I like this little charger as it is surprisingly flexible. It is designed largely for small electronics that need to be powered while charging or having its battery removed/swapped. If a NTC/Pull-down resistor is present the charger behaves like a regular charger with safety features such as a low-current threshold and Timers. But without a NTC/Resistor it enters a “Timer Termination Disable Mode” and just acts as a dumb 4.2V regulator. This is nice for projects like this as one can just ditch using a Li-Ion cell if they don’t want to use that.

    Current limit is set to ~450mA with termination threshold being 1/10th of that (45mA). This should keep the device well within the limits of even a USB 2.0 data port (max 5V/500mA). Going to also use a NTC for monitoring battery temp just in-case.

    Battery Protection:

    At too low voltage the device should shut-down as much as it possibly can to prevent the battery from discharging any further. For this I went for an MCP65R41T-1202 3uA Comparator with built-in Voltage reference that controls a cheap little SY6280 Current limiting load switch. If voltage drops below ~3V the comparator shuts down the load switch, reducing the power consumption of the device to <7uA when taking in account the Comparator(3uA), resistor divider(2uA), off-state switch(1uA) and the leakage of the charger IC(1uA). This would take almost a week to drain 1mAh of charge at this point.

    The current limiting ability of the load switch should also protect the cell from short-circuits past the switch.

    Power Saving:

    Complete shut-down should be the last resort. Before that a grace period of trying to preserve power while still letting the clock keep ticking would be nice. The simplest way to do so is by turning off the Leds once the battery voltage starts to drop below 3.5V which one can assume equals nearing end of charge. As the leds make up for crudely 95% of power consumption.

    Idea is to use the same comparator as for the battery protection, but set to trigger at <3.5V and turning off a run of the mill BSS128 NFET.

    Final set-up diagram:

    Chaining all the blocks together this is the resulting diagram:

    A bit of a chain and arguably took more work than the actual BCD logic. But should be a decent solution for this project. Not super refined, but good enough for a single PCB BCD clock.

  • Calculating Power draw

    FoxHood08/31/2024 at 00:07 0 comments

    If I want to figure out options in power, gotta know what the circuit in theory would draw in current. Which meant a lot of datasheet reading and some napkin calculations to get a rough idea..

    LOGIC Power Draw

    Logic power consumption tends to be based on activity like clock speed. For most of the logic. The clock-speed is anywhere between 2hz for frequency divider and ~0.00003hz. For these it is safe to assume their consumption is just the Quiscent Current and IO to other logic. Which is between ~4-10 uA

    The 4060 is a little costlier as this one will have a 32Khz clock as an input. There is no exact way to calculate the current, so instead I am noting down the listed maximum Icc of 80uA.

    Tallying up the 9 ICs and being a little conservative. I would expect a power draw around 150uA or 0.15mA. That is very cheap in power.

    Calculating LED power consumption

    Leds are complicated, they are constantly switching and there is a notable difference in efficiency between various types of Leds and various sizes. For starters I wanted to figure out how much is consumed on average.

    I mapped out how many leds are on for any Binary Coded Decimal and from this calculated how many leds are on on average per clock digit. Before finally combining them to get a total average number of leds on per day for a full display and a Peak:

    Decimal

    Binary

    0

    0

    Average with max 9

    1

    1

    1,5

    2

    1

    Average with max 5

    3

    2

    1,167

    4

    1

    Average with max 2

    5

    2

    0,667

    6

    2

    TOTAL(295959)

    7

    3

    7,5

    8

    1

    Peak on (132323)

    9

    2

    14

    Calculation indicates anywhere between 0 and 14 being active at any time with an average of ~7.5 for the entire clock. This average not accounting for how the last two digits are cut off by lasting 24 instead of 30. But it’s better to overestimate than underestimate. The most leds that can be on at the same time are 14.

    Choosing a led

    Leds are a nightmare to shop for as few leds are the same. Some are more efficient than others. Example: My OSRAM Yellow and red 2V leds are still quite bright at a mere 0.45mA. But the green leds need at least 1mA to be visible. This being mostly because of the material used to actually get the coloured light.

    To choose an efficient led one must look at current and millicandela. Most modern leds have a almost linear relationship between current and millicandela (mcd) output. A led with higher mcd compared to the current going in, has a greater efficiency and if you got a target mcd in mind you can estimate how much current you need to get to it.

    From some quick testing of my owned leds i find that i would need ~3-7mcd from any led to be visible. Depending on colours.

    Since I am building three of these clocks. I’m going to be planting a variety of different colours in 1206 format. One I will give Red,Yellow,Orange leds, the second Violet and the third I was thinking green. Kingbright got a nice set of options in their APT series and if calculations are correct, they can be powered at anywhere between 0.5 and 1mA. I put down rough estimates below.

    LED iF (mA) vF (nom) Typ MCD I (target) vT MCD
    LYR976 (yel) 20 2 280 0,5 1,8 7
    LSR976 (red) 20 2 180 0,5 1,7 4,5
    LGR971 (green) 20 2 45 1,5 1,6 3,375
    APTR3216-VFX (Violet) 20 3,3 100 0,5 2,6 2,5
    APT3216LVBC (blue) 2 2,6 24 0,5 2,5 6
    APT3216LZGCK (green) 2 2,65 100 0,1 2,4 5
    APT3216LSECK (red) 2 1,8 100 0,1 1,75 5

    Notable is how there are a few that seem to be insanely efficient. Something i will want to verify properly once i order them all.

    Small note on Forward Voltage

    The Forward Voltage drop of a diode is not a constant. It too depends a great deal on the current passing through it. The rated forward voltage is that at nominal current, but if you go below the rated current the forward voltage also starts to drop. For example most standard leds have a forward voltage either around the 2V or...

    Read more »

  • BCD Logic

    FoxHood08/20/2024 at 13:11 0 comments

    CLOCK Generation

    For Clock generation i'm using a common circuit with a 4060 Oscilator/14-stage ripple counter circuit. This chip can use a 32Khz Clock Crystal as a input and from this generate various frequencies on its output from 2048hz down to 2Hz.

    Its a simple, but effective. I employ a trimmer capacitor for on of the crystal leads and have the 2048Hz broken out to a pad. This should make it easier for me to calibrate the circuit for a more accurate clock signal with the help of my scope. Instead of just blindly hoping the accuracy isn't too bad as i did with the original.

    Digit Logic

    So idea is 6 digits being displayed in binary coded decimals.

    The logic for the minute and second counters is straightforward. When a counter hits the values of 10 (8+2) for the first digit or 6 (4+2), the counter is to be reset and the next counter is to be clocked. This means that for each of these digits i only need a single 4-bit counter and a 2-input AND gate. The first digit will also need an OR gate if i want to clock in settings properly from switches.

    One issue is that by using 4-bit counters i don't need more ICs than before (3x dual 4-bit, instead of 3x single 7bit), but also means i still gotta divide the frequency by 2hz anyway despite hoping not to have to do that. I'm going to use another dual-4bit. Its overkill, but it saves a special entry on the BOM.

    At the hours it gets a little trickier as it ends at 24. Requiring the first digit to be reset at not just 10, but also at 4 when the second digit is 2. This requires the use of a OR gate for the first digit's reset and a AND gate to go off at the 24 hour mark.

    In total we need 7 counters , 4 OR gates and 6 AND gates. Rounded up in ICs that means:   4x dual 4-bit Counters, 2x quad 2-input AND and 1x quad 2-input OR

    side-note: A neat little thing i noted is that with every digit the top two Most Significant Bits are mutually exclusive. So i can have them share a resistor.

    Switches:

    For a proper switch that doesn't bounce. One needs to filter the bouncing out and trigger with preferably some Hysteresis. A common way is to use RC filter that is quickly drained by a switch, connected to a inverted Schmitt trigger that provides the hysteresis and sends out a positive pulse on button press..

    With three buttons for each of the pairs of digits. 3 Inverting Schmitt triggers are needed. standard logic ICs come with 6 of them so a single unit suffices.

    IC Choice

    If you looked at the schematics you will notice that the new ICs aren't CD4000 series. They are 74HC series.

    These are the most popular incarnation of the logic series today. Boasting a very high speed, supply current in the micro-amps and very high input impedance. Pretty much all 4000 have pin-compatible counterparts within the 74HC series. Though it can take a moment to properly figure out the new number as while some ICs are just 75HC40** like the 4060. Many were renumbered.

    In the end the ICs needed for logic are:

    • 4x 74HC939 Dual 4-bit counters (4520 equivalent)
    • 1x 74HC32  Quad 2-input OR (4071)
    • 2x 74HC08  Quad 2-input AND (4081)
    • 1x 74HC4060 14-stage binary counter (4060).
    • 1x 74HC14  Hex Inverter Schmitt Triggers. (40106)

    9 ICs in total. Not too bad, though it may become a pain during layout.

  • Improvements to be made

    FoxHood08/09/2024 at 21:59 0 comments

    With the old dissected. Next step to brainstorm what to change for a new design

    BCD over Binary

    BCD Binary clocks are a bit more common than regular. But reading 0-9 decimals from 4-bits is way easier and faster than deciphering a number from 0-59 from 6-bits. Slightly more animated too.

    This will require twice the number of counters (3->6) and switching from three 4-input AND gates to six 2-input AND gates. Shouldn't be that difficult to route on a two layer board (.... i hope)

    Upgrade to 74HC series

    These should perform better than the old CD4000 series. With better output drive, faster response and less quiescent current.

    New Leds

    The old 5mm sucked. So the new design will be built using small SMT leds. Likely standard 0805, though those may require a little extra indication to be correctly seen as a specific value.

    Bring in the OR gates

    To keep any output from going against another output, Proper OR gates will be used. Could have used Diodes, but this is more apt for the 4000 series theme of the project.

    Schmitt triggered

    All mechanical inputs, be they switch or button will get proper debouncing via a RC filter with a Inverting Schmitt Trigger and by default be pulled-up. This should eliminate any and all bouncing.

    USB Powered

    In this day and age USB is used for powering nearly everything. This project being 5V and even the original using very little power (~40mA). It should be viable to power this from even a standard 500mA USB port. May add a single header for a Battery pack.

    Connector wise i'm going to us the purpose built Power-Only USB-C. Makes the most sense and i got myself a bunch of these USB4125 for stuff like this. They are cheap and so easy to solder. Never going back to Micro/Mini for power again!

    Backup/Rechargeable Battery/Cap?

    I liked my old clock having some persistance on data, being able to hold enough charge to keep going for about half a minute as i swapped thanks to the dinky supercap. BUT i should be able to do better than that. Which i will have to read into. Worst case scenario: The clock will be purely USB powered.

    PCB and Casing:

    The original was just a perf-board put inside a small picture frame. The new one will still be in a frame, albeit one purposefully 3D-Printed for it. Naturally I'll be going for a PCB design.

    The PCB i hope to get done on a black board with a transparant mask on which the copper is still visible. Like the OSH After Dark type. This does mean avoiding ground pour on the front to keep contrast. Should make for an interesting look that fits well with the Frame Housing.

  • Dissection of the original (G1)

    FoxHood08/09/2024 at 16:13 0 comments

    First stop is a dissection of my original and the many failures as the creation of a teenager who just saw a couple of schematics and bashed them together for a clock.

    After all this time. Still working. These old CMOS ICs are seemingly immortal. Same can't be said for stuff like the switches. They got rusty/dirty and will simply NOT stop bouncing. Like i had better result setting time by just poking at the contacts with a jumper wire....

    Electronics:

    Logic consisted out of a set of CD4000 ICs:

    • 1x 4060 outputting 2Hz from a 32khz clock crystal
    • 1x 4013 that was halving the 2hz into 1hz
    • 3x 4024 7-bit Binary counters
    • 2x 4082 Dual 4-input AND gates for hitting the CLK and MSR pins on hitting 60 on (3 were used)

    Inputs consisted of:

    • 2x tactile switches for advancing Minutes and Hours
    • 1x Dual DIP switch for enabling CLK from 4013 to 4024 and turning off the leds via the NPN
    • 1x Jumper for switching between Power going through 2 Diodes or the 7805.

    Output:

    • 16x Leds for indicating time in Binary.

    Power:

    • a 9V Battery Clip acted as the input
    • A pair of diodes OR a 7805 acted as a voltage drop
    • A 10uF can along with a pair of small super-caps handled smoothing and backup in-case of disconnect.

    Problems:

    1) 4013 is redundant

    while it seems logical on paper to divide the 2hz into 1hz. The exact same effect could have been achieved by just shifting the output of the first binary counter by one bit. As in binary theory: every bit essentially counts half as fast as the previous.

    2) CD4000 is underpowered/overloaded

    I didn't really knew how to read Datasheets at the time, so i never really looked at what the CD4000 could use and how much they could drive.

    Turns out these were designed to be powered by up to ~18V and while they can work with just a few volt, their ability to drive plummets to just a few milliamps. Measuring the voltages show that the 4024 outputs were getting pulled down to 3V, indicating that they were being overloaded by the leds

    3) The Leds SUCK

    Speaking of leds. These old 5mm leds with coloured plastic domes diffusers are terrible. They are great for like a quick indicator in a project on a breadboard, but they are incredibly inefficient and not something i would recommend using in an actual permanent design. Modern (SMT) leds are far more efficient, achieving surprising brightness with 1/10th of what the old leds needed. Its why these days i use a DIP sized 10 pin board with SMT leds and resistors on-board for quick indicators.

    4) There is no Debouncing

    The two buttons are tied direct to VCC with no form of filtering or even a Pull-down. So they had a tendency to bounce and cause repeated hits. Which only got worse over time to the point its just unusable.

    5) Power is a mess

    The power was just a 7805, some big caps i had laying around and a single dinky 10uF capacitor, with a pair of diodes as an alternative to the 7805. The power input was a 9V battery clip. I didn't know how low in capacity 9V batteries were at the time.

    I cannot quite recall why had the option of two diodes to drop the voltage. I think i had a Battery holder that held 4 AA batteries and had a 9V clip. Which wouldn't have worked with the 7805. That would make way more sense than a 9V as a Power supply. But even on that its just wasting a whole battery in voltage.

    And in the end the clock never went on battery power. It sat on a table for years powered from a old wall-wart which had one of those ends that had 4 different barrel jacks and a 9V clip cable at the same time.

    6) Wiring:

    A good looking front, hid a hideous backside with a ton of wires i can barely recall how i did it. Think it was about individually going from chip to chip.