The iRX 2.1 as "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." It's a circuit card measuring 1.25" × 3" with an RS-232 serial port, a visible LED, an infrared LED, and a infrared detector. At the heart of the board is the PIC16F84, a wonderful little microcontroller made by MicroChip Technologies, Inc. The PIC16F84 features thirteen general I/O ports, instruction cycle times of 250 nSec. (2.5 MIPS!) and an efficient RISC-like instruction set. The iRX 2.1 uses five of the PIC's I/O ports, and makes the remaining eight ports available on a connector. The total cost of the iRX2 is under $20 US when built in modest quantities.
|
About this DocumentThis document is written for anyone who wants to develop an application using the iRX 2.1
1.1 AcknowledgmentsThe author would like to thank the following people. Fred Martin and members of Mitch Resnick's group introduced me to PIC chips and IR emitters / detectors. The original design of the iRX was based on a board designed and built by Fred. Pushpinder Singh and the MIT Robotics and Electronic Cooperative kept things moving. Push volunteered many of his hours to help our group program PICs. Push's design for a PIC-based "chord keyboard" helped shape the design of the iRX. Randy Sargent provided great piles of software tools (PIC simulator, Gerber to Postscript), code examples, and general inspiration. Encouragement and help from members of the Personal Information Architecture--especially from professor Mike Hawley, colleagues Maria Redin, Steve Gray, Manish Tuteja and John Underkoffler--have made this a fun project. Matt Debski converted the original iRX 2.1 documentation from Frame into HTML and convinced me that maintaining the HTML version is the way to go. And I haven't looked back...
|
Typical Applications for the iRX 2.1The iRX 2.1 can be used as a basis for a variety of interface tasks. Some scenarios in which the iRX 2.1 could be handy include:
|
Developing on the iRX 2.1: an overviewWhat you get out of the iRX2.1 depends mostly on what you put into it. It's unlikely that there will be any "pre-canned" configurations that exactly suit your needs--you will generally need to add custom hardware on the board and create a PIC program specifically for your application.
|
3.0: A Guided TourFigure 2 is an illustration showing the layout of the components of the iRX 2.1, Figure 3 is the schematic. The rest of this section discusses the major components in detail.
3.1 Layout of the iRX 2.1
3.2 iRX 2.1 Schematic
3.3 Component Descriptions
3.3.1 J1-DC Power JackThe iRX 2.1 requires a nominal 9V DC power supply. Jack J1 accepts a 2.1 mm plug, such as you might find on a "wall wart" transformer with center pin V+, outer sleeve ground.[Editor's Note: Although the iRX 2.1 is designed for a nominal 9V DC, it appears that it will work with any DC or AC source, 7.5V to 12V.] You may also find it useful to wire a 9V battery clip to a 2.1 mm plug and use a battery as your power source. 3.3.2 J2-RJ-11 / RS232 JackJ2 is an RJ-11 jack, which accepts a standard telephone-style "modular" plug. (The RJ-11 standard implies using four conductors in a jack wide enough to hold six.) Following is a picture of the RJ-11 jack, viewed from its opening.
3.3.3 J4-I/O HeaderThe iRX 2.1 board "hardwires" five of the PIC's 13 I/O pins: serial input, serial output, Red LED, IR LED, and IR input. The remaining eight I/O pins are brought out on J4 as follows:
The arrangement of J4 and the corresponding PU/PD holes makes it easy to connect push-button sensors and/or LED directly to the PIC. For example, to implement a push-button sensor on RB6, you would connect the switch between J4 pin 19 (PU/PD) and J4 pin 20 (RB6). You would connect a wire from PU/PD directly to the corresponding ground hole on the board (0.30" away). The PIC itself provides an internal pullup resistor, so when the switch is opened, RB6 will be pulled high. When the switch is closed, RB6 will be pulled to ground. To connect an LED to RB7, you'd connect the LED between J4-18 and J4-17. You'd also connect a 220W resistor between the PU/PD through-hole and the corresponding +5V through hole (0.40" away). With this arrangement, the LED would be off when RB7 was high, and on when RB7 is programmed low.
|
4.0 How to build an iRX 2.1Since you can't simply go to Radio Shack and purchase an iRX 2.1 (yet), this section details the steps to build complete iRX 2.1 boards. Be warned: an outside firm will charge about as much to make one printed circuit board as to make 100. When possible, pool your orders to make as many as possible at once.
4.1 Fabricate the Printed Circuit board
There are many companies that will fabricate PC boards directly from
machine-readable design files. There is a list of
fabrication houses, which is
only guaranteed to be accurate at the moment this was written.
Once you choose a PC fabrication house, you'll need to send them the
design files from which they'll make the circuit boards. Most of them
have a modem dial-up line and a BBS to which you can upload the files,
some of them have an FTP or WEB based connection. PC fab houses
universally accept DOS format files with "eight dot three" file names.
The design files are available online here.
You'll need to send these files to your PC fabrication house, using
whatever form of communication the fab house wants. You will
typically send them the single "ZIP" file that bundles these files
together.
You'll send the fab house the ZIP file and a purchase order. Some
weeks later, they'll send you completed (but unstuffed) boards. If
you are using an outside service to assemble the boards
(see below),
you can ask the fab house deliver the boards directly to the assembly shop.
Following is a list of all the components for the iRX 2.1. When
possible, we've shown Digi-Key's part numbers and prices (as of Sep.
1998).
Notes:
[Note 1] Prices shown are approximate, taken when possible from
Digi-Key Sep 1998 catalog and assuming 100 unit pricing. Prices
preceded with `*' aren't counted in the total.
[Note 4] The LT1061 infrared LED listed has a 40 degree viewing angle.
Almost any other infrared LED may be substituted, depending on the
application. Narrower viewing angles will give you a longer on-axis
projection distance, but will require more accurate aiming. Note
also that if your application doesn't require IR, you can substitute
another visible LED here (e.g. green)
[Note 5] Almost any visible LED will suffice for L2--the LT1078 shown
is inexpensive and bright.
[Note 6] Power can come from a 9V battery or an unregulated 9V DC
"wall wart."
If you stuff the boards yourself, there are a few points to keep in
mind:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5.0 Developing your iRX 2.1 applicationThe steps towards creating your PIC application are straightforward and have been outlined in Section 2.0 In this section, we jump into the details.
5.1 Not all I/O Ports are created EqualThe PIC16F84 has thirteen ports: RA0 - RA4 and RB0 - RB7. Of these, the iRX 2.1 "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.
The iRX 2.1 board leaves Port A entirely untouched. This was a conscious decision, making it possible to substitute other 18-pin PIC chips, such as the PIC16C71. The PIC16C71 isn't an EEPROM device, but it does have a four-channel A/D converter.
5.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 feel the urge to program in assembly:
First, resist the urge. Look at the C code listings, see if you can simply recast your code to avoid the need for assembly code. If you still must write in assembly code, write the bulk of the code in C and use #asm statements for the time or space critical sections. Refer to the C Compiler documentation for more information.
5.3 PIC C CompilersWe use PCM, a C compiler for the PIC by Custom Computer Services. PCM isn't perfect, but it has improved steadily over the last few years. At this point, PCM is fairly robust and generates surprisingly tight code (especially when you use the built-in functions). And 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.
5.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.
5.5 PIC SimulatorsA PIC simulator can simplify debugging in cases where real-time I/O isn't an issue. One popular simulator is MPSIM, available for free from Microchip.
5.6 Burning your program into the PICWe use the PICSTART PLUS programmer from Microchip (also available through Digi-Key). The programmer plugs into the serial port of a PC and is driven by the MPASM program (supplied with the programmer). 5.7 Configuring the PICBefore the PIC can run at all, you must program (at least once) the "configuration fuses" for the PIC. Make sure the fuses are set as follows when running MPASM:
5.8 Debugging Tips and Programming TechniquesFollowing is a random collection of tips, techniques, art and lore. Your mileage may vary. Press down while turning. Void where prohibited.
5.8.1 First principalsWhen you power on the card and things don't work, check the following in this order:
5.8.2 Debugging
5.8.3 Power Consumption
|
Appendix A: ResourcesHere are pointers and references that you might find useful when working with the iRX 2.1.
|