Saturday, November 25, 2017

Product Failure

I'll detail some of the failures of electrical products that I encountered.

Bluetooth Earphone

I have a Bluetooth earphone that I have not used for a long time.  I could not turn on; it obviously needed charging.  I plugged the USB cable, but it just would not charge.  I opened up and the tiny Li-Ion battery pack had a very small voltage.  It turned out the battery pack has protection circuitry, when the battery voltage drops too low, the switch would not turn on and could not be charged.  It was possible to bypass the circuitry and tap into the battery terminals directly.  I charged the battery directly for a while.  Then it was possible to charge regularly again.

Coffee Maker

In the middle of making coffee, it stopped.  While the light was still on, but the water was not dripping into the filter.  The heating element apparently is broken after perhaps ten years.  The heating element (probably filament inside ceramic)  is placed next to the water pipe and in contact of the top plate.  The water is heated up and forced out to the top and drips down to the filter.  The pressure is enough for the water to go up 1 foot to the top.


AC Adapter Wall Transformer

A short at the output of the 12V 500mA AC adapter caused it to fail.  It is a simple transformer followed by bridge diode rectifier.  The primary side of the transformer is protected by a thermal fuse, which opened when the output was shorted.


Compact Fluorescent Lamp

After about 5 years, the Philips Marathon 13W CFL failed; it flicked for a few minutes then was completely out.   One of the filaments apparently was burnt out, otherwise everything looked fine.  So it seems that the life time is still limited by the filament like the regular incandescent bulbs.

Digital Timer

The LCD started to lose segments.  It uses a plastic heat seal connector, which does not make a durable connection.  After one or two years, the connector loses adhesion.  This is typical of many cheap electronic gadgets with small LCDs and the connectors are the first ones to fail and render the devices useless.



Sony MDR-RF925RK 900 MHz Analog RF Wireless Headphone

This is really a design flaw because it does not work right from the start.  This product retails for $49.99 at Amazon, so it is not an el-cheapo.  It makes a popping and clicking noise constantly; it is loud enough to be unbearable.

Desktop Electric Fan

I have a desktop electric fan, three-speed and swinging head.  It is built with metal casing and solid construction.  I had it for 7-8 years.  It occasionally makes noise when it swings.  Recently, it failed to start or start and stop at the lowest speed.  Then it tripped the circuit breaker.  At a close inspection, the wires from the base to the motor head were nicked and evidently shorted.  The bundle of wires consists of earth ground, which is connected to the case, return, and three other wires for the three speeds.  Apparently, the wire bundle has been rubbing against the case as it swings, eventually cutting the insulation and shorting out the wires inside.


Upon disassembling the fan, I find the single phase induction motor, 3uF starting capacitor and it appears that the speed is controlled by activating the number of stator coils.  I soldered the wires and insulated them; it works again.

Notebook Computer Power Adapter

I'm sure the designers thought it was a good idea to build smarts into a lowly notebook AC adapter. My HP notebook AC adapter comes with a 3-pin power plug. As an electrical engineer, I had guessed that the center pin was a sensing pin to compensate for the IR drop of the wires. I measured the voltages: the inner ring is 20.0V and the center pin is 15.4V. I did not think too much of it why HP thought was necessary to have a center pin until a few months ago. My computer ran slow and took a long time to boot. Of course, I suspected software problems, maybe virus. I reinstalled the OS and the problem seemed to go away, but only reappeared later. It was very frustrating. One day I noticed that the computer would run fine when I unplugged the power adapter. It was very repeatable; I could see the CPU loading changing as I plugged and unplugged the AC adapter. I could not believe that the running on AC adapter could cause the computer to slow down. A quick search on the web showed other people had the similar problems. HP called the power adapter smart AC adapter. Apparently information is communicated between the AC adapter and the notebook PC and the PC throttles the CPU accordingly. When there is a connection problem on this center pin, the notebook gets stuck in the slow mode. I could juggle the wire to make the problem go away. The technical support at HP seemed unaware of this particular problem. (In general, HP tech support just isn't very good.)
Power supply failures seem very common on the computers. Now the smart AC adapter adds a new way for the power to fail.

Electric Shaver

Technically it did not fail.  It is a fine product, still usable after many years, but the batteries failed.  It has two NiCd cells, which can no longer t be charged.  I opened up and replaced the batteries with two NiMH cells.  The charger still work.  Its usable life has been extended.

LiFePO4 Charger

This was a case of misuse.  The charger was connected to the battery with the wrong polarity.  There was a popping sound and the charger was dead.  Designing a charger without reverse polarity protection, I think is a mistake, especially when the possibility of wrong connection exists.  The consequence is that an aluminum electrolytic capacitor blew up, spewing its guts and a jumper wire melted.  The jumper wire is 22 AWG, so it would take 40A to melt.  And a 50-milliOhm current sense resistor changed its resistance because of overcurrent, thus altering the maximum current output.



 

