Wednesday, August 23, 2023

Finding the Shorted Component on a Printed Circuit Board

Once in a while, you find yourself staring at a printed circuit board with a shorted power rail.  It could be any of the components, capacitors, diodes, ICs.  Sometimes, you have a hunch which component might be bad and remove that component to see if the short goes away.  But you might take off one component after another, still could not located the bad component.  

One way to quickly identify the faulty component is to apply current to the shorted rail and look for the hot part.    You may have to apply a few amps of current, but not too much current to damage the traces.  Sometimes you can actually see a component starting to smoke; other times, you have to feel the heat.  If you have a thermal imager, you can easily see the hot spot.

Sunday, August 20, 2023

A Ni-MH Battery Charger by Panasonic

 Here we'll look at Panasonic Ni-MH battery charger, rated as 0.3A for AA and 0.15A for AAA.  It can accommodate 1-4 AA or AAA cells.


The AC to DC conversion uses SC1142D1 by Power Integrations.  No datasheet is available, but an application schematic is found, which gives the idea how the circuit might work.  A third transformer coil provides the feedback; no opto-coupler is used.

A slot in the PCB increases the creepage distance from the AC primary.

The charging control is based on a microcontroller EM78P418N by ELAN Microelectronics, a Taiwanese company.  EM78xxx is called  "a RISC-like single chip microcontroller" by the manufacturer.  But its instruction set is akin to PIC or 8051.  It has an internal oscillator of 4MHz.

Pulse charging method is used:  power is applied on and off and open-circuit voltage is measured when the power is off.


Monday, May 1, 2023

Failure of a 5V AC Adapter

The adapter is for an Android TV box, input 100-240VAC 50/60Hz 0.3A, output 5V 2A.  The item was in use for about four years.

There is no screw; there is a seam, but it is glue together.  So we cut it open.  There is no obvious sign of damage.  The resistance across the output terminals is about 22Ω.  One of the output capacitors, 1000uF/10V, seems to bulge a little on the top.  But after removing this capacitor, the resistance remain the same.  It is eventually found that the diode D4 is the culprit; this diode is across the output, so it is probably a 5.6V Zener.  The capacitor is also out of spec, measured only 28uF with 30Ω ESR.   The capacitor is 8mm diameter and 14mm height rated for -40 to 105C, claiming low ESR.  The capacitors of  this spec is not common, probably among the smallest for this capacitance and voltage rating.  Then the possible cause of the failure is the Zener damaged by the output over-voltage, maybe because of the output capacitor failure.


There is no fuse, only a 10Ω resistor before the bridge rectifier.  In case of a short, this resistor will open.  There is a slot next to the resistor for creepage.  The smoothing capacitor is 10uF/400V.  The bootstrap resistor is 220KΩ.

The controller IC is DP3733E made by Developer Microelectronics (深圳市德普微电子有限公司) and the datasheet is readily available online (although the company website has very little technical information).  According to the data code, it is made in March 2019.   The circuitry is close to the typical application circuit shown on the datasheet: a flyback controller with primary side regulation.  The voltage feedback resistor divider 13KΩ and 2.1KΩ and a pair of parallel 1.30Ω resistors for current sensing.  The difference is that there is a output LC filter but no input Pi filter.  DP3733E features a high voltage BJT switch and a technique of quasi-resonant switching.  The output voltage is sensed through an auxiliary transformer winding, no opto-coupler.  After the BJT is turned off, the secondary starts to conduct.  The output voltage is sensed as the current drops to zero on the auxiliary winding, which also starts to oscillate.  The BJT is turned on when the valley of the oscillation is detected (it is a little more sophisticated than this as it also takes into account of the loading).   This is the secondary waveform.

The flyback transformer inductances measured in circuit are Ls = 6.3uH, Lp=1.06mH, La=37uH.  Perhaps, 13:1 turn ratio between the primary and the secondary and 1:2.5 between the secondary and the auxiliary.

At 5Ω load, the RMS voltage over the 10Ω is 0.92V.  The efficiency is 45%.  

Wednesday, April 19, 2023

KiCad 7 vs Altium 22

 Both software evolves fast, so we compare the specific versions.

Altium is a feature rich package, exceeding KiCad in all capabilities.  However, KiCad is free and open-source and supported on multiple OSes, Windows, Linux, Mac OS.  It is very nice to be able to  work on the design on both Windows and Linux.  There is no license to mess with and not to have to worry about lose connection to the license server.

Altium still crashes quite frequently.  KiCad is getting more stable, but I have not tried with large design.  I suspect it may not handle large designs well.  

