Sunday, August 23, 2015

Simple Imaging using the Papilio Duo FPGA Board

This is a work in progress - have a look later for any updates


Earlier this year I bought a Papilio Duo FPGA board from Gadget Factory. It has the combination of a FPGA and Arduino on the same pcb.

This board uses a Xilinx Spartan-6 closely connected to a 2Mbyte SRAM.  This combination allows the FPGA to be used for generating VGA video - currently with a resolution of 800 x 600 pixels at 60Hz.

The killer feature of the Papilio Duo is that it will support the ZPUino - a 100MHz soft core which can be programmed using the Arduino IDE. This allows fairly rapid development of Arduino sketches - with the advantage of a fully accessible RAM block which can be used for frame buffers or other data storage.

In addition, the ZPUino will run the Adafruit GFX Graphics library. This is a generic graphics library for a number of different display types.  When used with the ZPUino VGA it allows RGB 5:6:5 data for the 800 x 600 display. It has basic pixel plotting, line and circle drawing and fill commands - as well as various fonts and colours for on-screen text.

The ZPUino is fast enough to update the video buffer in about 1 second - this is fast enough for displaying captured video stills.

The combination of the above components creates a very basic but accessible Imaging Platform - which can be rapidly coded to perform. Whilst at first glance it might appear to be 25 year retro-step backwards in terms of computer graphics capailities, it offers an easy hackable platform, without all the constraints of a modern PC or operating system.

A  Blast From the Past

30 years ago, in 1985, as my university final year project, I built up some hardware to allow the images from a scanning electron microscope (SEM) to be captured on an early x86 PC.  Years later, a friend of mine who is a member of the Open Source Hardware Users Group,  OSHUG,  has acquired second hand, a scanning electron microscope dating from that era.

The SEM in question is a Cambridge Instruments Stereoscan 250 dating from 1985.  It is in good condition, but lacks any means to capture images digitally, so is an ideal candidate to upgrade  with a vision system - loosely based on my degree dissertation.

Of course, digital electronics has moved forwards inexorably since 1995, both in terms of speed of operation and RAM density - such that hardware costs in real terms is less than 100th of the price it was 30 years ago.

This makes it extremely viable to produce a complete imaging system using readily available open source hardware.

Some Design Aims and Objectives

Fundamentally this should be an open hardware project - reproducible by anyone using off the shelf hardware.

It will have an educational theme - allowing the user the experience of video systems, FPGAs and modern embedded mirocontrollers.

It will be extendable, and hopefully portable to other hardware - for example Raspberry Pi.

Some Specs

The SEM has an absolute scanning resolution of about 4096 x 4096 8 bit monochrome pixels. A full high-res image would therefore occupy 16MB of storage.

This resolution is not displayable on any monitor, so the compromise is to allow a smaller window view into the larger scanned field of view.

512x512 pixels is a convenient size for the available VGA system, so it would be possible to display a small window of just 1/64th of the whole field.  When displayed on a 800 x 600 VGA monitor - this would allow adequate space around the image for text buttons, controls and tool icons.

It would be possible to extend this window to either (720x576) for 4:3 broadcast TV, or 800x600 for full screen display.

No comments: