Monthly Archives: October 2014

Add a Real Time Clock to Your Raspberry Pi

The Linux-based credit card sized single board computer, the Raspberry Pi or the RBPi is designed to be low-cost and of small form factor. As such, many features that are available on normal computers, but considered superfluous here, have been left out. The real time clock is one among them. That makes the RBPi unable to keep time when its power supply has been removed.

Typically, the RBPi is expected to be connected to the Internet via the Wi-Fi or the Ethernet and to update its time automatically from the Network Time Protocol servers available globally. In the absence of an on-board RTC, when there is no Internet connection or when the power to the board is removed, the RBPi is unable to keep time. However, that can be easily rectified by adding a small RTC module running on DS1307 and a tiny coin battery. This allows the RTC to continue to keep time even when the RBPi does not have power supplied to it.

To make things easy, use Adafruit’s Breakout Board kit for the DS1307 RTC. This kit already has all the parts required, including the coin battery. Although the components can be purchased separately and assembled on a breadboard, the coin battery holder can pose a problem, as it is not breadboard-friendly. The kit on the other hand, has a dedicated place for the battery holder, making it more convenient to use.

To allow the RTC chip to communicate effectively with the RBPi, the two 2.2KΩ resistors on the kit must be left out. There is no need for these resistors since the RBPI already has two 1.8KΩ resistors on-board and they are connected to the 3.3V supply, as the RBPi needs them to be. Therefore, either do not solder the two resistors to the breakout board, or, if you have already soldered them in, remove or clip them out. The breakout board needs 5V, so connect the VCC on the board to the 5V pin of the RBPi.

Now, you will need to set up the I2C interface on the RBPi. For this, your RBPi must be running a kernel that includes the RTC and DS1307 modules. The latest version of the Raspbian OS already has the modules included, but older versions may not have them. Adafruit has a wonderful tutorial that will guide you for setting up and testing I2C on the RBPi, check it out here.

At the command line, you can run the command “sudo i2cdetect -y 0” to check your wiring. If you have a rev2 RBPi, enter the command “sudo i2cdetect -y 1”. Once you see ID #68 being displayed, you know that your wiring is correct, as this is the address of the DS1307. Once you get the kernel driver running, i2cdetect will show UU instead of 0x68, further confirming that everything is good.

The next step is to load up the RTC module and set it up as root. Follow the tutorial for doing that and you can check the time with the command line “sudo hwclock -r”. If you are using the module for the first time, the date will be Jan 1 2000 – set it to the current time, and you are done.

Of what use is spark erosion?

For many decades, people have been using Electro Discharge Machining (EDM) or Spark Erosion to successfully remove material from difficult to machine location or shapes. Toolmakers come across such difficult to machine surfaces and shapes occasionally. Therefore, most good tool making workshops are usually equipped with a Spark Eroder. Spark Erosion techniques and machines are not new – this knowledge has been around for nearly two-decades and more. EDM machines are equipped with current generators, with typical currents being in the range of 75A.

Modern EDM machines are computerized and numerically controlled. With such machines, it is a very simple affair to make a single set up to cut an array of cavities. For example, with a sparker, you can drill square holes very easily. These machines can be programmed to make an undercut or cut profiles with a precision measured in microns.

Workpieces are normally metallic and must be electrically conductive. In the tool making business, aluminum or steel blocks are usual. However, a workpiece could also be a machine with a broken drill bit, stud or a broken tap that has jammed tight in a hole. Machinists also use sparkers to work on car parts.

The other important part required in the spark erosion process is the electrode. Mold makers or toolmakers use any shape such as a simple cylinder or a polygon. Other more complex operations need a CNC milled brush head, convolute or a diaphragm. If you need to remove a drill bit jammed into a car part, the machinist would normally use a cylinder such as a copper tube of small diameter. After precisely mounting the electrode in the machine head, the machinist will align its movement in the direction of the travel for the head. The alignment of the electrode and the workpiece is a precision task often requiring the help of a Digital Readout or DRO.

To start the spark erosion process, the workpiece must be immersed in a dielectric liquid. Earlier EDM machinists used paraffin as the dielectric, but now liquids that have a much higher flashpoint have superseded paraffin. Moreover, these liquids are not only safer, but also kinder to the machinists’ hands, as he has to dip them often in the liquid.

