Monthly Archives: November 2018

ATtiny Remote Power Switch for the Raspberry Pi

One of the shortcomings of most highly popular single board computers such as the Raspberry Pi (RBPi) is the lack of an on/off power switch. The board springs to life as soon as you insert the micro USB power cable into its socket. If you simply switch off power or pull out the micro USB cable off the RBPi, you stand the risk of not only losing data but also of corrupting the file system. Therefore, to shutdown the RBPi safely, you need to call a shutdown command, which closes down the file system and takes the RBPi into a safe state, allowing you to remove the USB cable.

The above has been the reason for several projects to incorporate a switch with the RBPi that will safely switch it off without corrupting the file system. Most of the projects incorporate a board sitting on the GPIO header of the RBPi along with a micro USB connector and a toggle switch to control the power supply for the RBPi. The entire control of the power supply comes from a tiny microcontroller on the add-on board, which monitors the state of the toggle switch and the RBPi. In turn, the microcontroller switches a MOSFET and an LED indicates the status of power. This also precludes the necessity of unplugging the RBPi from the power module after switch off.

This power switch from Nanomesher, using an Attiny85 microcontroller, adds a new dimension to controlling the RBPi—it has a remote that you can use to remotely control power to the RBPi. The entire arrangement comes as a kit, and you get a hack able and smart power switch for the RBPi that a removable Attiny85 microcontroller controls. There are also four jumper cables that allow the board to connect to the RBPi GPIO, a high quality micro USB cable 20 cm long, and an infrared remote control.

The project is hack able in the sense you can remove the ATtiny85 microcontroller and reprogram it to provide any type of functionality with the remote. Of course, reprogramming the ATtiny85 will require an Arduino-compatible platform such as the Uno. Other Arduino devices with switches are available, and you may already own some, or you may buy them for experimentation. The ATtiny requires wiring up with the Arduino on a breadboard for the programming.

You can use the included remote or any other remote already available with you. Since the kit is hack able and reprogrammable, you can make it recognize many more signals, changing the timings and functioning of the shutdown. For instance, you may add another button for a hard reset, and reprogram the Attiny85 to recognize it.

Although the kit does a fine job of shutting down the RBPi safely, the presence of the jumper wires to connect to the RBPi makes the kit somewhat cumbersome to use. The project would have been much more useful if the kit could be fitted onto the RBPi in the form of a HAT. Of course, the presence of jumpers does make the kit more flexible since one can select the GPIO pins for connection.

Low-Side & Hi-Side Current Sensing

Electronic systems tend to manage their power consumption to reduce the production of heat as waste. This calls for optimizing the system efficiency by effectively distributing power. As the voltage applied to the circuit is usually a constant, engineers monitor power consumption by keeping track of the current drawn by the circuit—power being the mathematical product of the current and voltage fed to the circuit. Current sensing has additional advantages, mainly that of maintaining the health of the system, preventing circuit faults from turning disastrous, and preventing batteries from over-discharging.

Engineers use two basic methods to monitor electric current. The first method follows Ampere’s law, and engineers measure the magnetic field surrounding a current-carrying conductor. The second method follows Ohm’s law, and engineers measure the voltage drop across a small resistor inserted in series with the circuit. The first is a non-intrusive method, but useful only for regularly changing currents, such as alternating current. It is also an expensive method, rather prone to temperature coefficient errors and effects of non-linearity. The second method is simpler, but introduces an element of insertion loss.

The semiconductor industry offers resistive-sensing techniques that are cost-effective and accurate, while making measurements suitable for various applications running on direct current. The resistive-sensing technique relies on sensing the current on the low-side or on the high-side of the circuit, the optimal approach depending on the application.

In resistive sensing, engineers insert a low-value resistor in series with the current path. This produces a small voltage drop in proportion to the current the circuit is consuming and which passes through the resistor. An electronic sense amplifies this tiny voltage to make it easier to process further. However, the sense resistor’s placement depends on the environment of the application and this can present some serious challenges for the sense amplifier.

