Category Archives: Guides

A Soundcard HAT for the Raspberry Pi

If you have been wondering how to use the popular Raspberry Pi (RBPi) single board computer for effects to be used with musical instruments such as the guitar, the Pisound board from Blokas may be the answer. With the Pisound board, any musician can connect any type of audio gear to the RBPi, and bring their project to an entirely new level. Pisound is a soundcard HAT for the RBPi.

HAT is an acronym for Hardware Attached on Top of an RBPi. HAT boards have an EEPROM that tells the RBPi the values of its variables specific to the device on the board. The HAT board will also have a GPIO connector to match with that on the RBPi, so that when plugged in, the HAT will sit atop the RBPi.

The Pisound HAT for the RBPi3 acts as a high-technology sound card. Not only does it allow sending and receiving audio signals from its jacks, but it can also send MIDI input and output signals to compatible devices. On board the card are two 6 mm input and output jacks, two standard DIN-5 MIDI input/output sockets, potentiometers for gain and volume, and a button for activating patches of manipulating audio. The Indiegogo campaign has given the Pisound board an incredibly successful start.

The Pisound website offers excellent documentation, making it a simple affair to set up the board. First, you have to mount the board atop your RBPi, matching the GPIO pins, and securing it with screws. Next, download and install a fresh installation of the Raspbian OS and set up the software according to instructions from the website. The only thing that remains now is to connect the instrument and create patches for Pure Data. This is a popular visual programming interface to manipulate media streams.

The possibilities with Pisound are endless. For instance, you can create simple fuzz, delay, and tremolo guitar effects. Limited only by your imagination, you could come up with endless ideas.

For example, the guitar effects could go into a web interface, accessible over a local network on a tablet or smartphone. On the other hand, with the characteristics of the guitar signals, you could control an interactive light show or project visualization on the stage. One of the advantages of the Pisound is you can use the audio input stream basically to generate other non-audio activities.

The compact and practical size of the project makes it convenient for embedding it within one of your instruments say the guitar. However, it is always possible to design and fabricate a custom enclosure for the board and the RBPi.

Sonic Pi, a musical community favorite, has also pledged to support the board very soon. That means even if you do not own a musical instrument, or play one, you can still make awesome sound effects with this clever little HAT.

You can load patches from Pure Data using a USB key. The button on the card makes it easier to interface with the RBPi. Moreover, it you are familiar with Automatonism, it will be easier for playing with the Pisound just as if it were a modular synthesizer.

What are Digital Circuit Breakers?

We need protection from fires resulting from an electrical overload caused by a faulty device or an accidental short circuit. The huge current from the overload heats up wires and their insulation may go up in flames. There are several ways to activate this protection.

The oldest method consists of a fuse wire. Usually, this is a thin wire enclosed in a casing. The material of the fuse wire is carefully chosen to heat up and melt (blow) when a certain current level is exceeded. Melting of the wire disconnects the circuit and interrupts the current, preventing heat buildup. Once a fuse wire blows, it has to be replaced by a similar wire to continue protection and reestablish electrical operation.

Nowadays, it is common to see switchboards where the fuse holder has been replaced by a miniature circuit breaker (MCB). The device has a bi-metallic spring holding pair of mechanical contacts, which can establish connection by throwing an external switch. An electrical overload causes the bi-metallic spring to trip and the contacts open up, disconnecting the fault from the rest of the circuit. Once the fault has been cleared up, the MCB can simply be rearmed by flipping the external switch.

Although simpler to operated compared to the fuse wire, MCBs have their own disadvantages of being slow to react and expensive, with their cost going up proportional to their trip current. Over time, the bimetallic strip tends to deform, reducing the current capacity of the breaker and its accuracy. The mechanical construction of an MCB makes it prone to wear and tear.

Opening mechanical contacts to interrupt high currents often causes an arc flash to jump across the contacts. It is necessary to quench the arc flash within a short time to prevent incidence of fires.

For overcoming the above problems, using a digital circuit breaker offers the most convenient solution. The device has an all-electronic construction involving an electronically controlled automatic switch. There are no mechanical components involved, no bi-metallic strips, and no electromagnetic coils inside.

