Author Archives: Andi

What Are Switch-Mode Power Supplies?

Linear power supplies, once quite common, have now been mostly replaced by switch-mode power supplies (SMPS). The liner power supplies typically had a dissipative regulator – a voltage control element – usually a transistor that dissipated power equal to the difference between the unregulated input voltage and the fixed output voltage times the current flowing through it. The dissipative element prevented the linear power supplies from reaching high efficiencies.

On the other hand, the switching regulator in a switch-mode power supply behaves more like a continuously variable power converter. That allows the difference of the input and output voltages to affect the efficiency of the switch-mode power supply only marginally. Therefore, the switching regulator acts as a non-dissipative regulator, since the regulating device always operates either in a cut-off mode or in saturation.

Typically, the SMPS chops the input DC supply at a high frequency using an active device such as a power MOSFET or BJT and feeds the chopped voltage to the converter transformer. As the chopping frequency is high, the transformer is made of a ferrite core that can handle such high frequencies. Another advantage in keeping the operating frequency high is that the size of the magnetics decreases. The output of the converter transformer is rectified and filtered before being useful for the load. A part of the output voltage is fed back to the regulating/drive circuitry of the switching element to achieve regulation.

An SMPS usually has an oscillator that switches the control element on and off. When switched on, the control element pumps energy into the primary of the converter transformer. As the switching element switches off, the magnetic field associated with the energy in the converter transformer creates a secondary voltage in the output winding of the transformer. This voltage is rectified, filtered and fed to the load.

The frequency of switching, or the duty cycle of the oscillator is varied to control the energy fed into the converter transformer and consequently the output power delivered. An SMPS operates at a high efficiency since only the energy necessary to maintain the load current is pumped in, leading to minimal power dissipation.

The higher frequency of operation of an SMPS, typically in KHz/MHz, drastically reduces the physically massive power transformer (hallmark of a linear power supply) and the corresponding power line magnetics meant for filtering. That reduces the overall size of the power supply and this is evident from the tiny wall-wart power supplies available for, say charging smartphones.

SMPS are designed for specific applications. They are available in different topologies such as DC to DC converters, forward converters, fly-back converters and self-oscillating fly-back converters. Although the principle of operation remains the same for all, the manner in which the switching operation works is the main difference between the various topologies.

Usually, SMPS employ a method called the pulse-width modulation or PWM to control the average value of the output voltage. The area under the output waveform defines the average voltage of the repetitive pulse waveform. As load increases, the output voltage tends to fall. On sensing this, the feedback/control circuit modifies the PWM to increase the voltage to the required level.

What Are Diacs And Triacs Used For?

When you switch on your fan or light, chances are you also have a dimmer controller to control the speed of the fan or the intensity of the incandescent or LED light. Typically, dimmers are useful only where alternating currents are used, because they have components that allow only part of the waveform to reach the appliance. That means the appliance receives only part of the energy supplied and hence runs slower or glows dimly. Dimmers accomplish this AC waveform chopping or phase control with the help of two active components – a diac and a triac.

A diac is a bi-directional diode, equivalent to two zener diodes connected back-to-back. The diac is designed to break over at a specific voltage. When the voltage applied (in either polarity) to the diac is less than this break over voltage, the device continues in a high resistance state allowing only a minor leakage current.

As the applied voltage crosses the break over voltage (in either polarity), the diac starts conducting with a negative characteristic. That means, as break over occurs, the current flow increases and there is a corresponding voltage drop across the device. According to Ohm’s Law, an increase in current typically leads to a larger voltage drop, provided the resistance remains constant. However, since the diac shows a drop in voltage with increased current at break over, its resistance must have decreased. This is the reason for stating a diac exhibits negative resistance at break over.

The triac operates similar to two thyristors connected in reverse parallel but with their gates in common. Therefore, a triac can conduct in both directions when a voltage of either polarity is present across it and it has been triggered on by its gate terminal. The polarity of the gate pulse is immaterial for initiating conduction of a triac.

By controlling the gate pulse to occur at a specific position in the voltage waveform applied to the triac, it can be made to conduct for only a part of the entire cycle. This allows delivery of a fraction of the voltage to the appliance.

