Announcements Homework #2 (due before class) submit file on LMS. Submit a soft copy using LMS, everybody individually. Log onto the course LMS site Online Assignments Homework 2 Upload your corrected HW2-vn.c file Submit Important to remember to do this. Everybody must submit their own work. Add the provided pseudo-code for Lab 1-1 to your notebook, corrected for 1 team member's version of lab Quiz 1 in 2 classes (Mon Sept 15, sections 1,2; Tue Sept 13, sections 3,4) 40 minutes; Open book (printed manual), open printed notes No web pages, no past quizzes, no sharing, calculators allowed Coverage: number conversion, logic, pseudocode, and wiring Make sure you are registered for the correct section Homework #3 on website: Online assessment 30 min time limit REMINDER: No food or (container without lid) drink in the lab! Outline for Today Procedures of Tools and Hardware: if you don t have a toolbox from Elect Ccts or Elect Instrumentation you will need to purchase one for your team ($25) Hardware for switches and LEDS Switches are inputs, LEDs are used for Output Worksheet #3 Lab 1, part 1 2 3 Teaching Assistants Introduce Grading TAs Side A (podium left) Yogish Didgi Side B (podium right) Yogish Didgi Introduce Helping TAs Jeremy Ang You will need to check out one logic probe per team each day of lab. Logic probes are located in a cabinet in the back right corner of the room (as entering the main door). A TA will need to unlock the cabinet and hold your ID. Students need to be responsible when using the equipment. If something is missing or not working, please let the TA or Instructor know. We will replace it. Make sure logic probes are replaced at the end of class. 4 5
Wire for your project can be found in the spare wire box and on the spools Please use the spare wire in the box before using new wire from the spools Less cutting, less waste, less cost Remember: red wires for 5V pwr, black wires for 0V gnd Each group will be assigned protoboards A team MUST put their names on the bottom of it (get new label sticker if needed) At end of lab, return it to the corresponding numbered location in cabinets REMEMBER THIS NUMBER Write the number of your protoboard on the inside cover of your lab notebook Cabinets located on each side of the lab (in back) Unless told otherwise, keep the circuit on the protoboard when you store your equipment at the end of class 6 7 Each group will be assigned a bag of chips and components. These should be left with the protoboard - not taken home (so you won t damage parts or forget to bring it to class). Not all components are in your bag LEDs, resistors, and some other components can be found in the trays on the center table 8 9
Preparing for Hardware Clean up your station before leaving lab! Don t just wipe wires onto floor! Turn off power on car. Remember: no food or drink allowed in lab! Take a few minutes and perform the following tasks (TAs will hand them out): If no one on the team owns a toolbox from Elect Ccts or Elect Instr then 1 member will need to sign up to purchase one ($25) One student get a protoboard and logic probe Partner get a bag of parts and label Mount label on bottom of protoboard and write names, section # & side, and semester on label Understand the protoboard nodes (see LITEC Manual, end of Ch. 2) Mount the protoboard on the car Connect the ribbon cable to the protoboard 10 11 Wiring Rules All partners should have a copy of your code Make sure all have a copy at end of each day One partner may be late/sick/gone next class Homework needs to be submitted on LMS If equipment is broken, inform a TA so it can get replaced or repaired Please be careful, only limited supplies and some equipment is custom built Power/Ground and color convention All connections to power (+5V) use red wire All connections to ground use black wire Do not use red or black wires for any other connections No wires over chips Wire around them Use tight wiring Easier to debug Trim leads of resistors & LEDs 13 14
Help Procedures TAs there to help you Be aware there are only four or five TAs in the room with up to 70 students We are limited Try to use the resources available & troubleshoot on your own first, then ask a TA if you cannot solve the problem If TAs and professor are busy, please wait patiently Help Procedures There are also Open Shop hours posted in the lab and on-line The schedule is posted on the pillar in the center of the room TAs will be in the lab at those times to help if necessary 15 16 Lab 1-1 Overview Lab 1 focuses on the hardware and the functions used to interface the hardware to the C8051 Lab 1-1 specifically introduces the use of digital inputs and outputs Acquire digital input from external source Use this to determine a digital output It is important to develop reusable code Use of functions in your programming GOAL: Control 2 LEDs and a buzzer with two switches 17 Common Digital Gates Inverter Buffer X Q X Q 0 0 7407 74365 1 1 (logic level unchanged, voltage level may change & current increased) OR X Q 7404 X Q Y 7432 X Q 0 1 1 0 X Y Q 0 0 0 0 1 1 1 0 1 1 1 1 18
AND NAND Common Digital Gates X Y X Y 7408 7400 There are many, many other digital circuits, but these are the common ones we will use. Q Q X Y Q 0 0 0 0 1 0 1 0 0 1 1 1 X Y Q 0 0 1 0 1 1 1 0 1 1 1 0 Hardware Components Refer to the components when discussing the following slides Buffer chips LEDs Pushbuttons Slide switches Note: voltage inputs/outputs corresponding to On/Off are not necessarily 0/5 [V] Circuit examples 19 9/1/2016 Lecture #3 20 Chip Numbering Resistors & Potentiometers On the physical chip, the pin numbers are arranged from the top-left around the chip in a counterclockwise (CCW) direction. The top-left is found by locating the small dot or notch on the chip. Example of a resistor component: Physical appearance Electrical symbol Resistance value is indicated by the colored bars. Resistor color codes can be found in Appendix C of the lab manual and on the poster on center column in the lab. 21 22
Light-Emitting Diodes Application in Circuit LEDs are common components that provide a visible indication of a digital output. Diodes only allow current to flow through in one direction. From the cathode to the anode Must be a potential drop across it to emit light Current (i) 23 Connect an LED and resistor in series Power +5V Choose resistor to limit current in LED to rated value i<=10 ma Can use an output pin on microcontroller to turn on/off Power +5V Current (i) Ground 0V Logic High no current flow Logic Low current flow Use buffer gate to protect microcontroller (acts as a current sink) 24 Switches Different types of switches can provide digital input to the microprocessor. Pushbuttons provide different status only when pressed. Slide switches can be placed in either status. Application in Circuit Connect a switch and resistor in series Resistor limits current and provides a voltage drop When open circuit, no current flow, no voltage drop across resistor, therefore reading +5V at point A When closed circuit, current flows, voltage drops across resistor, therefore reading 0V at point A Microcontroller can read the status at this point A - Voltage at this point w.r.t. ground is: High when not pressed (no current) Low when pressed common 25 Power +5V Current (i) only when pressed Ground 0V 26
Worksheets #3 and #4 To prepare for Lab 1, we will begin with an example Port initialization and hardware circuit. Worksheet #3 uses hardware similar to Lab 1, part 1, but without the microprocessor control. One switch activates an LED and one activates a buzzer. This circuit can be used as the basis circuitry for Lab 1 (note the similarities). Use proper wiring conventions (neatness, wire color) Don t disassemble it when finished! Hardware Wiring and Testing Additional items in open supply in the Parts Drawers on the table in the middle of the room. Wire, Resistors Some special items like LEDs Read the schematic for Worksheet #03. Plan the circuit layout on the protoboard. Connect wires and check. Remember to connect power and ground to the chip. Turn on power. Verify correct function. Debug if necessary with logic probe. Enter procedure and results in Lab Notebook Show TA the result. Save your work for Lab 1, part 1. Lecture restarts in 30 minutes 27 28 Lab 1, part 1 Objectives Lab 1, part 1 Representation Your program for Lab 1, part 1 should (or some variation of): When the Slide switch is off (input is a HIGH voltage), LED0 is on, all other output devices are off When the Slide switch is on and both Pushbuttons are pushed, the Buzzer is turned on When the Slide switch is on and only Pushbutton 1 is pushed, the BiLED is green When the Slide switch is on and only Pushbutton 2 is pushed, the BiLED is red print LED and buzzer status to the screen Print button and switch states to the SecureCRT window See Tutorials website for helpful info. C code Switches (pushbutton, slide switch) Input Port 2 & 3 C8051 Controller Port 3 Output buzzer LED0 BicolorLED 29 30
Lab 1, part 1 Schematic Inputs Why do we need inputs? We want to send some type of information to the system. What type of signals can we send? Digital (True/False, 1/0, High/Low, +5V/0V) High for the C8051 microcontroller is ~3V, while logic gates need ~5V Analog (variable voltage) 31 32 Creating Digital Inputs Creating Digital Inputs The Goal: Communicate information to the microcontroller. The Approach: Force an input line to a TRUE or FALSE condition. Recommended practice: Make the input line either high or low at all times do not let input lines float. Floating lines create the possibility of ambiguous information at best, and undesirable information at worst. The usual implementation: R V cc To input pin 33 34
C Program for Lab 1, part 1 Sample Code Look on LMS Course material, Laboratory 1 for the lab1-1.c starting code. This code is incomplete in many ways As we look over this example now, think of these questions: How can this be applied in this project? What modifications and additions need to be made to meet our goals? Your pseudo-code should reflect these considerations Lets refer to the Sample code provided with Laboratory1-1. This code will control one LED with one switch You need to modify this code to control 2 LEDs and a buzzer with two switches (as described previously) Things to note as a review of C programming Include header files we need to include c8051_sdcc.h (website) Function prototypes note what is returned/passed Variable declarations must declare at beginning of function Use of indentation & brackets proper use is very helpful Function calls need () for functions, not variables 48 49 Lab Check-Off Lab Notebooks When you complete a lab assignment, you will need to demonstrate your lab to a TA Check-off procedure TAs/Prof from any section may check you off All partners should to be present (no credit if missing) Lab Notebook needs to be completed to that point You will be asked questions from the Demonstration and Verification section at end of lab as well as some additional questions All partners need to know lab well Questions will be directed towards each partner individually Don t forget to keep your lab notebooks up-to-date! Details in Lab Manual Appendix B Part of lab check-off procedure 53 54
Good Communication Connections to the Microcontroller Inform TAs of any partner changes over next week. After that, you will remain partners for rest of semester You will receive email updates from your grading TA Be sure to check your email Thank you for your help in making this course run smoothly Each protoboard has an EVB Port Connector, see back cover of lab manual and pin sheet For example, hardware connects to Port 3 by using pins 31-38. Review the numbering scheme on the protoboard connector block to EVB. Note the location of pins 1 and 2 to see how they are sequenced. 55 56 Additional Hardware Notes Note: LEDs will only turn on for forward current flow. Reverse connections if they do not light. See lab manual. The same applies to the polarized buzzer (look for +). Slide protoboards into the slots on top of the car above EVB. This will ensure proper connection of the ribbon cable. Brown edge of cable should be at low number end of pin connector. Next Class Homework 3 is due before class C8051 SFRs & Port I/O Continue Lab 1, part 1 Before you leave Return your protoboard to cabinet slot that matches number on protoboard. Parts bags should be left with protoboard. Return your toolbox (with everything put back) to the TA by the back cabinet. Turn off your car. 57 58