Friday, 29 July 2016

This NES Emulator Build Lets You Use Cartridges to Play Games

You may not remember this, but Nintendo hardware used to be a pretty big deal. The original Game Boy and NES both had remarkable industrial design that, like the Apple II and IBM Thinkpad, weren’t quite appreciated until many years after production ended. But, like many of you, [draftmike] had nostalgia-fueled memories of the NES experience still safely locked away.

Memories like lifting the cartridge door, blowing on the cartridge, and the feel of the cartridge clicking into place. So, understandably, reliving those experiences was a key part of [draftmike’s] Raspberry Pi-based NES build, though at 40% of the original size. He didn’t just want to experience the games of his youth, he wanted to experience the whole NES just as he had as a child.


Now, like any respectable hacker, [draftmike] didn’t let gaps in his knowledge stop him. This project was a learning experience. He had to teach himself a lot about 3D design and modeling, using Linux, and programming. But, the end result was surely worth the work; the attention to detail shows in features like the USB placement, the power and reset buttons, and of course the game cartridges which work with the magic of NFC and still include the insert and toggle action of the original cartridge carriage.

If you have a 3D printer and Raspberry Pi available, you could build a similar NES emulator yourself. But if you don’t have a 3D printer, but do have an original NES lying around, you could pull of the Raspberry Pi in a NES case hack. Whichever you do, the NES’s beauty deserves to be displayed in your home.

Filed under: 3d Printer hacks, nintendo hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Thursday, 28 July 2016

Squirrel Café To Predict The Weather From Customer Data

Physicist and squirrel gastronomer [Carsten Dannat] is trying to correlate two critical social economical factors: how many summer days do we have left, and when will we run out of nuts. His research project, the Squirrel Café, invites squirrels to grab some free nuts and collects interesting bits of customer data in return.

Animals are said to have a predictive sense for natural events, and [Carsten’s] experiment is about verifying this. The hypothesis [Carsten] is trying to prove with this setup is the following:

The amount of nuts taken by red squirrels from a squirrel feeder correlates with upcoming winter weather conditions significantly.

To prove this, [Carsten] regularly fills a wooden squirrel feeder with a known amount of nuts. A mercury switch on the feeder’s lid triggers the execution of a Python script on a Raspberry Pi. The script then polls a Dallas DS18B20 temperature sensor and takes a photograph through a Raspberry Pi camera module. All gathered data is automatically compiled into a tweet and also sent to ThingSpeak for further processing.

squirrel_station squirrel_raspi squirrel_tweet

The setup works well, providing squirrels with peanuts and [Carsten] with precious data. The video below suggests that the little fellows tend to take one nut at a time, so the mercury switch effectively counts individual nuts. When refilling, [Carsten] checks how many nuts have actually been taken from the station, which allows him to track the nut consumption more accurately.

Yet, for some mysterious reason, the local squirrel population recently decided to boycott the café entirely. For two weeks now, not a single guest has shown up. The outside temperature was around 35° C (95° F) for these days, so regarding the hypothesis, the appetite loss could already be an indicator for a certain weather dependency of the squirrels’ nut consumption. There are certainly some more factors to consider, like the overall food supply, instinctive behavior, and software bugs, but we’re already curious if we will see more squirrels when the temperature drops again. What do our readers think, can squirrels really predict the weather?

Enjoy the video below, which shows the café’s furry guests before they took summer vacation:

Filed under: misc hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Wednesday, 27 July 2016

DIY Smart Home Device Means No More Fumbling in the Dark

Smart home tech is on the rise, but cost or lack of specific functionality may give pause to prospective buyers. [Whiskey Tango Hotel] opted to design their own system using a Raspberry Pi and Bluetooth device connectivity. Combining two ubiquitous technologies provides a reliable proximity activation of handy functions upon one’s arrival home.

Electrical Wiring Diagram

The primary function is to turn on a strip of LEDs when [Whiskey Tango Hotel] gets home to avoid fumbling for the lights in the dark, and to turn them off after a set time. The Raspberry Pi and Bluetooth dongle detect when a specified discoverable Bluetooth device comes within range — in this case, an iPad — after some time away. This toggles the Pi’s GP10 outputs and connected switching relay while also logging the actions to the terminal and Google Drive via IFTTT.

[Whiskey Tango Hotel] has included their Python code and build steps at the end of their blog post to help save you some time should you start a similar project. Indeed, the Raspberry Pi + Bluetooth combo can be used to great effect in many different areas — like adding non-standard functionality to your vehicle’s stereo.

Filed under: home hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Hackaday Prize Entry: A Cheap Robotic Microscope

Monday, 25 July 2016

Hackaday Links: July 24, 2016

Right now HOPE is dying down, and most of the Hackaday crew will be filtering out of NYC. It was a great weekend. The first weekend in August will be even better. We’re going to DEF CON, we’ll have people at VCF West, and a contingent at EMF Camp. If you’re going to EMF Camp, drop a line here. There will be Hackaday peeps wandering around a field in England, so if you see someone flying the Hackaday or Tindie flag, stop and say hi.

Raspberry Pi’s stuffed into things? Not all of them are terrible. The Apple Extended keyboard is possibly the best keyboard Apple ever produced. It’s mechanical (Alps), the layout is almost completely modern, and they’re actually cheap for something that compares well to a Model M. There’s also enough space inside the plastic to fit a Pi and still have enough room left over for holes for the Ethernet and USB ports. [ezrahilyer] plopped a Pi in this old keyboard, and the results look great. Thanks [Burkistana] for sending this one in.