Thursday, May 4, 2017

OrangePi Prime

As I was pleased with the OrangePi PC module, I purchased another OrangePi product, OrangePi Prime for $35, about doubling the price of OrangePi PC.  The extra cost got me AllWinner H5 quad-core A53, 2GB DDR3, and onboard WiFi and Bluetooth module (based on RTL8723BS).  The board is a little larger and the hole patterns are not the same.


I downloaded the Ubuntu desktop image from orangepi.org and wrote to a uSD card.  The image took about 4GB disk space.  I connected the HDMI to an HDTV, but there was no display; the screen said the mode not supported.  I connected to the 3-pin UART at 115200 baud and power cycled.  I saw the boot message and login prompt.   And I logged in with the default password (root/orangepi).  Everything seemed running fine; the X server was running.  So I should try a different monitor.  It worked on a newer model HDTV.  But it needed a keyboard to login.  I was able to use my USB keyboard/mouse emulator.  The desktop environment is Xcfe; the default display resolution is 1280x720.  I connected to the WiFi to my router.  But the default browser did not work.  I went to Ubuntu Software Center and installed Chromium Web Browser.  I was able to get on the web.  The Linux partition ran out of space.  I had to resize the partition.

I also gave Armbian a try.  Armbian had a nicer setup.  It created a single partition and expanded to the full capacity on the first boot.  The display defaulted to 1920x1080 resolution.  The desktop is also Xcfe.  However, it did not appear to have the driver for the onboard WiFi.  I  had to connect to the internet with an ethernet cable.

During the startup, the board draws 2A peak for a brief period of time.  The current does not exceed 1.2A during normal use.  It idles around 0.35A.   After shutdown, it still draws 0.18A.  During heavy load with average current ~1A, the CPU temperature can exceed 75C even with a heatsink.  With a fan, the temperature can stay below 40C.

See an update here.

Tuesday, January 3, 2017

DT9205A - another cheap multimeter

I talked about the Cen-Tech multimeter, which was a little better than expected.  Another cheap multimeter is DT9205A.  There are actually several versions which have slightly different looks.  The one here costs $9 (including shipping); it has no discernible manufacturer brand information and comes with a rather generic users manual, but at least it has accuracy specifications.

The DC voltage accuracy is +/-(0.8% + 3), so measuring 5V, it could be off by as much as 70mV.  It turns out the measurements are much better than specified.  At 1V, the measurement is within 1mV and at 10V, the measurement is within 10mV.  However at 5V, the measurement is off by 30mV.

While the DC voltage measurement seems OK, other measurements do not fare as well.  A 1.6K Ohms resistor should be within +/-(0.8%+2), or +/-15 Ohms; it is actually off by about -30 Ohms, twice the limit; and 31.6KOhms off by -1K Ohms, again twice the spec.

The meter has superficial resemblance to the Fluke multimeter, which costs around $400.  The venerable Fluke 87 has the DC voltage accuracy specification of +/-(0.1% + 1) over all the ranges and the resistance accuracy of +/-(0.2% + 1).  So the accuracy specification is about an order of magnitude better on paper.

The Cen-Tech multimeter actually has much better accuracy for less than half the price.  Although this meter has additional desirable features: the auto power off, continuity beep, capacitance measurement, wider resistance measurement range, 10MOhm input resistance for voltage measurement (for 20V and upper range),  the poor accuracy is enough of a disappointment to not recommend it for purchase.


Sunday, November 27, 2016

OrangePi PC

The OrangePi PC based on Allwinner H3 SOC, a quad core ARM Cortex-A7 processor, with 1GB DDR3 SDRAM, selling for $15 (plus $3.35 shipping) is possibly the lowest cost PC with the similar capabilities.  (Cheaper boards have less RAM which limits the usability.)


The board has the same form factor as the more famous Raspberry Pi (not the same mounting holes) and the same expansion 40-pin header; the OrangePi PC also features an OTG USB port, a microphone and an IR receiver. Indeed, H3 is an impressive chip -- the board only needs DRAM, voltage regulators and connectors; no need for ethernet phy chip, USB hub etc.  The OTG micro-USB port can be turned into a serial port, an ethernet port etc through USB gadget support.  Also see https://linux-sunxi.org/Orange_Pi_PC.

