In this chapter, I will present a few useful "cookbook" applications for real-time control circuits designed to perform some specific low-level task and interface with a master controller for instructions and overmonitoring. For the moment, we will deal principally with the design and firmware of the peripherals themselves. In the next chapter, you will find more detailed detailed explanations of how to develop Linux code to access these peripherals from an embedded PC-compatible SBC or desktop PC.
The purpose of this chapter is to provide introductory-level information on how to interface with some common robotics-type sensors and actuators, and in particular to show how these can be tied into the type of system we have been discussing. Although the projects are standalone and don't directly develop on each other, you should read at least the description of the stepper motor controller in full, because that section describes how the SPI slave interface is implemented. This information isn't repeated in the descriptions of the other projects.
Note that in this book, we will discuss an overall system configuration where all devices are connected directly to the Linux SBC, as illustrated in Figure 3-1.
Figure 3-1: Simplified system layout.
This configuration is easy to develop and test, and is an excellent basis for many types of projects; in fact, this is how I prototyped all the E-2 hardware. [For more on the E-2 project see the author's E-2 Autonomous Submarine Project webpage.] For the sake of completeness, however, I should point out that in the actual E-2 system, all of the peripherals are connected to a single master controller (an Atmel ATmega128, in fact). This controller is connected to the SBC over an RS-232 link as illustrated in Figure 3-2.
Figure 3-2: Actual E-2 system layout.
The master controller is the real brains of the vehicle. In fact, in E-2 the Linux system can be considered just another peripheral of the master controller. The Linux board performs strictly high-level functions; it interfaces to two USB cameras and an 802.11b WLAN adapter, besides writing the vehicle log on a high-capacity storage medium and performing some computationally intensive tasks such as image analysis and digital spectrum analysis of audio coming in from the exterior microphones. This design is basically an engineering refinement of the system we'll be talking about in this book; discussing it in detail really wouldn't add much to the material you already have here. Pay no attention to that man behind the curtain!
For your convenience (and mine, too!), I have developed rough-and-ready PCB artwork for all the example circuits in this book. The PCB artwork is subject to revision, and as a result is not provided on the CD-ROM; you can download it freely from http://www.zws.com/. The schematics are, however, provided on the disk. In order to edit the PCB layouts or view the schematics from which they are generated, you will need to install the evaluation version of the Cadsoft Eagle PCB CAD package, which is included on the accompanying CD-ROM. Versions for both Windows and Linux are provided.
Please note that these layouts are designed with largely surface-mounted components. This reduces the manufacturing and assembly costs of the PCB (and it also makes routing easier in some circumstances). However, it does make hand-assembly slightly more challenging. The parts I have used can easily be hand-soldered with a little practice, but if you aren't sure of yourself, every part I've used is available in a through-hole version, with the exception of the Analog Devices accelerometer chips.
Ergonomics Tip: A scroll-wheel mouse is highly recommended if you're using Eagle. The wheel controls zoom level. Since the zoom in/out functions are centered on the current position of the mouse cursor, you can navigate all around a large schematic or PCB layout using only the scroll wheel and minimal mouse movements. It's rarely necessary to touch the scroll bars in the Eagle window; it's easier and much faster to zoom out, then zoom back in on the area of interest.