UNIVERSITY OF BOLTON TW59 SCHOOL OF ENGINEERING B.ENG (HONS) ELECTRICAL AND ELECTRONIC ENGINEERING EXAMINATION SEMESTER 1-2015/2016 INTERMEDIATE EMBEDDED SYSTEMS MODULE NO: EEE5004 Date: Thursday 14 January 2016 Time: 10:00-12:00 INSTRUCTIONS TO CANDIDATES: There are SIX questions. Answer ANY FOUR questions. All questions carry equal marks. Marks for parts of questions are shown in brackets. Electronic calculators may be used provided that data and program storage memory is cleared prior to the examination. CANDIDATES REQUIRE: Data Sheet (attached).
Page 2 of 12 Q1. Digital Input /Output. An embedded system uses a PIC microcontroller to interface to two buttons and two LEDs. The connections as given below: Button 1 PORTB 0 Button 2 PORTB 1 LED1 PORTB 2 LED2 PORTB 3 The buttons and LEDs are connected to the microcontroller in active low mode. a) Draw the circuit diagram required for this design. b) Determine the values of any components required for the design. c) Write a C function to initialise the system. d) Write a C function to set or clear an LED. e) Write a C function to read the status of the buttons. Total 25 marks Please turn the page
Page 3 of 12 Q2. a) When you are designing the embedded software, you should try to break the program down along device lines. It is usually a good idea to associate a software module called a device driver with each of the external peripherals. i) Show a diagram illustrating this approach when designing software. ii) Discuss the advantages of taking this approach when designing software. b) Describe the following embedded system design tools i) Flow chart ii) Pseudocode iii) Structure diagrams Total 25 marks Please turn the page
Page 4 of 12 Q3. a) Describe a state machine and outline the benefits of using them in an embedded system design. b) A motor used to drive a conveyor belt is to be controlled by a software algorithm. Three buttons are used to control the conveyor belt as listed below: StopButton Stops the conveyor belt MoveForward Makes the conveyor belt move forward MoveBackward Makes the conveyor belt move in reverse The motor must be protected from overload and shock by preventing the operator from being able to make the conveyor belt move in the opposite direction to which it is currently operating in software. i) Develop a state machine diagram to represent the system. ii) Write C code implementing the state machine. Total 25 marks Please turn the page
Page 5 of 12 Q4. a) There are two common methods to insert a delay in our code the for loop or a timer. Discuss the advantages and disadvantages of these methods. b) The 16-bit timer of a PIC18452 on TMR0 is configured to generate an interrupt on each timer count overflow. If the clock frequency used for the microcontroller is 4 MHz and the timer module is configured with the prescaler enabled and the prescaler bits set as 101. Calculate the period of the interrupt that will be generated. Show all your working and considerations. c) The PIC18F452 has a 16-bit timer, Timer1 but the data bus is only 8-bits wide. Explain how a 16-bit timer read / write is carried out. Total 25 marks Please turn the page
Page 6 of 12 Q5. a) Many embedded applications often need to acquire real time world signals. This function is performed using an analogue to digital converter (ADC). One common method is the process of successive approximation. Describe the process of successive approximation. b) A microcontroller application is required to process an analogue signal with the conditions given below. The microcontroller to be used is the PIC18F452 having a system clock of 16MHz The analogue signal is connected to AN5 Pin AN6 will be used as a digital output pin External voltage references of +1.5V fed into pin AN3 and +0.5V fed into pin AN2. The ADC module is switched on but idle. The A/D Clock source must be selected to give the minimum TAD requirement (1.6us). The upper two bits of the 10-bit A/D Result are stored in the lower two bits of ADRESH register and the lower byte of the A/D result-value stored in ADRESL register. Determine the settings of the two A to D Control registers (ADCON0, ADCON1) to implement the above. Give explanations for your choice of settings. [15 marks] Total 25 marks Please turn the page
Page 7 of 12 Q6. Matrix Keypad Many embedded applications require devices to accept user input. One such devices is the matrix keypad and the liquid crystal display. a) Show a diagram of a 4 by 4 matrix keypad. b) Describe how the matrix keypad would be interfaced to a microcontroller. Include in your description the operation of reading one of the keys. Which is the recommended port to use on a PIC microcontroller and why? c) Show C or pseudo code to demonstrate the algorithm required to read the keys from a matrix keypad. Total 25 marks END OF QUESTIONS Data Sheet Information for the PIC18F452 Microcontroller
Page 8 of 12 Fig 1 Timer0 Block Diagram Fig 2 Timer0 Control Register
Page 9 of 12 Fig 3 INTCON register
Page 10 of 12 Fig 4 PIC18F452 Pinout Fig 5 ADC Block diagram
Page 11 of 12 Fig 6 ADCON0 Register
Page 12 of 12 Fig 7 ADCON1 Register