July 18

## uGrid: Critical circuits home grid backup (part 1)

“A microgrid is a localized grouping of electricity sources and loads that normally operates connected to and synchronous with the traditional centralized grid (macrogrid), but can disconnect and function autonomously as physical and/or economic conditions dictate.” – Microgrids at Berkly Lab

Boom, crash, the lightning flashed, and out went the power.

This is something that happens from time to time, though far less so where I live now than in my youth (where we kept a generator in the shed for such occasions).  However, several recent outages started me thinking: how would I bridge the occasional and sometimes relatively long power gaps?

### Phase 0: What happened, and initial parameters

Major component(s): Data, data, data! (I cannot make bricks without clay)

So the most recent outage was over 24 hours.  Long enough that we familiarized ourselves with food safety during a power outage (the refrigerated and frozen food briefs at FoodSafety.gov were quite useful, as would have been the USDA guidelines for emergency food safety).  As we did not take any supplemental precautions (such as icing the freezer) most everything was lost.  But in the time and uncertainty between the work reports (we have power; no, we don’t though some of our neighborhood does; we will have power soon – I can’t fault the response teams, they busted butt to get the most people restored as quickly as possible), I kept started running through ways to save the contents of the freezer, to charge cell phones, to run fans.  Why not power my home myself?  Or just a small, critical part of it.  After the power returned and the damage was assessed, I shared my musing with my spouse, who supported it rather enthusiastically1.  So, now to form a plan!

May 6

## Calculating an LED resistor: a technical test

Setting up this website, I have certain requirements.  Superscript, subscript, equation display, logical picture display, charts, formatting that I like and presents information in a manner I think works1.  This is the useful test post to evaluate all of these capabilities.  The subject below is covered in several other places on the wide wide webz.

#### Calculating current-limiting resistor for an LED

An LED is a great thing.  It makes a great deal of light with relatively little heat and over a long life.  However, LEDs are also a bit more sensitive to power requirements and more easily damaged than other indicators and/or illuminators6.  LEDs require a minimum amount of voltage before they will turn on, producing any illumination, and have a maximum amount of current they can tolerate before their lifespan is degraded (or they fry; I consider this a notable degradation of the expected life of the product).

Refer to the diagram to the right.  An LED is a diode; as such there is a voltage threshold below which no current will flow and above which current will.  This forward voltage drop of the diode, defined as Vf, varies depending on the type of LED used2.  Once voltage exceeding the forward voltage is applied across the LED, current will flow.  The LED has a maximum  forward current (and/or typical, and minimum, too) given by If, where the LED will emit light of the specified intensity and frequency for the given lifetime.  If the datasheet or part spec does not indicate if this is a typical or maximum value, assume it is maximum.

Note: exceeding the maximum current level of an LED will not necessarily fry it immediately.  Too, it will be brighter.  However, exceeding it will decrease the lifespan and luminous efficiency3.

A current limiting device must be used to protect the LED.  The simplest way to limit current is to add a resistor, R, in series with the LED.

April 29

## Some Stupid Rules

Maturity is knowing you were an idiot in the past.
Wisdom is knowing you will be an idiot in the future.
Common sense is knowing you should try not to be an idiot now.

We as a community (the internet) are becoming increasingly concerned with pointing out how something could go wrong, or the safety concerns of any project.  Whether the reason is an increasingly litigious society, a greater average degree of inexperience working with tools and materials, or other factors, any write-ups, instructions, or videos explaining how to create are invariably littered with commenter (if not the author) helpfully pointing out how they should be safe and not put an eye out.The fact is that everything we do, including doing nothing, carries a moment-by-moment risk of harming or killing ourselves.  This in mind, The Stupid Rules – the basic and overarching guidelines you need are:

• Don’t be stupid doing projects: Don’t show off, don’t rush, don’t work drunk or high or sleep-deprived or impaired.
• Don’t be stupid with new tools: When using a new tool, learn what it is and what precautions to take.  Get instruction, find a video, take it slow and focused the first few times, and initially follow the instructions and advice on how to use it.
• Don’t be stupid with new materials and systems: Cutting MDF for the first time? Spray-painting? Wiring a breaker?  Stop and learn about what you are working with.  Get advice, find an instructional sheet or video, and follow the advice, precautions, and instructions on handling.
• Don’t be stupid with familiar tools and materials: Working with 14 molar HCl all the time does not make it any less dangerous if you do something stupid with it.  Understand what precautions you are taking and why before you decide to violate them.

