Author Archives: Andi

Let Raspberry Pi Read You an Audio Book

People who have grandmothers (and grandfathers) are fortunate. Although most of these old people are healthy and strong despite their advancing years, not all are so lucky and may be impaired in some way, mostly because of their failing eyesight and trouble with arthritic hands. Since they have a physical handicap, they find it difficult to operate a laptop, a DVD player or a tiny MP3 player. A Raspberry Pi (RBPi) with a large play button is actually helpful if it can read back an audio book.

This can be done in two ways. The RBPi player can have a single large button to pause and play, or have no buttons at all and be operated by NFC tags. The tags are best attached to empty CD or DVD cases, on which the details of the Audio book are printed in large letters for easy reading. Simply passing a case over the player will cause the specific audio book to start playing from its last state.

The player saves its state after every two seconds. Therefore, when the listener is bored or otherwise wants to stop listening, he or she can simply disconnect the player from its mains socket. Reconnecting it allows the player to get back to playing from its last saved state.

The RBPi player with a single large button works as a play/pause button when pressed. Going back to the previous track is easy if the listener holds the button pressed for more than four seconds. Copying files into the player is also a simple affair with a thumb drive. The files are copied into the thumb drive under a special volume label. As soon as it is plugged into the RBPi USSB port, the books are copied into the SD card and starts playing when the drive is unplugged.

For the single button RBPi player, apart from the RBPi and its enclosure, you will need a blue LED, some wires, a pair of speakers and of course, the large button. Among the software that you will need are – Raspbian image (Wheezy), mpd, mps, mpd-python, pyudev and a python script.

When the RBPi player is first powered up, it boots, starts the python script and waits with the audio book in pause. Since at a time only one audio book is stored, pressing the button starts the player. If the button is held pressed by more than four seconds, the player goes back one track. The player always remembers its last playing position.

As soon as a USB thumb drive is plugged in, the player stops playing, mounts the thumb drive, deletes the old audio book, copies the new one from the special name/label on the thumb drive and rebuilds the playlist. A flashing blue LED signals the end of file copy. Once the thumb drive is removed, the new audio book starts in pause mode, proceeding to play when the play/pause button is pressed briefly once.

Use of mpd allows the RBPi player to support wave, Musepack, MOD, MP4/AAC, MP3, MP2, OggFLAC, FLAC and Ogg Vorbis file formats.

Using a Raspberry Pi to Hack an Apple Time Capsule

You may have an old Apple Time Capsule lying around, which you may not be using because it has a failing hard drive. These were expensive at the time Apple first introduced them and for many people, a failed power supply or hard drive might have forced them to stop using the device. If you are not familiar with the Time Capsule, it is a backup arrangement for everything on your Mac. Apple coined the name Time Capsule for the hardware and Time Machine for the software. Windows users will not have seen anything like it, and you can read about Time Capsule on Apple’s official link.

You can bring your dead Time Capsule back to life using the low-cost credit card sized single board computer Raspberry Pi (RBPi). Even if you do not have a Time Capsule to modify, you can simply add a Solid State Drive to your RBPi, house the two in a suitable box and make a Pi Capsule for using on your Mac with the Time Machine software. For information, Linux users may backup to the Pi Capsule using any one of the 21 backup software programs listed here.

Backing up over the wireless may be slow, depending on the Wi-Fi speed. However, you can get much faster speeds using the Pi Capsule over wired Ethernet. Of course, the first time you start a backup, the process will take a long time, so try not to interrupt it. Future backups will be faster because they will be only incremental.

You will need a power supply suitable to power up both your RBPi and the Time Capsule (in case the power supply in the Time Capsule has given up the ghost). Connect the SSD hard drive using a SATA to mini-USB cable via a powered USB hub. It is essential to connect only the wireless mouse and the powered USB hub to the RBPi. Anything else you want to connect to the RBPi, such as the keyboard, SSD, wireless card, etc., goes through the powered USB hub.

For the RBPi, you will need an 8GB SD card with the latest “Wheezy” Linux operating system on it. For instructions on how to load Linux on the SD card, see instructions here. Connect a display through the HDMI. When booted the first time, you will be taken to “Raspi-config” automatically, allowing proper setting for the keyboard connected to the RBPi. Now connect the Hard Drive or the SSD to the RBPi using a SATA to mini-USB cable via the USB hub. For getting the RBPi working with the Time Machine on a Mac, follow the guide here.

