Lab 1 – Basic Stamp II  Digital I/O

Assigned: February 14th 2002, Demonstration Date: February 28th 2002

(This file is also available here in PDF form)

 

 

Microcontrollers are elements that fall between electronic hardware and software. They are computers in that they are programmed using algorithmic languages, but they are hardware in that they are installed by being wired into the system with all of the other electronic components. In the first project, we take our first step into the hardware domain by interfacing our first few electronic components, LCDs and keypads, and initiating interaction with our microcontroller.

 

Objectives

1.      Gain familiarity with BS2 programming environment

2.      Implement digital inputs from a keypad

3.      Perform digital outputs to a seven-segment display

4.      Interface a LCD display


Please read the corresponding experiments thoroughly before you begin connecting the various pieces:

  1. Relevant StampWorks Experiments:
    1. LEDs – Experiments 3, 4
    2. Pushbuttons – Experiment 6
    3. Seven-Segment Displays – Experiments 8,9,10, 29
    4. LCD Display – Experiment 11

 

Implementation

 

Write a PBASIC program and implement the following in hardware using the Stampworks Board. You will be required to demonstrate only Part D. (Parts A, B and C are intended to help you break down the task into manageable portions –however, while doing so please keep in mind the final outcome desired and optimize your pinouts).

 

a)      Turn a LED on and off in response to a key input

 

Using appropriate resistors, interface the pushbutton switches S1-S3 and similarly LED 0 to the Stamp.

 

The initial state LED 0 is off and pressing a given switch alters the mode of operation of the LED. Pressing Switch S1 starts the flashing of LED0  (once every second) and pressing Switch S2 turns the flashing off. Pressing Switch S3 keeps the LED0 permanently on.

Note:

-         Review the discussions of the class with respect to (i) adding a resistance in series with the LED and (ii) ensuring the polarity of the LED before implementation.

-         The "button" command could prove useful.

b)      Interfacing a Seven Segment display

To part (a), we would like to add a feature that permits us to keeps track of the last button pressed. Using the pin diagram from the datasheet, connect the pins of one of the seven segment display directly to the digital I/O lines of the Basic Stamp and set it up to display the last key pressed on the pushbutton keypad.

Note:

-         These displays are common cathode displays with built-in current limiting resistors.

-         The display needs to be explicitly enabled.

c)      Interfacing the LCD Screen

Interface the Basic Stamp to LCD Screen so that you can keep track of the number of the last button (S1-S3) pressed display the button that has been pressed.

d)      Implement a digital stopwatch on the LCD

When Switch S1 is pressed, begin flashing the LED once per second and continuously display and update the time in seconds on the LCD display.  When Switch S2 is pressed, stop the clock and display the elapsed time. If Switch S1 is pressed again, continue counting up while waiting for Switch S2 to be pressed. Switch S3 is used to reset the display. LED0 and the Seven-segment-display of parts (a) and (b) continue to operate as originally outlined in their corresponding parts.

 

Reporting:

Provide a self-standing document which describes and explains the complete system (as outlined in Part D) and would enable someone else to replicate your work easily. 

·         Please follow the guidelines provided at http://www.eng.buffalo.edu/Courses/mae505/ReportFormat.htm.

·         For a sample report see http://www.eng.buffalo.edu/Courses/mae505/SampleReport.pdf

 

Specifically in your report:

·        Describe the implementation and operation of your system.  How accurate is the timer? How could you improve its accuracy?

·        Document your system with a circuit diagram, and a list of components.

·        Include a listing of your program with thorough comments.

 

Note:

There are many LCD stopwatch implementations described on the Web such as http://www.howstuffworks.com/microcontroller.htm (among others). You may choose to use these resources but make sure that you reference them appropriately in your report.