Tag Archives: RBPi

Raspberry Pi Pursues Ping-Pong Balls

Ping-pong balls are light and apt to bounce around a lot. Players have a hard time running after them, and when many are playing, finding a number of balls on the floor is a common sight. This was the case at the office of the 37signals at Chicago as well, until their system administrator, Will Jessop, who runs the North West Ruby User Group in Manchester, decided that enough is enough. He designed a solution for the problem with a Raspberry Pi running a robot to pick up the balls and collect them in a basket.

Raspberry Pi or RBPi is a low-cost, credit card sized single board computer with Linux as its operating system. Will designed the original version of the robot using the Custard Pi breakout. However, he changed over to MotorPiTX motor controller developed by Jason Barnett, as this was a much neater board. Will then sourced some of the parts necessary for the robot and built the others.

For example, he designed and 3D printed the motor mounts, the caterpillar track mounts, the ball basket and even a new base. In the end, he added a PiCamera mounted with a fish-eye lens. This made the whole contraption a neat little camera robot, reminding one of Wall-E.

Since the robot had to move around and pick up ping-pong balls, it needed its own power source to allow it to roam free. Will looked at the power requirements and tested its power usage while it was running all its motors. The RBPi robot had its own lifter arm fitted to the chassis and while this was controlled independently, the robot itself streamed video over wireless. Will finally opted for a lithium battery rated at 5AH, 7.4V.

For the software, Will decided to use Go. This, he found, was a great language for the RBPi, as he could use Go to create small, efficient statistically compiled binaries. Additionally, he could also fit them easily within the resource limits of the RBPi. Will runs the Go binaries alongside his gamepad library on his laptop, and these are available as a Ruby gem in C. To allow the RBPi to shutdown cleanly via the MotorPiTX, Will had also to write a power controller script.

Now that the robot was capable of roaming free on its battery, Will controlled it with an Xbox controller, with its camera feed streaming over Wi-Fi. By watching the video stream on a laptop, it was easy to let the robot pick up ping pong balls; see it in action below.

There were some suggestions that Will considered. One of them was to allow the robot to recognize the ping-pong balls on its own and pick them up. Initially Will did think of using OpenCV for accomplishing this, but then he found that people are more excited at driving a robot around and had more fun. Another suggestion that Will is considering for the future is using a vacuum pick up, since ping-pong balls are very light, and easily slip away from the robot’s fingers.

The Raspberry Pi-Fi bundle

The mighty single board computer, the credit card sized Raspberry Pi or RBPi, as it is fondly called, is making waves for all the good reasons. Developed by the Raspberry Pi foundation as a low-cost, hands-on for children learning about the inner workings of a computer, this tiny SBC has caught the imagination of hobbyists all over the world. As a result, people have developed innumerable projects based on the RBPi, and the flood shows no signs of abating.

For those still not initiated in the RBPi bandwagon, it is best to buy the SBC as a bundle. The Pi-Fi bundle will include the RBPi, a preloaded 8GB SD card, a Wi-Fi dongle along with an instruction manual “Getting Started with Raspberry Pi.” Add an appropriate power supply, a USB keyboard, a mouse and a display and viola – you have a fully functional Linux computer, fully Wi-Fi enabled, capable of playing games, writing programs, streaming media and web browsing. The USB keyboard and mouse is not a strict requirement. You may also use a wireless keyboard and mouse with their USB receiver.

Other sundry things you may need are an HDMI cable and a USB A to micro cable. Make sure the power supply is capable of supplying 5V at 1.0A on its USB port, and you are good to go.

To start, plug in your keyboard, mouse and monitor to the RBPi. Next insert the SD card and plug in the power cable between the RBPi and the power supply. Hook up the power supply to the mains and switch it on. On the monitor screen, the NOOBs (New Out Of Box) interface from your SD card will prompt you with a choice of the operating system you would like to install. If you dislike the OS you just installed, shut down, switch off, and reboot but hold down the shift key while the RBPi reboots. You will be returned to the NOOBs interface to select a new OS.