Pi Capsule has some extended features over the Apple Time Capsule. For one, it can plug into your TV or any other display. Apart from using it only as backup device, the Pi Capsule is actually a full-fledged computer, which you can simultaneously use for web surfing or emailing. If you are not using an Apple Time Capsule and if you have the ability to make cases, build one to house both the hard drive and the RBPi, taking care to leave openings for the RBPi connectors.

What Are NFC Tags And How Do You Use Them?

NFC stands for Near Field Communication. These are small tags, which can be programmed to talk to your phone. As you swipe your phone over an NFC tag, it triggers preset commands you have programmed into it. NFC tags are quite cheap, for example, you can pick up 10 of them on Amazon for about $13.

Here are some examples of using NFC tags –

• Tag No.1: On key chain. A simple trigger to take you to a specific website
• Tag No.2: On the kitchen counter. It triggers several commands – turn Wi-Fi on, turn Bluetooth off, turn Sync on, turn Brightness up and turn Volume up
• Tag No.3: Besides the bed. Turns volume to silent, turns brightness down
• Tag No.4: In the car. While entering the car, turns Wi-Fi off, turns Bluetooth on, opens Audible App, turns Synch off
• Tag No.5: In the car. While leaving the car, turns Bluetooth off, turns Sync on

Therefore, you can program these tags to make your phone do a bunch of things by simply passing it over the top of a tag. You do not need to open an app and individually change each setting; simply passing your phone over a pre-programmed tag will do the trick. To set up your Android phone, go to settings > More > Check off NFC. Unfortunately, Apple does not support NFC, so you cannot use the tags with iPads and iPhones.

You will need to download the Trigger App. If you have not downloaded this, your phone will take you there the first time when trying to use and NFC tag.

Technically, NFC has the ability for two devices to send data to each other simply by bringing one near the other. Here, the word device stands for a tag and a cell phone. NFC tags, also referred to as smart tags, have chips embedded into them and these can be programmed to transfer just about any instruction or data via NFC.

MOO.com offers business cards with NFC tags embedded within them. The idea is that when you hold your NFC enabled business card to an NFC enabled cell phone, your contact details are automatically added to the phone’s contact book. Therefore, you need to carry only a single card with you, which saves time and money. Moreover, no sensitive data is exchanged and there is virtually no security risk involved.

Advertisements have QR codes on them, allowing people to scan them to go to their blogs. That requires a barcode scanning app, the light has to be just right and the entire QR code has to be captured properly. With NFC tags, you only need to pass your cell phone over the advertisement to get the required information.

The NFC Task Launcher will allow you to program your NFC tags with your mobile phone. Once you have them programmed, the tags will help you to do almost anything from going to a website to enabling/disabling the Wi-Fi, adding contact details, setting an alarm, embedding information for a location and more.

What Is A Semiconductor Compass?

Chances are that your smartphone has a compass to show you which way is North. A normal compass consists of a magnetic needle suspended on a pivot and the earth’s magnetic field aligns it towards the magnetic North Pole. Since there is no magnetic needle within the smartphone, it is a wonder how this digital compass works. Well, a modern smartphone contains a built-in electronic or semiconductor compass, also called the eCompass. Moreover, this eCompass is calibrated for the magnetic interference from the circuit board and compensated for the tilt of your smartphone.

Probably the first sensor to be incorporated into a smartphone was the accelerometer that selected between the portrait and landscape display orientation. Then came the magnetometer and this evolved into the electronic or eCompass. The electronic compass is used to align the street maps to the geographic heading of the smartphone or to overlay augmented reality. With the high-volume production and use of smartphones, sensors for accelerometer and magnetometer now cost less than $1 each.

However, just having a magnetometer sensor is not enough to provide an accurate compass heading for a smartphone. There are two reasons for this – first, the magnetic field measured with the magnetometer varies significantly with tilt, the angle at which the owner is holding the smartphone. Second, the magnetometer requires to be calibrated not only for its own offset, but also against spurious magnetic fields caused by the nearby ferromagnetic components on the circuit board.

