...[back] ...[home] |
Robert D. Poor |
If you're looking for documentation on the original
iRX 2.0 board, you can find it in
http://www.media.mit.edu.ezproxyberklee.flo.org/~r/projects/irx2_0/.
|
|
The need for "Digital Glue"At the MIT Media Lab, we constantly explore new metaphors for interconnecting the physical world and the digital realm. We monitor heart rates for affective computing, display the latest stock quotes for individuals, create new sensors for electronic tags, and build LEGO toys that respond to voice commands. Each of these activities binds some physical process or action to a corresponding digital expression.To simplify this process of binding "atoms" to "bits," the Personal Information Architecture group has created a simple interface device named the "iRX 2.1." The iRX is a circuit card measuring 1.25" × 3" with an RS-232 serial port, a visible LED, an infrared LED, and an infrared detector. At the heart of the board is the PIC16F84, a nifty little microcontroller made by Microchip Technologies, Inc. The PIC16F84 features thirteen general I/O ports, instruction cycle times of 400 nSec. and an efficient RISC-like instruction set. The iRX 2.1 uses five of the PIC's I/O ports; the remaining eight ports are available for user applications. The total cost of the iRX 2.1 is under $20 US when built in modest quantities.
| |
About this DocumentThis document is written primarily for anyone who wants to create an interface using the iRX 2.1. It is also useful for anyone who wants to understand the process of developing applications for microcontrollers in general, and for Microchip PIC processors in particular.Here's what you'll find in this document:
| |
AcknowledgementsThe author gratefully acknowledges help, support and inspiration from the following people. Fred Martin, Brian Silverman and members of Mitch Resnick's Epistemology and Learning Group introduced me to PIC chips and IR emitters and detectors. The design of the iRX 2.1 owes much to the Interface Cricket, one of the many members of the Cricket family designed by Fred and others.Pushpinder Singh and the MIT Robotics and Electronic Cooperative kept things moving through the formative stage of the iRX board. Push volunteered many of his hours to teach our group about PICs and his design for a PIC-based "chord keyboard" helped shape the physical design of the first iRX boards. Randy Sargent provided me with lots of software tools (PIC simulator, Gerber to Postscript converter), code examples, and general inspiration. Encouragement and help from past and present members of the Personal Information Architecture group--especially from professor Mike Hawley, colleagues Maria Redin, Steve Gray, Manish Tuteja and John Underkoffler--has made this a fun project. The first iRX boards were built in April of 1996. Since that time, hundreds of iRX boards have been built and put into various forms of service. Some iRX boards found their way to the top of Mount Everest, others have been stuffed inside plush toys, glued under ping-pong tables, suspended from florescent lights, and one was even concealed in an office chair as part of a "digital whoopee cushion." The author would like to thank everyone, both at the Media Lab and beyond, who has contributed to the success of the iRX project. |
1.0 |
OverviewWhat you get out of the iRX 2.1 depends on what you put into it. It's unlikely that there will be any "pre-canned" configurations that exactly suits your needs--you will generally need to add custom hardware on the board and create a PIC program specifically for your application. But that's the fun part of the process!To give you a taste of what's possible with a PIC and iRX board, here are some projects that people have created using the iRX 2.1 (or should have created):
|
Overview of the Development ProcessThis section briefly describes the steps you'll need to take to create your very own iRX application.Ready...The first step is to make sure you have all the materials at hand. You'll need both some hardware and some software:
Set...It's unlikely that there's any pre-canned firmware for the PIC and iRX 2.1 that will do exactly what you want. Usually, you'll need to write a program for the PIC (or perhaps modify an existing one). In many cases, you'll also be adding components or wires to the iRX 2.1 board.Don't be shy; the iRX was designed to be modified!
Go...Creating and downloading code for the PIC is a five step process, described in the picture and in the text below.
|
2.0 |
Guided Tour of the iRX 2.1This section describes the layout and schematic of the iRX 2.1. It will show you where each component is located, and describes what each component does.Figure 2 shows the layout of the components on the iRX 2.1 board, Figure 3 is the schematic for the board.
2.1 Layout of the iRX 2.1 |
2.2 Schematic of the iRX 2.1Figure 3: Schematic of the iRX 2.1 board 2.3 Component Description2.3.1 J1: DC Power JackThe DC power jack is a standard 20 mm barrel connector. You can plug a 9V "wall wart" power supply into it (center pin positive), or you can wire a plug onto a 9V battery cable and power the iRX 2.1 from a standard 9V battery. The regulator on the board is fairly forgiving, and the circuit will probably work if you provide anything between 7 volts and 15 volts DC.2.3.2 J2: Serial I/O JackThe serial I/O jack, J4, is a telephone-style RJ-11 "modular jack". Figure 4 shows how you can use a standard telephone cable and an RJ11 to DB9F adaptor to connect the iRX to the serial port on a computer.Figure 4: Serial I/O port and cable The "twist" in the telephone cable also makes it possible to hook two iRX boards together directly without creating a special "null modem" cable. In some cases, it's possible to steal enough power from the host computer's DTR and RTS modem control lines to power the PIC and run the iRX board without a battery or external power supply. To take advantage of this, you must use a 6-pin modular cable and connect the DTR and RTS lines as indicated by the gray lines in Figure 4. But there are several caveats. First, not all computers have enough drive in their serial ports to drive all PIC boards. Secondly, the controlling application on the host computer must hold DTR and RTS high. Your mileage may vary. 2.3.3 J4: PIC I/O PortsJ4 on the circuit board isn't really a connector, it's just a row of ten holes that provide access to power, ground, and the PIC's I/O ports. You can solder a "SIP socket" into these ten holes if you want a simple means to temporarily connect wires and components to your iRX board.The layout of J4 appears as follows (and is also printed on the circuit board). A description of the characteristics of each I/O is in Section 4.
Figure 5: J4: I/O Ports 2.3.4 J5, J6: Ground and PowerTo the left of the prototype area on the circuit board are two columns of holes. All of the holes in the left column are connected to +5 volts, all the holes in the right column are connected to ground.Figure 6: J5, J6: Power and Ground 2.3.5 D1, D2, D3: Power Collecting DiodesD1, D2, and D3 are three Schottky diodes (1N5817). D1 connects to J1 (the DC input jack), D2 and D3 connect to the serial port, and can be driven from modem control lines from your computer's serial port. The diodes serve two purposes. First, they protect the circiut: if you connect the DC supply backwards, nothing bad will happen. Second, these diodes serve as a "power or" circuit: you can supply a voltage through the DC jack OR through the serial connector; the iRX board will get the power wherever it can.2.3.6 U1: 78L05 voltage regulatorThe voltage regulator on the iRX board is a garden variety +5V linear regulator. Depending on the exact model, it will accept voltages as low as 6.5 volts and as high as 15 volts and produce a clean +5 volts for the devices on the iRX board.2.3.7 U2: MAX233 RS232 Level ConverterThe MAXIM MAX233 chip converts between "TTL levels" (0 to +5 volts) of the PIC and "RS232 levels" (+9 to -9 volts) of the serial line. The magic of the MAXIM chip is that it does this conversion with a single +5 V supply; oscillators and charge pumps internal to the chip generate the required + and - 9 volts.The price of this magic is in power consumption: the MAX233 consumes about 5mA whether or not serial data is being sent or received. If your application doesn't require serial I/O and you're concerned about power consumption, simply omit this chip when you're building the board. 2.3.8 U3: PIC16F84The PIC is the heart of the board. It's a programmable microcontroller with 1K words of program memory and 68 bytes of general purpose RAM. It has 13 general purpose I/O ports. On the iRX board, five of these ports are dedicated (Serial In, Serial Out, Infrared Receive, Infrared LED, RED LED). You can use the remaining eight ports for anything you wish.2.3.9 U4: Sharp IS1U20 IrDA receiverThe Sharp IS1U20 is an IrDA-compliant infrared receiver. When it detects IR, it outputs a low signal. You can write code for the PIC to decode IrDA signals (such as sent by laptops and PDAs) or many other IR communication protocols.2.3.10 L1: Infrared LEDThe infrared LED cited in the bill of materials has a wavelength of 940 nM and a 40 degree dispersion pattern. You can use an IR LED with a narrower pattern (e.g. 20 degrees) for applications that need a longer range.As an aside, note that the IrDA specifications calls for a wavelength of 850 to 900 nM. DigiKey doesn't carry any infrared LED emitters in that range, and the 940 nM LED we use seems to work passably well. 2.3.11 L2: RED LEDThe Red LED is any garden variety LED. It's typically used simply as a status indicator (e.g. flash upon startup), so it doesn't even need to be red.2.3.12 Y1: 10MHz Ceramic ResonatorA ceramic resonator is like a crystal oscillator, only it's slightly less accurate and considerably less expensive. This particular part has the built-in capacitors required to make it oscillate properly. Resonators with other frequencies are available, but 10MHz was chosen since it's the maximum specified frequency for the PIC16F84. |
3.0 |
Building an iRX 2.1This section details the process of building complete iRX 2.1 boards from scratch:
3.1 Fabricate the iRX PC BoardsSince you can't simply go to Radio Shack and purchase an iRX 2.1 (yet), you'll have to have the Printed Circuit (PC) Boards fabricated by a PC Board fabrication shop. Be warned: a shop will charge almost as much to make one printed circuit board as to make 100. When possible, pool your orders to make as many iRX boards as possible at once.
3.1.1 Choose a PC Board Fabrication shopThere are many companies that will fabricate PC boards directly from machine-readable design files. See Appendix A for a short list of places that have been recommended.
3.1.2 Send the PC Board design filesThe design files for the iRX 2.1 can be found in the design files directory. For PC Board fabrication, the most important file is irx2_1.zip, a single ZIP file that contains all the files a PC Board Fabrication shop will need to make the boards:
Contents of irx2_1pc.zipFor most fabrication shops, all you need to do is send them the ZIP file and a README.TXT file. The README.TXT tells the fabrication shop the particulars of your order - here's a sample README.TXT file that you can edit for your own needs. Normally, you'll send the files via e-mail or by uploading them on a modem line.In a week or two, you should receive your boards. In the meantime, you can purchase the components.
3.2 Purchasing the componentsAll of the components, with the exception of the infrared detector and the printed circuit board itself, are available from Digi-Key, a mail-order electronics part supplier. While Digi-Key is not always the cheapest, they have a large selection, take telephone credit card orders, and will get you your parts the next day via FedEx. If you have more time than money on your hands, you may be able to shop around and get a better price on some of the parts shown here.The following lists detail the parts require to build 100 iRX 2.1 boards. The first list specifies components that go on the circuit board. The second list shows ancillary components that are generally useful for complete iRX projects, but are not always required. When possible, I've shown Digi-Key's part numbers and prices (as of January 1999). A more detailed list of parts and alternatives are spelled out in this iRX 2.1 Bill of Materials Spreadsheet (Microsoft Excel format). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bill of Materials for iRX PC Board |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Auxiliary Components for the iRX |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3.3 Soldering the components onto the PC boardSoldering the components onto the iRX board isn't difficult. Assuming you've already had basic experience with soldering, here are some hints:The only components that don't care which way they're inserted are the resistors (R1, R2, R3), the ceramic capacitor (C3), and the ceramic resonator (Y1). For all others, use the silk screen printed on the board as a guide. Note that for each LED and electrolytic capacitor, the longer wire goes in the hole marked with a '+'. To keep components from falling out while you're soldering others (since you have to flip the board over to solder the leads) work from the "shortest" to the "tallest" components in the following order:
Be careful not to overheat the sensitive components during soldering, especially the voltage regulator (U1), the IR detector (U4), and the MAX233 (U2).
|
4.0 |
Developing an ApplicationThe steps towards creating your PIC application are straightforward and have been outlined in Section 2. In this section, we jump into the details.
4.1 Not all I/O Ports are created EqualThe PIC16F84 has thirteen ports: RA0 - RA4 and RB0 - RB7. Of these, the iRX 2.0 "reserves" RB1 - RB5 for serial and optical inputs and outputs. (Note: you can still use RB2 - RB4 if you're willing to give up optical inputs and outputs; see Section 3.3.5 for details.) Some ports have particular traits that may make them more or less suited for your particular application. The following table summarizes the differences; for the full scoop, consult the Microchip data sheets.Except as noted, all ports support TTL levels and are bi-directional under program control.
4.2 C versus Assembly codeWhenever possible, program in C instead of in assembly language. You'll find the development and maintenance of firmware programs to be much faster and easier. However, there are some times when you may still need to program in assembly:
The moral: think three times before you decide you need to write in assembly code!
4.3 PIC C CompilersWe use PCM, a C compiler by Custom Computer Services. For $99 for a single license or $50/user for a site license, it's a good deal. Contact and purchasing info can be found in Appendix A.
4.4 PIC AssemblersWe use MPASM, the free PIC assembler from Microchip. It's a DOS-only application, but has proven to be robust and reliable. Randy Sargent also has a free Unix-based PIC assembler named picasm. See Appendix A for where to find them.
4.5 PIC SimulatorsA PIC simulator lets you step through your program, set breakpoints, examine registers; all those things you can't do with a real chip. I've used the simulator built into MPLAB with good results.Randy Sargent has written picsim, a PIC simulator that runs under Unix. Consult Appendix A for where to find them.
4.6 Burning your program into the PICThough there are many PIC programmers available, we've settled on the PICSTART Plus programmer from Microchip. You can purchase it via Digi-Key (Universities should ask for the educational discount), and Microchip is good about providing upgrades for the programmer as they introduce new chips.The easiest way to download your program into the PIC is through the PICSTART Plus menus found in MPLAB.
|
5.0 |
Debugging Tips & TechniquesFollowing is a random collection of tips, techniques, art and lore. Your mileage may vary. Press down while turning. Void where prohibited.
5.1 First principlesWhen you write your program, you should always make the Red LED flash briefly upon startup, just to indicate that the chip is alive and running. So assume you've written your program, compiled and loaded the code, and powered up your iRX. And the LED doesn't flash. Now what?
5.2 Debugging
5.3 Programming Tips
|
App A |
Related LinksPC Design FilesThings remaining to be done:
|