To power the board, we need a power plug and a 5V power adapter capable of 2A.  The best OS flash image is Debian Jessie Desktop from armbian.com.  Connect the HDMI port to a TV for display.  It is good to connect to 3-pin UART serial console to see the boot message.  Once it boots up; the display resolution can be changed with the command h3disp and it is capable of 1920x1080p60.   The desktop environment is Xfce.  At least a USB mouse is required; without a physical keyboard, a virtual keyboard can be used.  I use a Bluetooth keyboard/touchpad, with a Bluetooth dongle, which it supports nicely.

The performance is OK for most of applications; but youtube video playing is a little jerky.  The audio output can be the HDMI or the 3.5mm jack.  The H3 gets a little hot when playing video; still it is impressive not needing a heat sink.

To test it as for code development, I try to build the recent version of KiCad.  A number prerequisite packages have to be downloaded.  The entire build takes almost 10 hours.  The speed of the micro SD card is probably a factor here.  It is also close to running out of memory.  The build is successful, but this probably is not a platform for serious software development.

While it is not a replacement for a good laptop or desktop, it is certainly good enough for seriously embedded applications.  The 40-pin expansion port has 28 signals, 5V, 3.3V and ground.  The signals can be GPIOs or 2 I2Cs, 3 UARTs, 1 SPI and 1 PWM.

There is a port of WiringPi call WiringOP that supports the I/O functions of the expansion header.



There is also a port of python package pyA20. 

For a more capable 64-bit version, see OrangePi Prime.

Also see this post for adding a small LCD screen.

Monday, October 24, 2016

Bluetooth Headset Battery

I have a Bluetooth headset that is 7-8 years old.  I used it occasionally in the car.  It just quit completely and could not be charged.  I never threw out a piece of electronics without opening and studying it.  So I peeled the cover off and took a look inside.  It is designed around Philips BGB204 Bluetooth 1.2 system-in-a-package radio chip that includes the Bluetooth core and an ARM7 processor.


The first thing to check was the battery.  I was surprised to find the battery voltage was at dead zero.  I was expecting it had at least some voltage albeit low, but it should not be at exact zero volt.  I took the battery off the circuit board and powered the board with external supply at 3.7V.  Everything seemed to work fine: it connected to the PC and transmitted sound through Bluetooth.  So the culprit had to be the battery.

I carefully peeled the tapes off the package and exposed the battery contacts and the protection circuit.  I measured the voltage across the battery contacts and there was some voltage as I expected.  So it was the protection circuit that completely cut off the power.  Probably the voltage had dropped too low to even power the protection circuit.  Also the pouch that contained the battery cells looked a little puffy.  It appeared that the battery cells might have released gas.  I was tempted to pop the pouch to vent the gas, but I resisted, thinking that it could possibly cause fire because of lithium built up.  I started to charge the battery directly at 100mA to 4.2V; it took about one hour.  And at about the half way, I switched the charging through the protection circuit and it charged fine the rest of the time.  Then I tested the battery by connecting it back to the headset.  It worked and seemed to hold charge.

So it is curious what happened to the battery.  And since the battery pouch is a little puffy, it is also a little worrisome.  I have to be careful to continue using it.

After some research online, it seems that the battery puffing is caused by excess oxygen which is released from the organic solvents in the electrolyte likely because of overcharging.

Tuesday, July 12, 2016

USB Serial Keyboard/Mouse