The RBPi consists of a System on Chip, a Broadcom BCM2835 that has a CPU, a 700MHz ARM 1176jZF-S and a GPU, a Broadcom VideoCore IV that supports MPEG-2, OpenGL, h.264/MPEG-4 AVC and 1080P. For memory, the SBC has 512MB of RAM, and an onboard storage of MMC/SD/SDIO card slot, for which a minimum size of 4GB is recommended. The board consumes about 700mA or 3.5W of power at 5VDC via the Micro USB or the GPIO header.

The RBPi is capable of outputting video as composite RCA or HDMI, audio via 3.5mm jack or HDMI. It has two USB-2.0 ports and a Micro USB port, exclusively for power. An onboard Ethernet network is available – 10/100 RJ-45. There is support for low-level peripherals such as SPI bus (along with two chip selects at +3V3 and +5V), I2C bus, UART and 8x GPIO or General Purpose Interface Bus.

If you are not too keen on an Ethernet cord dangling from your RBPi, simply plug in the wireless USB adapter to get 802.11b/g/n networks. In case power flakiness is observed, go for a powered USB hub to plug in the adapter. Wi-Fi requires substantial amounts of power.

Cassandra on a Raspberry Pi

The Cassandra database typically runs on large clusters of computer systems as it is designed to hold massive amounts of data. Now, a lecturer from the Dundee University is running it on the tiny, credit card sized, single board computer – the ARM based Raspberry Pi or RBPi.

At the Cassandra Summit, 2013, Andy Cobley, a lecturer at the University of Dundee, Scotland, presented his process of running Cassandra on multiple RBPis, which work as multiple Ethernet connected computers for his students. The advantage – no server racks and no data-centers required.

With 512MB of memory and a 700MHz ARM processor booting off an SD card, the Linux running RBPi does not look like a suitable candidate for usefully running Cassandra – the big data oriented Java-based database. Facebook originally contributed Cassandra as an Apache project. Organizations such as CERN, Twitter, eBay and Netflix use it to process huge amounts of data. For this, they use powerful servers in multiple data centers. Cassandra stores data and spreads the load over several clusters of connected disks and RAM loaded servers and connecting these clusters over highly constrained links results in an internationally reliable and resilient database.

Andy Cobley wanted to make it possible to run Cassandra on multiple RBPis, so that his students could experience running a database on multiple computers connected via the Ethernet, without having to build data centers and server racks. For this, Andy had to accept some compromises.

Cassandra is designed so that it can write data to disk at high speeds. Typically, in the time a laptop completes 12,000 write operations, a single RBPi can manage only 200 writes to its SD card. Making it write to an external USB drive only slows it down further. Moreover, the Ethernet port of the RBPi shares the same bus as its external USB port and the SD card. Cassandra, being very network centric, sees drastic reductions in network performance when there is any improvement in disk performance. Therefore, the route data takes through a system affects its performance.

With four to eight RBPis powered from USB hubs and all attached to an Ethernet switch, Andy was able to run Cassandra. Each of the RBPis was running the Debian Linux variant Raspian. Although he was unable to run the current Oracle JDK with the above setup, he ran Cassandra over OpenJDK. Running Cassandra in this manner, although complicated, resulted in some bugs being fixed for Cassandra. For example, Andy had to make the startup script resilient to accepting no CPU cores in the system.

Cassandra uses compression for boosting performance. However, it was not possible for Andy to use the native default method – Google’s Snappy compressor. Instead, he had to settle for the Java-based Deflate compressor, which is slower and has a penalty in write performance. Further performance boost for Cassandra came from ensuring that the RBPi CPU has more memory as compared to its GPU.

Andy has scaled down the Cassandra platform for his students, without actually rewriting it, making it easier for them to examine how a combination of Linux and Java runs on an RBPi cluster.

The compute module for Raspberry Pi

If you thought that the tiny single board computer, the Raspberry Pi (RBPi), could get no smaller, well, you really need to think again. There is now a Compute Module, which is much smaller. It contains the processor of the RBPi and 4GB of memory. The size of this board is roughly equal to a DDR2 laptop memory stick. However, the Compute Module is not exactly a miniaturization of the RBPi.

The advantage in fitting the system onto a small connector-less standard circuit board allows users to attach their own choice of interfaces. They need not be tied down to the built-in ports and devices that are available on the conventional RBPi board. The Compute Module is used along with a Starter IO board, which contains the rest of the devices.