Atom Power is proposing a solid-state digital circuit breaker to replace the traditional types and thereby avoiding the related problems. Currently awaiting approval from the Underwriters Laboratory (UL), Atom Power has two models, one each for AC and DC circuits.

So far, Atom Power was producing only a few numbers of their digital circuit breakers, using their in-house 3-D printers for producing the plastic parts of the housing. With increase in production, they will use the resources of an external rapid manufacturing company, and will move to injection molding for higher volumes of commercial operations.

The Atom Switch, within the breaker, responds to a digital signal generated whenever the current exceeds a certain level, whether due to overload or short-circuits. With tripping speeds exceeding 16,000 times those of its mechanical counterparts, the arc flashes simply do not happen.

Another technique used to prevent arc flashes is to switch the device off when the AC voltage passes through zero. This is called zero voltage switching or ZVS, and is a very useful technique to prevent arcing across the open ends of the circuit.

Peltier Cell Generates Electricity from a Lamp

The early 20th century saw the end of the use of candles and oil lamps as electric lighting became more common. Earlier, candles were made from various items such as natural fat, wax, and tallow. However, most manufacturers make candles from paraffin wax, a substance obtained from refining petroleum.

Compared to an incandescent bulb, a candle produces nearly a hundred times lower luminous efficacy. The luminous efficacy of a modern candle is about 0.16 lumens per watt, and it produces nearly 80 W of heat energy. Another form of the candle, tea lights, come with a smaller wick and produce a smaller flame. However, a standard tea light produces about 32 W, depending on the wax it uses.

The Peltier cell makes it possible to convert a small fraction of the heat energy from tea light into electricity. This can be used to drive a highly efficient LED light. This arrangement helps to boost the total luminous efficacy of the tea light and we can get a larger amount of light.

The Peltier element is really a solid-state active heat pump. Electricity applied to the element causes it to transfer heat from one side of the device to the other. Therefore, a Peltier element can be used for heating or cooling. If one side of the Peltier element is heated to a temperature higher than that on the other side, the Peltier element works in reverse, generating a difference of voltage between the terminals. This reverse effect is known as the Seebeck effect and the device works as a thermoelectric generator.

As the efficiency of a typical thermoelectric generator is only around 5-8%, the heat from a tea light should be capable of generating about 1.6-2.56 W of electrical power from the Peltier element. In practice, the Peltier element gives only about 0.25 W with the heat from the tea lamp. The reason being the inability of the Peltier element to capture the entire heat produced by the tea lamp to generate electricity—some heat is lost in transmission, and some in heating up the Peltier element. However, the energy generated by the Peltier acting as a thermoelectric generator is capable of running a small fan and drive an LED lamp satisfactorily.

A thermoelectric generator can be built around two 40×40 mm TEC1-12706 Peltier elements, mounted between two heat sinks, and connected in series to boost the voltage output. The smaller heat sink at the bottom serves to spread the heat from the tea light to heat up the Peltier elements evenly. The larger heat sink at the top has a fan to cool it and maximize the temperature difference between the two sides of the Peltier elements.

Although the fan draws power from the Peltier elements, it also helps to improve the efficiency of the system and make more energy available for the LED light. The fan also helps to keep the Peltier elements from overheating. Peltier elements are internally soldered with a bismuth allow solder melting at 138°C. Therefore, no Peltier element should operate above this temperature.

How to Simulate the Raspberry Pi?

You may have an urgent project that requires the use of a Raspberry Pi (RBPi), but do not have immediate access to a physical kit or the SBC. However, that should not hamper your progress with the project, as Microsoft is now offering an online RBPi simulator. The online RBPi simulator allows users to write code for controlling emulated hardware. Therefore, for the present, users can interact with a sensor to collect data from it and control an LED.

On the simulator, the user has a graphic of an RBPi wired on a breadboard to a combined humidity, temperature, and pressure sensor, along with a red LED. On a side panel, the user can enter JavaScript code as Node.js, with which, they can control the LED while collecting dummy data from the simulated sensor. A command line at the base of the panel allows execution of the code.

When loaded, the simulator starts with a sample program, which the user can use to collect temperature from the sensor and display it on the command line. Tutorials are available from Microsoft on running this code, and for this, the user has to first sign into Microsoft’s Azure IoT Hub, and select the free tier service option. Microsoft has designed the simulator to be compatible with a real RBPi. Therefore, anyone can test their code for controlling hardware using the RBPi, before they are ready to transfer their code it to a real device.

