fj laboratories

Musings, deliberations, and end results.

# Circuit Protection for Keyboards

Felix Jen – 15 March 2021

## Keeping Things Safe

Circuit protection in electronics design is a bit of an underappreciated topic. No one likes their board going up in smoke when things go wrong, so it’s important to determine the possible failure modes and how to save the board from catastrophic circumstances in those conditions. This blog post will first cover the most frequent failure modes, in a nonexhaustive list, then dive into correcting each of the potential failure modes. Expect this post to be text-dense—apologies to the picture inclined folk among us.

Photo by Malachi Brooks on Unsplash

## Be Not Afraid

“I have not failed. I’ve just found 10,000 ways that won’t work.” — Thomas Edison

### Electrical Modes of Failure

In an electrical system, we typically deal with two distinct but interconnected phenomena: voltage and current. Each system is designed to operate within certain boundaries of voltage and current. Exceeding any of those boundaries can often do significant damage to the system itself or be physically dangerous in some cases. Furthermore, in systems like keyboards, voltage and current is expected to flow in only one direction—from the computer to the keyboard. Reversing this direction may result in damage to the other side, if it was not designed to withstand such a scenario.

From the above, we can summarize our failure modes into five distinct and independent types:

1. Over-Current
2. Under-Current
3. Over-Voltage
4. Under-Voltage
5. Reverse Bias

While each of these five represent a possible mode of system failure, these are not all equally dangerous to keyboards specifically. In cases of under-current, there is simply not enough current available from the source to properly run the circuit. While this may be problematic in sensitive circuitry like phones and drones, this does not present itself as a “fatal” failure mode in keyboards.1 If a keyboard were to receive insufficient current, it would just not function or function only intermittently. An undercurrent condition will typically not cause damage to any components in a typical mechanical keyboard implementation. The same is similarly true in under-voltage. Most components are designed to operate within a minimum voltage range, and insufficient voltage will cause a component not to “turn on.” Likely, no physical damage will result from a mere insufficiency in voltage.

This primary purpose of this blog post is to understand how to prevent fatal failure modes, not all potential circuit instabilities, and therefore, we’ll focus on the three fatal types:

1. Over-Current
2. Over-Voltage
3. Reverse Bias

### Physical Modes of Failure

In addition to the electrical failures discussed above, systems may also be subject to certain physical failures as well. Typically, these revolve around the usual enemy of electronics: heat and humidity. These will be touched in the final sections of this post, but physical protection is not the focus of this post.

Photo by Louis Reed on Unsplash

## Over-Current

### Why it matters

The over-current (OC) condition is often one of the fatal modes of failure. All electrical components have a certain amount of resistance to electrical energy, defined in ohms. While most components are “fairly” low-resistance, the amount of power that is dissipated by a component varies by the square of the current flowing through it. Mathematically, this is represented as

$P = I^2 * R$

Power is expressed in Watts (W) and this power dissipation results in heat. Each component is only rated to a temperature before it fails entirely or “releases its magic smoke.” Imagine a $$1/16 W$$ resistor at $$300\Omega$$. Following the power dissipation equation above, we are left with:

\begin{align} I &= \sqrt{\frac{1}{16} \div 300} \\ &\approx 0.0144 A \end{align}

Therefore, any amount of current flowing through this imaginary resistor above 0.0144A will be over the ratings. If we apply something like 2A to the resistor, it will most likely glow a beautiful bright red for a few seconds before burning and smoking. We would like to avoid this for obvious reasons.

### How do we prevent this

You are most likely already familiar with how to protect against OC conditions already. This is typically achieved using a “fuse” that is designed to cut the circuit past a certain amount of current flow. If you ever had to replace a fuse after some incident, you’ll be intimately familiar with the idea that fuses are single-use products. Once a fuse has tripped, there is no way to “reset” it typically.

However, there is a type of fuse which is indeed resetable after being tripped. These fuses are unsurprisingly known as “resetable” fuses. However, to avoid confusion and to make people’s lives more difficult, you will more commonly see them called PPTC fuses, PTC fuses, or PolyFuses. The name PPTC—polymeric positive temperature coefficient—device gives us an indicator of its operation. A PTC is constructed using a nonconductive polymer which is then impregnated by conductive carbon particles. As current flows through the device, the PTC heats up due to its internal resistance (see above). Under a certain temperature, the carbon particles are in a solid state and are able to conduct electricity. Once a certain amount of current flows through the fuse, it will heat to the extent where the carbon polymer will expand and become “amorphous.” At this stage, the fuse will become increasingly less conductive and will therefore cut off current to the downstream circuit. Once the source of the current is completely removed, the PTC will cool down and will return to its normal conductive state. In effect, the power dissipation is exploited to create a fuse which trips and resets depending on its temperature.