Bonus guidelines, once you have a handle on the cardinal Stupid Rules:

• Don’t be stupid around other people’s projects (aka a hacked, modded, rough, or even final thing or system):  It may look cool.  It may look safe.  It is shiny and you want to touch it, play with it.  ASK FIRST.  It may be dangerous if mishandled, it may be delicate; it is always courteous.
• Don’t be a whiny butt if you do something stupid: If you get hurt or something gets screwed up, learn why and fix it if you can.  Don’t whine and moan and sue some random manufacturer because they thought “don’t dry-hump our product” was a obvious enough that it did not warrant a printed warning.
April 22

## Launch box

Ah, Fourth of July.  The joys of smokebombs and explosives.  The delight of shooting off rockets.  Who wouldn’t want their toddler to participate?  To see his shining face as there is a boom or a shower of sparks at the press of a button?

I planned to use a model rocketry ignition system to create a safe way for the youth mentioned above to participate.  Unfortunately I had given all of my model rocketry equipment away in an effort to increase usable space (and to get it in the hands of budding rocketeers).  Commercial options were available, but they were relatively expensive, and frankly lacked visual appeal.  Engineer’s audacity (not hubris, though) may have had something to do with it.

Initial research / Functional Specification
I started with a fairly clear idea of what I wanted and how I wanted it to work.  The launch box itself should look like something a government scientist or military agent would carry – aluminum box, black briefcase, field com box or similar.  It should have large functional switches and buttons (power, arm, and ignition), various LED indication (power, safe, ready, continuity, armed), and a removable safety key that disarms the launcher.  The last is a feature of every commercial hobby rocket launcher I have seen, and is doubly important when you are on the launchpad and there is an excitable toddler near the controls.
February 4

## Class X/Class Y (Safety) Capacitor Parameters

“There are more capacitors in a distributor catalog, Horatio, than are dreamt of in your philosophy. “ – Shakespeare  (I think? Close enough)

Specifically, I am talking about Safety capacitors, aka X-capacitors, Y-capacitors, XY-capacitors, RFI/EMI suppression capacitors, line filtering capacitors, and no doubt other modes of reference.

When you have the occasion to mix hazardous household voltage with capacitors (perhaps to keep noise from leaking out of your circuit, or for surge protection), special care needs to be taken in selecting the capacitors used.

Normal ceramic capacitors have the distressing tenancy of failing short.  In the case of diagram to the right, such a capacitor in the “Cx” position would cause the mains to short through the capacitor, creating a risk of fire, (small) explosion, and a Bad Day.  Should the failing capacitor be in the “Cy” position, the mains could be shorted to earth ground (risking fire, etc) or, if the case is not connected to earth, could just directly connect the case to mains, creating the risk of arcing, electrocution, and a Bad (hair?) Day for someone. Continue reading

October 22

## Kyocera Car Charger hack

Cell phone car chargers are plentiful, inexpensive, and rarely compatible with a new phone.  An upcoming car trip created a need for a small variable supply I could use for the duration.  These factors, and a mention of hacking phone chargers on one of the sites I regularly read inspired me to crack open an old charger.

Initial Device

To the right is a Kyocera charger, split open.  There were no screws holding it together; a series of plastic posts kept the two halves together.  Careful application of a flat-bladed screwdriver pops it apart.  Inside was a delightfully accessible circuit board – the components were all labeled and through-hole, and the IC was unobscured. Continue reading

October 20

## Voltage triggered switch

Minimum Voltage Indicator

This is a simple analog circuit that can be used to indicate if a minimum voltage is present at Vcc.  Minimum voltage is primarily determined by the zener voltage Dz.

Overview of how it works:

When Vcc < the zener breakdown voltage of Dz, the voltage drop across R1 and R2 are close to zero.  This means the voltage at base of the PNP transistor Q1,B is ~Vcc.  When VEB < VEB,on, the transistor does not conduct.  Therefore, current through R3 = 0, and the voltage drop across R3, defined as EN, is 0V.