In a dimmer circuit, a diac is used to trigger the triac. Typically, a capacitor is allowed to charge via a variable resistance from the supplied AC voltage. As the capacitor charges through the resistor, the voltage on the capacitor rises until it reaches the breakdown voltage of the diac. The diac then conducts and triggers the triac, which, in turn, applies the remaining voltage of the cycle to the load/appliance. As the supply AC voltage crosses over, the triac switches off automatically, until again triggered by the diac.

If the resistance is large, the capacitor charges slowly and voltage on the capacitor takes more time to reach the breakdown voltage of the diac. That triggers the triac later in the waveform, preventing a major part of the voltage waveform from reaching the appliance. If the capacitor is allowed to charge faster, by keeping the resistance smaller, the triac triggers early in the cycle, and more voltage can reach the load.

Give Your Raspberry Pi an Intelligent Power Switch

Whether you use a desktop or a laptop computer, one of its features is the intelligent power supply that shuts down the system once it detects that the software has sent the shutdown command. To switch the system on, you need only press a small button. The Raspberry Pi, or the RBPi, being a low-cost single board computer, does not have this feature. After shutting down the OS, you have to unplug the power cable physically from the RBPi.

With large numbers of community projects springing up around the credit-card sized SBC, the RBPi can also enjoy the features of an intelligent power supply. This is the Pi Supply project, which sits between the actual power supply and the RBPi, adding its own intelligence as necessary. Pi Supply takes its power from the micro-USB charger and powers the RBPi.

When the RBPi issues a ‘sudo halt’ command, Pi Supply detects the shutdown command and switches off the power to the SBC at a safe moment. To switch the power back on, simply press a button on the Pi Supply, and your RBPi springs back to life. You do not need to plug/unplug the micro-USB connector anymore. With power supply issues being one of the biggest headaches for SD card corruption, the Pi Supply is a very handy project.

The Pi Supply provides a single window solution to all the power management problems your RBPi currently faces. This intelligent ATX style power supply switch is a revolutionary solution for the RBPi, since you do not need to disconnect any power supply wire from the wall-wart to the RBPi. Turning power on/off to the RBPi is now possible simply by touching one of the two buttons on the Pi Supply.

Once your work with the RBPi is over, you simply issue the command ‘sudo halt’. Once the OS has safely and fully shutdown, the Pi Supply will cut the power to the RBPi. If you would like to resume working, touch the on button, and the Pi Supply will restore power to the RBPi.

The second button on the Pi Supply is meant for a hard power off. In case of emergency, pressing this button will immediately cut the power to your RBPi. However, this button must only be used when absolutely necessary, as when your SBC has crashed or is in the frozen state and is refusing any attempts of revival. Note that use of this button increases the risk of file corruption on your SD card, if operated at the wrong moment.

One of the most amazing features of the Pi Supply is that it is able to distinguish between ‘sudo halt’ and ‘sudo reboot’. That means not only can Pi Supply shut down the power supplied to your single board computer when you give the halt command, but it can also reboot your SBC when you want, without you touching a single button or removing a single connector. That makes it almost as intelligent as the ATX power supply of your desktop.

MIPS Creator CI20: Challenge for the Raspberry Pi?

Although the Raspberry Pi or the RBPi did bring a revolution in the world of tiny computers that can teach children the intricacies of computer programming with inexpensive ease, not all are happy about its capabilities. There are two main points of contention with the credit-card sized single board computer – the low amount of RAM and the lack of onboard storage.

A quick recap of the RBPi’s specifications shows that it uses a system on a chip (Broadcom BCM2835). This includes the 700MHz processor (ARM1176JZF-S) and a GPU (Videocore IV). Initially, the board shipped with 256MB of RAM, but later up-gradations had 512MB in the Models B and B+. There is no built-in storage device and RBPi uses the SD card for booting and persistent storage. The latest model B+ has four USB2.0 ports, one Ethernet port, one 15-pin MIPI camera interface, one composite video output, one HDMI output and one audio output on 3.5mm jack. The 40-pin expansion header has 27 GPIO pins.

Now, there is a more powerful computer in the market to challenge the RBPi. Moreover, it is available free. The MIPS Creator CI20 is a development board from Imagination Technologies and it can run Linux distributions such as Gentoo, Arch and Debian 7.