### Selecting a Polyfuse

Like all electrical devices, polyfuses exist with a near infinite combination of options. Therefore, this section will attempt to narrow down the important options and give recommendations to those options. Of course, this is merely a recommendation, and your exact choice of component will vary depending on your individual project’s needs.

The following table shows the important parameters and a recommended value range:

Parameter Recommended Value Explanation
$$I_h$$ 250mA – 750mA Hold Current
$$I_t$$ 500mA - 1.5A Trip Current
$$V_{max}$$ > 6V Maximum Operating Voltage
Package Size 0603, 0805, 1206, 1210 Package Size

#### Hold Current

A PTC’s hold current is the current it is guaranteed not to trip. In a typical keyboard application, the system is connected to a USB port, with a maximum USB 2.0 specification power delivery of 500mA. However, most keyboards will likely not utilize the entire power budget, especially if there are no LED’s present. Therefore, a lower hold current is also viable if needed. 250mA presents itself as a safe middle ground if no LED’s are used. Additionally, for certain higher power boards, it is possible that the USB port can be capable of delivering more than 500mA. While the upper limit depends on the USB port itself, it is wise to set a lower upper limit of 750mA. This should provide ample energy for even high-powered circuits without being too much current for most other downstream components to handle.

#### Trip Current

A PTC’s trip current is the current a PTC is guaranteed to trip. This is typically expressed as double the hold current. As this value is almost always tied to the hold current choice, it’s exact value is of little value. However, its upper limit should be set to not cause damage to any other downstream or upstream components, should such limit need to be reached. 1.5A is a solid upper limit as the USB port itself may be susceptible to damage too. Furthermore, a short occurence of 1.5A will not likely cause any irreversable damage to downstream components.

#### Maximum Operating Voltage

PTC’s have a maximum allowed operating voltage before they break down. Keyboards are typically powered through USB and therefore, must receive their power through the USB specification. Though usually at a nominal 5V, certain badly-designed devices may produce power up to 5.5V before violating USB specifications. Therefore, for enough margin of safety, a fuse capable of withstanding anything greater than 6V should be chosen.

### Implementation

A polyfuse is often the most resistant device to over-current in the entire system. Therefore, to avoid damaging any components that come before a polyfuse, it should often be placed as the first component in the power line. Similarly, it should be placed as close as possible to the actual source of power (the USB port) to avoid heating of traces and damage the board itself in OC conditions.

Photo by Magnus Engø on Unsplash

## Over-Voltage and Static Discharge

A discussion on potential over-voltage should really be broken into two categories of over-voltage. The first category is a sustained over-voltage condition (OV). In this scenario, a higher voltage is provided through the power source and this is a continuous condition. The second category is an electrostatic discharge transient condition (ESD). In this scenario, a sudden very large spike of voltage is applied somewhere in the circuit. This is not a continuous condition and only occurs in a sudden shock. Each of these needs to be modulated somewhat differently and therefore will be covered separately.

### ESD

A typical static shock will range anywhere from 500V (spark threshold of standard air) to upwards of 8,000V. 2 This is way over the rated voltages of any electrical components in a typical keyboard circuit. As this is a sudden transient condition though, our main worry is not the power dissipated in ESD conditions. Rather, we are worried about killing sensitive components like the microcontroller directly which is unable to handle extreme voltages.

In an assemebled keyboard, one of the biggest sources of static electricity is the exposed USB port. This is the directly-connected metal object most frequently interacted with. While the case is another place where static can discharge through, it is rarely connected electrically to the PCB and is therefore, not a major concern in most circumstances. Therefore, our primary concentration should be the USB port area when it comes to protecting the circuit.

#### Static Protection Devices

