Table of Contents Introductory Material 0.1 Equipment Intoduction 1 breadboard area stimulator board 2 The Board of Education The TDS 340 oscilloscope 0.2 Getting Started with the Micro-controller The Basic Stamp Signals The Basic Stamp Memory Organization Laboratory Scripts Lab 1: Lab 2: Lab 3: Lab 4: Lab 5: Lab 6: Lab 7: Logic Gates, Flip Flops and Registers Counters The Basic Stamp 2 micro-controller: Basic digital I/O Digital-to-Analog and Analog-to-Digital Conversion Counting and Timing Servo motors and Stepper Motors GPIB and LabView programming
Notes The schematics in the lab manual usually indicate the 7400 series logic chips without the letters indicating the family. Two common families in current use are the 74LSxx, low power TTL, and the 74HCxx CMOS variant. In the text it is indicated that we generally use the 74LS family. Several pages have been left blank so that sections and lab scripts will begin on the right-hand pages. Acknowledgments Fig 0.3, Pin Table and the RAM table are provided by Parallax inc.
Physics 430 Laboratory Manual 0.1 Equipment Intoduction This lab involves digital electronics and interfacing to a version of the PIC 16C57 micro-controller called the Basic Stamp II. All work is done on an experimental box and the micro-controller prototyping system called the "Board of Education". Fig 0.1 illustrate the basic components. 1. a breadboarding area 2. a breadboard stimulator 3. the Board of Education which contains the micro-controller a signal header to attach a jumper cable a small breadboard with signal connections on two sides (The ISA bus edge connector has been left on but is no longer used.) Buffered ISA bus edge connector (obsolete) 9V Board of Education RS232 Stamp II Breadboard Area Stimulator Connector for 16-pin jumper cable. Fuse On/Off Fig. 0.1 The Experimental Box (not to scale) The +5V and ±12V appearing on the bus edge connector come from the box power supply. The power for the board of education can be obtained from either a 9V power supply adapter or a 9V battery. The Board of
Education can be removed from the Experimental Box and is able to function independently of it. +12 V +5 V gnd 12 V Insert jumpers to create a continuous bus from one side to the other. Use the horizontal bus pins for the voltages shown here. ic ic ne These 5 are connected These 5 are connected but not to the ones above. These 25 holes are connected together, but not to the ones on the right-hand side. These 25 holes are connected together but not to the ones on the left-hand side. Fig. 0.2 The Breadboard Area The breadboard area is meant to accept IC leads, small diameter resistor and capacitor leads, and #22 solid, not stranded, wire. Do not force larger diameter wires into it. It is not meant to accept the thinner wire-wrap wire good contact may not be obtained. Note that the bare breadboard is divided into four identical areas. The four horizontal bus lines in each area, which are meant to distribute ground and power, are all divided at the center. If you wish them to be continuous, you must install small jumpers. Mount the ICs consistently. A convenient convention is to mount the ICs so that pin 1 is on the left when viewed from the top. The small circular sockets on the stimulator board are also designed to accept #22 solid wire. This makes interconnection between the breadboard and stimulator board simple. The stimulator board (Fig. 0.3) contains LEDs, pushbuttons, switches, a 10 kω potentiometer, power supply outputs, and several clock frequency outputs. There is a sixteen-pin connector to jumper some of these outputs the prototype board. The LEDs on the stimulator have current-limiting circuits so they may be connected directly to 5V without problems. Similarly the pushbuttons of the stimulator board have debouncing circuitry to avoid noisy signal edges. The first two labs on digital electronic fundamentals will use the breadboarding area and the stimulator board. The small bread board area on the Board of Education will be used starting in lab 3.
Fig. 0.3. The Stimulator Board The LEDs have current limiting resistors and the push-button switches are debounced. Clock signals on the stimulator board are somewhat noisy, use a function generator for "clean" clock signals. Do not leave loose wires or components lying around on top of the stimulator board because they might accidentally touch the exposed contacts. The TDS340 oscilloscope has many options which can make it difficult to operate at first. If you have trouble read the manual. Fig. 0.5 shows some settings for simple operation. If nothing seems to be happening, press the AUTOSET button. Most oscilloscope measurements should be made using a x10 probe to avoid affecting the circuit while it is being measured. An image of the oscilloscope screen can be transferred to your computer via the GPIB interface by a command-line program "SAVE" which is available. In order to use this
program the oscilloscope must be configured to use the GPIB interface. It is recommended to send bmp format files. General Purpose knob Cursor control Miscellaneous controls Acquisition controls TDS 34 Menu controls Menu controls Vertical controls Horizontal controls Trigger controls Fig. 0.4 The Tektronix TDS340 Oscilloscope Control Panel
0.2 Getting Started with The Micro-controller The Basic Stamp Pins 1.25 (32 m m ) 9 Vdc Rocklin, CA - USA Battery 6-9 C3 C4 1 Sout Sin ATN Vss P0 P1 P2 P3 P4 P5 P6 P7 VDC STAMPS in CLASS Need Tech Support? email: stamptech@parallaxinc.com TM Vss P0 P2 P4 P6 P8 P10 Vin P12 Vss P14 Rst Vdd Vdd X1 P15 P14 P13 P12 Pwr P11 P10 P9 P8 Reset Vss P1 P3 P5 P7 P9 P11 P13 P15 Vin X3 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 X2 3.7 (94 mm) 4.0 (101.5 mm) 15 14 13 12 X4 Vdd Red Black X5 Rev B Vin Vss (c) 1998 Board of Education www.stampsinclass.com (916) 624-8333 2. 75 (70 m m ) 3. 0 (77. 5 m m ) Fig 0.5 The Board of Education with the Basic Stamp module correctly inserted. The power supply and serial cable are not shown. The following signals are on the Basic Stamp chip. Most of them are available on the holes beside the small breadboard in the Board of Education and on its header which can be used for attaching a ribbon cable to another board.
Pin Name Description 1 SOUT Serial Out: connects to PC serial port RX pin (DB9 pin 2 / DB25 pin 3) for programming. 2 SIN Serial In: connects to PC serial port TX pin (DB9 pin 3 / DB25 pin 2) for programming. 3 ATN Attention: connects to PC serial port DTR pin (DB9 pin 4 / DB25 pin 20) for programming. 4 VSS System ground: (same as pin 23) connects to PC serial port GND pin (DB9 pin 5 / DB25 pin 7) for programming. 5-20 P0-P15 General-purpose I/O pins: each can sink 25 ma and source 20 ma. However, the total of all pins should not exceed 50 ma (sink) and 40 ma (source) if using the internal 5-volt regulator. The total per 8-pin groups (P0 P7 or P8 15) should not exceed 50 ma (sink) and 40 ma (source) if using an external 5-volt regulator. 21 VDD 5-volt DC input/output: if an unregulated voltage is applied to the VIN pin, then this pin will output 5 volts. If no voltage is applied to the VIN pin, then a regulated voltage between 4.5V and 5.5V should be applied to this pin. 22 RES Reset input/output: goes low when power supply is less than approximately 4.2 volts, causing the BASIC Stamp to reset. Can be driven low to force a reset. This pin is internally pulled high and may be left disconnected if not needed. Do not drive high. 23 VSS System ground: (same as pin 4) connects to power supply s ground (GND) terminal. 24 VIN Unregulated power in: accepts 5.5-15 VDC (6-40 VDC on BS2- IC rev. e), which is then internally regulated to 5 volts. May be left unconnected if 5 volts is applied to the VDD (+5V) pin. Basic Stamp 2 Memory organization (adapted from Parallax documentation) The BASIC Stamp has two kinds of memory; RAM (for variables used by your program) and EEPROM (for storing the program itself). EEPROM may also be used to store long-term data in much the same way that desktop computers use a hard drive to hold both programs and files. An important distinction between RAM and EEPROM is this: RAM loses its contents when the BASIC Stamp loses power; when power returns, all RAM locations are cleared to 0s. There are only 32 bytes of RAM. Three of these bytes have predetermined functions, the other 29 can be used in programs. The preassigned names can be changed by declaring other variable names in the PBasic program which are more convenient
Word Name Byte Names Nibble Names Bit Names Special Notes INS INL INA, INB IN0 IN7 Input pins INH INC, IND IN8 IN15 OUTS OUTL OUTA, OUTB OUT0 OUT7 Output pins OUTH OUTC, OUTD OUT8 OUT15 DIRS DIRL DIRA, DIRB DIR0 DIR7 I/O pin direction control DIRH DIRC, DIRD DIR8 DIR15 W0 B0 B1 W1 B2 B3 W2 B4 B5 W3 B6 B7 W4 B8 B9 W5 B10 B11 W6 B12 B13 W7 B14 B15 W8 B16 B17 W9 B18 B19 W10 B20 B21 W11 B22 B23 W12 B24 B25 Note: All registers are word, byte, nibble and bit addressable EEPROM retains the contents of memory, with or without power, until it is overwritten (such as during the program-downloadingprocess or with a WRITE instruction.) There are 2048 bytes of EEPROM in the Basic stamp 2. These locations are used to store the tokenized version of the program and for longterm data storage. The program tokens are stored starting at location 2047 and contining in successive lower locations (2046, 2045,...). Data written by the program starts at location 0 and continues at succesive higher locations (1, 2,...). Thus the longer the program, the less storage space you have for data. It is possible to clobber your program by writing too much data into the EEPROM so you must be careful. A memory map function is available in the Windows development system to help you avoid this catastrophe.
EEROM Memory Map 2047 Start of Program Program Tokens End of Program Last Data Data 0 First Data For an introduction to using the Basic Stamp 2 please read the document What is a Microcontroller supplied by the Parallax company (files WAM2_1.pdf). More complete information can be had in the Basic Stamp Programming Manual (file basicstampman.pdf).
Appendix A - Lab Integrated Circuits Inventory number I.C. Function 2 74LS00 Quad 2-in NAND 2 74LSO2 Quad 2-in NOR 2 74LS04 hex inverter 1 7407 hex open collector buffer 1 74LS10 triple 3-in NAND 1 74LS20 dual 4-in NAND 1 74LS30 8-in NAND 2 74LS73 dual JK flip flop 2 74LS74 dual D flip flop 1 74LS86 quad excl. OR 2 74LS90 decade counters 1 74LS123 dual monostables 2 74LS138 1 of 8 decoders 1 74LS153 dual 4 to 1 multiplexer 2 74LS161 4 bit binary counter 1 74LS174 hex D flip flop 1 SAA1027 stepper motor controller 1 MC1408 D/A converter 1 ADC0831 A/D Converter 1 LM358 Operational Amplifier 1 DS1307 Real-time Clock 1 24C32 32 k-bit EEPROM (4 k-byte) 1 LM35 Celcius Temperature Sensor (voltage output 10 mv/ C)
Other components 1 CdS Photocell (photoresistor) 2 SPST pushbutton switches 1 DPDT Pushbutton switch 1 Hexadecimal encoded rotary switch 1 4 bit DIP switch
Pin Outs and Descriptions TOP VIEW.