According to a Microsoft employee, Xin Shi, the simulator is presently in preview, offering only basic functionality. That means the embedded image of the RBPi is static, allowing only a limited interaction with the sensor and the LED. There are plans for emulating new devices and sensors, but there is no timeline. Moreover, the simulator’s code being open-source, anyone is free to work on expanding the simulator.

However, this is not the first time a simulator has been designed for simulating RBPi controlled hardware. Working with the US startup Trinket, the Raspberry Pi Foundation had created a web-based emulator for Sense HAT. This is an RBPi compatible add-on board bundled with several sensors, a joystick, and a matrix of LEDs.

Just as the Microsoft simulator does, the emulator for the Sense HAT also allows users to work with Python codes for interacting with the add-on board. Compared to the Microsoft simulator, the emulator from the Foundation offers users a greater number of sensors to interact with, and allows the user to have more control over the simulated version of the LED matrix on the board.

On the website, users have a choice of four Python programs. The first one allows selecting temperature, pressure, or humidity sensors, and manipulating the sliders to change the readout of the LEDs. The second is a game of rock, paper, and scissors, which the users can play using arrow keys to select while competing against the RBPi. The third is another game where a small bird has to fly through obstacles, and the fourth is a game of Astro Bug, which has to eat the food, while avoiding enemies.

What are Harmonics and What do they do?

In the 19th century, Jean-Baptiste Joseph Fourier presented his theorem, which is known as the Fourier’s theorem. According to this theorem, a periodic function of period T can be represented as the summation of a sinusoid with the identical period T, additional sinusoids with frequency same as integral multiples of the fundamental, and a possible continuous component, provided the function has a non-zero average value in the period. The first two are known as harmonics, while the third is known as the DC component.

Of the three, the first waveform with a frequency matching the period of the original waveform is called the fundamental harmonic, while the second may have more than one component. Those with frequency equal to ‘n’ times of the fundamental are called harmonic components of order ‘n’. A conclusion drawn from the above discussion about Fourier’s theorem is a perfectly sinusoidal waveform can have only the fundamental component, and no other harmonics.

This also means an electrical system with sinusoidal current and voltage waveforms has no harmonics. However, protective devices and malfunctioning equipment in an electrical system can lead to distribution of electrical power with distortions of the voltage and current waveforms, creating harmonics. In other words, harmonics represent the components of a distorted waveform, and their presence allows analysis of any repetitive non-sinusoidal waveform from a study of the different sinusoidal waveform components.

Most non-linear loads generate harmonics. When a sinusoidal voltage encounters a load of this type, it produces a current with a non-sinusoidal waveform. It is possible to deconstruct these non-sinusoidal waveforms into harmonics. Provided the impedances present in the network are low, the distortions of the voltage resulting from the distorted current are also low, and the pollution level in the system from harmonics is below the acceptable level. Therefore, even in the presence of distorted currents, the voltage can remain sinusoidal to some extent.

Typically, the operation of many electronic devices leads to cutting the sinusoidal waveform to change its rms value or to obtain a direct current from the alternate value. In such cases, the current on the line transforms to a non-sinusoidal waveform. Several such equipment produce harmonics—welding equipment, variable speed drives, continuity groups, static converters, fluorescent lamps, personal computers, and so on.

In most cases, waveform distortion results from the bridge rectifiers present within the above equipment. Although these semiconductor devices allow the current to flow for a major duration of the whole period, they stop conducting for the balance part. This creates discontinuous waveforms with the consequent addition of numerous harmonics.

Apart from electronic equipment, transformers can also be the cause of harmonic generation and pollution. Even when a perfectly sinusoidal voltage waveform is applied to a transformer and it generates a sinusoidal magnetizing flux, the magnetic saturation of its iron core may prevent the magnetizing current from remaining sinusoidal.

The distorted magnetizing current waveform from the transformer now contains several harmonics, with the third one being of the greatest amplitude. Fortunately, compared to the rated current of the transformer, its magnetizing current is only a small fraction. As the load on the transformer increases, this percentage becomes increasingly negligible.