Previously, we made a PS2 keyboard emulator.  Here we are going to create a USB keyboard that makes easy to control another PC from a laptop.  (Alternatively, we can turn a tablet into a keyboard/mouse, that's a project for another time.) We'll use the USB serial port from the laptop to transmitt keystrokes to a microcontroller that provides the USB keyboard device interface.  The microcontroller module we choose is the TI's EK-TM4C123GXL LaunchPad.  It features the TI's Tiva series microcontroller with an 80MHz Cortex M4F core.  The Cortex M4F adds more computational capabilities to Cortex M3 with DSP and single precision floating number instructions.  The board actually has two Tiva M4C123 microcontrollers: one serves as the In-Circuit Debug Interface (ICDI) and a USB serial interface and the other is programmable and has a USB OTG/Host/Device port with a USB micro-A/B connector as well as the other pins broken out to the Launchpad BoosterPack XL expansion connectors: two 2x10 headers that include 35 signals and power/ground.  In addition, there are two pushbutton switches and 3-color LEDs.  The board cost is $12.99, a very capable board at a very attractive price.


TI Code Composer Studio (Ver 6.1.1) with TI ARM compiler 5.2.6 is used as the development tools and TivaWare C Series (2.1.2)  as the device library.  In the CCS, we create a new project by selecting the device TM4C123GH6PM, Stellaris In-Circuit Debug Interface and TI v5.2.6 compiler version.  The startup code and the linker commands are automatically generated.  The startup code sets up the interrupt vectors, including the reset handler which jumps to c_int00 to start the application.  The linker script sets up the memory allocation.  This device has 256K Flash and 32K SRAM.  At this point, we can make sure things are set up correctly by compiling the skeleton code.  We can also take a look at the default compiler options.

The first thing to add is the UART.  We simply borrow code from the examples in the TivaWare.  One of the interesting features of Tiva is that the TivaWare Peripheral Driver Library (DriverLib) code resides in the internal ROM.   These functions are prefixed with ROM_.   Also there are the MAP_ version of the functions that make it easy to switch between the ROM version and the Flash version. We have to define a compiler variable TARGET_IS_TM4C123_RB1 in order to resolve these functions (by mapping to ROM addresses).  Here RB1 refers to Silicon Revision B1; it is not clear how to tell the silicon revision.  If the flash version of the driver functions are used, driverlib.lib has to be linked in.  It is relatively easy to modify compilation options from the project properties.  As a debugging aid, we print out __DATE__ and __TIME__ macros so that we know if the microcontroller is flashed with the latest code.

Next is to initialize the USB in the device mode and set up as the USB HID device class.  Again we borrow from the examples.  Thanks to the usblib, it is fairly easy to set up the HID keyboard device.  Be sure to enable the USB peripheral and configure the pins and add USB0DeviceIntHandler to the interrupt vectors.  A callback function is defined to receive the events from the HID keyboard driver; the events includes connected/disconnected, suspend/resume, transmit complete.  Finally the key press and release are sent by calling the key state change function.  For starter, the ascii character received from the UART has to be translated into USB HID keyboard usage code and we have to transmit both key press and key release.  Only a subset of the usage code is defined in the TivaWare; the complete code can easily be found on the web.  Microsoft has a USB HID to PS/2 scan code translation table.  Once the USB is plugged in, to a computer, it is recognized as USB HID Keyboard and the key strokes are received as we type on a serial terminal.  I have to set the force device mode, otherwise it is not detected.  By default, the VBUS and ID pins are not monitored;   And as a side effect, the disconnected event is not reported in the mode.

Now we need to develop an application to transmit key press and key release in a raw form.  The USB keyboard reports up to 6 keys along with keyboard modifiers (CTRL/SHIFT/ALT/GUI).  We'll have to see if we need to send modifiers together with the keys or separately.  Also multiple bytes has to be sent, so we need a way to synchronize.  The serial protocol has to be a little more complex: three bytes may be needed, one for modifiers, one for key code and one to indicate key press or release.  Some unused bits may be used for sync.  Timing should also be used: the three bytes are transmitted together.  Tests indicate that the modifiers' states have to be transmitted with the keys, so the modifiers have to be maintained.  Also note that you may have to turn the legacy USB keyboard/mouse mode in the BIOS; that was the case for the GRUB running on one of my older computers.

A further modification is to turn it into a keyboard and mouse composite device.  We simply call the composite initialization functions, then we deal with two separate devices.   The mouse device reports the pointer delta movements and the button states.  Using Python tkinter, we bind ButtonPress, ButtonRelease and Motion events.  From the event coordinates, we calculate the delta movements.  Note that the deltas are signed 8-bit numbers.  In the Tk event, the left/middle/right buttons are numbered 1, 2 and 3 respectively.  But it appears that the middle and the right buttons are swapped at the receiving end.  It might be a configuration issue.  I tested it with both Linux and Windows; it worked fine.

In the future, more input devices can be integrated.

Another version is created using Cypress PSoC5LP kit CY8CKIT-059, a small $10 board, which is more convenient to carry.   The implementation effort is similar.  But I had to dig a little deeper into setting up the USB descriptors for a composite HID device and the endpoint programming.  Most of the USB device code is auto generated.

Tuesday, June 14, 2016

Power White LED Light Properly


The cheap LED light simply drives a parallel string of white LEDs with two or three batteries.  There is no other circuit elements, not even a current limiting resistor.  The most annoying problem is that the light gets dim fast as the battery voltage drops when there is still plenty of battery capacity left.  The proper way of doing it is a constant current boost converter,  LT1932 is such as an IC that comes in a small package, works down to 1V and is simple to hook up.  Here is the circuit diagram,

Here is the actual circuit board,


LT1932 can supply up to 40mA.  For higher current, we can take a boost regulator like LTC3429 (600mA 500KHz synchronous boost) and close the loop with current sensing.  The following circuit sources 120mA and works down to 1.8V.  It has about 90% efficiency.  When the input voltage is higher than the output voltage (such as using a Lithium Ion battery), LTC3429 acts like a low-dropout linear regulator.  


The actual circuit board,


Another incarnation with higher current (250mA) and in the size of a flashlight bulb (P13.5S),