The machine is switched on and the electrode is brought closer to the workpiece. For this motion control, the mechanism may be hydraulic or electronic. As soon as a critical distance is reached, a tiny spark jumps between the electrode and the workpiece. This is an electrical discharge creating extremely hot plasma and it melts a little part of the workpiece into a tiny pool. At the same time, a small part of the dielectric also vaporizes creating a bubble around the spark.

Seen on a microscopic scale, the pool and the bubble both get larger until the control electronics stops the spark. This collapses the bubble, whereby the surrounding dielectric rushes in and flushes away the molten workpiece. The process creates a large pit on the workpiece and a smaller one on the electrode. When repeated tens of thousands of times each second, the workpiece is slowly eroded away to the required depth.

Use Apples as Switches for Your Raspberry Pi

You may rightly question the logic behind using apples as switches for your Raspberry Pi, as against the usual hard plastic ones. Well, for one, we live in an analog world and there is much more fun in integrating items of daily use with your computer. For another, it pays to see the look of astonishment on someone’s face when picking an apple from a basket, if the computer were to reprimand him.

The tiny credit card sized single board computer, the ever-popular Raspberry Pi or RBPi can sense inputs with capacitive touch breakout boards. This is the basics of using several household objects as input sensors for the RBPi. You can use any conductive object, not only an apple, such as pencils (the graphite part), spoons and potatoes including any other fruits or vegetables that you may find handy.

Capacitive touch sensors detect the tiny amount of electric charge every human body carries. The breakout boards have a pad that is sensitive to touch. You can extend this pad to any object by attaching a wire, allowing the object to develop a sensitivity to touch. You will of course need to inform the RBPi of your intentions and to do that, put in some effort in programming it. Get help from this website.

With the hardware above and a few lines of Python, you will soon have a new way of controlling your projects and games that is fun and easy at the same time. There are three types of breakout boards that you can experiment with.

The first type is the momentary capacitive touch sensor. This detects as long as something continues to touch it. The sensor has an LED that glows when anyone touches the pad and remains lit until it detects the end of touch. This breakout board has a large touch-pad and a small copper hole near it. You can solder a piece of wire to the hole and extend it to a capacitive item such as a drawing you have made with pencil (graphite).

The second type of breakout board is the toggle type of capacitive touch sensor. The LED on the board comes on as soon as you touch its pad. The LED remains lit up even when you lift your finger off the pad. The LED will go off once you touch the pad again. Therefore, when you solder a piece of wire to the hole near the touch-pad and connect its other end to any conducting item such as a spoon, you can easily detect if someone has touched the spoon at least once.

The third breakout board is the most versatile of the lot. Surprisingly, it does not have any touch-pads, although it is named as a 5-pad capacitive touch sensor. Instead, it has five copper holes, so that you can connect five objects with five pieces of wire. Therefore, if you have five different fruits or vegetables, you can connect them up and the RBPi will help you to chart their individual responsive speeds against touch.

While the two boards will both need a 10K resistor each connected between the object and the board, the 5-pad touch sensor board does not require any resistors, as it has them on-board.

Why is Power Factor so Important?

The specifications of any electrical appliance working on AC supply, such as a refrigerator, a toaster, a fan, etc., list a minimum of three important parameters – Voltage, Wattage and PF. The voltage rating indicates the nominal operating voltage of the appliance, the wattage rating indicates the power the appliance will use when switched on. The third parameter, PF, stands for the Power Factor – usually a value between 0.6 and 1.0.

All electrical appliances consume power for operating or working such as for lighting, heating, motion, etc. The appliance transforms a major part of the consumed power into its intended activity and the rest is wasted as heat. The ratio of the power converted to useful work to the total power consumed is the efficiency of the appliance.

Of the power converted to useful work, only a part is used as true or real power and the balance as reactive power. Engineers express real power in W (Watts) and reactive power as VAR (Volt-Amperes-Reactive). The appliance converts the real power into actual work, while it needs the reactive power to sustain a magnetic field and this does not directly contribute to the actual work done by the appliance. Therefore, the real power is also called the working power, while the reactive power is called non-working power. The sum total of the working and non-working power of an appliance is called its apparent power, expressed as VA (Volt-Amperes) and is the product of the nominal operating voltage and the current consumed by the appliance when operating.

