FPGAs For The Raspberry Pi

FPGA development has advanced dramatically in the last year, and this is entirely due to an open-source toolchain for Lattice’s iCE40 FPGA. Last spring, the bitstream for this FPGA was reverse engineered and a toolchain made available for anything that can run Linux, including a Raspberry Pi. [Dave] from Xess thought it was high time for a Raspberry Pi FPGA board. With the help of this open-source toolchain, he can program this FPGA board right on the Raspberry Pi.

The inspiration for [Dave]’s board came from the XuLA and StickIt! boards that give the Raspberry Pi an FPGA hat. These boards had a problem; the Xilinx bitstreams had to be compiled on a ‘real’ PC and brought over to the Raspberry Pi world. The new project – the CAT Board – brings an entire FPGA dev kit over to the Raspberry Pi.

The hardware for the CAT Board is a Lattice iCE-HX8K, 32 MBytes of SDRAM, a serial configuration flash, LEDs, buttons, DIP switches, grove connectors, and SATA connectors (although [Dave] is just using these for differential signals; he doesn’t know if he can get SATA hard drives to work with this board).

Despite some problems with his board house, [Dave] eventually got his FPGA working, or at least the bitstream configuration part, and he can blink a pair of LEDs with a Raspberry Pi and programmable logic. The Hello World for this project is done, and now the only limit is how many gates are on this FPGA.

Continue reading “FPGAs For The Raspberry Pi”

Code Craft: When #define Is Considered Harmful

An icon of Computer Science, [Edsger Dijkstra], published a letter in the Communications of the Association of Computer Machinery (ACM) which the editor gave the title “Go To Statement Considered Harmful“. A rousing debate ensued. A similar criticism of macros, i.e. #define, in C/C++ may not rise to that level but they have their own problems.

Macros are part of the preprocessor for the C/C++ languages which manipulates the source code before the actual translation to machine code. But there are risks when macros generate source code. [Bjarne Stroustrup] in creating C++ worked to reduce the need and usage of the preprocessor, especially the use of macros. In his book, The C++ Programming Language he writes,

Don’t use them if you don’t have to. Almost every macro demonstrates a flaw in the programming language, in the program, or in the programmer.

As C retrofitted capabilities of C++, it also reduced the need for macros, thus improving that language.

With the Arduino using the GNU GCC compilers for C and C++ I want to show new coders a couple of places where the preprocessor can cause trouble for the unwary. I’ll demonstrate how to use language features to achieve the same results more cleanly and safely. Of course, all of this applies equally when you use any of these languages on other systems.

We’re only going to be looking at macros in this article but if you want to read more the details about them or the preprocessor see the GNU GCC Manual section on the preprocessor.

Continue reading “Code Craft: When #define Is Considered Harmful”

Hackaday Links: October 11, 2015

[Kratz] just turned into a rock hound and has a bunch of rocks from Montana that need tumbling. This requires a rock tumbler, and why build a rock tumbler when you can just rip apart an old inkjet printer? It’s one of those builds that document themselves, with the only other necessary parts being a Pizza Hut thermos from the 80s and a bunch of grit.

Boot a Raspberry Pi from a USB stick. You can’t actually do that. On every Raspberry Pi, there needs to be a boot partition on the SD card. However, there’s no limitation on where the OS resides,  and [Jonathan] has all the steps to replicate this build spelled out.

Some guys in Norway built a 3D printer controller based on the BeagleBone. The Replicape is now in its second hardware revision, and they’re doing some interesting things this time around. The stepper drivers are the ‘quiet’ Trinamic chips, and there’s support for inductive sensors, more fans, and servo control.

Looking for one of those ‘router chipsets on a single board’? Here you go. It’s the NixCoreX1, and it’s pretty much a small WiFi router on a single board.

[Mowry] designed a synthesizer. This synth has four-voice polyphony, 12 waveforms, ADSR envelopes, a rudimentary sequencer, and fits inside an Altoids tin. The software is based on The Synth, but [Mowry] did come up with a pretty cool project here.

