Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Lecture #3 September 1, 2016
29/1/2016 Lecture #3
AnnouncementsHomework #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 labQuiz 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 limitREMINDER: No food or (container without lid) drink in the lab!
39/1/2016 Lecture #3
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 #3Lab 1, part 1
49/1/2016 Lecture #3
Teaching Assistants
Introduce Grading TAs Side A (podium left)
• Yogish Didgi Side B (podium right)
• Yogish Didgi
Introduce Helping TAs• Jeremy Ang•
59/1/2016 Lecture #3
Lab Equipment & ProceduresYou 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.
Lecture #3 September 1, 2016
69/1/2016 Lecture #3
Lab Equipment & ProceduresWire 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 spoolsLess cutting, less waste, less costRemember: red wires for 5V pwr, black wires for 0V gnd
79/1/2016 Lecture #3
Lab Equipment & ProceduresEach 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
89/1/2016 Lecture #3
Lab Equipment & ProceduresEach 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).
99/1/2016 Lecture #3
Lab Equipment & ProceduresNot all components are in your bagLEDs, resistors, and some other components can be found in the trays on the center table
Lecture #3 September 1, 2016
109/1/2016 Lecture #3
Lab Equipment & ProceduresClean 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!
119/1/2016 Lecture #3
Preparing for HardwareTake 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
139/1/2016 Lecture #3
Lab Equipment & ProceduresAll 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
149/1/2016 Lecture #3
Wiring RulesPower/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
connectionsNo wires over chips Wire around them
Use tight wiring Easier to debug
Trim leads of resistors & LEDs
Lecture #3 September 1, 2016
159/1/2016 Lecture #3
Help ProceduresTAs there to help youBe aware there are onlyfour or five TAs in the room with up to 70 students We are limited
Try to use the resources available & trouble-shoot on your own first, then ask a TA if you cannot solve the problemIf TAs and professor are busy, please wait patiently
169/1/2016 Lecture #3
Help ProceduresThere 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
179/1/2016 Lecture #3
Lab 1-1 OverviewLab 1 focuses on the hardware and the functions used to interface the hardware to the C8051Lab 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
189/1/2016 Lecture #3
Common Digital GatesInverter
Buffer
(logic level unchanged, voltage level may change & current increased)
OR
X Q
7404
X Q 0 1 1 0
X Q
740774365
X Q 0 0 1 1
X Y Q 0 0 0 0 1 1 1 0 1 1 1 1
X
YQ
7432
Lecture #3 September 1, 2016
199/1/2016 Lecture #3
Common Digital GatesAND
NAND
There are many, many other digital circuits, but these are the common ones we will use.
X
YQ
7400
X Y Q 0 0 1 0 1 1 1 0 1 1 1 0
X
YQ
7408
X Y Q 0 0 0 0 1 0 1 0 0 1 1 1
9/1/2016
Hardware ComponentsRefer 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
20Lecture #3
219/1/2016 Lecture #3
Chip NumberingOn the physical chip, the pin numbers are arranged from the top-left around the chip in a counter-clockwise (CCW) direction.The top-left is found by locating the small dot or notch on the chip.
229/1/2016 Lecture #3
Resistors & Potentiometers
Example of a resistor component:
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.
Physical appearance Electrical symbol
Lecture #3 September 1, 2016
239/1/2016 Lecture #3
Light-Emitting DiodesLEDs 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)249/1/2016 Lecture #3
Application in CircuitConnect an LED and resistor in series Choose resistor to limit current in LED to rated value
• i<=10 mA Can use an output pin on microcontroller to turn on/off
Current (i)
Power+5V
Ground0V
Power+5V
Logic High – no current flowLogic Low – current flow
Use buffer gate to protect microcontroller(acts as a current sink)
259/1/2016 Lecture #3
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.
common
269/1/2016 Lecture #3
Application in CircuitConnect 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
Current (i)only when pressed
Power+5V
Ground0V
A - Voltage at this point w.r.t. ground is:High when not pressed (no current)Low when pressed
Lecture #3 September 1, 2016
279/1/2016 Lecture #3
Worksheets #3 and #4To 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!
289/1/2016 Lecture #3
Hardware Wiring and TestingAdditional 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 NotebookShow TA the result.Save your work for Lab 1, part 1.Lecture restarts in 30 minutes
299/1/2016 Lecture #3
Lab 1, part 1 ObjectivesYour 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.309/1/2016 Lecture #3
Lab 1, part 1 Representation
C8051 Controller
Port 2 & 3
Switches (pushbutton, slide switch)Input
C code
Port 3Output
LED0 BicolorLEDbuzzer
Lecture #3 September 1, 2016
319/1/2016 Lecture #3
Lab 1, part 1 Schematic
329/1/2016 Lecture #3
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)
339/1/2016 Lecture #3
Creating Digital InputsThe 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.
349/1/2016 Lecture #3
Creating Digital Inputs
The usual implementation:
R
Vcc
To input pin
Lecture #3 September 1, 2016
489/1/2016 Lecture #3
C Program for Lab 1, part 1Look 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
considerations499/1/2016 Lecture #3
Sample CodeLets 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
539/1/2016 Lecture #3
Lab Check-OffWhen you complete a lab assignment, you will need to demonstrate your lab to a TACheck-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
549/1/2016 Lecture #3
Lab Notebooks
Don’t forget to keep your lab notebooks up-to-date! Details in Lab Manual Appendix B Part of lab check-off procedure
Lecture #3 September 1, 2016
559/1/2016 Lecture #3
Good Communication
Inform TAs of any partner changes over next week. After that, you will remain partners for rest of semesterYou 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
569/1/2016 Lecture #3
Connections to the Microcontroller
Each protoboard has an EVB Port Connector, see back cover of lab manual and pin sheetFor 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.
579/1/2016 Lecture #3
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.589/1/2016 Lecture #3
Next ClassHomework 3 is due before classC8051 SFRs & Port I/OContinue 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.