First we look at the importing Altium files into KiCad, which gives an indication of the equivalency in the features.   It does not seem to be an option to import the project directly (as there are for EAGLE and CADSTAR project).  We start by importing the PCB file in the PCB editor and a KiCad project is created.  Then we import the schematics in the schematic editor.  The importer seems doing a reasonable good job.  A hierarchical design can be imported all at once, but  for a flat design, sheets have to be imported one by one and sheet blocks have to be added.  But this leads to discrepancies with the imported PCB which uses flat netlist, and not all can be resolved by relinking.  Netclass is imported into the PCB, but the netclass labels are not shown the schematics. Harness is not handled correctly.  Text links are not imported,  Off Sheet Connectors are imported to global power net symbols, which does work correctly, but they are more propriate as global labels., Text locations are not always show correctly, because the justification is not applied correctly.  No compiler mask.  Solid region is mapped to polygon but it cannot be assigned a net.  There is no line arrow mode.  Ellipse drawing object is not supported.  Embedded bitmap is not imported.  Altium nets are flatten in the PCB, but KiCad maintains hierarchical net names. Stackup information is not imported, such as layer thickness, dielectric constant.  Polygon cutout turns into a keepout area.  Some multi-part symbols are not imported correctly.  Overall it seems to do a much better job with the PCB documents than schematics.  Schematic editor does not allow reference designator to contain space, although the netlist seems to allow it, just cannot manually edit it.

 KiCad schematic origin is at the upper left corner.  KiCad's coordinates y-axis points downwards and Altium is the opposite.  Altium uses parameters, KiCad has Text Variables.

KiCad's symbol and footprint libraries are very extensive.  And SnapEDA, Ultralibrarian can support KiCad and Altium.  Altium has BOM support with distributors, which can get inventory information.

KiCad has no specific support for rigid flex design, like specifying multiple stackups.   But rigid flex PCB can certainly be design using KiCad; some footprints may have to be modified to be placed on the inner layers that are used for flex section.

In KiCad, whether to tent via is a global option, actually only in effect when generating Gerber files.  So it can be applied to selected vias. The 3D viewer seems to ignore the option, only show tented vias.

KiCad lacks something like Altium's Navigator.  Symbol Field Table can somewhat remedy this by browsing the components, but no netlist.

Altium has more extensive support for design rules, which is vital for large complex designs. 

Altium Note is collapsible.

KiCad use Python as the script language for plugins.  Interactive HTML BOM (ibom) plugin is very nice.

KiCad themal relief properties are settable for each pad.

KiCad has only one type of copper area, zone. Altium has fill, solid regsion, polygon pour.  KiCad does not have real plan layer; the plane layer has to be created with zone.

Altium is much more capable of editing multiple selected objects.  This is an important feature that a good PCB layout tool must have.  KiCad property manage can do some of it, but lack a similar feature in schematic editor (Edit Symbol Field edit can edit multiple symbol field.).   

Altium has more ways to select, Find Similar is useful.  KiCad has selection filter for PCB, but not for schematic.

KiCad cannot open multiple sheets at the same time, no tabbed view like Altium.  One way to get around it is to open another sheet separately with  another instance of Schematic Editor

KiCad has bus similar to harness.  KiCad bus can define fields beyond simple array.

KiCad requires hierarchical bocks for multiple sheets.  It is not necessary a bad thing, but sometimes you just want to draw one circuit over over multiple pages.

KiCad does not have multichannel support.  Altium has the concept of room, which aids multichannel layout.

Crossing probing works, the components are selected, but the nets and pads have to use net highlighter. 

Search Panel shows Footprints, Zones, Nets and Text, but the list cannot be sorted.  When clicked on, the item is highlighted, but not centered and zoomed.  It does center and zoom on the schematics.

There is no integrated library in KiCad, which is not much an issue.  The symbols can have default  footprints, but cannot be overridden, which I think is preferable.

KiCad does not have a way to create a simple 3D body; but creating mechanical models are better done in MCAD anyway.  The integration between KiCad and FreeCAD through KiCadStepup is good enough.

For interactive routing, KiCad supports  Highlight collisions, Shove, Walk around; more or less matching Altium's.  Altium also has a HugNPush mode and Altium seems faster especially for large designs.

Altium has more copper zone editing features.  Altium can shelve copper pours.  KiCad can display copper zone in filled or outline mode.  KiCad can control thermal relief on individual pad settings.  Altium does it with design rules.

No revision control integration.