The combination of the Compute Module and the Starter IO board is aimed at business and industrial users. The idea is to free the core technology of the RBPi to become an integral part of several new and exciting products and devices. The software of the RBPi is now full-featured and stable. A heroic community of volunteers is always hard at work constantly improving and improvising on the software. The manufacturers feel that this is the right time to free the hardware of the RBPi and make it more open.

Looking at the different types of users putting the RBPi to good use, it is really amazing to witness the huge number of products the community is developing around the tiny credit card sized SBC. The creativeness, ingenuity and inventiveness of the users are simply stunning. People are using the RBPi as not only a standalone module, but also embedding the tiny SBC into commercial products and systems. The dual combination of the Compute Module and the Starter IO board will make it even more versatile for these users.

The Compute Module contains the guts of the RBPi – the BCM2835 controller along with 512MBs of RAM. It also has a 4GB eMMC Flash memory, as a replacement of the SD card on the RBPi. Although all this is integrated onto a DDR2 SODIMM standard connector of the size 67.6x30mm and looks very much like a laptop memory card, it is not pin compatible to the memory card. Therefore, do not make the mistake of plugging in the Compute Module into a standard memory slot; it will only end in disaster.

The flash memory on the module is connected directly to the processor, but the remaining interfaces of the processor are freely available on the pins of the connector. That means you now have the full flexibility of the BCM2835 SoC. Compared to the original RBPi, many more number of GPIOs and interfaces available to the user on the Compute Module. That makes interfacing the Compute Module into a customized system should now be relatively simpler.

Although the Compute Module is aimed primarily at users who will be designing their own PCB, others not willing to go that far may use the Starter IO board. Snap the Compute Module into its connector on the Starter IO board and you are good to go.

A smartphone built from Raspberry Pi: the PiPhone

You may not be looking for a new cell phone right now, but someone has just managed to transform his Raspberry Pi (RBPi) into a working cell phone. David Hunt has used only off-the-shelf components and put them together for the project. Although it is not as slick as the regular cell phones available in the market, at about $160, David has created a one-off project that certainly has no economics of scale working for it. The best part is all components of the phone can be taken apart at any time, used for some other projects and then reassembled. Can you do that with your regular cell phone?

David has called his cell phone the PiPhone, in honor of the base RBPi that powers it. The other major parts used for making the PiPhone work are a Sim900 GSM/GPRS module and an Adafruit touchscreen interface. The GSM/ GPRS module allows the cell phone to make and receive calls, while the touchscreen provides the user interface. A 2500 mAh LiPo battery powers the entire contraption. The GSM module connects to the RBPi through a UART, while the battery fits in between the TFT screen and the RBPi, allowing the PiPhone to work standalone, without wall warts or dangling wires.

The touchscreen interface has a numeric keypad displayed on the screen. After dialing the required number, you need to touch the phone icon at the bottom to make the call or hang up.

The Sim900 GSM/GPRS is an intelligent module, which oversees the entire communication process of the PiPhone, including sending the standard AT commands to the RBPi for making calls, hanging up and sending text messages or data. Towards the bottom of the PCB is the connector where you can insert your SIM card. Therefore, you can use a regular prepaid SIM card available in the local phone store.

Just below the GSM module, there is an on/off switch and an off-the-shelf standard DC-DC converter. This converts the 3.7V supplied by the battery to the 5V required by the rest of the electronics. Heat dissipation was the only problem that David faced because of sandwiching the RBPi, the TFT, battery and the GPS module together. During development, as all the components were placed apart, they remained cool to the touch even after extended periods of use. However, sandwiching prevents air from circulating within, resulting in the CPU getting a bit warm after switching the unit on for a few minutes.

The GPS card is insulated from the RBPi with a thick foam-core board, allowing no accidental electrical connections between them. David used a couple of cable-ties to hold the different parts together.

Of course, walking into a local phone shop and picking up a normal smartphone would be simpler and cheaper, but that would not be as much fun as making your own. Moreover, as said earlier, you can put the parts to other uses as well, which you cannot do with a standard phone.