Both the above reasons are taken care of by the accelerometer. This is usually a three-axis component operating in the +/-2-g range with at least a 10-bit resolution. Its output changes by 512 counts as the accelerometer rotates 180° from pointing upward to downward. That gives it an average sensitivity of one count for every 0.35° change in tilt. For tilt-compass purposes, this is an acceptable sensitivity figure.

The other important measurement required from an accelerometer is its 0-g offset accuracy. This is the output of the accelerometer when it is in a free fall and experiencing zero gravity. As this value is an error adding to each accelerometer channel, it adds a bias in the calculate angles of tilt.

The geomagnetic field of the earth has a magnitude of 50µT, with a horizontal component varying over the earth’s surface. It varies from a maximum of about 40µT and goes down to zero at the geomagnetic poles. Therefore, for an eCompass to operate in horizontal geomagnetic fields, for example in the arctic Canada, where the field can be as low as 10µT and an accompanying noise jitter of +/-3°, then the magnetometer required must have a maximum noise level of 0.5µT.

In a smartphone, the software uses the aerospace coordinate system, where the initial eCompass orientation has X-axis pointing North, the Y-axis pointing East and the Z-axis pointing down. The three orientation angles are defined as clockwise rotations about the x, y and z-axis. These are named roll (ø), pitch (Ɵ) and yaw (Ψ) respectively. The earth’s gravitational vector points downwards at a magnitude of 1-g or 9.81ms-2.

Some of the Best Raspberry Pi Add-Ons

To most people, the Raspberry Pi or the RBPi Single Board Computer is only a cheap desktop. That is because by the time you have added a monitor, a keyboard, a mouse and the SD card, it would have cost as much as a cheap laptop and would still be a lot less powerful.

However, the real innovation of the RBPi lies not in its cost, but in its form factor. You can run the tiny RBPi on a few batteries or solar cells and use its exposed General Purpose Input and Output pins. This trio of combinations does not have any precedents in computing, at least not in the price range of the RBPi.

Being a new type of device, the RBPi is a lot easier to understand with some of the readily available components that connect to it to enable some function or to add some feature.

Most of these add-on components are not from large companies, but developed by hobbyists who saw the need for and filled it. One of these add-on components is the multi-purpose LED display Pi Lite. This is a simple board full of LEDs allowing people to use the RBPi to turn them on or off individually. This has made the RBPi SBC different from the regular PC and forced people to think differently for using it in its particular niche.

Pi Lite has 126 red LEDs, with a white LED version on its way. You plug the board into the GPIO pins on the RBPi. Pi Lite nearly covers the main RBPi board and has about the same form factor. Of course, you need a little configuration to enable the board to use the RBPi serial port, but that is well documented.

You send commands to the Pi Lite via a minicom terminal. Once connected over the serial port, anything sent over will scroll across in beautiful red light. Not only can you send text, you can also send commands preceded by three-dollar signs. You can turn all pixels on or off, display horizontal and vertical graphs and manipulate individual pixels.

You can improve the connectivity of your RBPi by expanding its ports. As the GPIO pins are exposed, any circuitry can be added to the RBPi. That may cause accidents and fry your RBPi very easily. Although there are several add-on boards that provide access and protection to the RBPI GPIOs, Quick2Wire has a board that uses the I2C and SPI features of the RBPi.

These are the Inter-Integrated Circuit and Serial Peripheral Interface and the board comes in two parts. The main board provides the I2C and SPI ports, adds protection for the RBPi and voltage selectors. Additional boards provide more GPIO ports including analog inputs and outputs that RBPi lacks. You can daisy-chain the boards to allow even more ports to be added to the RBPi.

To control the ports, you need to program the board with the Python programming language. For this, you may have to install the python3-setuptools package. You can find additional details of the above two add-on boards in openmicros.org and Quick2Wire.com.

The Raspberry Pi Command Line Interface

Being Linux based, the tiny Single Board Computer Raspberry Pi or RBPi has a graphical user interface familiar to regular computer users. Again, as most users of Linux will be familiar with, RBPi also has a command line interface where you have to type in the commands you want the SBC to execute. Well, a graphical user interface does have its merits and although the command line interface is a little more intimidating to the uninitiated, it is not a very difficult beast to tame.