If the position of the sense resistor is between the load and the circuit ground, a single operational amplifier, acting as a sense amplifier, is adequate to amplify the resulting voltage drop. Engineers call this low-side sensing, and is different from high-side sensing, where they place the resistor between the positive lead of the supply and the load.

In both cases, the sense resistor must be of adequately low value to prevent it from dissipating high power, but its value must be high enough for it to generate a detectable voltage for the sense amplifier to multiply it accurately. The sense amplifier multiplies the difference of voltage across the sense resistor, but uses a common-mode voltage for the purpose.

For low-side sensing, the common-mode voltage is close to the ground, and the rest of the circuitry following the sense amplifier may run on low voltage. However, high-side sensing requires the common voltage to be close to the supply voltage, and sometimes this may be high enough to present supply voltage problems for the circuit following the sense amplifier.

Some applications are unable to tolerate the tiny voltage drop introduced by the sense resistor on the low-side. The situation aggravates as the load current increases. For them, engineers have to follow high-side sensing inevitably.

What are Ball Grid Arrays?

Initially, surface mount devices, especially ICs, came as perimeter-only packages, with pins for soldering placed along the edge of the device. As ICs became more complex, they needed more pins for external interfacing, which made the packages larger. Manufacturers soon realized there was a large unused real estate that lay just under the package. Therefore, they made the ball grid array (BGA) packaging, which, in place of pins, had solder balls aligned in a grid under the device. Soldering BGAs involves melting these solder balls onto pads on the PCB.

Using BGAs leaves a considerably larger area free on the PCB. Compared to mounting a package with pins on its perimeter, BGAs offer better thermal and electrical properties, and this has made the format popular, following the continued miniaturization of electronics.

Since their introduction, although their basic concept has remained the same, BGAs have changed in dimension and now come with far smaller pitches and smaller outlines. There are varieties as well, with some packages having connections only on the periphery and none at the center, while others have the connections distributed evenly across the bottom of the package.

For simpler BGAs, routing traces on the PCB is simple as the balls are placed well apart or there is space in the middle of the device. However, with increasing pin counts and decreasing pitches, routing between the pins becomes more difficult, resulting in increasing the layers of the board, thereby increasing the cost and reliability concerns.

As BGAs become increasingly more complex, designers have to depend on vias to connect the BGA with the rest of the circuitry on the PCB. Vias are small holes drilled through the multilayer PCB and plated with copper to provide connection between pads and traces on different layers. Some vias are through-hole types, meaning they start and end on the two extreme layers of the PCB, and may connect to other layers in between. Other vias can be blind types, starting from one of the outermost layers and ending on an internal layer, possibly connecting other layers in between. Blind vias are not visible on the PCB surface as they start and end at different internal layers, and may connect other internal layers as well. However, all the above require great precision while manufacturing, and are expensive processes.

Ordinarily, PCB designers prefer not to use vias on a pad, as during soldering, vias can wick solder from the pads leaving the joint in a dry and unsoldered state. However, with BGA pitches getting increasingly smaller, designers do not have much choice, but tenting is offering a way out. Tenting allows filling the via hole with an insulating material and covering the top with a layer of copper, thereby preventing wicking.

As the BGA pins lie in between the device body and the PCB, traditional soldering methods such as hand soldering and wave soldering are no longer useful, and assemblers rely on infrared heating or reflow ovens to solder BGAs to a PCB. This requires a pick-and-place machine placing the BGA package precisely on the pads and uniformly heating the area to form the actual connections.

How Do Power Supplies Share Current?

Those who use power supplies to run different devices often face a peculiar problem. The load may demand more power from a single power supply that it can safely provide continuously. Since the voltage to the load has to remain constant, the situation calls for using additional power supplies to supply the excess current, and inevitably, users must connect them in parallel. However, simply connecting power supplies in parallel does not guarantee they will share the load current between them in an acceptable manner to operate normally.

Although designers do design some power supplies with dedicated circuits within them to ensure proper sharing of load current when connected in parallel, this is not a generalized practice. Moreover, even if power supplies of one manufacturer can optimally share current when connected in parallel, they may not do so when operating in parallel with power supplies from another manufacturer. In fact, power supplies from the same manufacturer but different models may also not work satisfactorily in parallel.