David has put up all his code and instructions on the GitHub. There are links available to instructions on installing the TFT.

Using the Texy’s Mini TFT Screen for Your Raspberry Pi

The single board computer, the Raspberry Pi (RBPi) is a wonderful device, but it needs a screen for you to see what it is doing. The Mini TFT screen from Texy’s is just made for the RBPi and the kit comes in a beautiful Perspex box too, which makes it very smart and practical. The Perspex box has a neat slot in the corner for the RBPi-Camera, although you may have to add blu-tack to prevent the camera from popping out. The screen and display are pre-built and ready to plug into the RBPi GPIO socket.

The display is backlit TFT, measuring 2.8-inches. The resolution is 320×240, which is a quarter VGA or QVGA, with 64 thousand colors. The current consumption is a mere 99mA. A major portion of this current is on account the backlight, which consumes 85mA. That means, if you switch the backlight off, by setting P1 on Pin18 to low, this screen uses only 19mA, which is great for battery-powered applications.

If you compare this with the 9-inch DVD player screen, which is 640×220 in resolution, and runs from the RBPi Analog output, the Texy’s screen is much sharper and more usable. Note that the standard TV resolution is 720×480 or 720×576. The digital connection makes the RBPi desktop very clear, perfectly formed and very easy to read on the small TFT screen.

The Texy’s screen provides a useful terminal display, fully displaying the entire RBPi desktop. Although it may not run full speed frame-rates, the display shows video perfectly. The compact fonts get a lot of text displayed on the terminal despite it being only 2.8-inches.

The addition of the resistive touch screen is the magical bonus as this opens up a great multitude of project possibilities, where a mouse, full keyboard and display setup would be rather impractical. You can bring the touch panel alive by combining some python code and Tkinter to get a very effective touch-based control system for your RBPi.

Texy’s has added flexibility to the screen in the form of the PI header pass-through available on the display board. You can use a ribbon cable to link the display to the RBPi GPIO and use the GPIO connections on the underside of the display. Alternately, you can connect the display directly to the RBPi GPIO and extend the GPIO with the cable.

Since the display uses SPI interface pins on the GPIO, including CE0, CE1, GPI00, GPI01 and GPI06. The GPIO pass-through allows you to connect your own ribbon cable to add further hardware, which can use the rest of the GPIO pins. A convenient GPIO pin out key is printed on the board for reference.

The easiest option for most is to use pre-configured images for driving the Texy’s display. Others, who are more confident, can modify the existing OS to use the screen; it is suggested to make a backup before setting out. Follow instructions here.

The display case, while providing support to the display unit, also extends out providing protection to the SD-Card while allowing full access to all sockets and connections of the RBPi.

Use your Raspberry Pi as a Hi-Fi Player

If you use your Raspberry Pi (RBPi) in combination with a USB DAC and RuneAudio, it will become a Hi-Fi music player providing surprising sound quality. RuneAudio is a free and open source software that you can use with the single board computer for running the custom-built Linux distribution. The RuneAudio and RBPi combination replaces the PC or the laptop that you normally use as a digital source for music.

Like other open source projects, RuneAudio also came to be born due to personal needs. The developers were not very happy about having to use the laptop as a digital source, its absolute sound quality and ease of use. They started the RuneAudio project and encouraged people to download it, try it free and contribute to the development.

Project RuneAudio has two distinctive goals: One, to provide exceptional sound quality and two, make it easy to use for everyone. The developers are using the RBPi and other supported platforms for deriving the best results. For this, they are using Arch Linux as the base for their RuneOS and optimizing it as best as possible for audio reproduction.

For making project RuneAudio easy to use for everyone, the developers have built a handy web interface – RuneUI, that lets users control the playback and system settings, without any need for touching the Linux command line. With a cross-platform web-interface, the responsive RuneUI adapts to the screen size automatically. That makes it accessible from all types of devices, whether you are using a PC, notebook, tablet or a smartphone. All you need to do for installing is to write an image file to your SD card.

To install, first you will have to download the latest RuneAudio image for your RBPi from the official webpage. Next, extract the contents of the zipped file with a utility for manipulating compressed files such as Unzip on Linux, Zipeg on Mac or 7-Zip on Windows. That will leave you with a raw disk image file (an extension of .img).