What is Cabinet-Free Motion Control?

Controllers, drivers, and servomotors usually control automated platforms and machines in the automated production industry. With the evolvement of technology for machine motion, control and driving of individual machine axes is being increasingly taken over by highly intelligent electronics. Therefore, the control cabinet is assuming the central role with the rest of the system being designed around it.

With the rest of the machinery developing much more slowly, the faster evolving complex automation design and development becomes a cost-constraint for the OEM, system designers, and end users. Control cabinets need redesigning, especially with the increasing numbers of servo-driven axes. Typically, the location of the control cabinet is relatively fixed on the machine, which limits the manufacturers’ ability to modify and update the footprint of their machines.

As a solution to the above constraints, system designers are moving towards a new concept where the motion control and servo-drive mechanism is distributed rather than bound within a physical cabinet. By locating the controllers, servo drives, and power supplies nearer to the motors and axes they control, OEMs and system designers overcome several challenges arising from installation, cabling, and multiple engineering.

Initially, system designers had reoriented their designs in attempting to drive multiple machine components with a single servo motor. Although this approach had the benefit of reducing the physical number of servo motor and drives, it required a larger motor with higher power to handle the load, and several additional mechanical components for delivering the centralized power. A Cartesian motion system with a single motor for a palletizing application is an example of such a centralized approach.

By separating the servo motors on each axis, mounting them on the independent frames, and driving them separately, system engineers were able to use smaller motors, thereby reducing the overall power requirement, and developing a solution with higher efficiency.

One of the barriers to cabinet-free motion control architecture comes from PLC limitations. By limiting the axis count supported by their PLCs to 16 or 32 axes, some manufacturers force users to purchase a second PLC, which means addition of a more expensive control box with higher capacity.

For some time now, OEMs have been following a common practice of moving power supplies, servo drives, and related devices out of the control cabinet and placing them closer to each motor and its drive axis. This trend began with several leading suppliers introducing electric motors with their drives integrated into the motors’ housings. This required control electronics to be shock and vibration resistant as well as capable of withstanding the higher temperatures usually associated with environment outside the control cabinet.

Recent advances of cabinet-free components include separate ac-to-dc power supplies, independent drive units capable of mounting close to the servomotor on the machine, and power cables integrating communication capable of daisy-chaining several drive-integrated servomotors into a single circuit.

A further introduction of newer motion controllers or PLCs is helping the cabinet-free technology portfolio. These integrate the controller hardware into modules capable of mounting on the machine along with the necessary power supplies and drives. This eliminates the requirement of a control cabinet entirely.

Industrial Motors for Machine Automation

Industrial engineers use different types of motion control devices for improving the production rates and efficiencies on the floor of automated factories. Three major types of motion control devices are in demand for machine automation—stepper motors, servomotors and variable frequency drives (VFDs).

In general, stepper motors along with their drives, and controllers are widely used as they offer simple implementation, beneficial price/performance ratios, and high torque at low speeds. This motor is essentially a brushless DC version, moving in equal fixed steps during rotation, and only a single step at a time. Not requiring tuning or adjustments, stepper motors provide very high torque at speeds below 1000 RPM. They are cost-effective, as their prices are substantially lower than the cost of comparable servo systems. Since the torque they produce decreases as they speed up, it makes their operation difficult. Therefore, the work done by stepper motors becomes impractical at speeds in excess of 1000-1500 RPM.

Servomotors come with a motor, drive, a controller, and a device for positional feedback. For variable load applications, engineers prefer them to stepper motors, as they deliver high torque when rotating at speeds above 2000 RPM. Servos require adjustments and tuning, making them more complex to control compared to stepper motors. Including maintenance costs, their positional feedback arrangement can push their prices well beyond those of stepper motors.

Costing less than stepper motors or servomotors, VFD systems include an AC motor and a drive, but are unable to provide positioning. However, they can be good for applications requiring speed control on variable loads. For applications where the motor need not run continuously at full load, a VFD system can save considerable amount of energy. Another feature of VFDs is their soft-start capability, allowing a limit to high inrush currents.