This phenomenon of reactive power is true mostly for inductive appliances such as motors, compressors or ballasts. Power Factor is the ratio of the real or working power to the apparent power – an indication of how effectively the appliance will be using electricity. The problem is, although you will be paying the electricity utility for the entire apparent power consumed, the appliance will be converting only the real power into useful work for you. Therefore, a higher PF rating for your appliance works to your advantage – choose one with PF as close to 1.0 as possible.

In reality, low PF is also a headache for the utility supplying you with power. This is best explained with an example. Let us assume you have an operation that requires 100KW to run properly. If you install a machine that has a PF of 0.8, it will chalk up 125VA on the Apparent Power meter, but will convert only 80% of its incoming power into useful work. Since the electricity utility will have to supply both active and reactive power to its consumers, the wasted power ends up heating the conductors of the distribution system, resulting in a voltage drop at the consumers end.

The simplest way of improving the power factor is to add capacitor banks to the electrical system. PF correction capacitors offset the reactive power used by inductive loads, thereby improving the power factor. That maximizes the current carrying capacity, improves the supply voltage, reduces transmission power losses and lowers electricity bills.

What is stretchable electronics?

Imagine carrying your solar panel rolled up like a grapefruit while going camping and stretching it to the size of a room on the spot. It will not break, since it is made from fracture-proof electronics that is super compliant. Well, for the moment, that is the dream of Professor Darren Lipomi, department of Nano engineering, University of California at San Diego.

Darren has a vision of self-repairing skins for sensors. A special super-thin layer of organic material will make up the stretchable skin, very similar to a thin layer of plastic. As this will be as pliable as foil, it will allow the semiconductor to conform to the object and stretch with movement. Such a new phase of bendable materials will influence change in the supply chain by turning flexible electronics into a layer similar to skin. Not only will this give a new meaning to the current phrase – mobile technology, to accommodate to the transition, OEMs will have to alter their manufacturing processes.

Darren is exploring different materials and types of electronics that have molecular structures for allowing conductive materials to function even when deformed or contorted in any direction for long durations. Of importance here, is the molecular level structural details of organic semiconductors. According to the scientists at the University of California, the super-thin film-like material, sometimes as thin as 100 nanometers, could be made to stretch without any loss in its electronic functions. Display light emitters need only be about one hundred billionth of a meter thick, according to Darren.

The professor is interested in solar panels, which he plans on making in the form of a thin, stretchable film on any object such as a piece of clothing or a tent. He describes this as an extremely large solar module that is fracture proof while generating electricity. He also envisions flexible commercial displays used in wearable devices such clothing and watches from Microsoft, Samsung, LG, Google, Apple and many others.

The professor’s research has identified several types of electronic materials that can stretch. However, he feels the major challenge here is to understand the way in which the molecular structure of the flexible materials influences the mechanical and electrical properties. This is especially true when moving from the laboratory material to a commercial product. Depending on the acceptance of the industry towards development of new processes and technology, Darren expects stretchable organic materials will find use in about 10-20 years.

The research is proceeding in two directions. One way is trying to obtain working electronic properties from films of highly amorphous nature. The other is trying to prepare stretchable fabrics or nanowires from processing solutions or by electro spinning. According to the researchers, the latter path forms the middle ground between molecular and composite approaches to elastic semiconductors.

This presents a challenge of representing high-performance molecular semiconductors that have predictable mechanical properties. A tight collaboration will be required from materials scientists, device engineers, synthetic chemists along with theorists – specializing in both the mechanical behavior of soft materials and the electronic structure calculations.

Raspberry Pi and Wolfram Alpha

If you are looking for something different from the regular Internet search that you get from Google, Yahoo or DuckDuckGo, try the new Computational Knowledge Engine Wolfram|Alpha (www.wolframalpha.com). In 2009, Stephen Wolfram Research released the new engine that could answer questions written in natural language.