Once Vcc > VZ, current starts to flow through R1.  Once there is sufficient current through R1 such that VR1 > VEB,on, Q1 begins to conduct.  This causes a voltage drop across R3, and EN to measure a >0 voltage (up to Vcc – VCE,sat).  R2 is in place to limit the current from the base of the transistor (as part of Q1’s conducted current will flow through the base from the emitter). The sensitivity of this circuit to the specific turn-on point and the Vcc/EN curve are strongly dependent on the values of R1 and R3, and somewhat dependent on the current knee of the zener diode.

This circuit as presented optimizes cost and provide a high signal when Vcc is above the minimum.  Variations on this circuit include

• a low signal at EN when Vcc is above minimum, using an NPN and flipping the circuit’s topology
• Using a P-channel MOSFET for Q1 would eliminate the need for R2

As a note, a single LM431 (available from many manufacturers) can also perform a function similar to the “low EN” variation of this circuit with only a pair of external setpoint resistors and a pull-up resistor.  Which approach you choose depends on your application and need; the above could be advantageous for reason of cost, polarity (high EN when over Vcc,min using LM431 requires an inverting component), or voltage range (Maximum operating voltage of a LM431 is 37 volts, discrete bipolar transistors can operate in the hundreds of volts).

January 15

## Tech – Fulmen Hominem

From the laboratory notes of Abraham van Helsing

Generation of high differential tension and effect on tissue (living and dead)

Who is not familiar with the galvanic reaction?  While Galvani made many fine contributions to science, history will best remember him for his demonstration of the invigoration and  reanimation of a severed frog’s leg by means of electrical application.  This most fascinating application, taken to an extreme by the hubris of doctor Victor Frankenstein, suggests a use for this phenomenon somewhere between a twitching severed limb and a monstrous creature last spotted above the Arctic circle.

I have had the occasion and privilege of speaking at length with a brilliant Austrian, Nikola Tesla, at the Exposition Universelle in Paris.  The brunt of our conversation fixed primarily on Herr Tesla’s furtherance in generating large differential potentials from meaner levels.  His demonstrations of lightning summoned and tamed by his hand were like watching a Zeus of old.  While his displays harmed him not, he noted that without his preparations, the wrath of the tamed bolts would be terrible to behold.

On the train back from the Exposition, my mind had occasion to wander from Herr Tesla’s display to Volta’s demonstration of Galvani’s work.  While the apparatus Tesla employs for his work was great in power, so too was it in bulk.  If, perhaps, less power were employed, the size may be reduced to something a man may easily carry?  For  any tissue, whether it belong to those living or once living, will jump and tense to the influence of a bolt of electricity.  Among the creatures I have read of or even had the occasion to face, all shared the commonality of flesh.  To this end, their bodies betraying their will by the introduction of a high potential, I bend my next focus.

The resultant device created quite satisfying displays, and its damped bite was enough to deny me the use of my hand for a notable duration.  I must note that the full effect must be terrible indeed to be effective against the things outside man’s usual sphere: to this caution must be taken not to introduce the effects of this on a man, as the result will be most severe.  The device proved, the next challenge comes in reducing the size of coils and galvanic pile to something that can be carried – currently the excitation device occupies much of a laboratory table.”

As part of a costume for the character of Abraham van Helsing (less the bold scholar of medicine in Bram Stoker’s Dracula, more the swashbuckling character in a recent movie), I created several props of varying degrees of function.  One of them is this baton capped with man’s lightning.  For this, I gutted an inexpensive stun gun, and formed the rod around the secondary, high-step transformer.  The priming circuitry, responsible for stepping 9V up to a few hundred, was housed in an arm guard that was frankly ugly.

The central ball was one of the output electrodes, and the guard ring around it the second half.  When it was energized, arcs would strike at random around the ring.  The energized section was isolated from the control by an acrylic rod (illuminated with an LED for effect)

Notable problems I had with this device:

• Variable display: the arcing display would not be consistent, varying with environmental conditions and ring oxides, from violet tracers (like a plasma ball) to full arcs, to no arcs.
• Insulator breakdown: I do not know if the potential reached the neighborhood of the advertized 100kV, but the insulation between the outer bronze conductors and the hidden wire to the secondary transformer developed a flaw.  It began arcing across the base.  Once the initial strikes burned through the insulation, I could not create a good replacement.  I tried stripping the area and filling it with hot glue, resin epoxy, clay, even silly putty (which burns interestingly, by the way).

