Monthly Archives: February 2017

How Does Ladder Logic Work?

Over the last 30 years, there has been a significant evolvement of ladder logic for industrial controllers. It now supports advanced functionality that includes data acquisition, networking, data manipulation, motion control, and process control. Designers starting a new control system are faced with many basic functions this tried-and-trusted language needs to perform, and it does so, almost effortlessly.

Object Detection

Detecting the presence of an object is one of the most pervasive functions a control system is asked to perform. Whether it involves detecting an object passing by on a conveyor, the closing of a gate, or locating a machine part as it revolves, object detection is a staple function in the automation industry. Objects can be sensed in myriad ways, and these include mechanical, inductive, capacitive, optical, and ultrasonic techniques and devices to detect proximity or nearness.

Limit Switches

The limit switch is a most basic sensor, mostly an electromechanical device detecting the absence or the presence of an object. As the actuator of the switch touches the sensed object, it operates a set of contacts. Depending on the actuator style, the specific means of contact may vary from plungers to wands, springs, levers, and rollers. However, the moving parts are prone to damage and wear, and it may not always be possible or desirable to make physical contact with the object to be sensed.

Inductive Proximity Switches

Non-contact sensing technology uses inductive proximity switches to detect the absence or presence of metallic objects without actually making contact with it. These are the most common and inexpensive devices. Inside the proximity switch is an oscillator driven coil. The magnetic field created by the oscillator appears at the active face of the switch. As soon as a metal target approaches this area, the electromagnetic field reduces, and this turns the switch on or off.

Capacitive Sensors

For objects that have a dielectric constant different from air, detecting them is easy with a capacitive sensor. Unlike the inductive proximity sensors that sense only metal objects, capacitive sensors can detect plastic, liquids, and wood. Although their method of operation is similar to that of the inductive proximity sensors, capacitive sensors detect objects based on an electrostatic field rather than an electromagnetic field.

Ultrasonic Proximity Sensors

These sensors measure the time of flight of a burst of sound impulse from the source until detecting the echo signal returned by a reflection from the detected object. Almost all materials reflect ultrasonic sound, which remains unaffected by color, transparency, or polish of the object.

Photoelectric Sensor

These sensors use a light beam as the detecting medium. Most popular photoelectric sensors are the diffuse, reflective, and through-beam types. The sensing distance depends on the type of light used—laser, LED, infrared, or visible.

Diffuse Sensors

Diffuse sensors contain both the receiver and emitter in the same unit. The optical beams may be either slightly diverging, or parallel. When an object appears in the luminous beam, it causes diffused reflection. The receiver detects the reflections from the object.

The ladder logic represents the contacts of the sensor and the PLC CPU assigns it a memory location. The CPU represents them in the Normally Open or Normally Closed in the ladder logic.

A Raspberry Pi Computer in an Altoids Tin

Turning an Altoids Tin into a Raspberry Pi computer

Turning an Altoids Tin into a Raspberry Pi computer

Although Altoids, a brand of breath mints, has its origin in the UK, it is less widely available there than it is in the US. The mints come packaged within a distinctive tin case, which people commonly reuse for different purposes, mainly as a container for small household items such as sewing materials, coins, paper clips, among many other items.

DIY enthusiasts often find the tins eminently suitable to contain electronic projects. For instance, Texas Instruments makes the BeagleBones, a single board computer, with rounded corners deliberately shaped in, so it will fit within the tin box. You can easily use the Altoids tin for enclosing the CMoy pocket headphone amplifier. The design of some microcomputer kits allow them to fit perfectly in the Altoids tins.

All the above led M. Wagner to come up with an idea of housing a Raspberry Pi (RBPi) SBC within an Altoids tin box. With the release of the RBPi Zero, he firmed up the project, calling it the PiMiniMint. His first version of the PiMiniMint had a screen, Wi-Fi, Bluetooth, 32 GB storage, infrared camera, and a full-size USB port. However, he found no space for a battery—to add the battery, he needed to remove the camera. His latest version of the PiMiniMint has a battery that lasts about 6-8 hours, a 2-inch screen, 32 GB storage, Bluetooth, Wi-Fi, and an OTG cable serving as a full-sized USB port.

Wagner uses a 1200 mAh 3.7 V Li-Po battery for PiMiniMint. This thin, rechargeable battery fits easily under the RBPi inside the case. He has soldered the red and black wires from the battery to the ‘+’ and ‘—’ connection points on the charging circuit. Any 3.7 V Li-Po battery should work here, preferably thin ones that the tin can hold.

Although the RBPi runs at 5 V, the battery needs 3.7 V to charge. Li-Po batteries are notorious for exploding if overcharged for long or for not being charged properly. Adafruit has a circuit that both charges the Li-Po and steps up its voltage to 5 V for the RBPi. However, Wagner uses a cheaper option—a generic USB charger. He chose a USB charger with a 3.7 V battery and with an output of 5 V. Although these tiny chargers do require a bit of preparation and de-soldering to get them to work with the RBPi, they are much cheaper.

To fit into the Altoids tin case, Wagner chose to use the RBPi Zero. Usually, the RBPi models do not boot off a hard disk, but needs an SD card. Wagner used one that had a suitable OS on it. You can select the OS of your choice and load it into an SD card. As the RBPi Zero does not come with any header, it is necessary to solder a 2×40 male header on the RBPi to connect to the iotHAT.