The CI20 runs on a dual core processor based on the MIPS architecture and operating at 1.2GHz. The GPU, a PowerVRSGX540, is capable of running OpenGL ES 2.0.The onboard RAM size is 1GB, with 8GB onboard flash storage. The board features an SD expansion slot, one pair of USB 2.0 ports, Bluetooth 4.0, Wi-Fi and Ethernet. The expansion header features 25 GPIO pins and 2 SPI buses. You can boot the board from either the SD slot or the flash memory.

Compared with the RBPi model B+, the advantages that CI20 has are – double the RAM, a faster processor, onboard storage and built-in Wi-Fi and Bluetooth. In addition, CI20 has its power supply onboard, which the B+ does not. The disadvantages are – CI20 has only two USB ports compared to the four on the B+. In addition, the form factor of the CI20 is larger than what the B+ has.

Since the CI20 has higher capabilities such as more computing power, onboard storage and wireless connectivity, it is assumed that it will cost more than the current price of the RBPi B+ ($35). However, Imagination Technologies have not yet revealed the price of their new board. Imagination, instead of selling the initial batch of CI20s, is giving them away free to tinkerers.

Therefore, if you want to lay your hands on a CI20, you must have a grand project idea for the board. That means this giveaway is not actually meant for the hobbyists, but rather aimed at developers. However, do not be discouraged even if you are planning to create a video arcade console/home entertainment center/TOR proxy at home. It may turn out that your CI20 based home automation hub is interesting enough for Imagination and they are willing to send one of their free development boards your way.

How do Electronic Potentiometers work?

Nowadays, most electronic gadgets change their settings such as volume, bass, treble, brightness, contrast, sharpness etc., through “up/down” or “+/-” buttons in contrast to the rotary mechanical controls earlier. These are the electronic or digital potentiometers in action.

While the principle of operation remains the same whether it is a mechanical or an electronic potentiometer, the functionality of the two is quite different. While the mechanical potentiometer offers a continuous variation because it is an analog device, the electronic version is a digital type, offering discrete variations. The difference is due to the way the voltage dividing functionality is implemented in the two versions. As opposed to a single resistance in a mechanical potentiometer, the electronic version has several resistors, also called the resistor ladder network, switched into the circuit with multiple switches.

The voltage at the center terminal of the electronic potentiometer, therefore, depends on the resistance presently connected to the circuit with one of the switches. At first glance, it would seem to be a simple matter to increase the number of resistors and switches to reduce the granularity. However, electronic or digital switching requires each switch to have a unique digital address, usually in the binary format, defined by bits (0 or 1). Higher number of switches means larger number of bits, which increases the complexity of the electronic circuit controlling the switches. The switches, instead of being individual mechanical types, are usually semiconductor types and are integrated into a circuit along with their controller and the resistor ladder network.

This results in a neat little package, which can be soldered in-circuit and requires no panel or knob for its control. Usually, the control is via a micro-controller, which reads the increase or decrease instruction from the UP/DOWN buttons on the remote. It then generates a suitable binary word and sends it to the specific electronic potentiometer chip controlling the volume or any other function you want to change. Depending on the binary word, a specific switch turns on, connecting the required resistance to the central terminal of the potentiometer.

Just like their analog counterpart, electronic or digital potentiometers are also available in a variety of tapers such as linear, log, reverse-log, etc. Taper defines how the wiper voltage changes as it is moved from one end of the potentiometer to the other. For a linear taper potentiometer, both analog and digital, the wiper voltage bears a linear relationship to its physical position. For a potentiometer following the logarithmic or the reverse logarithmic taper law, the wiper voltage is nonlinear.

Since an electronic potentiometer is implemented in a chip, manufacturers adopt different ways of achieving the same results. While resistor ladder network is the most popular, the ladder implementation itself may differ for achieving the desired taper. Some manufacturers use operational amplifiers as buffers before or after the network, some use an anti-thump circuit to reduce the plop noise that is heard when one switch opens and another closes.

One major difference between the analog and the digital versions of potentiometers is the power handling capacity. Typically, the digital versions, in chip form, are unable to handle more than a few mill watts. In comparison, analog potentiometers capable of handling a few watts are quite common.

How Do Mechanical Potentiometers Work?