We’ve been chronicling [Arsenijs] Raspberry Pi project for months now, but this is big news. The Raspberry Pi project has cracked 10k views on, and is well on track to be the most popular project of all time, on any platform. Congrats, [Arsenijs]; it couldn’t happen to a better project.

A few months ago, [Sébastien] released SLAcer.js, a slicer for resin printers that works in the browser. You can’t test a slicer without a printer, so for the last few months, [Sébastien] has been building his own resin printer. He’s looking for beta testers. If you have experience with resin printers, this could be a very cool (and very cheap) build.

Anyone going to DEF CON? For reasons unknown to me, I’m arriving in Vegas at nine in the morning on Wednesday. This means I have a day to kill in Vegas. I was thinking about a Hackaday meetup at the grave of James T. Kirk on Veridian III. It’s about an hour north of Vegas in the Valley of Fire State Park. Yes, driving out to the middle of the desert in August is a great idea. If anyone likes this idea, leave a note in the comments and I’ll organize something.

Filed under: Hackaday Columns, Hackaday links

from raspberry pi – Hackaday
via Hack a Day

Monday, 18 July 2016

ArduCAM Introduces A Third Party Raspberry Pi

There are hundreds of ARM-based Linux development boards out there, with new ones appearing every week. The bulk of these ARM boards are mostly unsupported, and in the worst case they don’t work at all. There’s a reason the Raspberry Pi is the best-selling tiny ARM computer, and it isn’t because it’s the fastest or most capable. The Raspberry Pi got to where it is today because of a huge amount of work from devs around the globe.

Try as they might, the newcomer fabricators of these other ARM boards can’t easily glom onto the popularity of the Pi. Doing so would require a Broadcom chipset. Now that the Broadcom BCM2835-based ODROID-W has gone out of production because Broadcom refused to sell the chips, the Raspberry Pi ecosystem has been completely closed.

Things may be changing. ArduCAM has introduced a tiny Raspberry Pi compatible module based on Broadcom’s BCM2835 chipset, the same chip found in the original Raspberry Pis A, B, B+ and Zero. This module is tiny – just under an inch square – and compatible with all of the supported software that makes the Raspberry Pi so irresistible.

nano-rpi-cmio-backAlthough this Raspberry Pi-compatible board is not finalized, the specs are what you would expect from what is essentially a Raspberry Pi Zero cut down to a square inch board. The CPU is listed as, “Broadcom BCM2835 ARM11 Processor @ 700 MHz (or 1GHz?)” – yes, even the spec sheet doesn’t know how fast the CPU is running – and RAM is either 256 or 512MB of LPDDR2.

There isn’t space on the board for a 2×20 pin header, but a sufficient number of GPIOs are broken out to make this board useful. You will fin a micro-SD card slot, twin micro-USB ports, connectors for power and composite video, as well as the Pi Camera connector. This board is basically the same size as the Pi Camera board, making the idea of a very tiny Linux-backed imaging systems tantalizingly close to being a reality.

It must be noted that this board is not for sale yet, and if Broadcom takes offense to the project, it may never be. That’s exactly what happened with the ODROID-W, and if ArduCAM can’t secure a supply of chips from Broadcom, this project will never see the light of day.

Filed under: ARM, news, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Sunday, 17 July 2016

Kansas City Maker Faire: Lawn da Vinci is the Droid You’re Looking For

Summer is now in full swing, which means that mowing the lawn once a week is starting to get old. So why not build a robot do it for you? That’s what [Blake Hodgson] did, and he’s never been happier. It only took him a couple of weeks of quality time at one of the local makerspaces.

[Blake] was showing off Lawn da Vinci at this year’s Kansas City Maker Faire. He had his own booth around the corner from Hammerspace, the shop where it all came together. [Blake] started with a standard push mower from a garage sale and designed a frame around it using OnShape. The frame is made from angle iron, so it’s strong enough that he can ride on the thing. To each his own, we say. The wheels and motors came from a mobility scooter and match the beefiness of the frame. These are powered by two 12v car batteries wired in series. He drives it around his yard with an R/C airplane controller.

lawnmower gutsLawn da Vinci’s brainpower comes from two Arduino Pro Minis and a Raspberry Pi. One Arduino controls the motors and the R/C signal from the remoteThe other runs some extra kill switches that keep the Lawn da Vinci out of trouble.

So what’s the Raspi for? Right now, it’s for streaming video from the webcam attached to a mast on the frame back to his phone. [Blake] says he has had some latency issues with the webcam, so there could be a pair of drone racing goggles in his future. He also plans to add a GPS logger and to automate part of the mowing.

Now, about those kill switches: there are several of them. You probably can’t have too many of these on a remote control spinning suburban death machine. Lawn da Vinci will stop grazing if it goes out of range of the remote or if the remote is turned off. [Blake] also wired up a dedicated kill switch to a button on the remote and a fourth one on a separate key fob.

The Lawn da Vinci is one of many example projects that [Blake] uses to showcase the possibilities of KC Proto, a company he started to help local businesses realize their ideas by offering design solutions and assistance with prototyping. Between mowings, [Blake] puts the batteries on a trickle charger. If you make your own robot lawn mower, you might consider building a gas and solar hybrid.