ESD protection is often in the realm of dedicated components designed to handle such high voltages. These devices are able to “shunt” large excessive spikes in voltage directly to ground, and therefore keep them away from the remainder of your components. They do not typically trigger unless a voltage reaches a certain threshold, preventing dead shorts in your circuit under normal conditions. Of note, in a typical USB 2.0 connection, you are presented with three “vulnerable” lines: power, D+, and D-. Therefore, in protecting against ESD, you should pay equal attention to all three lines.

While single-line ESD devices exist, it would be easier to implement an all-in-one USB ESD protection device for all three lines at the same time. Luckily, such devices readily exist and are very commonplace. A quick lookup for USB 2.0 ESD Protection Devices will return a laundry list of components, all of which are feasible. It’s important to bear in mind that not all devices contain “power-line” protection. If you opt for a device which does not have power-line protection, the following OV section should be implemented as well.

Implementation of such a device is usually trivial and described in depth by most data sheets. Therefore, this blog post will not cover such implementation in depth.

### Constant Over-Voltage Condition

Apart from ESD transients, the electrical system should be protected against a constant over-voltage (OV). Most microcontrollers used in keyboard are rather sensitive to voltages over a certain value (typically 6.5V) and will be destroyed by prolonged exposure. Therefore, there needs to be a mechanism to “bleed off” voltages in excess of this rating.

#### The Zener Diode

Diodes are electricalc components which normally conduct electricity in only one direction. However, if a certain breakdown voltage is reached in the opposite direction, a diode’s ability to block electrical flow will collapse. At certain voltages then, if reverse-biased, a diode will allow current to flow in that direction (known as an avalanche condition). A Zener diode is a type of diode which exploits this characteristic to bleed off “excess” voltage.

Zener diodes are unique in that their main characteristic is their “breakdown” voltage. If a circuit’s voltage is higher than the specified breakdown voltage, the Zener diode will avalanche and allow current to flow in that direction. Therefore, we can use this feature to our advance and have our circuit collapse in cases of continuous OV, protecting the rest of our downstream components.

#### Selecting a Zener Diode

As above, the following values are merely suggestions and each component choice should be considered with regards to the entire system.

Parameter Recommended Value Explanation
$$V_z$$ 5.5V – 7V Zener Voltage
$$P_d$$ >500mW Power Dissipation
$$I_R$$ $$< 1\mu A$$ Reverse Leakage Current
##### Zener Voltage

The Zener Voltage is equivalent to the breakdown voltage of a regular diode. Any voltage above this amount will be allowed to flow through the Zener diode, effectively bleeding it off. As mentioned above, USB 2.0 specifications allow a maximum working voltage of 5.5V, and therefore, we would not like to bleed off anything below 5.5V. Therefore, 5.5V is the minimum recommended Zener voltage in these cases. As well, because microcontrollers are sensitive to higher voltages, we would like to avoid anything higher than microcontrollers are capable of handling. While keeping voltages below 6.5V is adviced, it may be difficult to find such a Zener diode on short notice. Therefore, a 7V maximum Zener voltage is recommended.

##### Power Dissipation

Like all electrical components, Zener diodes have an internal resistance and therefore an associated power dissipation. Typically, excess voltage is bled through these diodes, and therefore, we do not need a large amount of continuous power dissipation capabilities. 500mW is a standard power dissipation amongst surface mount Zener diodes, and it is the recommended minimum.

##### Reverse Leakage Current

Zener diodes are typically placed in the “reverse biased” direction. Current will usually not flow in this direction below the Zener voltage. However, diodes are not perfect devices and some minimum amount of current will always leak through Zeners when reverse biased. We would like to minimize that as any current flowing will just generate heat. Most Zeners are rated for significantly less reverse leakage current than $$1\mu A$$, so this value is typically not contested or concerned.

#### Implementation

Zener diodes are sensitive to OC conditions, each having a maximum allowed power dissipation. Therefore, to protect the Zener from OC, we should place the Zener diode downstream from the PTC discusssed above. However, as other downstream components are all susceptible to OV conditions, we should place the Zener diode immediately after the fuse. Indeed, this leaves the fuse vulnerable to OV conditions; this is unlikely to be problem as PTC’s generally have very high voltage ratings in the tens of volts. To effectively bleed off excess voltage to a neutral source, the Zener should be connected between the power line and ground.

Photo by Adi Goldstein on Unsplash

### Reverse Bias