Electronic gadgets of about one generation back (prior to the prolific use of SMD), used rotary mechanical potentiometers for setting different parameters such as volume, tone, brightness, contrast, etc. For adjusting circuit parameters within the gadget, a smaller variation called the trim pot was a common sight. These are outdated now, but those who still own and use these gadgets often wonder how mechanical potentiometers function.

The most common example of a mechanical potentiometer is the rotary volume (also tone, bass, midrange and treble) control in an audio amplifier. Unless your amplifier has a remote control, chances are that for increasing or decreasing the loudness, you turn a knob labeled as “Volume” control. When you want to reduce the sound output from the speakers, you rotate the knob counterclockwise. The sound output increasing when the knob is turned clockwise. On the remote control, the knob is replaced by two buttons, one marked “+” for increasing and another marked “–“ for decreasing the sound output. Another example is the fan speed control, used mostly prior to the electronic versions.

Therefore, a mechanical potentiometer is a device to control a gadget’s complete range of operation. In its most common use, a potentiometer acts as a voltage divider. This three terminal device has a central pin that allows the resistance to be varied. This is called the wiper – named for the way it makes the mechanical connection to the fixed resistor between the other two terminals. If you connect the wiper electrically to any one of the other terminals, you transform it into a variable resistor or rheostat.

That the device acts like a voltage divider is easily verified from the schematic. If the voltage across the fixed resistor is the difference of voltages Va and Vb, the wiper will show a voltage Vw anywhere between Va and Vb depending on its position. Mathematically, (Va ~ Vb) = (Va~Vw) + (Vw-Vb). The device serves to cancel out tolerances of other components, when used in-circuit as a trim pot; thus allowing the required voltage setting to be achieved.

In construction, a mechanical potentiometer has a fixed resistor in the form of a circular track, stopping just short of a full circle (usually about 270-degrees). The track is printed on a ceramic or a glass-fiber base. The two ends of the resistance form terminals that may either be PCB solderable or suitable for wire termination. Depending on the requirement, the resistance may be of any value between a few ohms to several hundreds of ohms. The entire arrangement is encased in a housing, which also serves to accommodate the wiper assembly.

The wiper assembly consists of a phosphor-bronze spring that lightly bridges the surface of the resistance track and a circular metal track that forms the third terminal. The spring and track arrangement is attached to a metal shaft, but electrically isolated from it. The spring turns as you rotate the shaft, allowing the wiper to change its voltage.

The trim pot has a similar arrangement, lacking only the metal shaft for rotating the wiper. Instead, the phosphor-bronze spring doubles as the shaft, suitable for adjustment with a trimmer screwdriver. Potentiometers may also be of multiple turns to increase their resolution.

Turtle Graphics on the Raspberry Pi

In 1966, Seymour Papert and Wally Feurzig developed the Logo Programming Language. As a part of this, Turtle Graphics was a very simple way of teaching programming to children. It consisted of a robotic turtle starting at coordinates 0, 0 in the X-Y plane on a computer screen. With a command turtle.forward(20), the turtle would move forward by 20 pixels in the direction it was facing, drawing a line as it moved. To turn the turtle where it is standing, a command turtle.right(30) would make it rotate 30-degrees clockwise. By combining the two commands and a few others, drawing intricate pictures and shapes on the screen was possible.

Now, the Python standard distribution contains a module “turtle” that allows extending the re-implementation of Turtle Graphics. You can run this on your tiny credit card sized inexpensive single board computer, the Raspberry Pi or RBPi. The Python module tries to keep the same merits as available with Turtle Graphics and is nearly fully compatible with it. That means the learning programmer can use the same commands, classes and methods interactively, when using the module.

For example, if you want to find out where your turtle is at present, you can query it with turtle.postion(), and the turtle will respond with its current X & Y coordinates. Now you can command it to move forward or backward, turn right or left and even check its orientation. For a complete list of the turtle commands, look up module-turtle. Apart from moving in straight lines, you can command the turtle to move in a circle of a given radius.

The Python module turtle is a versatile program. Various commands make the turtle do different things. For example, you may want the turtle to move but without drawing any line. Another command can make the turtle leave a stamped mark at its current position. Yet another command can make the turtle invisible, and another can make it draw lines in the color you specify.

