• USB Power bank

    K.C. Lee04/30/2023 at 14:28 0 comments

    I got one of those Leed's USB power bank from my apartment building during a planned power outage.  It blew up when I tried to charge it.  There wasn't a whole lot I could reverse engineered from the dead parts. There was a 5-pin and a 6-pin chips and a bunch of passives. My understanding is that it uses an inverting buck boost converter for both charging and output as the VUSB pins of both the USB connectors are connected together.

    I finally got around to rebuild it from scratch this weekend with what I have on hand.  The parts I have were from aliexpress before the big chips shortages. I use a LTC4054 Li-ion charger chip and a MT3608 boost converter. 

    The charging rate is limited by heat dissipation on a tiny single sided PCB.  The output current is limited by the Schottky diode, inductor and battery discharge rate to about 1A (or slightly higher) or so matching to the original power bank. 

    Power bank schematic

    Q1 and the 1M pull down (R3) is used to invert the logic level of my switch to drive the Boost converter Enable pin.  The switch is also used to connect the R2 from the voltage divider feedback to the ground.  RGB LED is used as for Charging/Operating indicator.  

    The converter goes into a PFM (Pulse Frequency Modulation) power saving mode for low current loads.
    I used Green LED as they have the highest efficiency.  It is connected across the inductor to further reduce idle power.  It only get energized only when the boost converter is supplying current to the load.  The brightness is proportional to load.  Fancy!

    Your USB power bank might have a detection circuit that shuts itself off.  I could have used a low power microcontroller that wakes up every hundreds of milliseconds to detects voltage drop across the Schottky diode to turn on the converter.

    The idle current is about 200-300uA while maintaining a 5V output when the external USB device not drawing power.  That seems high, until you realize that it'll take thousands of hours before the battery is drained.    


    Power bank PCB

    My PCB is taped to the existing stripped down PCB.  I had to cut the VBUS trace between the USB connectors.  The blue wires are for the RGB LED.

    Populated PCB (I only have 1A/20V Schottky diode.)


    I modified the USB A connector to include a contact switch that is grounded when the USB A is plugged in.    This is used to enable the boost converter circuit.

    Modified connector to sense presence of USB plug

    Red LED = Charging

    Green LED = Operating.  Brightness proportional to load

    Yellow is when both are connected, but that doesn't usually happen as the connector spacing is too closed together.

    https://hw-by-design.blogspot.com/2023/04/usb-power-bank.html

  • Recent stuff

    K.C. Lee02/14/2023 at 21:38 0 comments

    Servo amplifier PCB replacement

    DIY Dell Dimension 3000 heatsink fan

    PSU case PCB mounts

    I made 3 ugly screw mounts on a PSU case using dremel, a drill and a few hardware.

    Solving a few power supply cold cases

    fixing a phone charger that went out regulation, LED driver that cause flickering, fixing a blown PSU, recapping a fruity wall wart.

    Optocouplers

    Basics, gotchas and how to make them go faster!

    STM8 - Generating 2 phase PWM

    How it can be generated on the STM8S003 using TIM1.  (Not covered in the reference manual.)

  • Intel heatsink mounting brackets on my AM4!

    K.C. Lee01/09/2022 at 01:01 0 comments

     I bought a Zalman tower heatsink for my old FM1 a long while ago.  It was overkill, but I bought it at a discount. AMD changed the mechanical spec for AM4 socket, so it couldn't be used.

    AM4 vs FM1/FM2/AM3

    Mounting kit for my old heatsink

    Zalman updated the rev. 2 of the heatsink by changing the backplate and the 2 pieces of springs for the AM4 with both sets of mounting holes.  

    New heatsink mounting kit

    They offer an AM4 upgrade kit for some of their other heatsinks for $11, but not my old model.  That's 1/2 the price of what I paid for and I'll be taking a gamble.  The old springs are too narrow.  I'll have a very hard time trying to drill it without good carbine drill bits and a drill press.  I am using the Intel mounting kit as it leaves just the right amount of space for the extra screws holes.

    I placed the heatsink on top of the AMD Wraith Spire.  It turns out that the fan mounting hole lines up with the Intel 775 mounting holes.  I took advantage of that for my alignments.

    Zalman heatsink (with Intel mounting kit) on top of Wraith Spire

    I use some scrap piece of "stiffener" 0.06" thick plated mild steel from a server card to make my adapter.  I measured off 54mm spacing for the backplate mounting hole.    The hole sizes are 9/64" and all the screws for this project are 6-32.

    I use cooking oil as cutting oil for drilling.  Once that's done, I lined it up to my set up and mark off the mounting holes for the springs.  I used the first mounting bracket as a template for the second piece.

    My mounting bracket

    I got a bit head of myself without thinking about how to equalize the spring tensions of the four corners. The original screws (metric) have short threads. I only have the full thread screws.  I made a wild guess and used some #8 nuts as thick washers that acts as a stop.

    Bottom view of the finished bracket
    Heatsink mounted using the backplate that came with the motherboard.

    The heatsink fits!

    How well does it works?  I ran P95 for stress testing the set up with a 3.7GHz Overclock and 1.275V undervoltage. The CPU junction temperature is at 75.3C with CPU at around 131W when all fans are running at 100%.  This is actually slightly better than the other heatsink I was using before for the same PC.

    Thermal result on my Ryzen 1700

    I decided to swap the old heatsink back and use this heatsink with my Ryzen 5800X PC.  I did some minor clean up to replace the screws with pop rivets to make more height clearance for the motherboard components.  This time I super glued the 4 nuts/spacers in place.  I also have to trim off the top left bracket as it was running a bit too close to the VRM capacitors on my new motherboard (not shown).


    Heatsink bracket with some minor clean up.

    I ran Cinebench as a way to warm up the thermal paste before removing old heatsink.  I used a 2 fans push-pill configuration trying to get the 5800X thermal under control.

    The Before picture with the old heatsink (Thermaltake Contac Silent 12)

    Here is the same test again with this heatsink also in a push-pull configuration.

    The After thermal with this heatsink (Zalman ENPS10X Optima).

    The Zalman is about 2.3C cooler and has a slight higher Cinebench R23 score (15225 vs 15133) as it has a slight higher (thermal throttle) frequency limit (4480MHz vs 4475MHz).

    Thermaltake probably sourced a commodity heatsink that have the cutouts that supports a rotated orientation not used here.The bottom part (5mm or so) of the fan is not fully covered by the heatsink allowing for  some airflow under the heatsink.  For some reasons, they added fins on the baseplate perpendicular (instead of parallel) to the airflow. This messed up the airflow and collects dust.  They also did not include a pair of clips for adding a second fan.

    Zalman fan has a higher top RPM and interesting enough they didn't mill the heatpipe...

    Read more »

  • Attack of the blinking dimming flashlight

    K.C. Lee12/29/2021 at 20:58 0 comments

    I would never have thought that the blinking dimming light movie tropes is being kept alive by poorly made flashlight clicky switches in my flashlight mod.

    I managed to extract the mechanism that was pressed fitted into the end cap of the flashlight.  They use some iron strips as part of the contact.  There are 2 such contacts in series and they gets even worse as I use the switch for the boost supply with about 3X currents.

    I cut2 pieces of gold plated (15um) pin from a 2mm connector.

    I soldered them onto the contacts.  The contacts needed to be bent flat as the pins adds extra thickness.

    There is a metal piece that looks like a top in the previous picture.  I had to bent the circular part down to make more clearance for the pins. I reassembled the switch and soldered a short piece of bare stranded wires.  This wire helps to make better contact to the side wall of the end cap.

    Unfortunately the plastic they used is too soft and I do not have the right jig to press it back in place.  If there were a time I wish I had a 3D printer, this would be it.

    Anyways this fix got rid of the flimsy flickers and the light a lot brighter.

  • Flashlight 3xAAA replacement

    K.C. Lee12/23/2021 at 23:43 0 comments

    I got a flashlight as the first ever kind gesture from my apartment management for the most recent schedule 24+hours maintenance power shutoff. It has a very nice reflector for a square LED and a smaller chip inside that controls the 3 operating modes. 

    Off course I had to open it up right away.  It uses 3AAA on the usual battery holders for cheap flashlights.  I smell trouble or an opportunity for some corrective active.  I am not fond of using odd numbers of AAA batteries as I have been using rechargeable since NiCd days.  I don't know if they use a constant current driver, so could be trouble for 3 fully charged NiMH (1.4V x 3 = 4.2V) with low internal resistance.

    I used the parts from a 5V booster board I bought from the usual places, but modified the feedback divider for 3V which is just bright enough to drive LED, but low enough to not go into thermal run away.


    U1 has the same pin out as the unknown part used on the board.

    As my replacement board has 3 contacts - 3V and 2 GND, I had to move the battery off centered to avoid shorting the 3V output to the front of the PCB.  

    I used easily soldered and bent metal strips  to form a battery guide and the hinged -ve terminal.  They are used to crimp the end of plastic mesh for store bought onions and garlic.  

    My battery terminal help to make better connection between the offset battery and the spring loaded terminal the of the flashlight cap to the right side of the picture below.

    It also acts as a pull tab for the PCB assembly when it is time for replacing battery.

  • DIY Amplifier collection

    K.C. Lee12/23/2021 at 15:18 0 comments

    Here are some of my DIY amplifier collections:

    I built one of these back in my school days out of a pair of TI/National Semiconductor's Class A-B LM1875 20-W Audio Power Amplifier. Build straight out of their application circuits. I mounted in 2 of these amplifier into a 60W heatsink.

    I recapped, cleaned up the layout and mounted it with a Transformer (33V CT 1A), rectifiers (200V/3A) and filter caps (1000uF x 4) onto a piece of board from a clementine box.  It served as my TV/Computer amplifier for about a year.

    It was from the days of good old analog design with honest specs.  Note their 20W is at the lowest THD.  

    They have excellent PSSR (Power Supply Rejection Ratio) around 95dB at 120Hz.  I can simply run it off a full wave rectifier from a transformer.  They aren't too efficient, so my choice of 60W heatsink was appropriate for continuous operation of 2 amplifier at full power.

    I later built a few of the 60W module out of a pair of TI/National Semiconductor LM3886 68W Class-AB amplifier.  (I didn't have a LC meter, so the inductance value on that coil as way too low.)

    Sadly at that point I gave into craze and bought myself a  surround sound receiver. I sworn to rip out and replace the "discrete" amplifier at the expiration date of the warranty, but didn't follow through.

    They are probably one of the better if not the best chip amplifier that a lot of the DIY amplifiers designs are based on.

    However you would want to use 4ohms speakers to take advantage for the full rated power at low distortion.  

    Recently, I started playing around with those Class D modules from China to connect to my computer surround sound analog output.  I tried the $0.30 PAM8403 modules but there was a lot of noise for my rear speaker probably due to the parasitic of the longer cables.  I went for the PAM8610 "10W" modules.  The first one was bad as it took too much design freedom.  

    I then read the reviews and moved on to the "better" version of the module that did follow the reference design. I wish they break out the volume control and the balanced input.

    I mounted 3 of those modules onto a extruded heatsink from an old monitor.  The heatsink is probably good for up to 10W. I covered area on the bare aluminium heatsink  with "Kapton" tape where I have wire connections.  I used pieces of thermal conductive tape on the thermal vias under the chip to carry heat to the heat sink.  The heatsink tape I used was electrically conductive, so the heatsink and the metal case was grounded because of that.

    I ran a power bus with a 1000uF electrolytic cap and a few 1uF ceramic caps near each of the power input of the amplifier blocks.  There is a ferrite bead for each amplifiers to block the high frequency noise injecting back to the VCC bus rail. I didn't have the same layout for the amplifier at the bottom and it was a bit noisier.  The layout in the picture below fixed that.

    The heatsink was mounted at the opposite to the messy wiring which helps a bit to balance the drag from the wires.

    Here is why i used air quotes on "10W" as I am using a 9V supply, so I would be happy to get 5W out of mine.


    The PSRR isn't as good as my other amplifiers.  I actually can hear 60Hz hums using AC transform + rectifier.  I ended up using a good quality 9V 40W brick, so 5W per channel was the best I can hope for anyway.

    Either I have insanely good ears for the hiss or the -90dB isn't quite feasible without a lot of extra work.  I can't hear any noise from my 20W Class A-B.

    It is not a perfect set up, but it is good enough for me for now.

  • Ghetto TV speakers

    K.C. Lee12/22/2021 at 17:13 0 comments

    It is kind of sad for what pass for speaker in sub $100 LCD TV  these days when I can hack a better one from mostly recycled junk I have.  It is not much to look at as most of the parts are already paid for one way or the other. i.e. recycled

    Ironically the speakers I used are from my old CRT TV back in the days before form over function.  I cut up one old FedEx shipping box as they are a bit more sturdy than regular cardboard boxes.  If I only had cans of epoxy and fiber glass cloth around, I would try to build-up a more rigid shell.

    I use old ball point pen to create creases lines for folding without damaging the cardboard.  Just to humor myself, I stuff the box reusing some of those foam sheet from usual chinese orders.  A few self tapping screws are used to loosely mount the speakers.

    A $0.30 PAM8403 "3W" class D amplifier is used to power these speakers.  It runs off my TV USB port.

    I have modded the amplifier by reducing the gain with the values from the datasheet as they weren't built correctly.  I think they were using 10K.

    I also added a 5V power supply supervisor circuit to pull the /Mute to reduce the popping as TV powers on/off its USB.  I needed a few hundred millseconds on mine.

    As usual, read the datasheet especially for cheap questionably modules .

  • NiMH Battery backup

    K.C. Lee12/22/2021 at 16:22 0 comments

    Battery compartment of my digital clock project (Caller ID case)

    The power in my apartment used to be very reliable, but things have deteriorated in the last 10 years or so.  I have experienced serval power outage and some up to 6-7 days.

    The Supercap I have is only good for a few minutes as the STM8 clock uses around 2mA to keep its firmware RTC working at the minimal state.  It requires a minimum of 3V, so Li coin cells are out. I don't quite trust Li-ion batteries enough to be trickle charge 24/7. 

    I use some old NiMH batteries.  They lost most of their capacity, but they are still good for a few mA load. They are sitting in a compartment at the bottom of the clock, so gravity would protect the electronics from any leaks.

    Here is a battery backup for the digital clock. +5V is the power source (e.g. USB) that can go away and +UB is the backup rail.


    From Reddit: Can you replace a Ni-Cd backup battery by NiMH in a Tandy TRS-80 model 100?

    So, NiCd's are super easy to charge. You just throw current into them at about 0.1C, and once they're full, they turn the rest into heat. Harmlessly, and forever. You can just slowly overcharge NiCd and it's fine with that. Lots of old two-way battery cradles did just that, and it's why the radios were always warm when you picked them up. 
    Do that to NiMH, and they "vent". NiMH needs charge termination, or needs to be floated at a lower voltage so it never gets quite "full". Right around 1.35 volts per cell seems happy.

    You'll notice it a bit funny as theLTC4054ES5 is a Li-ion charger chip and I am using it for NiMH. It turns out that 3 NiMH has just around the same charge voltage as Li-ion battery.  (The minimum charging current for this chip is 50mA.)

    The -ES5 part has a recharge threshold of -150mV, so it would starts charging the batteries when they drop to 1.35V each.  It charges the cells at 50mA to about 1.4V and stop charging when the charge current is below 5mA.  

    I use a P-MOSFET (Q1) as a switch for the back up rail to reduce the voltage drop vs a Schottky diode.

    This has been working for close to half a year now without any leaks.  It also survived a 24+ hour of back out with plenty of  juice left.

  • Boring PC case mod

    K.C. Lee12/22/2021 at 16:17 0 comments

    I bought a new CPU and a motherboard from a Black Friday sales.  It is like a reverse hermit crabs upgrade with each of  my PC downsize to an older case.  The old $20 thrift store P4 Dell lost in the musical chair to my older FM1 PC.  It has PCI, PCIe, Parallel, Serial port (header) and no Pesky Security Processor (PSP).

    You may think that stuffing a mini-ATX board into a mini-ATX case is straight forward, but this isn't the case here.

    One of the most annoying thing about the Dell Dimension 3000 is the missing Reset button.  The Dell case has a removable cover and uses push rods for the buttons and light pipes for the LED.  Their push rods are mounted from behind the front cover.  Instead of a long dangling wire for a quick and dirty mod,  I have decided to follow the flow as it is a bit easier for maintenance.

    It ain't pretty, but it does the job

    I used a ball point pen for the push rod.  It was one of those freebies I got from either a trade show or a vendor.  It has just the right length and right push button.  I used some hot glue to attach it to the middle piece behind the front case panel.  I extended the other end with an empty pen cartridge cut to the right length for the push button.  I used the mounted ballpoint pen part as a guide for my drill bit for the metal panel and the front cover.

    The diameter of this cartridge is a loose fit over the narrow part of the push button.


    Back side of the panel

    I use a (grey) PCV insulation from a power cord on the transparent tubing to stop the push rod from falling out the front. 

    I used a nibbler to cut out a slot for the panel mount Reset switch from an old PC.  I could have solder a push button onto a small PCB and mount it to the case with a spacer.

    I was going to use the existing hole below it, but it was a bit too closed to the On/Off button mechanism.  It was probably for an optional LED illuminating the On/Off switch.

    The new Reset button in the full depressed state.

    Dell uses a swing out removable vertically mounting bracket for the 3.5" HDD.  I made a mounting bracket for 2.5" SSD with 100% recycled DIMM PCB.  I used a nibbling tool to cut the slot that was needed to clear the bracket.  The bracket is mounted to the HDD screw holes.

    I have a left over AMD Ryzen 7 1700 Wraith Spire Coolers.  Too bad they change the mounting brackets in the AM4 socket the the old FM1 days, but doesn't stopped me from replacing the fan on the old stock cooler.   The larger fan is quiet with a lot more air flow.

    I was going to make a two piece mounting bracket as an adapter for the larger fan, but it was too much work.  It turns out that all I needed was 4 short strips of old FR4 PCB.  They are mounted diagonally with 4 screw to the original heatsink mounting holes and another 4 to the larger fan.  I offset the fan so that it would clear the heatsink latch mechanism.


    FR4 strips mounted to the heatsink

    The fan is then mounted with 4 screws onto the FR4 strips.



    This is what the internals looks like when the AMD logo is lit up.

  • ghetto captured nut - how I made a mount for the gyrostick

    K.C. Lee05/13/2021 at 18:56 0 comments

    Just when you needed a captured nut...  

    need: FR4 PCB with undersized hole, small file, C clamp

    • File the hole as close to the right shape for the nut.  The mismatched FR4 hole will be expanded and provide grip.
    • Put it in a C-clamp or a vise or hammer
    • Apply extreme pressure
    • File/trim the FR4.  

    You get a captured nut!  The FR4 provides a large surface area to be superglued behind a screw hole.

    Here is what's what it is used for in a more refined manner.  This is my 2nd try with the "captured nut". I cut a small piece of plexiglass with a saw blade attached to a Dremel tool.  I used a hand drill to drilled 2 holes - one for the screw and a larger one the nut.

    Note the edge of the plexiglass is flush with the module and this helps to prevent the PCB assembly from spinning.

    The plexiglass is then superglued to the captured nut PCB to form a mount.  I screwed in the PCB assembly to show how things fitted together. Notice the white stress points on the FR4 at the corner of the nut.  That's what holding the nut in place (along with the superglue).  FR4 can handle stress a lot better than plexiglass.  The thickness is just right for the M3 screw and clears the PCB assembly.  Luck or math? :)

    The mount can then be superglued to the base of the controller.  Mine has a label area.

    The inside of the game controller case has a Li-ion batter pack pushed against it, so it is not safe to simply drill a hole to mount a standoff.  Like they said "look before you drill!"

    Here is what it looks like with everything in place.  The PCB components are protected by the back side.  The PCB assembly can be easily removed for easy access.