When you try out Wolfram|Alpha, you may be surprised that the site does not actually work like the search engines you are so accustomed to. In fact, you may not see results to some of your simple queries. Regular search engines attempt to catalog the information on the Web, and that is exactly what Alpha does not do. Rather, the Wolfram engine is a computational knowledge engine.

Traditional search engines scour the web for sites to add them to their directories. They rank different pages up or down based on the algorithms built into them, judging them on several factors. If you have a public web site and it has links to it from other sites, chances are that traditional search engines will pick it up without any effort from your side.

It is different for Wolfram|Alpha. They rely on their own licensed databases where the content entered is tagged and cataloged by employees of Wolfram Research. To give an example of the scale of things we are dealing with, at the time of launch, Alpha servers had more than 10 trillion individual chunks of data. According to Wolfram Research, its employees vet all the information for accuracy before adding anything to the Wolfram|Alpha database.
Apart from the scientific search engine, Wolfram Research also has a piece of software called Mathematica, which is a highly respected program that helps people manipulate data in many ways. Now the company has released its Wolfram Language and this is the underlying platform for all its engines from Mathematica to Alpha. The best part is that you can run it on your tiny, credit card sized single board computer, the Raspberry Pi or RBPi.

Not only is Wolfram Language free to download and use, it runs on any platform and that includes RBPi and supercomputer clusters alike. You can run it locally or in the cloud to suit your requirements. According to Wolfram Research, its performance on the RBPi is somewhat faster than the NeXT cubes when Mathematica first shipped. Considering that the NeXT cubes were multi-thousand-dollar workstations, it is surprising what your tiny RBPi is capable of.

With the RBPi taking computing back to the level of hobbyists once again, the Wolfram Language and Mathematica take it to the next level for schoolchildren. In essence, the combination becomes a highly effective knowledge-driven computational device for kids to learn about programming computers at practically no major cost.

Wolfram Language claims to be ten times faster at development compared to other languages. This is because Wolfram Language aims to maximize the productivity of the programmer by automating most of the work and building as far as possible directly within the language. The programmer has to build only the unique parts of the code, while relying on the language for everything else. The result is concise readable code, which is easy to debug. Large systems can be simply built up incrementally with symbolic components.

Is banana pi tastier than raspberry pi?

It is surprising that for so long, no one had come up with a variant or clone of the ever-popular credit card sized single board computer, the Raspberry Pi or the RBPi. Ultimately, there is a Banana Pi from Lemaker, a China-based company. Banana Pi, although an RBPi-alike, is not a direct clone, but rather an evolution. Lemaker has used a more modern dual-core processor – the 1GHz ARMv7 AllWinner A20 – in place of the single-core ARMv6 700MHz Broadcom BCM2835. Lemaker has doubled the RAM to 1GB and Banana Pi has additional connectivity such as a USB OTG port and a SATA 2.0 port with built-in 5V power supply for 2.5-inch storage devices up to 2TB.

Performance comparisons between the two are stunning. During testing, the 95th percentile SysBench time for the Banana Pi was 29.72ms, outshining the RBPi’s 51.45ms. Banana Pi took only 2.39s to compress and 0.21s to decompress a 10MB gzip test file. RBPi was much slower on the same test and clocked 8.64s and 3.08s respectively. This proves that the dual-core processor is better at multithreaded applications as compared to the single-core processor on the RBPi.

Banana Pi has a somewhat larger footprint than the RBPi, which makes it incompatible to the several RBPi cases and mounts available in the market. Although the 26-pin GPIO header is claimed to be pin-for-pin compatible electrically, its position is shifted from the RBPi’s layout to make room for a mounting hole. Therefore, larger piggyback boards foul with the composite video output on the Banana Pi.

The A20 chip on the Banana Pi lacks the CSI or Camera Serial Interface and uses a parallel camera interface instead. Therefore, none of the off-the-shelf camera modules meant for the RBPi will connect to the Banana Pi. Lemaker has promised a camera module of its own in the near future.

Rather than produce a distribution just for their board, Lemaker has taken the route to porting existing Linux distributions to the Banana Pi. Therefore, users are treated to flavors of Linaro, Arch, openSUSE, Raspbian and Google’s Android as SD Card images. These distributions had trouble addressing the GPIO ports at the time of launch. However, Lemaker has worked hard and removed these bottlenecks. Now, most projects based on Wiring Pi, Raspbian or RPi.GPIO libraries have no trouble at all working on Banana Pi.