Since RBPi is for children who are starting to learn computer programming, the combination of Turtle Graphics and RBPi is a powerful way of teaching them the basics of robotics. The language used by the module turtle is very similar to every-day English, which makes it very easy for children to learn and use.

Children find it difficult to grasp the abstractions on which traditional Euclidean geometry is built. For example, how do you have a point without size or a line that has a length but no thickness? Young people find all this difficult to grasp. However, the turtle being a real concrete object can be seen and manipulated. Turtle geometry being body syntonic, is easily understood since the turtle moves about just as everybody does. That makes it easy to identify with and its actions are well understood by kids.
Seymour Papert has explained the rationale behind turtle geometry in his book Mindstorms.

Another very simple way of learning turtle graphics on the RBPi is through Kids Ruby. Overall, with Turtle Graphics you can teach absolute beginners the concept of storing algorithms and running them so that the computer will simply obey the given commands.

What’s the difference between SD vs SDHC cards?

We use several types of digital devices, which store data on external memory cards. Unfortunately, just as there is a large variety of digital devices, there is a plethora of memory cards to add to the confusion. People juggle with SDHC, SDXC, SD, MiniSD and MicroSD among the most popular cards. Often it is puzzling to ascertain what type of memory card will suit your camera, phone, MP3 player, tablet or other mobile digital device. Most memory cards are flash type with difference in formats, sizes and speeds.

SD vs SDHC:

Apart from Apple products, most digital devices offer means of adding to the internal storage capacity. Typically, this is some variety of the Secure Digital or SD memory card. Although SD has emerged as the most popular flash memory format, there are scores of SD cards of all shapes, sized and speeds to choose from – making it somewhat confusing to pick the right one for your device.

With flash memory cards, the primary aspects that need consideration are their physical format, size and speed. Since each of these variables has its own set of classes, you may find anything from 1GB Class 2 MicroSD card to a 16GB UHS-1 SDXC card.

When buying a memory card, consider where you are likely to use it. Chances are that your camera, smartphone and your camcorder use different sizes of card. Although you can start with the smallest physical format and use adapters to make it fit in different gadgets, it is better to use the card size that is intended for the device.

The largest format is the standard SD card measuring 32x24x2.1mm. Most digital cameras use this format, with high-end cameras shifting to CompactFlash cards, which are smaller. These days, the least frequently used card is the MiniSD card, measuring 21.5x20x1.4mm. Almost all cell phones and smartphones nowadays use the MicroSD card, which has dimensions of 15x11x1mm.

Memory cards come in a huge variety of storage capacities. However, the maximum capacity of a standard SD card is limited to 2GB. The most popular MicroSDHC or Micro Secure Digital High Capacity cards are available with capacities between four and 32GB. The Secure Digital Extended Capacity or SDXC can theoretically range from 64GB to 2TB. However, currently, the largest capacity available is only 128GB.

Larger the memory capacity, so much more you can store. However, if you have an older device, chances are that it can use only the larger SD card. The classification SD/SDHC/SDXC applies to devices as well. Therefore, double-check the type of cards your device can handle. SDHC cards will not work in a device that can handle only an SD card.

Flash cards are available in various speeds as well. The speed class ranges from Class 2 (slowest) to Class 10 (fastest). Class 2 is useful for standard-definition video recording. With Class 4 to Class 6, you can record high-definition video. When you are recording HD video or consecutive recording, Class 10 is more suitable.

If your camera or smartphone can shoot HD video or if you are going to shoot many high-resolution photos in quick succession, you should buy the Class 10 card. For occasional snapshots or casual videos, Class 4 to Class 6 cards will do fine. Prices vary between different types of cards – high-speed high-capacity cards are more expensive.

Drive a 16-Channel Servo with the Raspberry Pi

To drive servomotors micro-controllers must have PWM outputs. These are output pins on which the micro-controller will generate pulse outputs with controlled or modulated variable widths. Most embedded micro-controller units have one or more of these outputs. The famous single board computer, the tiny credit card sized Raspberry Pi or RBPi also has one IO pin dedicated for PWM. This is the PWM channel available at the GPIO18 of the RBPi and with this, you can drive a single servo at best. However, if you want the RBPi to drive more than one servo, it will need additional circuitry.

