DIGITAL II - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

DIGITAL II

Description:

You Asked for It... Design Using the Z-World. Next Week In DIGII. Timers and counters ... This is a wacky multiple choice fill in the blanks prove the following ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 9
Provided by: poli3
Category:
Tags: digital | wacky

less

Transcript and Presenter's Notes

Title: DIGITAL II


1
DIGITAL II Microprocessors Embedded Systems
ECE 0909.242.01
Week 9
You Asked for It Design Using the Z-World
Robi Polikar, Ph.D. John L. Schmalzel, P.E., Ph.D.
2
Next Week In DIGII
Chapter 4 Standard Single Purpose Processors
Peripherals
  • Timers and counters
  • Watchdog timers
  • UART (Universal asynchronous receiver /
    transmitter)
  • Pulse width modulators
  • LCD controllers
  • Keypad controllers
  • Stepper motor controllers
  • Analog to digital converters
  • Real time clocks

3
Dig-Off
  • This is a wacky multiple choice fill in the
    blanks prove the following theorem gimme the
    correct answer or else type trivia game show,
    that is mostly on class material. You will be
    divided into groups, and each will have a buzzer.
    As soon as you think you know the answer, buzz
    in. Get it right, get base number of points for
    that question. Get it wrong, you lose that many
    points. The question, now twice the value, is up
    for grabs, until it is correctly answered or
    skipped. Note that some questions may have more
    than one correct answer, in which case, you need
    to identify ALL of them.
  • During each round, each group will have a screw.
    If you think the others do not know the answer to
    a question, buzz in first, and screw the group
    of your choice. If that group misses the
    question, they lose points. If they get it right,
    however, they get the points, and YOU lose the
    points, umthen you are screwed...
  • There are also special impossible questions
    worth 10 points. These are eligible for screw
    (except one), and hence make perfect opportunity
    to screw other groups.
  • After each round, the group with the lowest
    score, will ask for one team member from another
    group to be joined into their group. The other
    group then asks a member of the first group to
    join them. The team member lost to another group
    cannot be transferred back until the next round.
  • 5 (or a suitable portion) of the final score of
    the winning group will be added to their final
    grade.

4
This Week in DigII
  • Actual design example using Z-world
  • Buzzer design for Dr. Polikars semester-end
    Dig-Off! review Game Show
  • Specs
  • There will be four buzzers
  • The system will continuously listen for any
    buzzer pressing activity
  • As soon as one of the buzzers is pressed,
  • the actual buzzer on for 1 second when the button
    is pressed
  • all other buzzers are disabled,
  • an LED corresponding to that buzzer turns on
  • the LCD displays group name / number
  • The active LED and LCD retain current information
    for 10 s. then reset
  • When any of the buttons are pressed, reset entire
    system.

5
Buzz-In !
// BUZZ-IN.c // Application polls four switches
to determine which one is pressed first. // When
a "winner" is detected, a light corresponding to
the successful switch // is activated the other
switches are disabled, and the buzzer is sounded
for 1s. // SW2 controls led D2. // SW3 controls
led D3. // SW4 controls led D4. // SW5 controls
led D5. use lcd2l.lib use vdriver.lib main()
int state,found,bcount,lcount foundbcountlcoun
t0 outport(CS1,0) // Clear LEDs (D2-
D5) outport(CS11,0) // Note CS1 is
predefined to be address 0x4000 outport(CS12,0)
// Each LED is then addressed at 0x4000, 4001,
etc. outport(CS13,0) outport(CS14,0) //
At 0x4004 is the buzzer. Turn off the
buzzer. VdInit() // initialize the virtual
driver lc_init() // initialize the
LCD lc_pos(0,0) // Move LCD cursor to the
0,0 location (1st row, 1st column) lc_printf("
System Ready") // Display " System Ready"
on the LCD display lc_pos(1,0) // Move LCD
cursor to the 1,0 location (2nd row, 1st
column) lc_printf("Polikar's Buzz-In 1.0")
6
Buzz-In !
for() // endless loop hitwd()
runwatch() // This code uses the watchdog timer
facility, resetting timer at each
pass. costate // Start costate everything
within the costate loop is executed "at the
// same time" (sort of) waitfor(DelayMs(1L)
) // Wait for 1 milisecond. So, all of the
following will be // repeated every
1ms. state inport(CS21) // Get the
pushbutton values SW2-SW5 by querying //
address 0x4041 (i.e., CS21) // All switches
are located at the address 0x4040. // One
additional 8 bit address bit used as a mask,
// controls individual switches. 0-3 actual
switches, // 4-7 for external switches,
controlled by the jumper. if ((!found)( state
0x10 )) // External switch ESW2 pressed...we
find this out by // masking all bits except
bit b4, which corresponds to // ESW2
lc_init() // initialize the LCD
lc_pos(0,0) // Move LCD cursor to the (0,0)
(1st row, 1st column) lc_printf(" Player
One") outport( CS1 , 1 ) // Turn on
D2 (first LED) found1 // Set flag to
1. if ((!found)( state 0x20 )) //
ESW3 pressed (second switch)... outport( CS11
, 1 ) // Turn on D3 (second LED) lc_init()
lc_pos(0,0) lc_printf(" Player
Two") found1
7
if ((!found)( state 0x40 )) // ESW4
pressed... outport( CS12 , 1 ) // Turn on
D4 lc_init() lc_pos(0,0) lc_printf("
Player Three") found1 if
((!found)( state 0x80 )) // ESW5
pressed... outport( CS13 , 1 ) // Turn on
D5 lc_init() lc_pos(0,0) lc_printf("
Player Four") found1 // This is
where we control the buzzer time out and round
time out. If none of // the reset buttons
(ESW2-5) are pressed (see below), the program
runs the buzzer // for 1 second (10x100ms,
obtained through the bcount counter). The
round // times out after 10 seconds (100x100ms,
obtained through the lcount counter) if
(found1) bcountbcount1 lcountlcount1
// At each millisecond wait (see above), the
counts are // incremented by one. if
(bcount 1) outport(CS14,1) // When the flag
is up (found1), turn on the buzzer waitfor(Del
ayMs(100L)) // Wait for 100 ms. if (bcount
10) outport (CS14, 0) // When bcount
reaches 10 (which means, 1000 ms has //
elapsed), turn off the buzzer if (lcount gt 100)
// When lcount reaches 100, (which means 10000
ms 10 seconds), found 0 // remove
the flag and ... outport(CS1,0) // ...
turn off everything outport(CS11,0)
outport(CS12,0) outport(CS13,0)
outport(CS14,0) lc_init()
lc_pos(0,0) //Reinitialized the LCD
lc_printf(" System Ready")
foundbcountlcount0
8
// Alternatively, keep checking the four
pushbuttons on the board (actual // switches,
SW2-5, not ESW2-5). If any one of them is
pressed, then the entire // system is to be
resetted for the next round of play. if
((state 0x01)(state 0x02)(state
0x04)(state 0x08)) found
bcountlcount 0 outport(CS1,0) /
/turn off everything outport(CS11,0)
outport(CS12,0) outport(CS13,0)
outport(CS14,0) lc_init()
lc_pos(0,0) lc_printf(" System
Ready") // End if top button
hit // End if found 1 lc_pos(3,0)
// Move cursor offscreen // End
costate
Write a Comment
User Comments (0)
About PowerShow.com