In a stepper motor system, the controller regulates the position of the step, the torque generated by the motor, and the speed of the motor as it moves from one step to another. The driver operates on the control signals the controller generates by modifying and amplifying these signals to regulate the direction and magnitude of the current flowing into the motor’s windings. This way, it drive rotates the shaft of the motor to its desired position, and holds it in position with the required torque for the required time.

Controllers for stepper motors can be either open or closed loop types. Open-loop controllers are simpler, not requiring any feedback from the motor, but are less efficient. Open-loop controllers operate on the assumption the motor is always at the programmed step position and is producing the desired torque.

On the other hand, closed-loop controllers always operate with feedback based on the effective load on the motor. Therefore, the performance of the closed-loop stepper motor controller is similar that of a servo motor, and makes the operation more efficient.

Making a stepper motor rotate through each of its steps requires energizing the several windings within the motor in a specific sequence. Typically, stepper motors rotate 1.8 degrees per step, necessitating 200 steps to make a complete revolution.

How are RS232 and RS485 Different?

When engineers need to connect electronic equipment, they resort to serial interfaces such as the RS-232 and RS-485. Although dozens of other serial data interfaces exist today, most are meant for use in specific applications. A few of them are considered universal, such as I2S, MOST, FLEX, SPI, LIN, CAN and I2C. Other high-speed serial interfaces are also used, including Thunderbolt, HDMI, FireWire, USB, and Ethernet. Despite the proliferation of interfaces, the two legacy interfaces, RS-232 and RS-485, continue to survive, used in several applications.

As a rule, serial interfaces provide a single path for data to be transmitted over a cable or wirelessly. Although some applications do use parallel buses, serial interface alone provides the only practical option for high-speed data movement today over any distance greater than several feet.

RS-232

RS-232 is one of the oldest serial interfaces, originally established in 1962, as a method of connecting a DTE or data terminal equipment such as a teletypewriter to a DCE or data communications equipment. Personal computers earlier had an RS-232 port, commonly called the serial port, to connect to a printer or other peripheral device. Embedded computer development systems still use the port today, as do many scientific instruments, and several industrial control equipment.

Officially, the standard defining the RS-232 serial interface is the EIA/TIA-232-F, with F signifying the most recent update. According to the standard, a logic 1 is defined as a voltage between -3 and -25 V, and a logic 0 as a voltage between +3 and +25 V. The logic 1 is generally termed as a mark, with logic 0 being termed as a space. Any voltage between +3 and -3 V is termed invalid and is rejected, providing a huge noise margin for the interface. The configurations of the receiver and transmitter are both single-ended and referenced to ground or 0 V.

The cable medium in RS-232 can be simple wires in parallel or a twisted pair. According to the standard, the cable length must not exceed 50 feet. However, by reducing the data rate, it is possible to use longer lengths of cable. For a 50-foot cable, the highest data rates in RS-232 are roughly 20 Kbits/s, and matched generator and load impedances are necessary for eliminating reflections and data corruption. Although earlier 25-pin connectors were used, the de-facto standard for RS-232 is the 9-pin DE-9 connector today.

RS-485

The EIA/TIA standards also define the RS-485 interface, now commonly known as TIA-485. This is not only a single device-device interface, but is a complete communication bus used for simple networking of multiple devices.

Rather than a single-ended voltage referenced to the ground, the RS-485 uses differential signaling on two lines. A logic 1 is a voltage level greater than 200 mV, while the logic 0 is a level greater than +200 mV. The maximum cable length for RS485 is about 4000 feet or 1200 m, with typical data rates as 100 Kbits/s. However, compared to the speed of the RS-232 interface, a 20-meter cable in RS-485 can allow a maximum data rate of 5Mbits/s. Industrial control equipment using the RS-485 use the 9-pin DE-9 connector.

Raspberry Pi Controls the Cardboard Dog

This is a project for beginners using the Raspberry Pi (RBPi) single board computer. The RBPi is used to control a servo for turning the head of a cardboard dog away whenever a person is looking at it. This is to mimic a begging dog that seems ashamed of its begging nature.

This project requires the SBC RBPi, its power supply with the 5 V micro-USB cable, a USB keyboard and mouse, a display, and an HDMI cable. For storing the OS, an 8 GB micro SD card is also necessary. Another computer will be necessary to write the OS to the micro SD card and edit the files in it. The official PI camera will help to recognize the faces looking at the dog, and a micro servomotor is required to turning the head.

