university of bolton school of engineering msc systems engineering … · page 3 of 13 school of...

13
TW30 UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING MSC SYSTEMS ENGINEERING AND ENGINEERING MANAGEMENT SEMESTER 2 EXAMINATION 2016/2017 MICROPROCESSOR BASED SYSTEMS MODULE NO: EEM7016 Date: Wednesday 17 May 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.

Upload: dangnhi

Post on 12-Apr-2018

223 views

Category:

Documents


4 download

TRANSCRIPT

TW30

UNIVERSITY OF BOLTON

SCHOOL OF ENGINEERING

MSC SYSTEMS ENGINEERING AND ENGINEERING

MANAGEMENT

SEMESTER 2 EXAMINATION 2016/2017

MICROPROCESSOR BASED SYSTEMS

MODULE NO: EEM7016

Date: Wednesday 17 May 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 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Page 3 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

1. a) Describe the terms data bus and address bus in relation to a microprocessor based system. (5 marks) b) Describe the two types of architecture used in microprocessor based systems. What are the advantages and disadvantages of these two types of architectures? (10 marks)

c) Describe the term “Instruction Set” in relation to a microprocessor based system.

(5 marks) d) Describe the operation of a microprocessor based system when a call instruction is executed or an interrupt causes a branch in terms of the program counter and the stack. (5 marks)

Total 25 marks 2. a) Describe the following terms, Machine Code, Assembly Code, ‘C’ Code.

(5 marks) b) Loops in ‘C’ can be produced by using either a ‘for’ loop or a ‘while’ loop. Show code how these two types of loop can be implemented and describe when you would use one rather than the other. (5 marks) c) Write a function to meet the following specification. i) Accepts two numbers, a and b, whose values are between 0 and 255

ii) Returns a result based on the difference between the two numbers as follows,

‘0’ if the numbers are equal ‘1’ if a is greater than b ‘-1’ if a is less than b (5 marks) d) What is meant by a function call by value and a function call by reference. Show code examples illustrating both these methods. (10 marks)

Total 25 marks Please turn the page

Page 4 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

3. A PIC18F452 microcontroller is to be used to interface to 1 LED, 2 push buttons, and a 12V DC motor via a transistor switch having a hfe of 100. The specification of this interface is as follows:

The microcontroller is powered from a 5V supply.

The two Buttons are connected to bit 7 (button 1), and bit 6 (button 2) on

PortD. The buttons are wired in an active high configuration.

The LED is connected to bit 5 of PortD in active low mode.

The DC motor is to be controlled by bit 4 on PortD

The forward voltage of the LEDs is 2V, and the current required for optimal

brightness is 22mA.

The resistive load of the motor is 120 Ohms.

Bits 3 to 0 on PortD are connected to other equipment and should not be

affected by any operations carried out on bits 7 to 4.

a) Show using a circuit diagram how you would interface these devices to the microcontroller. (5 marks)

b) Determine the values of any components used in your design. (10 marks) c) Show a ‘C’ code instruction to correctly initialise the port. (2 marks) d) Show ‘C’ code which will i) start the motor and light the LED when Button 2 has been pressed (4 marks)

ii) stops the motor and extinguishes the LED after Button 1 has been pressed. (4 marks)

Total 25 marks

Please turn the page

Page 5 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

4. a) Timed events can be implemented in two ways, i) using a simple for loop, and ii) using a timer module. Describe the advantages and disadvantages of these two methods and situations when each could be used. (5 marks)

b) The PIC18F452 has a 16-bit timer but the data bus is only 8-bits wide. Therefore, two separate reads or writes would need to be performed to capture the full 16-bit data. Describe the implications of this situation when a precise read or write from the 16-bit timer is required. Also what mechanism is included in the PIC microcontrollers to avoid this situation? (6 marks) c) In an industrial application, using a PIC18F452, TMR0 is used to create a timed event using a timer interrupt. The timer module of the microcontroller is configured as given below: Fosc = 4 MHz (Fosc) T0CON = 0xC2; INTCON = 0xA0; The timer module is pre-loaded with the count 131 Determine the rate at which the interrupt will occur. (14 marks)

Total 25 marks

Please turn the page

Page 6 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

5. a) A 10-bit ADC is used to convert the signal from a sensor having a voltage range of 0 to 1.2V. If an external voltage reference of 1.5V is used what will be the result in hexadecimal format of the A/D conversion if the input voltage is 0.427V.

(5 marks) b) A common technique used to perform analogue to digital conversion is the successive approximation technique. Using a block diagram describe the operation of the successive approximation ADC. (10 marks) c) The block diagram of the 40 pin PIC18F452 analogue to digital converter (ADC) is shown in Fig 5. The two A to D Control registers (ADCON0, and ADCON1) which control the A to D module are shown in Fig 6, and Fig 7 respectively. Determine the settings of the two A to D Control registers (ADCON0, ADCON1) to implement the following:-

Analogue signal is connected to Channel AN0

Pin AN1 will be used as a digital pins

The voltage references will be between 2.5V and 0.5V.

The A/D clock source should be derived from the microcontroller master clock having a frequency of 16MHz.

The ADC module is switched on but idle.

Only the highest 8-bits of the result is required by the application (10 marks)

Total 25 marks

Please turn the page

Page 7 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

6. Matrix keypads are a common component in a small embedded system where human interaction or human input is needed. a) Show using a sketch the construction of a 4x4 matrix keypad. (5 marks) b) Show how you would interface a 4x4 matrix keypad to a PIC18F452 microcontroller. Use a simple block showing the matrix keypad if you wish. Include in your answer the port you would use and why. (10 marks) c) Describe using ‘C’ code how you would implement the software to read a matrix keypad. (10 marks)

Total 25 marks

END OF QUESTIONS

Please turn the page

Page 8 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Data Sheet Information for the PIC18F452 Microcontroller

Fig 1 – Timer0 Block Diagram

Page 9 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Fig 2 – Timer0 Control Register

Page 10 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Fig 3 – INTCON register

Page 11 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Fig 4 – PIC18F452 Pinout

Fig 5 – ADC Block diagram

Page 12 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Fig 6 ADCON0 Register

Page 13 of 13 School of Engineering MSc Systems Engineering and Engineering Management Semester 2 Examination 2016/2017 Microprocessor Based Systems Module No. EEM7016

Fig 7 ADCON1 Register