Date post: | 26-Jun-2015 |
Category: |
Technology |
Upload: | vijay-elavunkal |
View: | 2,804 times |
Download: | 2 times |
IMPLEMENTING A
DIGITAL STOPWATCH USING BASIC STAMP II
MAE 576 [MECHATRONICS] LAB-1GROUP E
Chembrammel Elavunkal Srinivasan Vishwajeet
University at Buffalo, Mechatronics, Spring 2010
2
INTRODUCTION
Implement a digital stopwatch on Liquid Crystal Display (LCD)
The components used and their functioning are The circuit used for the implementation is
drawn The code controlling the hardware is included
to complement the understanding of the functioning of the stopwatch
The accuracy of the stopwatch is discussed Solution to improve the accuracy is proposed.
University at Buffalo, Mechatronics, Spring 2010
3
OBJECTIVES
University at Buffalo, Mechatronics, Spring 2010
Gain familiarity with BS2 programming environment.
Implement digital inputs from a keypad Perform digital outputs to a seven-segment
display Interface a LCD display as a digital stopwatch.
4
HARDWARE OVERVIEW
University at Buffalo, Mechatronics, Spring 2010
Basic Stamp 2 (Rev. J) Module Professional Development Board 2 x 16 Parallel LCD
5
HARDWARE OVERVIEW
University at Buffalo, Mechatronics, Spring 2010
Professional Development Board (PDB) A Power switch L
L293D high-current quad half-H driver
B2.1 mm power connection,
centre positive, input voltage 6-12 VDC
MEight active-low push-
buttons with 5V pull-ups
CSerial programming
interface, DB-9N
Eight active-low DIP switches with 5V pull-ups
DBS1-IC, BS2-224, BS2-40
and Javelin Stamp socketsO
Pulse generator with 1Hz, 10Hz, 100Hz and 1 kHz
selectable output
EBS1 Serial Adapter
connectionP
RJ-11 connector for X-10 or 1-Wire I/O
F Sixteen blue discrete LEDs QMAX232E RS-232 DCE line
driver
GFive blue 7-segment LED
displaysR
DS1307 I2C real-time clock with 3V battery backup
HParallel LCD interface with contrast pot (4/8-bit modes
supported)S SX28AC/DP socket
I
Two servo headers (can also be used for Parallax Serial LCD displays and PING)))
sensor)
TSX-Key/SX-Blitz
programming connection
J Two 10K potentiometers USolderless breadboard for
connecting external components
KAudio amplifier with volume
control (speaker on-board/ext selectable)
6
HARDWARE OVERVIEW
University at Buffalo, Mechatronics, Spring 2010
Basic Stamp 2 (Rev. J) Module
7
HARDWARE OVERVIEW
University at Buffalo, Mechatronics, Spring 2010
EEPROM
Regulator
InterpreterPIC16F57
Name BS2-IC
Package 24-pin DIP
Package Size (L x W x H) 1.2"x0.6"x0.4"
Environment-40 to +185 oF (-40 to
+85 oC) **
Processor Speed 20 MHz
Program Execution Speed ~4,000 instructions/sec.
RAM Size 32 Bytes (6 I/O, 26 Variable)
Scratch Pad RAM N/A
EEPROM (Program) Size 2K Bytes, ~500 instructions
Number of I/O pins 16 +2 Dedicated Serial
Voltage Requirements 5 - 15 vdc
Current Draw @ 5V 3 mA Run / 50 µA Sleep
Source / Sink Current per I/O 20 mA / 25 mA
Source / Sink Current per unit 40 mA / 50 mA per 8 I/O pins
PBASIC Commands 42
PC Programming Interface Serial Port (9600 baud)
Windows Text Editor Stampw.exe (v1.04 and up)
[i] http://www.parallax.com/tabid/134/List/1/ProductID/1/Default.aspx
Basic Stamp 2 (Rev. J) Module
8
HARDWARE USED
University at Buffalo, Mechatronics, Spring 2010
Component Name
On PDBY/N
Part # Page #
BS2 – IC Y Basic Stamp2 Module 9
PDB -Professional
Development Board3
Switches* Y [M] 6
LED Y [F] 6
7-segment Display
Y [G] 5
Piezo Beeper Y [K] 8
LCD Display N 2 x 16 Parallel LCD 11
9
HYPOTHESIS
University at Buffalo, Mechatronics, Spring 2010
When Switch S1(part M) is pressed, begin flashing the LED (part F) once per second and continuously display and update the time in seconds on the LCD (not a part of PDB) 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. The seven segment display (part G) should flash the number of switch being pressed.
10
PROPOSED SOLUTION
University at Buffalo, Mechatronics, Spring 2010
Integrate part A-D of experiments to obtain functionality of stopwatch
Develop a flow chart to get better understanding of process
Create circuit layout to integrate all necessary hardware
Program code to ensure full operation spectrum
Implement finished digital system
11
CONSTRAINTS [Self Imposed]
University at Buffalo, Mechatronics, Spring 2010
Ensure clean hardware implementation Reduce use of hardware resources Streamline coding to achieve optimal
functionality Test and achieve maximum timer
accuracy Welcome Message Status gesture to indicate operation
Additional Goals
12
PROCEDURE
University at Buffalo, Mechatronics, Spring 2010
Experiment- Part # Component NameDigital Stopwatch Implementation
Part A(Turn LED ON/OFF)
Switch & LEDS1 – LED7 FLASHES
S2 – LED7 OFFS3 – LED7 ON
Part B (Interfacing 7-
segment Display)7-segment Display
S1 – display “1”S2 – display “2”S3 – display “3”
Part C(Interfacing LCD
Screen)LCD Screen
Display Welcome message
Display Time
Part D(Piezo Beeper)
Piezo BeeperS1 – tone1 (repeat)
S2 – tone2S3 – tone3
Experiments A - D
13
PROCEDURE [Flow Chart]
University at Buffalo, Mechatronics, Spring 2010
Flow Chart
14
PROCEDURE [Circuit]
University at Buffalo, Mechatronics, Spring 2010
Circuit
15
PROCEDURE [Pin Layout]
University at Buffalo, Mechatronics, Spring 2010
Pin Layout
PIN # Component Device
P0 D4 LCD Data Input
P1 D5 LCD Data Input
P2 D6 LCD Data Input
P3 D7 LCD Data Input
P4 E LCD Pulse Input
P5 RS LCD Command/Write
P6 Speaker Piezo Beeper
P7 Seg -A Segment A of 7 Segment
P8 Seg - C Segment C of 7 Segment
P9 Seg - D Segment D of 7 Segment
P10 Seg - E Segment E of 7 Segment
P11 Seg - G Segment G of 7 Segment
P12 LED LED O/P
P13 Button0 S1 (Button)
P14 Button1 S2 (Button)
P15 Button2 S3 (Button)
16
PROCEDURE [Source Code]
University at Buffalo, Mechatronics, Spring 2010
Source Code (Attached to Webpage)
Please note the source code to run the digital stopwatch is attached to this website for your convenience
USED:38% of the
EEPROM5 registers
17
PROCEDURE [Special Connections]
University at Buffalo, Mechatronics, Spring 2010
Component Name Pin # Connection*
LCD R/W VSS GND (Voltage LOW)
7 – Segment Display FOpen
(Since digits 1,2,3 do not use F)
7 – Segment Display BVDD
(Since B segment is always ON)
7 – Segment Display Digit0VSS GND (Voltage LOW)
(To enable display)
*These connections should always be ensured for proper operation of the system
IMPLEMENTATION
University at Buffalo, Mechatronics, Spring 2010
18
7-segment Display
LED7
Power Switch/Ligh
t
Piezo Beeper
LCD
S1S2S3
19
CALIBRATION
University at Buffalo, Mechatronics, Spring 2010
Coarse Delay
(milliseconds)
Fine Delay
(milliseconds)
Total Delay
(milliseconds)
Reference Clock
(hh:mm:ss)
BS2 Stopwatch(hh:mm:ss
)
Error%
850 0 850 00:03:00 00:02:59 -0.5%
840 5 845 00:12:39 00:12:38 -0.01%
840 4 844 00:22:52 00:22:52 0%
840 3 843 00:12:02 00:12:03 0.01%
Coarse delay and Fine delay tuning mechanism to be able to manually adjust the timing operation
20
TESTING
University at Buffalo, Mechatronics, Spring 2010
Test Case No.
Time elapsed on Digital Stopwatch(hh:mm:ss)
Time elapsed on reliable time source
(hh:mm:ss)
Difference in time( s)
1. 00:01:00 00:01:00 0±0.5
2. 00:02:00 00:02:00 0±0.5
3. 00:03:00 00:03:00 0±0.5
4. 00:04:00 00:04:00 0±0.5
5. 00:05:00 00:05:00 0±0.5
6. 00:10:00 00:10:00 0±0.5
7. 00:15:00 00:15:00 0±0.5
8. 00:20:00 00:20:00 0±0.5
9. 00:25:00 00:25:00 0±0.5
10. 00:30:00 00:30:00 0±0.5
11. 00:45:00 00:45:00 0±0.5
12. 01:00:00 01:00:00 0±0.5
Test Case No.
Time elapsed on Digital Stopwatch(hh:mm:ss)
Time elapsed on reliable time source
(hh:mm:ss)
Difference in time( hh:mm:ss)
1. 00:10:00 00:10:00 0±0.52. 00:30:00 00:30:00 0±0.53. 01:00:00 01:00:00 0±0.54. 02:00:00 02:00:00 0±0.55. 03:00:00 02:59:59 1.0±0.5
1 second every 3 hours
21
ERRORS
University at Buffalo, Mechatronics, Spring 2010
0 5 10 15 20 250
5
10
15
20
25 Error Plot
Reference Time (s)
Sto
pw
atc
h T
ime
(s)
22
ERROR ESTIMATION
University at Buffalo, Mechatronics, Spring 2010
0 10 20 30 40 50 60 70 800
5
10
15
20
25
30
f(x) = 0.333333333333333 x
Error Estimation - II
Time (hr)
Err
or
(s)In simple terms there is an
error of 0.333s introduced every 60 minutes operation of the stopwatch timing
23
CONCLUSION
University at Buffalo, Mechatronics, Spring 2010
Able to implement the digital stopwatch using BS2 microcontroller
Familiarized aspects of integrating multiple electronic components and program them
Implemented the digital stopwatch with accuracy using minimum number of electronic components
Laid emphasis compact design 38% of the total EEPROM due to good programming
practice Calibration process yielded combined “Coarse & Fine”
delay of 844ms Accuracy and precision of ±0.5 seconds
24
REFERENCES
University at Buffalo, Mechatronics, Spring 2010
http://www.parallax.com/Store/Education/KitsandBoards/tabid/182/CategoryID/67/List/0/SortField/0/Level/a/ProductID/320/Default.aspx
http://www.parallax.com/tabid/441/Default.aspx BASIC Stamp Syntax and Reference Manual http://www.parallax.com/tabid/214/Default.aspx http://www.parallax.com/tabid/134/List/1/ProductI
D/1/Default.aspx http://www.parallax.com/Portals/0/Downloads/doc
s/prod/audiovis/lcd2x16par.pdf