It was a learning experience, and one I think I will revisit at some point to finalize.  I have some corona dope, so I am hopeful.

January 12

## Toy LED Lantern

Lights are an impulse buy I constantly struggle against. Soooo many lovely varied options.  My young son gives me new excuses to give in to that impulse.  On the Fourth of July, I was shopping at Michael’s when I found an LED lantern in the discount bin.  It seemed sturdy enough, with good fittings and a solid-feeling switch.  So I gave in to the impulse. After all, my son will be out after dark tonight, right?  He will need the lantern.

I loaded it up with 4xAA (NiMH, but the lower voltage shouldn’t cause any performance issues) and we took it to the evening fireworks show.  The lamp was bright through the evening, and my son turned it on and off at his whim. On the way back from fireworks, however, the new little plastic lantern started flickering.  I cracked it open, expecting a loose wire, or cold solder joint – both common problems in cheap consumer goods, especially with ROHS directives and lead-free solder.  The litany of problems went far deeper than that. The three white LEDs were wired in parallel, a fair design choice.  It could have used one fewer batteries at that point, but we will let that pass.  They were current-limited by a 22Ω, 1/8W, 5% resistor, which I noticed was hot to the touch.  Very hot.

Running the calculations*, each branch of the LEDs were running at ~37mA, which is 120% of their MAXIMUM rating.  Further, the resistor was dissipating ~260mW, about 200% of its maximum rating.  As a side note, the resistor had externally visible voids and a poor paint job, indicating possibly a rejected part (aka cheaper); it did measure within tolerance, though. As it turns out, one of the LEDs was partially burned out – occasionally working, occasionally shorting, causing the whole unit to flicker.  This particular LED configuration is not fault-friendly – if one shorts, the entire set goes out; if one opens, the other two LEDs each experience half of the burned-out LED’s current in addition to their own.

Oh, also the wiring was flimsy with cold soldering and no strain relief and part of the diffuser latch was cracked.

Many parts of this product were shodding (opposite of shining) examples of the shoddy engineering and poor foresight that plagues many consumer goods, many of which could be rectified inexpensively and easily.   Using a 33Ω instead of a 22Ω resistor (1/4W) would dramatically decrease the failure rate of these products, cutting down on returned product.  The human eye is not very sensitive to differences in high light levels, and LED life sharply decreases with higher currents / overcurrent.  I would venture that the consumer of a toy lantern is not looking for a room-lighting device so much as a rugged, long-lasting device.

This has turned into something of a rant.  In the end, I repaired the lantern with some white LEDs I had on-hand and a correct 33ohm resistor. Take-away lessons:

1. A 1/4 cent oversight/savings can be rectified with $1.51 in parts and$100 in equipment – on a \$5 plastic lantern
2. Don’t be afraid to open up a product, and do question everything. Just because it is on the market does not mean that it is correct, and price tag does not dictate quality. There are some quite elegant solutions found in cheap toys, as well as appalling oversights.
3. When buying cheap toys, don’t loose your receipt. You can’t take it back, and then you have to fix it.  :)

* Simple LED current-voltage calculations for single and paralleled configurations, derived from Ohm’s Law and Kirchhoff Current Laws A single LED driven by a voltage source and with a current limiting resistor is defined by the following equations:

$I=\frac{V_{s}-V_{f}}{R}$       OR       $R=\frac{V_{s}-V_{f}}{I}$

• Vf is the forward voltage drop of the LED (a characteristic of the LED based on its color) [volts]
• Vs is the voltage source [volts]
• R is the value with a current limiting resistor [ohms]
• I is the current through the branch (from the voltage source, through the resistor and the LED) [amps]

Given the forward voltage (available on the datasheet or package for the LED, or here) and the maximum continuous current (again, datasheet or package), you can determine the resistor needed, rounded to the next largest standard resistor value. With this information, LEDs wired in parallel (all anodes tied together and all cathodes tied together) being limited by a single resistor would be described by:

$I_{LED}=\frac{V_{s}-V_{f}}{R \cdot N}$       OR       $R=\frac{V_{s}-V_{f}}{I_{LED}\cdot N}$

with N being the number of (identical) LEDs wired in parallel.  ILED now only describes the current through a single LED. The calculations above were used with the assumptions of Vf=3.6V, ILED=Imax=30mA for LED characteristics, which are typical for a white “superbright” type LED.