One of the major advantages of the command line interface is its scope and speed – it easily accomplishes and most often surpasses what can be achieved with the graphical user interface, and does it faster as well. For most day-to-day tasks, however, the graphical interface is enough and has many useful applications including a web browser, test editor and file manager.

For those who want to delve deeper and learn more about how the SBC actually works, the command line interface is the way to go. Most of the work is done by opening up a Terminal or Shell and typing within it.

As the name suggests, the command line interface is an entirely text-based interface. You type in the commands that you want the SBC to execute, and it gives you a response. Although in the beginning, it will seem a little confusing, it is more like interacting in a natural way, just as we converse with another person. Once mastered, interacting with a computer via the command line interface will let you learn much more about it in the future.

You begin by opening up a Virtual Terminal/Console. Why is the name Terminal used? This is a legacy from the past when computers were gargantuan beasts, centrally located, with remote terminals distributed to the users. When you click on the LXTerminal on the Raspbian desktop, a small bordered box opens up, with ‘pi@raspberrypi $’ written inside it. The box is the terminal and inside it is the command prompt. The command prompt shows the name of the user – ‘pi’, the name of the computer – ‘raspberry’, also called the domain name, and the ‘$’ signifies that pi is a regular user and not the root or superuser (for root, the prompt would change to ‘#’).

The command prompt shows that your RBPi is now ready and waiting for you to type in your command. For example, you can see where you are by asking the computer to Print the Working Directory, by entering ‘pwd’ and hitting Enter. The SBC will most likely return – ‘/home/pi’, unless you have changed your username.

You can change the directory with ‘cd ..’, the computer knows that it has to return to the parent directory – ‘/home’. You may verify this with another ‘pwd’. With the command List Files or ‘ls’, you will be able to see all the files residing in the directory. Use a flag ‘-a’, to list the hidden files or all the files in the directory. Now the command becomes ‘ls -a’. Use ‘ls -l’ to see more information about the files.

For more information and for learning the command line, visit the website linuxcommand.org

What are IGBTs?

An IGBT or the Insulated Gate Bipolar Transistor is an amalgamation of a MOS and a bipolar transistor. It combines the best performances of both devices – the easily driven MOS gate and the low conduction loss of the bipolar. This effective device is quickly displacing most power bipolar transistors that were an obvious choice for high voltage and high current applications. IGBTs offer a balance in tradeoffs between conduction loss, switching speed and ruggedness. Manufacturers are now tweaking IGBTs to work successfully in the areas of high frequency and high efficiency that so long were the sole domain of power MOSFETs. In fact, barring applications that require very low currents, the industry trend is to replace power MOSFETs and power bipolar transistors with IGBTs.

When choosing an IGBT for a specific application, answering a few questions will usually narrow down the selection. Zeroing in on the most appropriate device will require a better understanding of the terms and graphs published by the manufacturers. These questions will be:
• What will be the operating voltage? Select IGBTs with VCES rating of at least 120% of the voltage that has to be blocked.
• Will the switching be hard or soft? A Punch-Through or PT type IGBT is best suited for soft switching because tail current reduces.
• What current does the device require to handle? In the part number of an IGBT, the first two numbers are a rough indication of the usable current. When looking for a device to work with hard switching applications, the selection usually depends on usable frequency versus current graph of the device. However, a certain amount of derating may be needed for which you could start with the IC2 rating.
• What is the speed you require to switch? For maximum possible speeds, a PT type IGBT is more suitable. Again, for hard switching applications, refer to the frequency versus current graph of the device.
• Will the device have to withstand short-circuit conditions? If you are driving motors, the device will certainly have to withstand shorts with low switching frequencies. Most often, short circuit capability is not required for switch mode power supplies.

A generic N-channel IGBT is fundamentally an N-channel MOSFET on a p-type substrate. PT type IGBTs usually have an additional n+ layer. Therefore, the operation of an IGBT is similar to how a power MOSFET works.

When you apply a positive voltage from the emitter to the gate terminal, electrons are drawn towards the gate in the body region. When the gate-emitter voltage is equal to or above the threshold voltage, electrons drawn towards the gate form a conducting channel across the body region, allowing current flow from the collector to the emitter or electron flow from the emitter to the collector.

The flow of electrons causes positive ions or holes to flow from the p-type substrate into the drift region near the emitter. Therefore, IGBTs can have simplified equivalent circuits such as:

The price for lower on-state voltage is the IGBT may latch up if operated outside the datasheet ratings. This is a failure mode where the IGBT cannot be turned off by the gate.

Latest Trends in Sensors – Miniaturizations and Combinations

We see various sensors in smartphones and other gadgets. So far, most of the sensors were available only as discrete solutions – one sensor for one parameter. The latest trend is to combine several sensors into one package, cutting the overall cost of the sensors.

It is now commonplace to find several sensors in a package, for example, gyroscopes and accelerometers. In fact, now the majority of the market is for combo sensors of this type, and such combination sensors are a very important trend on the technology side.

Another trend catching on fast is miniaturization. As cell phones grow thinner and more goodies are increasingly packed within them, miniaturization of sensors is enabling some of innovative sensor packages and devices. Starting with the X-Box Contact, which brought in various sensors for delivering rich fidelity, we see them moving in into mobile devices as well.

Today, you can visualize fitness as seeing the key vital signs, and the visibility of biometrics is fast becoming a reality. Sensor miniaturization along with the enhanced fidelity of devices is allowing device manufacturers and service providers experiment with devices for offering and fulfilling compelling specific needs.

The MEMS sensor from Bosch has combined pressure, temperature and humidity measurement in a single component. This sensor, BME280, is meant for use in handsets and wearables. It provides greater control and is useful for people interested in fitness and sports. The humidity sensor senses and measures relative humidity ranging from 0-100%, between -40°C and +85°C and with a response time of less than one second. With an accuracy of plus or minus 3%, a hysteresis of 2% or more, the temperature reading of the sensor has an accuracy of 0.5% Celsius.

The pressure sensor of BME280 makes indoor navigation very simple. The device is sensitive to pressure changes of plus or minus one meter of altitude difference with a resolution of 1.5 cms and a relative accuracy of plus or minus 0.12 hPA. The 8-pin LGA packaging of BME280 measures 2.5×2.5 mm, a height of 0.93 mm and has I2C and SPI serial digital outputs. Bosch provides the BSH1.0 algorithm for developers to place a function for temperature compensation in the device.

Miniaturization can be seen in the new generation of sensors for infrared sensing that are now entering the smartphone bandwagon for night vision and surveillance. At CES this year, people really welcomed the idea of scanning the environment at night. For example, walking out to the car at night feels much safer if the area can be seen beforehand.

FLIR Systems Inc., have fitted an infrared sensor to one of their smartphone jackets. It is a heat camera, and the jacket is suitable for thermal imaging attachment for the iPhone 5 and the 5S. The screen displays temperature in different colors. For example, the hottest temperatures are shown in yellow, while the colder ones have a more purple hue. This is a very useful attachment for detecting insulation or moisture leaks in the home and for spotting people or wildlife at night. You can record video of heat images or its photographs at low resolutions.

Do wirewound resistors suppress noise?

Specially designed wirewound resistors are used as noise suppressors in automotive ignition systems for reducing RFI or Radio Frequency Interference caused by electrical discharges. These resistors are usually placed in the leads and or caps of spark plugs and in the rotor of the distributor.

A gasoline engine generates high frequency electromagnetic Interference or EMI. This is commonly referred to as RFI or Radio Frequency Interference that comes primarily from the high-voltage side of the automotive circuit. At these places, the ignition system produces sparks at the coil that converts the battery voltage into high-voltage pulses. These pulses appear at the distributor, which routes the high voltage to the appropriate plug. Here, the spark ignites the air/fuel mixture in the combustion chamber producing the power that drives the crankshaft. Diesel engines do not have spark plugs as the air/fuel mixture is compressed to ignite and hence, diesel engines produce negligible EMI/RFI.

The high-voltage ignition pulses have a very rapid current change that generates an electromagnetic field around the ignition system. When electricity bounds through air, it passes through the air molecules, ionizing some of its atoms. As these atoms de-ionize, they release a tremendous amount of RFI. Although the frequencies are random and appear only for fractions of a second at a time, they affect almost any type of electronic device installed nearby to some degree.

Not only do these disturbances interfere with telephone and radio communications, they can even disrupt engine functioning and ABS control electronics. This type of interference sounds like a huge amount of crisps, crackles and rattles in radio receivers in communication systems.

International legislation requires manufacturers to reduce these disturbances to an acceptable level. That means the RFI must be reduced to a level so that there is no appreciable interference with the functioning of receivers not on the vehicle itself. Interference Suppression Regulations describe the RFI damping characteristics that manufacturers are required to follow, for example, VDE 0874 to 0879, CISPR or Council Directive 72/245/EEC, and usually differs from country to country.

Manufacturers usually track down the sources of RFI and limit it either at its source or filter it out before it can reach the instruments. The simplest and easiest method of prevention is by installing resistive spark plugs, resistive leads or ignition suppressor resistors. These contain internal impedance to dampen unnecessary emissions from the ignition system. Some manufacturers resort to redesigning the grounding circuit or installing feed-through/bypass capacitors.

Conventionally, spark plug leads usually carry a resistance of 6 to 15 Kohms per meter, and that makes them poor transmitters of RFI. However, electrical ignition systems may be sensitive to varying resistances in the spark-plug leads due to different lengths and can give mixed signals to the control module. Therefore, it is preferable to have solid-core wires with noise-suppressor resistors screwed onto brass fittings at the ends. This helps to maintain an equal resistance on each cylinder.

Use of noise suppressors is the best solution for reducing RFI. These resistors are designed for specific ignition systems and have the finest damping characteristics that do not cause disturbances to the ignition pulses. It usually suffices to place the resistors in the rotor of the distributor, in the spark plug caps or in the leads.

Why Does An Inductor Need A Fly-Back Diode?

An inductor usually stores energy when current flows through it, and releases it once the current flow stops. When the power supply to an inductor is suddenly reduced or removed, the inductor generates a voltage spike, which is also referred to as an inductive fly-back. Any current flowing through the inductor cannot change instantly and is limited by the time constant of the inductor. This is similar to the time constant of a capacitor, which limits the rate of change of voltage across its terminals.

The time constant of an inductor is the product of its inductance in Henries and the resistance present in the circuit. Usually, all current can be considered to have been dissipated within five time constants once the inductor has been disconnected. The process of inductive fly-back is best explained with an example – a 10H inductor in series with a 10Ω resistor, is charged long enough through a closed switch so that maximum amount of current is now flowing through the circuit.
When the switch is suddenly opened, the current flow has to come to zero within five seconds (five time constants). However, the switch opens far faster than five seconds, which implies current flow through an open switch – an impossible situation.

However, this can be explained by considering the switch to be bridged by air resistance of an extremely high value – 40,000,000 MΩ. Therefore, the inductor, in trying to keep the current flowing through the circuit will send a minute amount of current through this big air-resistor. According to Ohm’s law, every resistor will have a voltage drop commensurate with the current flowing through it. To maintain the current flow in the same direction, the inductor will have to change the polarity of the voltage across itself.

At the instant the switch opened, the current through the circuit would have been about 99% of the maximum current. Such a current multiplied by the extremely high resistance of the air gap will result in a huge voltage. Such a large voltage drop is possible because the inductor has stored energy, which it will use to create a very large negative potential on one side of the gap. That ensures the current flow will match the dissipation curve of the inductor. This is the origin of the huge fly-back voltage spike associated with the sudden disruption of current through an inductor.

The fly-back voltage generated by an inductor can be potentially damaging. Not only can the arc generated damage the insulation of the inductor, it can damage the switch or component being used to open or close the circuit. The arcing effect has been dramatically captured in this short video.
The use of a fly-back diode precludes the possibility of damage from an inductive fly-back. The diode provides a path for the inductor to drive the current flow once the circuit has been opened. As long as the circuit is closed, the diode is reverse biased and does not contribute to the functioning of the circuit.

When the switch opens, the inductor has a path to maintain the current flow through the diode. As the inductor reverses its polarity, it forward biases the diode, which then conducts current for the five time constants, until the current reduces to zero. That prevents the voltage spike.