Theoretically, an ideal voltage source will supply unlimited amounts of power all the while maintaining a constant voltage level. Real power supplies have a limit to the amount of current they can supply to the load. If a load wants to draw power beyond the capacity of the supply, it will reduce its output voltage such that the power delivered remains within its capacity. Should the demand for current increase further, the output voltage reduces further until it reaches zero, and the power supply shuts down. Recovering automatically or through an external reset from an over-current situation is a design feature.

In reality, all voltage sources come with a positive and non-zero internal impedance. This drops the output voltage at the terminals as the load current increases. Power supply specifications call this change in output voltage with load current as the load regulation, and this is specific to each power supply. As the requirement is to have the output voltage change as little as possible with increasing current, some power supply designers prefer to design for low output impedances. Some power supplies have remote voltage sensing to boost the output voltage by the amount it has drooped. However, this is not desirable when sharing current.

One of the problems in connecting power supplies in parallel to supply higher current than either can supply is the current balance characteristics of the units may not match. In case the error in the initial voltage settings between the units is bigger than the depression in the output voltage at maximum load, the first unit may supply its entire share before shutting down. This leads to the second unit attempting to deliver the load current, and since it cannot do so, it shuts down as well.

One of the methods to enable proper current sharing is to enhance the output impedance of each unit so that their individual output voltage droops at full load is far more than the no-load voltage difference between the units. Although the voltage regulation of the system degrades significantly due to the intentional voltage droop, the current sharing between the power supplies is more successful.

ElectroSmash Pedal for the Raspberry Pi

Guitarists favor expensive gear. For instance, they hold online discussions about the best types of wire for guitar pickups. They even go to great lengths while selecting the type of transistors that will give them the best fuzz tone. They hold extensive discussions about the merits of the pentode rectifier over the tetrode type. While the geeks in the electronics world share several common characteristics with the guitar geeks, the ElectroSmash Pedal Pi would interest both.

Both teams are already familiar with the single board computer, the Raspberry Pi (RBPi). ElectroSmash provides a pedal that works with the RBPi Zero and allows the user to program the effects. The brains behind the project are in the code that the user has to download and compile on the RBPi.

Although it is possible to write the code afresh, but downloading the sample provided by ElectroSmash is more sensible, and gets you started faster. The community behind the Pedal Pi has contributed the code, and the user has the complete freedom to use it as it is, or to modify the parameters. ElectroSmash provides the Pedal Pi in a kit form, which means owners have to assemble it first.

Instructions for the assembly are available from the ElectroSmash website. The kit comes with all components neatly labeled, which makes the kit easy and straightforward to put together. One does not need extensive soldering experience for the assembly.

The kit has two ICs, the first an op-amp, and the other an analog to digital converter chip. Follow the instructions on the ElectroSmash site to place them on the board the right way around.

Typically, the RBPi Zero comes with the header pins not soldered to the board, and the user has to do the placement and soldering. However, one can get around this problem by using the RBPi ZWH variant, as this board comes with the header pins soldered in place.

Once you have assembled the pedal, you may find it is not as robust as the regular guitar pedals available on the market. According to ElectroSmash, the aim of the Pedal Pi project is to offer learning about guitar pedals and having fun with them. As an electronics kit, the ElectroSmash Pedal Pi kit certainly lives up to its claim.

Although the kit may seem slightly expensive, comparing it with other guitar pedals shows its true value. For instance, the distortion pedal from Ibanez, the classic Tube Screamer, costs almost twice the full kit. Although the ElectroSmash kit has about ten other effects built in, the user can add many more—in fact, only the programmer’s ingenuity, imagination, and programming skills limit the range of effects that the kit can handle.

Following the code sample that ElectroSmash provides is simplicity itself. They list the code sample in order of increasing complexity, ranging from the simple tone to the looping effect. The user can have fun playing with different types of distortion and use a processed quality on the fuzz, bit-crusher effect, and distortion. The effects are all available in the file fuzz.c and one can change a few numbers to give a new effect.