The raw disk image file has to be written onto an SD card. You may follow these guides on elinux.org: Linux howto, Mac howto and Windows howto. Before you plug-in the SD card into your device, make sure the card’s write-protection is turned off. After the card has finished writing, unmount it safely and plug it into your RBPi.

Plug-in a USB DAC into the RBPi USB port (you can simply plug in the analog jack if you do not have a USB DAC). You can also plug-in your USB storage or your USB hard drive. If you are using a hub for the USB devices, it is strongly suggested that you use an external power supply for it. Now plug-in your Ethernet connector, plug-in the power supply unit of the RBPi power it on.

That’s all. RuneAudio boots up your RBPi for the first time, and acquires an IP address. Open a web browser on your Android mobile and run RuneAudio from http://runeaudio.local. You should be in RuneUI now. If you want to see this being done, you can view the videos that can be found online.

Pairing your Raspberry Pi with an SPI OLED

OLEDs are interesting because they produce very crisp and brighter displays than is possible with the regular Liquid Crystal Displays. Being made of thin films of organic molecules, OLEDs use less power than conventional Light Emitting Diodes and LCDs. Driving OLEDs from your Raspberry Pi (RBPi) can be a great project to learn about these nifty solid-state displays and the processes that drive them.

Adafruit offers a lovely little monochrome SPI OLED module with a resolution of 128×32, driven by a SSD1306 driver chip. You can refer to excellent tutorials, libraries and guides on the website if you are driving this display from an Arduino. Although other OLED modules support I2C interface, this module supports only SPI, has pixel and text drawing functions, without any geometric drawing functions.

Although very small, only about 1-inch diagonal, the display is very readable because of the very high contrast of the OLED display. It has 128×32 individual white pixels, and the controller chip can turn each one of them on or off individually. No backlights are needed, as the OLED display produces its own light. This feature enhances the contrast and reduces the power consumption as well. The SSD1306 driver chip of the display communicates over the SPI bus, and requires four to five pins from the RBPi.

The OLED and its driver require a power supply voltage of 3.3V and logic levels of 3.3V for communication. If you are using this with the 5V supply of the RBPi, a 3.3V regulator should be used to power the display. On average, the display consumes about 20mA from the 3.3V supply, but this actually depends on how much of the display is lit. OLEDs usually require a high-voltage drive for the good contrast, but since this switched capacitor charge pump is already built-in into the display, this is one of the easiest OLED modules to interface.

Apart from the SPI specifications of the module, there is also a D/C pin, which controls the Data/Command going into the module. When you pull the D/C pin HIGH (connect it to VDD), the signals present at the pin are treated as data. When you pull it LOW (connect it to VSS), the signals present at the D/C pin are treated as command and are transferred to the command register.

What this essentially means is the opcode and the argument bytes that follow it are treated as a single command, even though this is a multi-byte command. For example, the command for setting the contrast control consists of a one-byte opcode followed by a one-byte contrast value. Therefore, the D/C pin has to be pulled LOW for the entire sequence when sending this command. Similarly, when sending image data, the D/C pin has to be pulled HIGH, which will enable the data to be moved into the image memory buffer.

The project is simplified when you use the following software – Occidentalis 0.2 for boot image, WiringPi-Python for accessing the GPIO pins and Py-Spidev for accessing the python bindings to the spidev Linux kernel driver. For further details, refer here.

Make a time clock with the Raspberry Pi

People working on projects are usually required to keep their time records up to date. However, those who are more engrossed with the technicalities of their work, find that they slip on their time keeping chores. If you fall into that category, let your Raspberry Pi (RBPi) help you out. Along with the tiny single board computer, you will additionally need one RGB LED, an OLED character display and a rotary encoder. Your time will be logged directly into a Google Docs spreadsheet.

The purpose-built time clock has several off-the-shelf components. For the RBPi, use the Occidentalis 0.2 operating system. The 128×32 OLED display uses SPI interface and this OS has the interface bundled in.

The time clock is very simple to operate. When you start it up, it will pull in a list of jobs from a specified Google Docs spreadsheet. To scroll through the list of jobs, simply rotate the knob on the rotary encoder. When you want to record time for specific project, just locate it by rotating the knob and click it. That starts the clock ticking on the spreadsheet. For logging off, simply click once again.