The RBPi will be controlling the servo through its GPIO pins. The servo has three wires that need to connect to the GPIO pins using female connectors. The camera has a ribbon cable, which goes into the port labeled camera on the RBPi. The HDMI cable goes into its port on the outside of the RBPi, and its other end goes to the HDMI-compatible TV or monitor.

Download and install the latest version of the Raspbian (with Pixel) from the official website of the RBPi. While installing the image on to the micro SD card, the process will destroy all data on the card, so be sure there is nothing of value before you begin.

Once the OS is installed on the micro SD card, insert it into the slot on the reverse side of the RBPi. If the power cord is now plugged into the RBPI socket and the power turned on, there should be some code running on the monitor screen, with the desktop showing up at the end. At this time, right click anywhere on the desktop and select “Create a New File.” Name the file Dog Turn.py, and select it to open with Python 2 IDLE.  Now open IDLE, and paste the code from here into it.

To make the code in the file to work, the RBPi will need additional Python modules to be installed. These are the libopencv-dev, python-opencv, python-dev, and you must use the sudo apt-get install command to download them.

The cardboard dog for this project uses four 9×6 inch cardboard rectangles, and two 6×6 inch squares, which form the main body. A hole at the top of the box allows the servo to go through. Another 5-inch cardboard cube forms the head, and attaches to the servo. Some cardboard legs make the dog look more realistic.

The entire electronic hardware can fit within the body of the dog. It may be necessary to use standoffs to hold the RBPi in place. The camera should look out from one of the eyeholes in the dog head. Fix it in place so that the cable has sufficient play when the servo moves the head. Simply running the python code should be enough to let the dog do its trick. To stop, turn off the power.

What are Current Sense Resistors and how do they work?

Efficiency has become the keyword in global trends in meeting demands for lower carbon-di-oxide emissions. Whether it is the smartening of the electrical supply grid or the electrification of our automobiles, the global trend is driving the need for electronic circuits to become more efficient. Knowing the level of current flowing through the circuit and reaching the load accurately is an important factor in gauging its efficiency for circuit designers and systems operators. This knowledge helps in maximizing operating performances of a battery, hot swapping server units, controlling motor speeds, and many more. Current sense resistors are inexpensive components that provide optimal solutions helping OEMs create more efficient circuit designs for a wide range of applications.

Current sense resistors are components helping to improve system efficiency by reducing losses. They have high measurement accuracy compared to other technologies, and they are ideally suited for helping developers measure currents precisely in automotive, industrial, and computer electronic designs.

Current sense resistors detect and convert current to voltage, using Ohm’s law. According to this law, the product of the current and the resistance value through which it is passing gives the voltage developed across the resistor. As these resistors feature very low resistance values, the voltage drops are equally insignificant, of the order of 10 to 150 mV in specific applications.

Design engineers place the current sense resistor in series with the electrical load, which causes the entire current to be measured to pass through it. As the voltage drop across the resistor is proportional to the current through it, measuring this drop provides an estimate of the load current. Measuring the voltage drop is usually accomplished through various amplifier options such as operational, differential, and instrumentation amplifiers. Selecting the right current sense resistor amplifier for a specific application involves looking at the input common-mode voltage specification. This is the average voltage present at the input terminals of the amplifier.

With the current sense resistor sitting in series with the load, they can directly measure the current. Contrast this with indirect current measurement techniques using coils. Here the voltage is induced across a coil and is proportion to the current. As a series resistor senses current directly, it dissipates power. Therefore, series resistors tend to have very low resistance values.

Current sense resistors also feature a very low temperature coefficient of resistance or TCR. This feature defines its low drift with varying ambient temperature and its long-term stability. These characteristics make temperature dependency of current measurement to be very low, while increasing the accuracy.

However, when using very low ohmic resistors of the surface mount type the resistance of the solder pad and the copper tracks of the printed circuit board can be uncertain and more than the resistance of the current sense resistance itself. This can lead to inaccuracies in the current measurement. In addition, the TCR of the tracks of the PCB can be much higher than that of the series resistor element.

Therefore, it is necessary to use current sense resistors implementing the 4-wire Kelvin principle, as these employ additional leads for measuring current more accurately.