Filed under: home hacks, lifehacks, Microcontrollers

from raspberry pi – Hackaday
via Hack a Day

Friday, 15 July 2016

The Raspberry Pi 3 Compute Module Is On Its Way

The Raspberry Pi Foundation founder Eben Upton has revealed in an interview with PCWorld that there will be a new version of the organisation’s Compute Module featuring the faster processor from the latest Raspberry Pi 3 boards, and it will be available “In a few months”.

The Compute Module was always something of an odd one out among the Raspberry Pi range, being a stripped-out Raspberry Pi chipset on a SODIMM form factor card without peripherals for use as an embedded computer rather than the standalone card with all the interfaces we are used to in the other Pi boards. It has found a home as the unseen brains behind a selection of commercial products, and though there are a few interface boards for developers and experimenters available for it we haven’t seen a lot of it in the world of hackers and makers. Some have questioned its relevance when the outwardly similar Pi Zero can be had for a lower price, but this misses the point that the two boards have been created for completely different markets.

The Pi 3’s 1.2 GHz 64-bit quad-core ARM Cortex-A53 BCM2837 SoC will certainly up the ante in the Compute module’s market, but it will be interesting to see what changes if any they make to its form factor. The Foundation’s close ties with Broadcom mean that they have done an impressive job in maintaining backward compatibility at a hardware level between the different generations of their product, but it is unclear whether this extends to the possibility of the new module maintaining a pin-for-pin compatibility with the old. We’d expect this to be an unlikely prospect.

It is certain that we will see a new generation of exciting commercial products emerging based around the new module, but will we see it making waves within our domain? This will depend on its marketing, and in particular the price point and quantity purchase they set for it. The previous board when added to a Compute Module Development board was an expensive prospect compared to a Raspberry Pi Model B that became more unattractive still as newer Pi boards gained more capabilities. If they price this one competitively and perhaps if any cheaper open hardware breakout boards emerge for it, we could have a valuable new platform on our hands.

Here’s our coverage of the original Compute Module launch, back in 2014.

[via Liliputing and reddit].

BCM2837 image: By Jose.gil (Own work) [CC BY-SA 4.0], via Wikimedia Commons.

Filed under: news, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Code Craft – Embedding C++: Multitasking

We’re quite used to multitasking computer systems today. Our desktops run email, a couple of browsers in different workspaces, a word processor, and a few other applications, apparently all at once. Looking behind the scenes using a system monitor or task manager program reveals a multitude of other programs running in support of our activities. Of course, any given CPU is running a maximum of one program at a time. Multitasking is simply the practice of switching between active processes fast enough to give the illusion of simultaneity.

The roots of multiasking go way back. In the early days, when computers cost tons of money, the thought of an idle system was anathema. Teletype IO was slow compared to the processor, and leaving the processor waiting idle for a card reader to slurp in the next card was outrageous. The gurus of the time worked to fill that idle time with productive work. That eventually led to systems that would run multiple programs at one time, and eventually to more finely grained multitasking within a program.

Modern multitasking depends on support from the underlying API of an operating system. Each OS uses its own techniques, making it difficult to write portable code. The C++ 2011 standard increased the portability of the language by adding concurrency routines to the Standard Template Library (STL). These routines use the API of the OS. For instance, the Linux version uses the POSIX threading library, pthread. The result is a minimal, but useful, capability for building upon in later standards. The C++ 2017 standard development activities include work on parallelism and concurrency.

In this article, I’ll work through some of the facilities for and pitfalls in writing threaded code in C++.

Creating Threads

To implement multitasking within a single program, the code is broken up into multiple tasks, or threads, that run at the same time. Declaring and running a thread is simple. The hard parts come later while managing them and handling interactions among threads.

A thread is created from anything that is callable. That means a function or a class with, typically, an operator() method. Here is an example with three different callable objects created as threads and some management techniques.

#include <thread>
using namespace std;