The Redbear iotHAT is a little HAT for the RBPi Zero, sitting directly on top and interfacing with the RBPi. The HAT gives the RBPi Zero capabilities such as Bluetooth and Wi-Fi. Wagner chose the 2-inch Adafruit NTSC/PAL screen simply because it fits the tin case.

PiFM: A Pirate Radio with the Raspberry Pi

The popular single board computer, the Raspberry Pi (RBPi), can work as a radio transmitter as well. Using a simple hack, you can turn your RBPi into a powerful FM transmitter with adequate range to cover a bike parade, high school ball game, silent disco, DIY drive-in movie, or even your entire home. However, the broadcast frequency covered by the RBPi is rather large—one to 250 MHz, and there is a possibility this will interfere with government bands. Therefore, it is advisable to limit the transmissions to the standard FM band of 87.5 to 107.9 MHz.

You do not need much to make the RBPi start transmitting. The RBPi board itself, a power source, and the SD card with the OS is all that is necessary. The only accessory required is a piece of wire, which acts as the antenna. The entire project runs on the software PiFM.

Oscar Weigl and Oliver Matios developed PiFM originally, and Ryan Grassel revised it. This project uses the PirateRadio.py script, which enables playback without accessing the command line, while handling most common music file formats automatically. Wynter Woods, a MAKE labs engineering intern, wrote the script.

Oscar and Oliver had hacked the original PiFM code over a few hours. To output FM radio energy, their code used the hardware on the RBPi that actually generates spread-spectrum clock signals on the GPIO pins. Therefore, to turn the RBPi into a really powerful FM transmitter, all that was necessary was to add a wire length acting like an antenna to one of the GPIO pins. The original code used the GPIO pin 4 with a wire of length about 20 cm attached to it. For transmission, Oscar and Oliver had chosen the frequency of 100.0 MHz.

When Sam Freeman and Wynter Woods tested the present project, they found the FM signal only deteriorated once it had to pass through several conference rooms with heavy walls. The signal was able to cover 50 m easily, and objects such as heavy metal cabinets could stop it. They found the sound quality acceptable, although it has some clicks that came from the CPU switching to tasks other than playing music. For the technically minded, a kernel mode driver uses the DMA controller for preventing the RBPi CPU from being loaded, and thereby plays smooth music.

The Python script calls a C program that maps the peripheral bus of the physical memory into virtual address space. After this, it enables the clock generator module and sets points its output to GPIO4. Note that you will not be able to use any other GPIO pin at this time. It also sets the frequency of transmission to 100.0 MHz, which acts as the carrier. If you receive this on a radio, the radio will stop the background noise and become silent.

The carrier is modulated by the audio produced by adjusting the frequency using the fractional divider between 100.025 and 99.075 MHz. The fractional divider can produce audio with only 6-bit resolution. As the RBPi is very fast, it can use 128 subsamples on every real audio sample to produce 9.5-bit audio. The subsample algorithm now gives full 16-bit quality sound with FM pre-emphasis.

Colorful Images from Electron Microscopy

Almost everyone treats Christmas as the time to get away from regular work. Surprisingly, there are exceptions, such as Roger Tsien. This late biochemist would do an extra two weeks of uninterrupted research in his lab during Christmas. In one of his sojourns, he gifted the world the first electron micrographs—in color. His method used to create them will dramatically advance cell imaging.

Scientists use Electron Microscopy (EM) for magnifying objects up to 10 million times their original size. The technique makes use of accelerated electrons for the purpose. Conventional EM images are in gray scale, and scientists add color using computer graphics programs, once the images are recorded. Tsien and his colleagues modified the EM technique for directly incorporating color labeling into the images.

Along with co-workers Mark H. Ellisman and Stephen Adams, Tsien devised techniques for employing serial applications of various lanthanides or rare earth metals, which served as the labels. Along with this, the researchers used the EELS or electron energy-loss spectroscopy type of Ems. EELS is capable of differentiating among the lanthanides. It does this by measuring the differences in energy deflected or absorbed by each lanthanide from an electron beam.

For instance, for creating the color image of a cell organelle such as an endosome, the researchers had to stain the sample initially with a lanthanide called cerium. This made the sample appear green when viewed under EELS. After removing the excess cerium, they applied the element praseodymium. This targeted another protein within the sample, which EELS now registered as red. Now all that the scientists had to do was to overlay the green and red images onto a traditional gray scale EM image and create the composite image. The final image highlighted different distinct regions of the endosome with red and green color.

In the November issue of the publication Cell Chemical Biology, Tsien, along with his coauthors, has described their multicolor EM technique. Although the technique is still very new, scientists are using it to obtain new information about cell structure. For instance, regular light microscopy is incapable of showing protein movements with and between cells. With the new technique, scientists can now view cell components at a much higher level of detail.

For instance, until now, scientists had only a hypothesis about the fate of certain molecules since they are too small to be visible using light microscopes. EELS offered vibrant proof and confirmed the hypothesis. So far, scientists had only conjectured that certain CPPs or cell penetrating peptides were responsible for ferrying molecules as cargo into cells, and that the cells then took up these molecules into the interior of endosomes. With the praseodymium coloring one kind of CPP with a red label, scientists were able to verify their hypothesis, as the CPP visibly ended up inside the endosome. At the same time, another molecule, colored vivid green with cerium, ended up predictably at the endosomal surface.

Tsien’s death has deprived the world of further contributions to this transformative technique. However, the innovations will continue to inspire his co-workers and the newer generation of scientists. Tsien, as a fitting last gift to the scientific world, added color to electron microscopy to allow them to see more within cells.