The Banana Pi, along with its faster processor, also boasts of faster and more reliable USB ports. However, the most interesting addition is its SATA connectivity. This is not offered even in the newest RBPi Model B+. You can connect a mass storage device to the Banana Pi via the angled SATA port on the top side of the board, without tying up one of the USB ports. However, Banana Pi has only a 233Mb/s network throughput.

Overall, although Lemaker may have blatantly attempted to copy the RBPi, it has demonstrated possibilities of a few impressive improvements. On the positive side are the more powerful processor and the useful SATA port. On the negative side, there is the larger footprint, lack of CSI and altered layout along with a bottlenecked network and software bugs.

How do you measure cable length?

Where miles of cable are involved, how do people determine where the fault lies and decide where to dig for initiating repairs? The method involves something very similar to how people determine the depth of a well, the distance of a cliff or the location of a thundercloud – by echolocation. If you know the speed of sound in air, you can find the distance of the sound source from the product of the amount of time sound is taking to travel the distance to its speed in air. For example, light travels much faster than sound; therefore, light from a thunderclap precedes its sound. By timing the gap between seeing the flash of light and hearing the thunder, it is easy to tell how far away the thunderclap occurred.

When an electrical pulse is directed into one end of the cable, it travels down the length until it meets a change in the cable’s impedance. This may be a fault in the cable or it may simply be its other open end. Whatever the situation, the change in impedance causes the pulse to turn back to its point of origin. The time gap between the original pulse and its return represents the length it has traveled. Therefore, if it has returned in, say 30ns, instead of the 100ns expected, the fault is at about 1/3rd the cable’s length from the end where the pulse was injected.

Engineers usually rig up an oscilloscope and a pulse generator for the purpose. Knowing the cable’s characteristics is necessary to set the pulse generator’s output impedance. The pulse generator needs to output a narrow pulse of about one to 100ns, with as small a duty cycle as possible – the two parameters depending on the length of the cable under test. The pulse voltage is not critical – 1V peak is enough.

The oscilloscope’s trigger level should be just under the peak voltage of the 1V pulse. The time base should be set just long enough to display one pair of the 1V pulses generated. That completes the setup.

As you launch the pulse into the cable, it triggers the oscilloscope sweep. The pulse now continues to the other end of the cable, until it encounters an open end. Since energy cannot be destroyed, the pulse is reflected back to the generator. When it passes the oscilloscope, it is displayed again. You can differentiate the reflected pulse from the original by the reduction of its amplitude and a difference in the rise/fall slopes. This happens because of attenuation when traveling within the cable and a loss of high-frequency harmonics. Although there may also be additional reflections caused by input capacitance of the oscilloscope, the echo of interest is only the first one after the original pulse was launched.

The round trip time is dependent on the cable length, which is usually known. For most cables, the pulse will travel at about 66% of the speed of light in vacuum (300m/µs). That makes its speed within the cable about 200m/µs. You may have to play with the time base and the pulse period until you can see both the launched and the reflected pulse.

Will UEFI replace BIOS?

BIOS or the Basic Input Output System, designed by IBM for its Personal Computers has been with us for more than thirty years now. Whenever a computer is switched on, it conducts a self-check to see if it has a keyboard, a display and memories. Then it proceeds to look for a suitable Operating System. A small program, the BIOS, resident on a flash memory on the motherboard accomplishes all the above tasks. Once it has found a satisfactory operating system, it hands over the control of the computer. Those who are into programming of micro-controllers will recognize BIOS as the Monitor program.

However, the humble PC has come a long way in these thirty years. From a paltry 4/8 bit system with hardly 256bytes of RAM, PCs now work typically at 64 bits and 8/16GBytes of RAM. The evolution of Operating Systems and external threats to PCs has led to a demand for an overhauling of the BIOS. Introduction of Intel’s Itanium processors in 1998 put the final nail in the coffin of BIOS and a new Intel Boot Initiative was born. This initiative went on to become the EFI, or the Extensible Firmware Interface. In 2005, a new forum was born, UEFI, a consortium of AMD, IBM, Apple, Microsoft, Intel, and so on.

