TW34 UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BEng(Hons) Electrical and Electronics Engineering SEMESTER 1 EXAMINATION 2016/2017 INTERMEDIATE EMBEDDED SYSTEMS MODULE NO: EEE5004 Date: Thursday 12 January 2017 Time: 10.00 12.00 INSTRUCTIONS TO CANDIDATES: There are 6 questions. Answer 4 questions. All questions carry equal marks. Marks for parts of questions are shown in brackets. This examination paper carries a total of 100 marks. All working must be shown. A numerical solution to a question obtained by programming an electronic calculator will not be accepted. Extracts from the PIC18F452 data sheet is provided at the back of the paper containing Figures 1 through to 7.
Page 2 of 11 1. 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 Button 2 LED1 LED2 PORTD bit-4 PORTB bit-5 PORTB bit-6 PORTB bit-7 The buttons and LEDs are connected to the microcontroller in active high mode. The LEDs require a forward current of 22mA, and have a forward voltage of 2.1V. The microcontroller is supplied by a 5V voltage. a) Draw the circuit diagram implementing for this design. b) Determine the values of any components required for the design. c) Explain using C statement how you would: i) Initialise the system. ii) Set and clear an LED without affecting the status of other pins iii) Read the status of the buttons 2. 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. Describe how you would implement this approach and outline the benefits that can be gained. b) Before the actual coding takes for the design of embedded software we can use several design methods to aid the understanding of the design at a high-level. Describe the following embedded system design methods: i) Flow chart ii) Pseudocode iii) Structure diagrams
Page 3 of 11 Please turn the page 3. a) A common way of designing complex software applications is by using a state machine. Describe what a state machine is and outline the benefits of its use. [10 marks] b) An embedded system is to control the operation of a security door. The system has four buttons to control the operation of the door, Open, Close, Lock, and Unlock. The Lock, and Unlock buttons are only operational when the door is closed. And the door can only be opened after it has been unlocked. i) Develop a state machine diagram to represent the system. ii) Write C code showing the implementation of the state machine. 4. a) A simple way to create a delay in C code is to use a for loop. Discuss the advantages and disadvantages of implementing a delay using this technique. Also explain the instances when its use is appropriate. b) The 16-bit timer of a PIC18F452 on TMR0 is configured to generate an interrupt on each timer count overflow. If the clock frequency used for the microcontroller is 8 MHz and the timer module is configured with the pre-scaler enabled and the prescaler bits set as 010. 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. Please turn the page
Page 4 of 11 5. a) What is meant by TAD in relation to a Microchip microcontroller b) An ADC is using internal voltage references of 5V and 0V. If the ADC has a resolution of 10-bits what would be the result of an ADC conversion if the voltage being measured is 1.425 V. Give your answer as a hexadecimal number. c) 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 8MHz The analogue signal is connected to AN0 Pin AN1 will be used as a digital output pin External voltage references of for V+ and V- will be used. 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 required A/D result is just 8-bits. Determine the settings of the two A to D Control registers (ADCON0, ADCON1) to implement the above. Give explanations for your choice of settings and show any necessary calculations. [15 marks] 6. a) Describe what is meant by switch bounce and explain why this can be a problem when interfacing buttons to a microcontroller. b) The problem of button de-bounce can be avoided in hardware using analogue filtering technique. i) Explain with the aid of a circuit diagram how this technique operates.
Page 5 of 11 ii) Calculate the values of components required if the actual bounce time for the switch is 10ms and it is connected to a 5V power rail. END OF QUESTIONS Data Sheet Information for the PIC18F452 Microcontroller Fig 1 Timer0 Block Diagram
Page 6 of 11 Fig 2 Timer0 Control Register
Page 7 of 11 Fig 3 INTCON register
Page 8 of 11 Fig 4 PIC18F452 Pinout Fig 5 ADC Block diagram
Page 9 of 11 Fig 6 ADCON0 Register
Page 10 of 11 Fig 7 ADCON1 Register
Page 11 of 11