No support for curve routing, but Fillet Track can round corners.  There is also a plugin to round tracks.

No support for auto routing, but there is the freerouting plugin.

Altium includes field solver integrated in the stackup to calculate controlled impedance.  KiCad's Calculator Tools can estimate some transmission line parameters.

KiCad may not be able to replace Altium for professional work, but it can certainly handle most of the PCB designs and it will keep Altium on their toes, which is a good thing.


Thursday, April 6, 2023

Building KiCad from Source

KiCad has become increasingly capable of taking on large PCB designs.  It's good to take a look at the source code.  We'll try to the build on Ubuntu 20.04.  The latest version is 7; and the work on version 8 has begun.  The source code is cloned, `git clone --filter=blob:none https://gitlab.com/kicad/code/kicad.git`; we use the filter to keep the repo small, still it is almost 400MB. 

The next is to install all the necessary libraries, wxWidgets, Boost C++, GLEW, ZLib, GLM, GLUT, Cario 2D Graphics, OpenCascade, ngspice, curl, wxpython

libbz2-dev, libcairo2-dev, libglu1-mesa-dev,  libgl1-mesa-dev, libglew-dev, libx11-dev, libwxgtk3.2-dev, mesa-common-dev,  libssl-dev, python3-dev,  python3-wxgtk4.0, libboost-all-dev, libglm-dev, libcurl4-openssl-dev,  libgtk-3-dev, ngspice-dev, libngspice0-dev, libocct-modeling-algorithms-dev, libocct-modeling-data-dev, libocct-data-exchange-dev, libocct-visualization-dev, libocct-foundation-dev, libocct-ocaf-dev, unixodbc-dev, zlib1g-dev

The KiCad 7 requires  wxwidget 3.2, which is not in the Ubuntu repositories.  We have to get an unofficial release from https://repos.codelite.org/wx3.2.0/ubuntu/.  And wxpython version 4.0 has to be installed and built against wxwidget 3.2.

And some tools, 

cmake, doxygen, build-essential, pkg-config, source-highlight, cmake-curses-gui, debhelper, swig4.0, dblatex, po4a, asciidoc, shared-mime-info

To make the build faster, we'll use ninja as the build system and lld as the loader.

cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=/opt/kicad -DCMAKE_CXX_FLAGS=-fuse-ld=lld ../../

Then kick off the build with ninja.  The build process took a hour and half on my computer.   The build files total 11GB.   The installed files are almost 3GB, without symbol and footprint libraries which are on a separate repository.  The files are large because we build with debugging info.  

To make a smaller release build, 

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DKICAD_BUILD_QA_TESTS=OFF -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=/opt/kicad -DCMAKE_CXX_FLAGS=-fuse-ld=lld ../../

This only takes about half an hour, with the build files total 600MB and the installed files less than 300MB.  The executables are much smaller in size.

Tuesday, February 21, 2023

Lead Acid Battery Charger to Lithium Ion Battery Charger

I have a spotlight lamp that runs off a small 6V lead acid battery which no longer holds charge.  I replaced it with some used laptop battery cells.   The charger power adapter is just a simple transformer with full-bridge rectification; its output voltage depends on the load and can be as high as 11V .  The lead acid battery is tolerant of overcharging, but not the lithium ion battery.  So I decide to add circuitry to limit charging voltage to 8.4V.  There is a blocking diode before the battery, so the output of the power adapter should be 9V or below.   I put a 5.6V Zener off a 3.3V LDO to generate 8.9V.  The circuit is first drawn using KiCAD before assembled on a prototype board that is small enough to be placed inside the power adapter.

Thursday, November 17, 2022

Microsoft Wireless Mouse Power Circuitry

 The Microsoft wireless mouse takes two AA batteries in parallel.  Tests show that it can start at 0.8V and run down to 0.7V provided that there is enough current, which is generally not available when the batteries are drained to this low.   The voltage has to be boosted to run the optical mouse sensor, the LED and the EEPROM.  There is a boost converter, a 10-pin SSOP IC U2 that I could not identify.   But I believe it is a synchronous boost converter.   The output of the converter is measured to be 1.8V.    


We also see two diodes (D1 and D2) and another voltage of 3.2V.   We  can see the following circuit.


We can see the switch node S (Ch1) and the node A (Ch4).


The switching frequency is about 550KHz.  When the switch is on driving the node S to ground, the node A is being charged up to 1.8V and when the switch is turned off, the node S is up to about 1.8V and the output diode is turned on to drive the node B to 3.2V.   This appears to be common technique to generate an auxiliary voltage.