A PWM driver IC such as the PCA9685 can drive 16 servos at a time, but requires commands and data through its I2C interface. Fortunately, the RBPi can also communicate using the I2C protocol, enabling it to control 16 servos via the PCA9685. Adafruit has a very convenient breakout board with the PCA9685 on it and that makes it very convenient to connect to the RBPi. Not only can you drive servos with the PWM outputs, you can use the PWMs for controlling LED lighting as well.

To let RBPi communicate with the I2C protocol, it will require a special OS available from Adafruit. This is the Occidentalis flavor and it has all the libraries required for invoking I2C. However, if you are using the stock Raspbian OS, you must install the python-smbus and the i2c-tools using the “sudo apt-get install” command. To learn more about using I2C, refer Adafruit’s rather informative tutorial.

The two packages will allow you to search for any I2C device connected to the RBPi. The easiest way you can connect the servo breakout board to your RBPi is with the help of the Adafruit Pi Cobbler. Here, VCC is the digital supply for the IC or 3.3V, and V+ is the supply for the servomotors (typically 5V).

The actual chip that drives the servos, the PCA9685, needs 3.3V, and connects to the VCC on the cobbler board. Servos usually require much higher currents to operate. Therefore, they are powered from a separate power supply, typically 5V, and are connected to the V+ on the Cobbler. Note that this 5V is different from the 5V supply for the RBPi. The PWM operation on the servos creates a huge amount of electrical noise, which can cause the 5V supply voltage to fluctuate significantly. RBPi may not be able to tolerate such voltage fluctuations, and this may cause it to crash and lock up.

If you are driving many servos, it will be a good idea to add a capacitor to the driver board. There is a spot already marked for such a capacitor. As a thumb rule, you need a capacitor with a value n x 100uF, where n is the number of servos you are driving. Capacitors are manufactured in standard ratings, and you may have to go for the next higher standard value that you have calculated.

Depending on whether you are using a standard or continuous rotation servo, your python code will vary. For the actual code with which you can control the various parameters of I2C and hence the servo, you may refer to this site: https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi

What should my CPU temperature be?

Normally, computer users are not very concerned about what temperature their CPU is running at. Desktop users may feel the hot air coming out of the back and laptop users may be concerned if the heat is too much for their laps. In reality, the temperature of the CPU depends on what the computer is doing, that is, how many programs it is currently running and how the manufacturer has arranged the fans in the cabinet.

Although the exact information of how hot your CPU should be running will be available with the processor manufacturer on their website, most processors used in desktops today do not exceed 90°C and typically operate between 70 and 90°C. However, this is only a general idea of what the processor should be running at, and as said earlier, the actual temperature depends on what programs the computer is concurrently running.

If you notice your computer running much slower than usual, restarting often or randomly crashing or turning off, it is likely that the processor is getting too hot. These effects are usually more noticeable when playing advanced games or when too many programs are running at the same time. If you continue to use your computer when its processor is exceeding its temperature limits, it is likely to reduce the life expectancy of the processor.

As the CPU speed reduces when its temperature goes up, you get more performance when the processor is running cooler. Overclocking a processor may allow you to run the CPU at a higher speed, but there is a likelihood that it will also generate more heat and its temperature will go up. Therefore, paying attention to how to remove excess heat from your computer may help in extracting more performance from it.

It is very important to keep your computer clean. Over time, hair, dirt and dust build-up can clog the ventilation holes and prevent good airflow inside the case. Therefore, make sure all ventilation holes are clean and heat sinks are not covered in grime.

For good air circulation, make sure the computer is placed in a good location, and not in a closed space such as inside a cabinet or a drawer. Unless there is plenty of ventilation, you may remove the back of the cabinet or the drawer. Keeping a space of at least two inches on both sides and the front of the computer is a good practice.

Verify that all the fans mounted inside the case and on the CPU heat sink are operating properly; look for any spinning or noise issues. Operating systems can monitor and display the fan speeds of the major fans in the computer. If you have replaced the processor or its fan lately, make sure you have applied the thermal paste properly, as that helps to transfer the heat away from the processor to the heat sink. You may also want to install more fans or replace those present with ones more efficient in moving air; check the CFM rating – higher is better.

Lastly, for those heavily into gaming or interested in over-clocking, water cooled solutions are available to keep processors cool.