void fa() {
void fb(int a) {
class Fc {
        Fc(int a) :
                        mA { a } {
        void operator()() {
        int mA;

int mainx() {
        int value;

        thread t_fa { fa };
        thread t_fb { fb, value };
        thread t_fc { Fc { value } };


        /* ... */
        // code waits for one second

// code continues in the ‘main’ thread


        return 0;

There is nothing special about these functions or the class. They could be used in a program as functions or as class instances. They become independent threads when passed to the constructor of class thread along with any arguments that are required of the function or the operator() method. The thread class is a variadic template class with a variable length number of typenames. This capability allows the class constructor to forward the arguments to the function or class method.

Now that the thread is running, how do you stop it? Unfortunately there is no method provided by thread. But it is easy to create a way. One technique I’ve used is a simple global boolean flag passed as a reference:

#include <atomic>
static std::atomic_bool run { true };

void fr(int a, std::atomic_bool& run) {
        while (run) {

int value { 0 };
thread t_fr { fr, value, std::ref(run) };

The thread checks for run becoming false and exits. We’ll see later why the std::atomic_bool is used.

Arguments can be passed by value or pointer just as in calling a regular function. Passing a reference requires the use of std::ref, as demonstrated with run.

Working With Threads

After the threads are created the remainder of main() is executed. When main() exits the situation gets interesting. What happens to the running threads? What happens to the resources they may have allocated, like an open file or serial port? Also consider that you can start a thread in any function, not just main(), so what if fa() created another thread and then exited? What happens to that new thread?

The standard provides two ways of handling this situation: thread::join() and thread::detach(). When function calls join() it is hold until the thread completes. In the example this is done just before main() exits.

A detached thread runs independent of the rest of the program. Generally, a call to detach() should be made soon after the thread is created. When the creating function exits, the thread continues running, even beyond the end of main(). If detached threads are not stopped by using some technique, like shown with run above, an exception is thrown. This leaves program resources in an indeterminate state.

A thread that has been neither joined nor detached is a joinable thread. This can be tested by thread::joinable(). An attempt to join a detached thread throws an exception. If the state of the thread is uncertain it, should be checked by calling joinable().

What happens if a thread throws an uncaught exception? The standard specifies std::terminate() is called, which calls std::abort to end the program. You can avoid this by catching the exception or specifying a std::terminate_handler. The details for this are available in a C++ reference site or book.

The need to join with a thread, if appropriate, requires diligence akin to management of resources, e.g. files or memory. It is solved by the same approach which underlies one reason for the existence of classes: Resource Allocation Is Initialization (RAII). A class constructor performs initialization, which includes resource acquisition, while a destructor releases resources. A simple class (see Notes at end) to handle threads is:

struct thread_guard: thread {
        using thread::thread;
        ~thread_guard() {
                if (joinable()) {

The class thread_guard is a derived class of thread. The using thread::thread tells the compiler to use all of thread’s methods, eliminating the need to create a constructor for thread_guard, since we only want to provide a destructor. The destructor tests if the thread is joinable, i.e. that it isn’t detached, and does a join, if allowed. This provides two capabilities. The function creating a thread no longer needs to explicitly join the thread, although it safely can, before the function exits. If something interrupts the creating function, like an exception, the destructor will do the join.

In the example code the namespace this_thread is demonstrated with a call to this_thread::sleep_for(). This namespace provide three routines for controlling the timing of threads. You can, as illustrated, sleep for a period of time, sleep until a specified time, or simply yield. The fourth routine in the namespace gets the thread’s identification number. Its appearance in main() points out that it is also a thread. The chrono header is well worth studying since it provides convenient tools for working with time values in the form of clocks, specific points in time, and durations.

Racing Threads

Let’s go back to atomic_bool which is defined in the atomic header along with atomic versions of many standard types. Atomic variables are needed to prevent race conditions on a variable. It takes sometimes hundreds of processor cycles to read or write a variable, even something as small as a boolean or character. During that time an interrupt can occur or a new task swapped for the current task. If this newly executing code reads or writes the same variable the state of the variable is corrupted. For example, a 32 bit integer contains four bytes. The first task reads two bytes, is interrupted, the new routine writes all four bytes, and when the first task is restarted it reads the last two bytes. The original first two bytes it read are now invalid. An atomic operation prevents this from happening.

Other race conditions occur when attempting to access resources. If the tasks in the example were sending output to cerr such a race would occur. One task could start outputting text, be interrupted by a task swap, and the new task also start writing to cerr causing their outputs to intermix.

The long established technique for handling this is with mutual exclusion, shortened to mutex.

#include <mutex>
   std::mutex cerr_mutex;
   . . .
   cerr << "Hello Hackday! "  << '\n';

A mutex is locked when a task wants to access a resource and is unlocked when the task is done. This is a quick and inexpensive operation. If another task requests the mutex, the task is held until the mutex is released.

The use of multiple mutex can lead to a deadlock situation. Task A requests mutex X and Y, in that order. Task B requests Y and then X. Each can gain their first mutex ,but neither can obtain the second. The standard provides the function lock(X, Y, …) which waits until all the locks in the argument list are available.

The mutex header provides more classes and functions for handling race conditions so deserves careful study when using threads.

Peeking Behind the Curtains

It helps when doing multitasking to understand a little bit about what is happening behind the curtains. On Windows or Linux we are working with preemptive multitasking, in contrast to cooperative multitasking.

In the former, the system is driven by a timer interrupt to switch, using a scheduling algorithm, among the tasks running on the system. A cooperative multitasking system relies on tasks to voluntarily relinquish control so other tasks may be scheduled

The simplest preemptive scheduler is time-slicing where each task is allowed to run for a specific amount of time. If a task yields for IO, to wait on a mutex, or voluntarily, the next task is allowed to proceed. More sophisticated algorithms, even with cooperative multitasking, perform priority scheduling where a high priority task gets more time. In real-time system, tasks marked as real-time might get as much time as they need. With priority multitasking developers must assure that all tasks receive sufficient time. One reason they might not is when high priority tasks consume all the processing, starving lower priority tasks. A problem, dubbed priority inversion, can occur when a low priority task grabs a mutex preventing a higher priority task from running.

Multitasking Costs

Multitasking consumes time and memory resources. When a task swap occurs, the processor registers used by a task are pushed onto its stack. The next task’s registers are popped from that task’s stack to start it running. This obviously takes time and memory since each task must be allocated a stack. Setting the stack size is almost an art. Enough space must be allocated for the worst case number of function calls and local, stack based, variables the task might need. In addition, when an interrupt occurs to handle external events, say a serial port receives a character, the interrupt requires stack space.

The Arduino ecosystem generally does not support these forms of multitasking because the processors do not have the memory for the stacks required by multiple tasks. There are scheduler techniques usable on Arduinos that are cooperative but do not save the state of the task, pushing that burden onto the task itself. The C++ concurrency libraries are not usable since there is no underlying system to provide a multitasking API. The Arduino community has developed a large number of scheduler libraries to use on those systems.

Wrap Up

Multitasking is a useful technique for keeping the processor busy. It must be remembered that it isn’t a panacea and, as always, should be tested to make sure the overhead of multitasking isn’t costing more than it provides.

Another consideration is the impact on the organization of the code. Dividing a program into its logical parts as separate tasks can make creating, testing, and debugging the code easier. Individual developers can work more easily and independently on separate portions of the code. Even a single individual, like myself, finds it easier to concentrate on the the code for a specific task while ignoring other processes.

I’ve only touched on the complex requirements for creating a multitasking system. There are many other C++ capabilities available for working with tasks, including safely coordinating their activities and transferring data among them. Once you start hacking with larger code bases, breaking the code into multiple tasks may prove beneficial for your system and sanity.


The thread_guard class is from Bjarne Stroustrup, “The C++ Programming Language”, 4th Edition. Read this book for all you ever want to know about C++.

Filed under: Hackaday Columns, Raspberry Pi, robots hacks, Software Development

from raspberry pi – Hackaday
via Hack a Day

45-Year Old Nixie Calculator Turned UDP Server

In this beautiful and well-documented reverse engineering feat of strength, [Eric Cohen] reverse-engineered a 1971 Singer calculator to gain control of the fabulous Nixie tubes inside. Where a lesser hacker would have simply pulled the tubes out and put them in a more modern housing, [Eric] kept it all intact.

Not even content to gut the box and toss some modern brains inside, he snooped out the calculator’s internal wiring, interfaced a Raspberry Pi to it, and overrode the calculator’s (860 Hz) bus system. With the Pi on the inside, controlling the Nixie tubes, he did what any of us would do: set up a UDP server and write an Android app for his phone to push ASCII data over to the former calculator. When it’s not running in its default clock mode, naturally.


All of this is extraordinarily well documented both on his website, in a slide presentation (PDF), and in video (embedded below). Our hats are tipped to the amazing attention to detail and fantastic documentation.

Now where is that Singer EC1117 calculator from 1971 that we’ve been saving for just such an occasion?

Filed under: classic hacks

from raspberry pi – Hackaday
via Hack a Day

Hacker-Friendly SBCs: Which ones?

We have run out of fruits to name all the single-board computers on the market, but that doesn’t mean you can’t buy a rotten one. Bad documentation, incomplete specifications and deprecated firmwares are just some of the caveats of buying only by price and hardware features. To help you out in case you just need to find a great and open-enough SBC with community support, [Eric] has put together a decent list with 81 individually reviewed boards over at

With 81 boards, the list is as concise as it can be, ruling out almost half of the commonly available boards that are either deprecated or lack the necessary hacker-friendliness to use them off the groomed track. The list is derived from a survey held in June 2016. The survey resulted in more interesting statistics, such as the popularity ranking of certain boards (you can probably guess which one took the cake) and the most valued features of SBCs: Open source software support and the community ecosystem.

Thanks to [Greg] for the tip!

Filed under: Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Sunday, 10 July 2016

Kansas City Maker Faire: Pi-Plates

As soon as he spied the Jolly Wrencher on my shirt, [Jerry Wasinger] beckoned me toward his booth at Kansas City Maker Faire. Honestly, though, I was already drawn in. [Jerry] had set up some interactive displays that demonstrate the virtues of his Pi-Plates—Raspberry Pi expansion boards that follow the HAT spec and are compatible with all flavors of Pi.

[Jerry] has developed three types of Pi-Plates to date. There’s a relay controller with seven slots, a data acquisition and controller combo board, and a motor controller that can handle two steppers or up to four DC motors. The main image shows the data acquisition board controlling a fan and some lights while it gathers distance sensor data and takes the temperature of the Faire.

The best part about these boards is that you can stack them and use up to eight of any one type. For the motor controller, that’s 16 steppers or 32 DC motors. But wait, there’s more: you can still stack up to eight each of the other two kinds of boards and put them in any order you want. That means you could run all those motors and simultaneously control several voltages or gather a lot of data points with a single Pi.

The Pi-Plates are available from [Jerry]’s site, both singly and in kits that include an acrylic base plate, a proto plate, and all the hardware and standoffs needed to stack everything together.

Filed under: cons, Microcontrollers, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Saturday, 9 July 2016

Digital Opponent In An Analog Package

Unsatisfied with the present options for chess computers and preferring the feel of a real board and pieces, [Max Dobres] decided that his best option would be to build his own.

Light and dark wood veneer on 8mm MDF board created a board that was thin enough for adding LEDs to display moves and for the 10mm x 1mm neodymium magnets in the pieces to trip the reed switches under each space. The LEDs were wired in a matrix and connected to an Arduino Uno by a MAX7219 LED driver, while the reed switches were connected via a Centipede card. [Dobres] notes that you’ll want to test that the reed switches are positioned correctly — otherwise they might not detect the pieces!

A small LCD screen and four buttons also connect to the Arduino for configuring options a number of options, computer difficulty, and play styles, while a Raspberry Pi acts as the main computer.

The Raspberry Pi is using ChessBoard 2.05 as a rule set with consideration for special moves (such as en passant and castling). It’s currently unsupported but used with permission by its creator, John Eriksson. The chess program Stockfish is the actual engine; be sure to adjust the skill of the AI, as it defaults to an ELO of 2600! Unfortunately, it’s a rather finicky program, only running on Python 2.7. If that doesn’t appeal to you, [Dobres] has provided a nice list of other options to help you with your own build.

He has recently updated his design and done away with the need for the Arduino in the process which — especially if you use the Pi Zero — drops the cost of this project significantly. That should leave you with enough room in your budget to build a robot to make the moves for you!

[via Max Dobres]

Filed under: Arduino Hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Friday, 8 July 2016

Join the GUI Generation: QTCreator

More and more projects require a software component these days. With everything being networked, it is getting harder to avoid having to provide software for a desktop or phone environment as well as the code in your embedded device.

If you’ve done a lot of embedded systems work, you probably already know C and C++. If so, it is pretty easy to grab up a C compiler and write a command-line application that does what you want. The problem is that today’s users have varying degrees of fear about the command line ranging from discomfort to sheer terror. On a mobile device, they probably don’t even know how to get to a command line. I’ve been waiting for years for the WIMP (Windows/Icon/Mouse/Pointer) fad to fade away, but even I have to admit that it is probably here for the foreseeable future.

qtrigolSo what’s the alternative? There are actually quite a few. However, I wanted to talk about one that is free, has a wide range of deployment options, uses C++, and is easy to pick up: Qt. Specifically, creating programs with QtCreator (see right). Yes, there are other options, and you can develop Qt programs in a number of ways.

You might think Qt isn’t free. There was a time that it was free for open source projects, but not for commercial projects. However, recent licensing changes (as of version 4.5) have made it more like using gcc. You can elect to use the LGPL which means it is easy to use the Qt shared libraries with closed software. You might also think that a lot of strange constructs that “extend” C++ in unusual ways. The truth is, it does, but with QtCreator, you probably won’t need to know anything about that since the tool will set up most, if not all, of that for you.


If you ever used Visual Basic or something similar, you will feel right at home with QtCreator. You can place buttons and text edit boxes and other widgets on a form and then back them up with code. Buttons create signals when you push them. There are lots of signals like text changed or widgets (controls) being created or destroyed.

To handle a signal, an object provides a slot. There is a meta-compiler that preprocesses your C++ code to get all the signal and slot stuff converted into regular C++. Here’s the good news: you don’t really care. In QtCreator you can write code to handle a button push and exactly how that happens isn’t really much of a worry.

QtCreator has kits that can target different platforms and — in general — the code is reasonably portable between platforms. If you do want to do mobile development for Android or iOS, be sure that you understand the limitations before you start so you can avoid future pitfalls.

You Need Class

Like many similar frameworks, Qt uses an application class (QtApplication) that represents a do-nothing application. Your job is to customize a subclass and have it do what you want. You add widgets and you can even add more screens, if you like. You can connect signals to existing slots or new slots.

There are many classes available, and the online documentation is quite good. Depending on which version of Qt you are using, you’ll need to find the right page (or ask QtCreator to find it for you). However, just to whet your appetite, here’s the Qt5 reference page. From there you can find classes for GUI widgets, strings, network sockets, database queries, and even serial ports.

I could do an entire tutorial on using QtCreator, but it would be a duplication of effort. There’s already a great getting started one provided. You’ll find there is plenty of documentation.


How do you enumerate serial ports? It depends on the platform, right? In Qt, the platform-specific part is hidden from you. For example, here’s a bit of code that fills in a combo box with the available serial port:

MainWindow::MainWindow(QWidget *parent) :
 ui(new Ui::MainWindow)
// initialize list of serial ports
 ports = QSerialPortInfo::availablePorts();
// fill in combo box
 for (int i=0; i comport->addItem(ports[i].portName(), QVariant(i));

The QSerialPortInfo object provides an array of serial port objects. The ui->comport is a combo box and the addItem method lets me put a display string and a data item in for each selection. In this case, the display is the portName of the port and the extra data is just the index in the array (as a variant, which could be different types of data, not just a number). When you select a port, the index lets the program look up the port to, for example, open it.

When the combo box changes, a currentIndexChanged signal will occur. Here’s the slot handler for that:

void MainWindow::on_comport_currentIndexChanged(int index)
 QString out;
 // get selected index
 int sel=ui->comport->currentData().toInt();
// build up HTML info string in out
 out="<h1>Serial Port Info</h1>";
 out += ports[sel].portName() + " " + ports[sel].description() + "
 out += ports[sel].systemLocation() + "
 if (ports[sel].hasVendorIdentifier() && ports[sel].hasProductIdentifier())
 out += ports[sel].manufacturer() + " ("+ QString::number(ports[sel].vendorIdentifier(),16) + ":" + QString::number(ports[sel].productIdentifier(),16) + ")";
 // and put it on the screen

In this case, the result is information about the serial port. You can see the resulting output, below. The QString is Qt’s string class and, obviously, the text display widget understands some HTML.


Not Just for GUIs

You can develop console applications using Qt, but then many of the provided classes don’t make sense. There’s even a Qt for Embedded (essentially Linux with no GUI). You can find guides for Raspberry Pi and BeagleBoard.

On the mobile side, you can target Android, iOS, and even Blackberry, along with others. Like anything, it probably won’t just be “push a button” and a ported application will fall out. But it still should cut down on development time and cost compared to rewriting a mobile app from scratch.

And the Winner Is…

I’m sure if you want some alternatives, and our comment section is about to fill up with recommendations. Some of them are probably good. But it strikes me that not everyone has the same needs and background. The best tool for you might not work as well for me. I find Qt useful and productive.

Even if Qt isn’t your tool of choice, it still can be handy to have in your tool bag. You never know when you will need a quick and dirty cross-platform application.

Filed under: software hacks

from raspberry pi – Hackaday
via Hack a Day

Beautiful Raspberry Pi Laptop Inspired By Psion

Wednesday, 6 July 2016

A Pi Robot Without a Hat

Daughter boards for microcontroller systems, whether they are shields, hats, feathers, capes, or whatever, are a convenient way to add sensors and controllers. Well, most of the time they are until challenges arise trying to stack multiple boards. Then you find the board you want to be mid-stack doesn’t have stackable headers, the top LCD board blocks the RF from a lower board, and extra headers are needed to provide clearance for the cabling to the servos, motors, and inputs. Then you find some boards try to use the pins for different purposes. Software gets into the act when support libraries want to use the same timer or other resources for different purposes. It can become a mess.

The alternative is to unstack the stack and use external boards. I took this approach in 2013 for a robotics competition. The computer on the robots was an ITX system which precluded using daughter boards, and USB ports were my interface of choice. I used a servo controller and two motor controllers from Pololu. They are still available and I’m using them on a rebuild, this time using the Raspberry Pi as the brain. USB isn’t the only option, though. A quick search found boards at Adafruit, Robotshop, and Sparkfun that use I2C.

This approach has challenges and benefits. A stack of daughter boards makes a neat package, where external boards makes a tangle of wires. Random sizes can make mounting a challenge. Providing power can also be a hassle because of the random placement of power pins. You can’t rely on USB power, especially from a Raspberry Pi whose USB is power limited.

On the other hand, external boards can offload processing from your main processor. Once a command is sent, these boards handle all the details including refresh requirements. They are likely to provide capabilities beyond the microcontroller software libraries since their processors are dedicated to the task.

I am using an 18-channel board from the Pololu Maestro Servo Controller family of boards that control from 6 to 24 servos using a single board. You might find the Adafruit 16 channel I2C board a useful alternative. For motor control I turned to the Pololu Simple Motor Controller family using one that will handle 18 amps. Others will handle from 7 to 25 amps. Or consider the Sparkfun Serial Controlled Motor Driver. Another source for USB controllers is Phidgets. I experimented with one of their spatial devices for the original robot. I should have used it to measure the tilt since one of my robots rolled over on a hill. Ooops!

Servo Control

The board currently installed on my robot is the Mini Maestro 18. The Maestro provides control over the servo speed, acceleration and movement limits. A home position can be set for startup or when errors occur. You can even do scripting or set movement sequences to play on command.

maestro familyOn the hardware side, the Maestro also allows channels to be used for digital input or output, and some channels for analog input. On some there is one channel for pulse width modulation output. An onboard regulator converts the servo power input to the voltage needed by the processor, simplifying part of the power distribution challenge.

My previous robot used the Maestro to control pan and tilt servos for camera positioning, a servo to lift samples from the ground, and a safety LED. Two analog inputs from current sensors on the motors helped avoid burnout during stalls, and four inputs from a simple RF key fob transmitter provided control. The latter came in handy for testing. I’d program a test sequence such as starting a 360° camera scan for landmarks or drive onto the starting platform and drop the sample. A button press on the key fob would initiate the activity. One button was always set up as an emergency halt to stop a rampaging robot. The rebuild is following this pattern with some additions.

Motor Controller

The two Simple Motor Controllers (SMC) each handled the three motors on either side of the Wild Thumper chassis. The SMC does more than just control the motor speed and direction. You can set acceleration, braking, and whether forward and reverse operate at the same or different speeds. The board monitors a number of error conditions for safety. These stop the motor and prohibit movement until cleared. Such blocking errors include lost communications, low input voltage, or drivers overheating.

smcAn additional capability I found extremely helpful is the ability to read signals from a radio control (RC) receiver. These signals can be used to control the motor and, with some cross wiring between two controllers, provide differential drive control. This is useful for driving the robot to a new location using an RC transmitter. I didn’t use the RC inputs directly. Instead I read the RC inputs and issued the control commands from my program. This let me monitor the speed in my program logs for correlation with the other logged data. I also used an input to command the robot into autonomous or RC control operations. There are also two analog inputs that can be used to directly control the motor and can be read through commands.

Serial Communications

USB ports were my choice for communications but there is also a TTL level serial port with the standard RX and TX pins. This port can be used by the Raspberry Pi, Arduino, or any other microcontroller that has a TTL serial port.

smc txinThe Maestro boards using USB appear as two serial ports. One is the command port that communications with the Maestro processor. The other is a TTL port. This port can serve as simply a USB to TTL serial port converter to allow communications with other boards, even from another vendor. Another use of the TTL port is to daisy chain Pololu boards. I could attach the SMC boards in this manner and save two USB ports for other devices. These boards support this by having a TXIN pin that ANDs the TX signal from the connected board with the TX on the board.

Both of these controllers support a few different communications protocols. I use the one Pololu created and is available on some of their other products. The command details are different between the boards, but the basic command structure is the same. They call it their binary protocol, and the basic format follows:

0xAA, <device address>, <command>, <optional data>, <crc>

All the fields are single bytes except for the data field which is frequently 2 bytes to transmit 16-bit data. The returned data is only one or two bytes with no additional formatting. Note they provide for detecting errors in the message by using a CRC (cyclical redundancy check). This is probably not critical over USB but a TTL line might receive noise from motors, servos, and other devices. A CRC error sets a bit in the error register that can be read if the command is critical.

I wrote my own code, C++ of course, for the PC and converted it just now to the Raspberry Pi. The main change is the different serial port code needed by Linux and Windows. Pololu now provides Arduino source for the protocol making it easy to use these boards with that family of controller boards.

Wrap Up

The chassis, Pi, and these boards are now installed on the Wild Thumper chassis along with a pan and tilt controlled by servos. A safety LED is on when power is applied and flashes when the robot is actively controlling the system. A LiPo battery powers all but the Pi because I need to configure a battery eliminator circuit to provide five volts. I’m powering it temporarily using a USB battery pack.

A test program, cross compiled from my desktop, moves the robot forward, pivots left than right, and then reverses. The pan / tilt moves and the LED flashes. I originally used a web camera for vision processing but will switch to the Pi camera since it is better. The Neato lidar discussed in a previous article will soon find a place onboard, along with an accelerometer to detect possible rollovers.

I’m sure I could have done this using Pi daughter boards despite the challenges I mentioned earlier. There are trade-offs to both approaches that need to be considered when working on a project. But there is one final advantage to the external boards: they have a lot of twinkly LEDs.

Product photos from Pololu.

Filed under: Arduino Hacks, Raspberry Pi, robots hacks

from raspberry pi – Hackaday
via Hack a Day

Tuesday, 5 July 2016

A 150MHz 6502 Co-Processor

If you are familiar with ARM processors, you may know of their early history at the 1980s British home computer manufacturer Acorn. The first physical ARM system was a plug-in co-processor development board for Acorn’s BBC Micro, the machine that could be found in nearly every UK school of the day.

For an 8-bit home computer the BBC Micro had an unusually high specification. It came with parallel, serial and analog ports, built-in networking using Acorn’s proprietary Econet system, and the co-processor interface used by that ARM board, the Tube. There were several commercial co-processors for the Tube, including ones with a 6502,  a Z80 allowing CP/M to be run, and an 80186.

As with most of the 8-bit generation of home computers the BBC Micro continues to maintain a strong enthusiast following who have not stopped extending its capabilities in all directions. The Tube has been interfaced to the Raspberry Pi, for instance, on which an emulation of original co-processor hardware can be run.

bbc-tube-screenshotAnd thus we come to the subject of this article, [BigEd]’s 150MHz 6502 coprocessor for the BBC Micro. Which of course isn’t a 6502 at all, but a 6502 emulated in assembler on an ARM which is in a way the very distant descendant of the machine it’s hosted upon. There is something gloriously circular about the whole project, particularly as the Pi, like Acorn, the BBC Micro, and modern-day ARM, has its roots in Cambridge. How useful it is depends on your need to run 8-bit 1980s software in a tearing hurry, but they do report it runs Elite, which if you were there at the time we’re sure you will agree is the most important application to get running on a BBC Micro.

We’ve featured the Tube interface before when we talked about an FPGA co-processor with a PDP/11 mode that was definitely never sold by Acorn. And we’ve also featured an effort to reverse engineer the primordial ARM from that first BBC Micro-based co-processor board.

BBC Micro image: Stuart Brady, Public Domain, via Wikimedia Commons.

Filed under: classic hacks, computer hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day

Saturday, 2 July 2016

Raspberry Pi Zero Becomes Mighty Miniature Minecraft Machine

In a clever bit of  miniaturization, [JediJeremy] has nearly completed a gyro-mouse controller for a Raspberry Pi Zero! Ultimately this will be a wearable Linux-watch but along the way he had some fun with the interface.

Using the MPU6040 gyroscope/accelerometer card from a quadcopter, [JediJeremy] spent a week writing the driver to allow it to function as a mouse. Strapping an Adafruit 1.5″ PAL/NSTC LCD screen and its driver board to the Zero with rubber bands makes this one of the smallest functional computer and screen combos we’ve seen. Simply tilt the whole thing about to direct the cursor.

It presently lacks any keyboard input, and [JediJeremy] has only added a single button for clicking, but look at this thing! It’s so tiny! In his own words: “I think this is the first computer that I can accidentally spill into my coffee, rather than vice versa.”

There have been a few issues along the way. He was originally planning to detect taps on the screen using the accelerometer and use that as the clicking input, but it disrupts the cursor position. The screen’s driver board also likes to overheat, and it tends to kill the battery life since the screen doesn’t shut off completely — but it is still a functional proof of concept.

Stripping away the need for clumsy mouse is in perfect thematic keeping with this efficient powerhouse of a computer. The best part is the extremely low price point of all the components so building your own is a cost-effective project as well! If that’s not to your taste, why not a button that plays a random episode of The Simpsons?

[via /r/raspberry_pi]

Filed under: linux hacks, Raspberry Pi

from raspberry pi – Hackaday
via Hack a Day



Donate Towards More Raspberry PI's for Projects