Use any case suitable for the RBPi or make your own. Since the HDMI, audio and video ports will not be used it is acceptable if the case does not provide access to these ports. For those who like to do things professionally, designing the carriage for the RBPi on OpenSCAD could be great fun. Printing the carriage on a Makerbot Replicator will give the required professional touch. Since the RBPi board does not have any mounting holes, you may have to put in edge-clips for holding it. Having posts at the corners of the board will make a snug fit.

Although the documentation of the RBPi mentions some ground pins as DNC or Do Not Connect, using them as extra grounds can be very convenient, just make sure you are using the proper ground pins.

Using the GPIO pin 5 of the RBPi for the push button can be of dual advantage. This keeps the pin 5 available for a Safe Mode boot, for example, when there is a recent firmware release. Simply hold the knob down when booting up and your RBPi comes up in the safe mode. Additionally, there is no chance of the pin being accidentally held low, such as could be the case if it was used for one of inputs to the quadrature encoders.

Use the software from here. The PWM library drives the RGB LED and the RgbLed class animates its color transition loops. The rotary encoder uses the RotaryEncoder.Worker class for polling through the encoder GPIOs and for keeping the application code as simple as possible.

Since the application code utilizes the CPU only to around 20%, its temperature rise is within safe range. The color-coding gives idea of the state of the machine. When no time is being logged, the LED shows purple. As time is logged against a task, the LED pulses slowly and turns blue. When rapidly flashing, you know that the spreadsheet on the Google Docs is being updated.

A live translation project using Raspberry Pi

Up until now, wearable computing has been confined to some odd bulky wristwatches. Most people are probably aware of the Augmented Reality Glasses, commonly referred to as Google Glass that Google has been working on for quite a while. Google Glass is still in limited release and not available to everyone. So, in the meantime, you can use your Raspberry Pi (RBPi) to fill in the gap. The project has everything you desire – small in size, light in weight and light in power consumption; a cheap lithium-ion battery makes it run for hours.

The project has two RBPi Single Board Computers working as close as possible to the universal translator of the Star Trek fame. The two displays are a pair of digital glasses, quite off-the-shelf. Other standard equipment used are a Jawbone Bluetooth microphone and a Vuzix 1200 Star wearable display. When fully functional, the system uses Microsoft’s publicly accessible API or Applications Programming Interface to perform voice recognition and translation on the fly.

For example, Will Powell, the originator of the project, uses the glasses to have a conversation with Elizabeth, who speaks Spanish. Although Will has never learned Spanish, he is able to converse meaningfully returning the answers in English. Powell’s blog shows a video of the system in action and shows the details of the build.

This project glass inspired translating unit works in real time and displays conversation as subtitles on your glasses. Both RBPi run the Debian squeeze operating system. For using the system, individual users will be wearing the Vuzix 1200 Star glasses, and these are connected to the s-video connector on his RBPi. For a clean and noise cancelled audio feed, Will uses a Jawbone Bluetooth microphone connected to either a smartphone or a tablet.

The Bluetooth microphone picks up the speakers voice and streams it across the network to pass it through Microsoft’s translation API service. For regularly used statements, a caching layer improves the performance. The subtitles face their longest delay when passing through this API service, The RBPi picks up the translated text the server passes back and this is then displayed on the glasses display.

Once a person has spoken, it takes a few seconds of delay before the translation pops-up on the other persons glass display. Moreover, the translations are not always fluid or coherent. However, that has nothing to do with the technology used here; rather it is based on the inaccuracies of the translation API. It is really amazing as to how such a relatively simple setup could offer speech recognition and translation at very near real-time.

At this rate, Augmented Reality Glasses will become popular very soon, and Google has suggested they will make their Glass project commercial very soon. Mobile communication is standing on the brink of a revolutionary technology that Google’s Glass is sure to bring about. However, Powell’s work shows there is still a lot of room to experiment and explore different kinds of functions and applications in this field.

The project also shows that very soon it may not matter what language you speak, anyone will be able to understand you, provided everyone is wearing the right glasses.