ECE473 Lab2: Purpose: *Learn to access AVR ports/pins and set i/o configuration. *Learn how to correctly connect uC to peripherals. *Understand I/O pin drive and input threshold levels. *Multiplex a display and push buttons to save pins. *Debouncing push button switches. *Use a software timing loop to create delays. *Gain experience creating a user interface. *Understand the limitations of using software timed loops Project Specifications: *Build a four-digit multiplexed LED display with eight push button switches. *Program uC to display (on LEDs) values created by the push button switches. *Leading zero suppression should be implemented. *Initially, the count indicates a single zero. *The display operates in base ten. *The I/O board push buttons will be utilized as follows: Button S0 increments the value displayed on the display by one. Button S1 increments by two, button S2 by four, etc. Button S7 increments by 128. The display max count is 1023, followed by 0. Calculations, Drawings and Questions before lab: a)Draw a complete schematic diagram of how you are going to hook up the display and switches to port A and B. This is not a sloppy crayon drawing. This is a fully complete schematic with all part numbers, values and pin numbers. If spot checks of your working schematic find that your drawings are not up to standard, you will loose points. *Port A will be used to "sink" segment currents AND also to sense the state of the push button switches. Careless coders will be rewarded with the distinct possibly of "magic smoke" emission. *Port B bits 4-6 will select the digit to display via a 74HC138 3-to-8 decoder. Note that the colon is considered a "digit". Look up how the 74HC138 works by reading its datasheet. *Port B bit 7 will be used to implement a PWM dimming control a following lab. It will be driven continuously low for now to saturate the 2N4403 it drives and keep the LEDs at full brilliance. *Determine the actual value of the PORTA LED segment current limiting resistors you must use using the resistors in your kit. A perfect solution may not be possible. Is PORTA overloaded or is there some "slack" left in the current specification? Show these values on your schematic. b)How can you know that the LED segments will be visible? c)Is the Mega128 total port/device current capacity exceeded? *Five 74HC138 outputs drive the digit driver transistors. Determine by analysis the correct value of the base bias resistors that will allow these transistors to source the necessary current. You are constrained by the resistor values in your kit. Show these values on your schematic. *PORTB bits 0-3 are not to be used at this time. They are reserved for other control and for SPI use. *Determine a mechanism that you can enable the tri-state buffer on the push button board when needed but is else off. The tri-state buffer allows the push buttons to pull the PORTA inputs low, but only under control of the uP. Otherwise, the push buttons will blank some segments. Your solution will of course be shown on your schematic. Assembly notes: *Think ahead and carefully consider what you are doing. This is not a hobbiest kit. *Don't solder connectors in everything that looks like a connector placement. Big mistake. Think! *Use the ribbon cables to make connections to PORTA and PORTB on the uC. The connector goes on the uC end. Split out the necessary wires to solder them directly to the boards on the front panel. Think twice and solder once. *The 2x5 connection block (A_2-G_2) is best connected to the Mega128 board. *The 1x8 connection block (A-G) is best connected to the push button board. *Mark your cables (sharpie pen) so you don't connect them to the wrong place. *Make sure unconnected wires don't short out to anything. *Remember to connect power to the push button board. *Place and solder the LED display on the ->BACK SIDE<- of the display board. This is the board side ->WITHOUT<- the IC. Removing the LED display is nearly impossible. *Use the power and ground available on the Mega128 board and through the connectors to get power to your boards. Also connect these grounds to the ground of the protoboard. *Carefully check all your connections for bad solder joints and bridged pads. Use eye magnification if necessary. Use the continunity "beeper" on our DMM to check connections. Software Notes: *Copy over the Makefile from lab1 and edit the project name. *Write some test code to test the display and the push buttons. This will check your wiring and avoid you spending too much time fiddling with software that is exercising broken hardware. This code will take you only a few minutes to write and will possibly save you hours or days. *This is most easily done with C preprocessor #ifdef statements. That way, your test code is always available in the future with the change of one constant. *Strongly recommend writing out pseudo-code or flowchart for your lab2 code. Don't start by first writing code. *Use of interrupts or timers is not allowed. We will add more grief later. :^) Testing: *Test and debug code and hardware. Write the test software first. You can add the rest of your code later. Turn into COE TEACH: *A _COPY_ of your high-quality schematic diagram of your circuit. Neatly done hand-drawn schematics are preferable. If we can't read them, its zero points. *One sheet showing calculations done for a,b and c parts of: Calculations, Drawings and Questions: *The file to submit is created with the linux tar command: tar -cvfz lab2.tar.gz file1 file2 file3 ..... This would create a single file "lab2.tar.gz" from the listed files after compression by gzip. Synopsis: (tar)tape archive, (c)create, (v)verbose, (f)use given tar file name, (z)compress with gzip You will demonstrate the functionality of your board and code. This will happen in person, in lab. Grading: *Circuit function +70% (demo system in lab) -performs as expected,switches debouncing cleanly -if count "jumps" -deduct 10% -dim display/flickers -deduct 5% -other abnormality -deduct 5% *Documentation +30% -complete, neat, correct -code well written, commented, including test code -sloppy/missing documentation -deduct 10% -poorly commented code -deduct 10% Lab weighting = 0.15