EMBEDDED CONTROL ENGR 2350
Popular in Course
Popular in Engineering and Tech
verified elite notetaker
This 10 page Class Notes was uploaded by Opal Bernhard on Monday October 19, 2015. The Class Notes belongs to ENGR 2350 at Rensselaer Polytechnic Institute taught by Jeffrey Braunstein in Fall. Since its upload, it has received 44 views. For similar materials see /class/224818/engr-2350-rensselaer-polytechnic-institute in Engineering and Tech at Rensselaer Polytechnic Institute.
Reviews for EMBEDDED CONTROL
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/19/15
Embedded Control Lab Manual Lab 1 art 1 Getting Started Digital InputOutput Lab 1 part 1 Getting Started Digital InputOutput Preparation Reading Lab Exercise Descriptions All of the hardware and much of the software developed for Lab 1 parts 1 and 2 will be utilized in Lab 2 A M icroprocessor Controlled Game Since Labs 1 and 2 form an evolutionary sequence you are encouraged to familiarize yourself with the objectives of both labs before you begin Lab 1 Lab Manual Chapter 1 Introduction Chapter 2 Lab Equipment Chapter 3 Programming in C Chapter 4 The Silicon Labs C8051F020 and the EVB InputOutput Ports and Timers Chapter 5 Circuitry Basics and Components Chapter 8 Troubleshooting C language reference concepts Data types declarations variables functions the while looping structure if then statements bitwise operations Embedded Control Multimedia Tutorials Hardware Circuit Components Hardware Logic Probe Objectives General 1 Familiarization with the laboratory computers the SDCC and the procedure to develop a C program on the computer and run it on the SiLabs C8051 EValuation Board EVB Preparation 1 Complete Homework 1 software installation 2 Complete Worksheet 1 binarydecimalhexadecimal number systems Worksheet 2 bitwise and bytewise logic operations Worksheet 3 digital hardware IO and Worksheet 4 software port initializations and hardware Lab 1 part 1 Getting Started Digital InputOutput Embedded Control Lab Manual 3 Complete Homework 2 develop pseudocode that describes your program observing formatting styles discussed in class 4 Complete the Pinout form specifying the Port bits required the sbit labels chosen and the initialization settings for the appropriate SFRs Hardware 1 Familiarization with the protoboard the use of the multimeter and the logic probe 2 Con guration of a LED on the protoboard to allow them to be switched on off by one of the C8051 s digital output ports 3 Con guration of a bicolor LED to allow it to be switched onoff by a pair of the C8051 s output pins 4 Con guration of one pushbutton switch and one slide toggle switch on the protoboard to allow them to be read by one of the C8051 s digital input ports 5 Con guration of a buzzer to allow it to be turned onoff by one of the C8051 s output ports Software 1 Introduction to aspects of modular program development in C including the concepts of top down program development scoping of variables and C functions 2 Development of a modular C program that will enable the C8051 to acquire digital input from the switches connected to its input ports and to light LEDs and to turn on buzzer connected to its output ports based on the digital input Motivation The ability of a microprocessor to interface with other digital devices used as sources of input e g switches a keyboard etc destinations for output e g relays motors LEDs etc or for input and output eg another microprocessor opens up a world of possibilities Moreover for a microprocessor to serve as the controller for a host system it must be able to acquire input digital or analog and it must be able to provide output digital or analog in response to those inputs The three most common forms of digital ports are input output and con gurable inputoutput While the first two types of ports are dedicated strictly to the type of task implied by their names IO con gurable ports may have some or all bits programmed via software instructions for either input or output All of the ports on the C8051 are fully con gurable In this lab you will be introduced to digital input and digital output ports With the attainment of the stated objectives you will have gained an understanding of how to develop a simple C program for the C8051 You will be able to con gure the C8051 to acquire a digital input from an external source and use this value to determine the output on one of its digital output ports Since you will apply much of what you develop in this exercise to later exercises you are encouraged to develop the C code for this exercise so that it is easily extensible to future applications Remember that one of the keys to software productivity is the ability to reuse software and the reusability of software is a feature that must be designedin from the start Embedded Control Lab Manual Lab 1 art 1 Getting Started Digital InputOutput Lab Description amp Activities In this lab you will develop the components necessary for a portion of a microprocessor controlled game In this lab you will connect a regular LED a bicolor LED 2 pushbuttons a slide switch and a buzzer Additionally you will create software for the EVB to read inputs from the pushbuttons and slide switch and produce outputs to the LEDs and buzzer Hardware The pushbutton and slide switch will act as simple switches when connected in the manner shown in the circuit schematic When the pushbutton is pressed or the slide switch is in the off position the circuit is closed causing the voltage to drop across the resistor and a logic LOW 0V to be read at the EVB input pin The pushbutton returns to a normallyopen state when released causing a logic HIGH 5V to the input pin The slide switch will have a logic HIGH at the input pin when the switch is in the A position because the switch is open and there is no voltage drop across the resistor When the slide switch is moved to position B the input to the port bit is grounded 0V corresponding to a digital logic LOW These switches will be connected to the C8051 s Port 2 and Port 3 as shown in the schematic The output signals from the EVB control the Buzzer the LED and the Bicolor LED Similar to the description for input signals output voltages of 0V and 5V are used to turn these devices on and offquot Recall a digital LOW 0V may be used to turn a circuit component on and a digital HIGH 5V may be used to turn a circuit component of It is necessary to study the schematic when determine the correlation between onoff states and digital voltage levels It is important not to confuse these circuit voltages with the concepts of TRUEFALSE used in the program By studying the schematic recognize that in order to turn the buzzer on the output signal at P37 needs to be set LOW 0V Similarly the output at P36 must be a digital LOW 0V to turn the LED on A digital HIGH 5V on these Port pins will turn the devices off The control of a Bicolor LED requires 2 output bits To turn the Bicolor LED OFF two possible output states are possible both bits can be HIGH or both bits can be LOW To turn it on with one of its colors one bit must be HIGH and the other must be LOW To turn on the other color the reverse is necessary In the initialization routine of the software the Port 2 and Port 3bits need to be configured for the appropriate input and output states Use the C8051 EVB Port Connector diagram on the back cover to determine the pin numbers that correspond to each of the input and output pins shown in Figure E1 Write the pin numbers in the blanks next to each bit representation eg bit 0 of Port 3 P30 is pin 380n the EVB connector Software Modify the C program listed following the last page of this lab description so that it controls the state of the LEDs connected to Port 3 by reading the switches connected to Port 2 according to the following criteria the program is available electronically on LMS under the Laboratory 1 section of Course Material with the name lab1 1c 1 When the Slide switch is of input is a HIGH voltage LEDO is on all other output devices are off 2 When the Slide switch is on and both Pushbuttons are pushed the Buzzer is turned on 3 When the Slide switch is on and only Pushbutton l is pushed the BiLED is green 4 When the Slide switch is on and only Pushbutton 2 is pushed the BiLED is red Lab 1 Hart 1 Getting Started Digital InputOutlaw Embedded Control Lab Manual Your program should also print the status of the Slide switch and Pushbuttons on the computer terminal screen For example if the Slide switch is on and both Pushbuttons are activated your program should print Slide switch on Pushbutton l and 2 activated on the screen Remember when setting an output Port pin in your initialization routine you will want to do this without affecting the other pins on the same port bitwise and unary operators such as EL and N are useful for this task More information on bitwise and unary operators can be found in Chapter 3 Programming in C of the Lab Manual You are required to develop your program in a modular fashion Your main routine should be rather short simply calling a series of C functions that in turn may call other C functions etc By employing C functions try to avoid duplication of functionally equivalent or even similar chunks of code Develop your program with comments and use functions that are easy to understand which is helpful when someone else needs to refer to your code Writing Assignment Lab Notebook You and your lab partner should be keeping a Lab Notebook one for each team which documents the progress of your work in the lab Be sure to read and follow the guidelines in Appendix 3 Writing Assignment Guidelines on page 117 for proper Lab Notebook formatting GradingPreparation and Checkoff The checkoff procedure for Laboratory 11 is available on LMS Prior to the starting the laboratory you must complete 1 The appropriate Worksheets 2 The Pinout form 3 The Pseudocode When you are ready to be checked off the TAs will be looking at the following items 4 That your project performs all the indicated requirements 5 Appropriately formatted and commented source code 6 Clean and neat hardware with appropriate use of colors for source and ground connections Additionally you will be asked a number of questions The questions will cover topics such as 7 Identify parts of software operations understanding the hardware components understanding the test equipment The final item that will be included in the Laboratory grade is your 8 Notebook The above 8 items each have an individual contribution to your Laboratory grade Embedded Control Lab Manual Lab 1 art 1 Getting Started Digital InEutOutgut Remember Do not remove the circuitry built for Lab 1 it will be used in Lab 2 Record in your lab notebook the identification number of the protoboard you are using and attach a sticker to the bottom of it with your name and your lab partner 3 name Lab 1 Hart 1 Getting Started Digital InEutOntpnt Embedded Control Lab Manual C8051 EVE Connector Output enable 0 O VCC5V Port 33Pin36 O 51 VCC5V Port 34Pin 74365 39 Port 3 6 Pin 2 K LEDU Port 37Pin 27a Buzzer 0 TD 1 Port 30Pin i k Push Button 0 PB1 J Port 3 1 Pln To 3 1k Push Button 0 PB2 E 1k 0 Off Port 20P1n o13 0n Slide Switch 039quot Figure 11 Suggested hardware con guration for Lab 1 art 1 Embedded Control Lab Manual Lab 1 art 1 Getting Started Digital InEutOutgut C Program for Lab 1 art 1 L Names Section Date File name Program description amp This program is incomplete Part of the code is provided as an example You need to modify the code adding code to satisfy the stated requirements Blank lines have also been provided at some locations indicating an incomplete line include ltc80517SDCChgt include files This file is available online include ltstdiohgt Function Prototypes void PortiInitvoid int sensorlvoid int sensor2void void Setgoutputsvoid Initialize ports for input and output function which checks Pushbutton function that checks the Slide switch function to set output bits Global Variables sbit at 0XB6 LEDO LEDO associated with Port 3 Pin 6 sbit BILEDO associated with sbit BILEDI associated with sbit Buzzer associated with sbit at OXAO SS Slide switch associated with Port 2 Pin 0 sbit at OXBO PBl Push button 1 associated with Port 3 Pin 0 sbit Push button 2 associated with ampampampampampampampampampampampampampampamp void mainvoid SysiInit System Initialization putchar39 39 the quote fonts may not copy correctly into SiLabs IDE PortiInit Initialize ports 2 and 3 while 1 infinite loop I main program manages the function calls Setioutputs L PortiInit 7 Initializes Ports 2 and 3 in the desired modes for input and output void PortiInitvoid Port 3 P3MDOUT set Port 3 output pins to pushipull mode fill in the blank P3MDOUT set Port 3 input pins to open drain mode fill in the blank P3 set Port 3 input pins to high impedance state fill in the blank Lab 1 Hart 1 Getting Started Digital InEutOuiput Embedded Control Lab Manual Port 2 configure Port 2 as needed ampampampampampampampampampampampampampampamp Set outputs The following code is incomplete lighting an LED depending on the state of a single pushbutton void Setgoutputsvoid if sensor2 if Slide switch is not activated off LEDO 0 Light LED printfquotrSlide switch is off nquot else if Slide switch is activated on LEDO l turn off LED printfquotrSlide switch is on nquot Sensor 7 Returns a 0 if Pushbutton 1 not activated or a 1 if Pushbutton l is activated This code reads a single input only associated with PEG Note this code is not used by function yet you must incorporate it int sensorlvoid if lPBl return 1 else return 0 Sensor 7 Returns a 0 if Slide switch is 39off39 r a 1 if Slide switch is 39 This code reads a single input only associated with SS int sensor2void if lSS return 1 else return 0 Embedded Control Lab Manual Lab 1 art 1 Getting Started Digital InputOutput Recommended Procedure for Laboratory Development When developing the code and hardware for the laboratories debugging mistakes typically accounts for the bulk of the work One classic mistake made by new project designers is to attempt to implement the complete system and then x errors However for a fairly large project it becomes problematic to identify the sources of error when there are hundreds of lines of code or dozens of hardware components To avoid this situation it is much better to develop your project in steps verifying operation at appropriate junctures For Laboratory 1 a suggested development cycle has been provided to give you an idea of how to improve your ef ciency and avoid timeconsuming mistakes In future labs some basic recommendations are provided it will up to you to determine the details of the development process 1 L V VI V l V Complete the hardware aspect of Worksheet 3 This procedure is required to prepare for Laboratory 1 and is mentioned since it represents a good example of scaling down the Laboratory Having nished the worksheet you will have wired a buffer chip the slide switch the LED and the Buzzer At this point if things are functioning as directed you are con dent the buffer chip outputs to the LED and Buzzer are functional and no further change is required Download and compile the code labeled lab1 1c from LMS Your goal is to verify that no syntax errors exist in the code before performing any edits Key sections of the code are commented out and it is incomplete with regard to completing Laboratory 1 However once the port initialization code is edited the code will be suf cient to control the LED with the Slide switch Fill in the missing pin labels of Figure 111 for both the EVB connector and the buffer chip Refer to the back of the manual and the explanation of the buffer chip Edit the initialization section of the code to con gure Port 2 and Port 3 for the appropriate IO operations indicated in Figure 111 Use the tools developed in Worksheet 3 to set bits to l or 0 as needed Make sure that you do not change the other bits Remember the assignment operations for this procedure make use of the amp and syntax operations You will need to complete the existing Port 3 commands and add the Port 2 commands Also you will need to remove the comments once you complete the Port 3 lines Connect the Slide Switch to the appropriate EVB input for SS You will need to remove the wires in Worksheet 3 that connect directly from the Slide Switch to the Buffer chip Refer to Step 3 to identify the pin number that is associated with this input Connect the appropriate EVB output pin for LEDO to the input on the buffer chip Again you need to remove the existing wire that connects to the buffer for LEDO Add print statements to the output portion of the code indicating the status of the slide switch This requirement is a debugging procedure It allows the user to test the input aspects of the code independently from the output portion Download the code to the microcontroller and run the program If the hardware and software are correct the LED should turn on and off depending on the Slide switch position This step veri es the functionality of both the hardware and software while minimizing the amount of code or wire connections that need debugging It is highly recommended that your initial efforts are as simple as possible so that mistakes Lab 1 Hart 1 Getting Started Digital InputOutlaw Embedded Control Lab Manual are easily corrected 9 Add the hardware for the two Pushbuttons and functions to determine their states 10 Re ne the output code to print the status of all three input devices SS PEG and PB 1 Following success with the simpler circuit continue to develop the laboratory in a stepwise fashion Adding two input devices and checking their status requires implementation of the circuit components and re nement of the code the controls the output status The additional if statements set the stage for controlling the outputs 11 Once again download the code to the microcontroller and verify operation 12 Add the buzzer hardware and refine the code that sets the Port pins controlling the output devices 13 Add the BILED hardware and refine the code that sets the Port pins controlling the output devices Steps 913 should be an iterative process based on the procedure you performed in Steps 5 8 Again it is highly recommended that you do not attempt to complete a massive section of code of hardware without incremental steps You will find the debugging much easier by take smaller incremental steps 14 Prepare for checkoff
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'