In most keyboard implementations, a keyboard will draw power from the USB port to which it’s attached. Therefore, the USB port will supply 5V and the keyboard will receive it. Most computers and USB hubs are not designed to accept power flowing in the other direction and can be damaged if 5V or greater is actually applied to the USB port itself. While it is rare for keyboard to actually emit power in such a way, certain strange conditions may exist to warrant protection.

#### The Schottky Barrier Diode

Much like we use a Zener diode for OV protection, we can utilize a diode’s one-way property to prevent reverse-bias conditions. All diodes have a “forward voltage” which can be described as the reduction in voltage from the anode to the cathode. For example, if a diode has a 1V forward voltage, and 5V is applied to the anode, we can expect to see 4V at the cathode. This, effectively, reduces the useful voltage of our power supply by a fixed value, and this voltage is wasted as heat. A Schottky Barrier Diode (often just called Schottky) is a specific type of diode used in power situations with a low forward voltage (dropout voltage). Therefore, using a schottky diode instead of a traditional p-n diode allows us to minimize wasted voltage in our power line and maintain as high an operating voltage as possible.

#### Selecting a Schottky Diode

As above, the following values are merely suggestions and each component choice should be considered with regards to the entire system.

Parameter Recommended Value Explanation
$$V_f$$ < 500mV @ >500mA Forward Dropout Voltage
$$V_{max}$$ >7V Maximum Operating Voltage
$$I_{max}$$ >500mA Maximum Operating Current
##### Forward Dropout Voltage

A diode’s forward dropout voltage (frequently just called forward voltage) is a function of the current running through the diode itself. Typically as the current flowing through a diode is increased, the forward voltage also increases. Therefore, we would like to choose a diode which has as low a forward voltage at our operating current as possible. Thankfully, most Schottky’s are rated at less than 500mV at levels much above 500mA. If a Schottky has a forward voltage of more than 500mV at less than 500mA, it is extremely inefficient and should be avoided. 500mV is chosen as a value which is easily achieveable and does not reduce our available useful voltage too significantly.

##### Maximum Operating Voltage

This value is usually never an issue as most Schottky’s are rated at very high voltages. Our system voltage is regulated by our Zener diode (see above) and will most likely never exceed the Zener voltage. Conservatively, a 7V Schottky should be plenty, but you are more likely to find higher rated Schottky’s frequently.

##### Maximum Operating Current

This value is regulated by our PTC and should almost certainly not exceed the level we set in our $$I_{t}$$ of our PTC. Like voltage, most Schottky’s are rated for a large amount of current, and this value is rarely an issue either. To be conservative, any Schottky rated higher than 500mA should be plenty sufficient.

Overall, Schottky diode selection is not critical as they are common components with very high ratings all around.

#### Implementation

As Schottky’s are typically vulnerable to OC, OV, and ESD events, they should be placed last in the chain of protection. This will ensure that OC, OV, and ESD is all mitigated before reaching the Schottky. Furthermore, as the OV and ESD chips are vulnerable to reverse-bias, this will ensure that any downstream reverse-bias events are stopped before reaching those components.

### Physical Damage

Physical damage events like overheating and liquid spills are rather difficult to “prevent” but their effects can be mitigated if designed. The most common keyboard event is a spilled liquid condition. Anyone with experience in electronics knows that liquid is the enemy of modern circuits. The areas most vulnerable to liquid damage are the microcontroller area (and supporting circuitry) as well as the USB area (with risk of shorts). Many PCB manufacturers (if ordering assembled boards) are capable of applying a thin layer of conformal water-repellant coating on those areas to help counteract the water damage before it occurs. Care should be taken with conformal coatings on keyboards though. The entire board should not be coated, as coated areas are not solder-able. Therefore, if the end-user needs to solder their own switches very close to the microcontroller area, it is best to leave the board uncoated.

Other physical damage protection events like overheating are beyond the scope of this blog post and may be potentially covered in a future post. However, such events are exceedingly rare.

1. The concept of “fatal” failure is used expansively to include any failure mode which has the potential to cause irreversable damage to any component in the system as a whole. “Fatal” failures do not necessary suggest that a system will be inoperable at after the event, merely that damage is a possibility. [Back]

2. The human body model, under IEC 61000-4-2, prescribes a maximum testing voltage of 8kV in contact discharge and 15kV in air discharges. [Back]