UEFI, or the Unified Extensible Firmware Interface, is a complete re-imaging of the computer’s boot environment and has almost no similarities to the BIOS that it replaces. While BIOS is basically a solid piece of firmware, UEFI is more or a programmable software interface that sits on top of the BIOS. This BIOS is shorn off most of its boot code, and the UEFI handles that while sitting in a part of the non-volatile memory, either on the motherboard, on the hard drive or possibly on a network share.

In essence, UEFI resembles more of a lightweight operating system. When switched on, the computer boots into UEFI, carries out a set of arbitrary actions and then triggers the loading of an operating system. As part of its specifications, the UEFI defines the boot and runtime services, device drivers, protocols for communication between services and extensions. There is even an EFI shell that allows execution of EFI applications.

As UEFI is a pseudo-operating system, it is able to access all the hardware on the computer, allowing you to surf the internet from the UEFI interface or backup you hard drive. There is even a full, mouse-driven GUI. With the boot data now stored on NAND flash or on a hard drive, a lot more space is available for language localization, boot-time diagnostics and various utilities.

UEFI enables secure boot in that it can sense if a malware is trying to take over your computer even before it has had a chance to boot into its OS. This no-compromise approach to security offers unparalleled capabilities to the customers while at the same time offering full and complete control over the PC. UEFI can validate firmware images before allowing them to execute, based on the PKI process. This secure boot helps to reduce the risk of boot loader attacks.

How to Measure Large DC Currents Accurately

The market has several instruments for accurately measuring small DC currents, say up to 3A. You can also find some devices that can measure DC currents that extend beyond 50A with good accuracy. Large currents are common in photovoltaic renewable energy installations, grid energy storage, electric vehicles, to name a few. Usually, it is a common necessity for such systems to be able to predict accurately the state of charge or SOC of the associated energy storage batteries.

Usually, systems for current or charge measurements are designed to include built-in data acquisition modules such as ADCs or analog to digital converters, filters and suitable amplifiers. The arrangement is typically that of a current sensor followed by a filter/amplifier and finally an ADC. The current sensor senses the current a circuit for converting the output into a usable form such as voltage, typically follows it. The signal requires filtering to reduce the radio frequency and electromagnetic interferences. The cleaned signal may have to be amplified before being digitized. Current data samples multiplied by the appropriate time interval are accumulated for charge values.

Two sensor technologies are commonly used for measurement of large currents. The first of these techniques measures the voltage drop across a resistor (also called a current shunt) that carries the current to be measured. The voltage drop follows Ohm’s law and equals the product of the current times the resistance.

Large DC currents may cause power bus bars and cables to dissipate significant amounts of heat. As a thumb rule, designers of power installations strive to achieve less than 1% power loss from the wiring, including bus bars and heavy cables. For example, an offline storage system of batteries with output of 1KV and 1KA supplies power at 1MW. Although the dissipation of a 50W shunt is insignificant at 0.005%, the power cables and bus bars may dissipate heat upwards of several KW.

To put things in perspective, designers go by 1W per µOhm at 1KA, therefore, for a shunt with 10 µOhm resistance, a continuous current of 1KA passing through it will heat it up to 10W. Alternately, copper wire, with a diameter of one-inch, will be dissipating 12-14W of heat at 1KA for each foot, since the resistance of the wire is about 10 µOhm per foot, after correcting for resistance increase due to heating.

The second technology senses the magnetic field encircling the current carrying conductor. The device for sensing the current is generally known as the Hall-Effect current sensor. Usually, the magnetic field around the current carrying conductor is concentrated in a magnetic core, which has a thin slot and the Hall element resides here. The magnetic field is thus perpendicular to the plane of the Hall element, while the magnetic core makes it nearly uniform. Energizing the Hall element with an exciting current makes it produce a voltage proportional to the magnetic field in the core and the exciting current. This voltage, suitably amplified and filtered, is presented to the ADC.

One advantage of the second technique using Hall elements is the isolation between the current carrying conductor and the measuring electronics. Since the coupling is only magnetic, the current carrying conductor may have very high voltage potentials, which do not affect the current measuring elements.