Open Source FPGA Pi Hat

Over on Hackaday.io, [Dave Vandenbout] has posted the CAT board, a Raspberry Pi daughterboard hat that features a Lattice FPGA, 32 MB of RAM, EEPROM, and a few Grove and PMOD connectors. The CAT takes advantage of the open source tool chain available for Lattice including the Python-based MyHDL (although, you could just use Verilog directly, if you prefer) and Icestorm. One interesting point: you can run the tool chain on the Raspberry Pi, resulting in a self-contained and largely portable FPGA development environment.

Continue reading “Open Source FPGA Pi Hat”

Latest Raspberry Pi Images Have Improved Scratch

Not everyone likes Scratch — the block-oriented programming language that MIT developed to help kids program. While dyed-in-the-wool programmers probably find it limiting, it can be an effective way to teach basic programming to newcomers and there are some people who enjoy the graphical style of programming.

The latest Raspbian release (the operating system image for Raspberry Pi) has a new and improved version of Scratch for those who want to use it on the Pi. According to the Raspberry Pi blog, the new version is up to ten times faster than previous versions and also includes an improved method for Scratch programs to access the board’s general purpose I/O and other I/O devices.

Continue reading “Latest Raspberry Pi Images Have Improved Scratch”

Raspberry Pi Sentry Turret Is The Enemy Of All Mankind

War, huh, what is it good for? Absolutely nothing, except as an excuse to build a Raspberry Pi powered sentry turret that will track and fire upon your enemies. That’s what [Matt Desmaris] decided to do, and he has released the full details of his build.

It lacks the polished elegance of most military hardware, but what do you expect of a quick and dirty hack? It’s not shiny or ominous, but it has that killer motion-tracking feature. [Matt] is using OpenCV to detect movement from a USB webcam, two servos to pan and tilt the camera and gun and a small relay to pull the trigger. Manual control over the Interwebs is also available.

We’ve seen lots of similar builds using weaponry such as rubber bands and Nerf guns, but this one is a great start if you are interested in seeing how you can tie together tools like OpenCV and servos to create a camera that actively tracks movement.

A Third Scale Mini PowerMac

We’re surrounded by tiny ARM boards running Linux, and one of the most popular things to do with these tiny yet powerful computers is case modding. We’ve seen Raspberry Pis in Game Boys, old Ataris, and even in books. [Aaron] decided it was time to fit a tiny computer inside an officially licensed bit of miniature Apple hardware and came up with the Mini PowerMac. It’s a 1/3rd scale model of an all-in-one Mac from 1996, and [Aaron] made its new hardware fit like a glove.

Instead of an old Mac modified with an LCD, or even a tiny 3D printed model like Adafruit’s Mini Mac Pi, [Aaron] is using an accessory for American Girl dolls released in 1996. This third-scale model of an all-in-one PowerPC Mac is surprisingly advanced for something that would go in a doll house. When used by American Girl dolls, it has a 3.25″ monochrome LCD that simulates the MacOS responding to mouse clicks and keypresses. If you want to see the stock tiny Mac in action, here’s a video.

The American Girl Mini Macintosh is hollow, and there’s a lot of space in this lump of plastic. [Aaron] tried to fit a Raspberry Pi in the case. A Pi wouldn’t fit. An ODROID-W did, and with a little bit of soldering, [Aaron] had a computer far more powerful than an actual PowerMac 5200. Added to this is a 3.5″ automotive rearview display, carefully mounted to the 1/3rd size screen bezel of the mini Mac.

The rest of the build is exactly what you would expect – a DC/DC step down converter, a USB hub, and a pair of dongles for WiFi and a wireless keyboard. The software for the ODROID-W is fully compatible with the Raspberry Pi, and a quick install of the Basilisk II Macintosh emulator and an installation of Mac OS 7.5.3 completed the build.