You are on page 1of 15

KENYA AERONAUTICAL COLLEGE

END TERM (YEAR THREE TERM TWO)


SUBJECT : MICROCONTROLLER TECHNOLOGY
CLASS : KNEC OCT/NOV 2019
TIME : 2 HOURS
DATE :

Answer ALL Questions

1. (a) Describe each of the following with respect to microcontrollers:

(i) Internal bus width;


(ii) Speed;
(iii) External memory.
(6 marks)

(i) Internal bus width: The internal bus width refers to the number of data lines or bits used
for communication within the microcontroller's internal architecture. It determines the
maximum amount of data that can be transferred between different components of the
microcontroller, such as the CPU, memory, and peripherals, in a single operation. A wider
internal bus allows for the simultaneous transfer of more data, resulting in improved
performance and faster data processing.

(ii) Speed: The speed of a microcontroller refers to how quickly it can execute instructions
and perform operations. It is typically measured in terms of clock frequency, which
represents the number of cycles per second that the microcontroller's central processing
unit (CPU) can execute. Higher clock frequencies generally indicate faster processing speeds
and the ability to execute more instructions within a given time period. However, it's
important to note that the speed of a microcontroller is not solely determined by its clock
frequency but also by other factors such as the efficiency of its architecture and instruction
set.

(iii) External memory: Microcontrollers have limited on-chip memory resources for storing
program instructions and data. External memory refers to additional memory devices that
can be connected to the microcontroller to expand its available storage capacity. This
external memory can be in the form of RAM (Random Access Memory) or ROM (Read-Only
Memory) and is typically used to store larger amounts of data or program code that cannot
fit within the microcontroller's internal memory. The microcontroller communicates with
external memory through specific interfaces, such as memory buses or protocols like SPI
(Serial Peripheral Interface) or I2C (Inter-Integrated Circuit). External memory provides
flexibility in designing applications that require larger storage capacities or non-volatile
memory for program code or data storage.

2. (a) State:

(i) Two types of photoelectric sensors:


1. Photocells or Photodiodes: These sensors work based on the principle of converting light
energy into electrical energy. They generate an electric current proportional to the intensity
of light falling on them.

2. Phototransistors: Phototransistors are similar to normal transistors but are designed to


respond to light. They amplify the current produced by incident light, making them more
sensitive and suitable for various applications.

(ii) Three manufacturers of PLC:

1. Siemens: Siemens is a well-known manufacturer of programmable logic controllers (PLCs)


and offers a wide range of PLC products suitable for various industrial automation
applications.

2. Allen-Bradley (Rockwell Automation): Allen-Bradley, a brand under Rockwell Automation,


is another reputable manufacturer of PLCs. They provide a diverse range of PLCs with
different capabilities and features.

3. Schneider Electric: Schneider Electric is a global company that manufactures a variety of


industrial automation products, including PLCs. Their PLCs are widely used in industrial
control systems for automation and process control.

(b) An analogue signal is passed through ADC then processed through a microcontroller and
converted back to analogue before it is displayed on a CRO. Draw a schematic diagram of the
system.

(c) Table 1 shows an Intel 8051 assembly language program.

TABLE 1

MOV R5, #30 H

MOV R7, # 24 H

MOV A, 00H

ADD A; R5

ADD A; R7

ADD A;

ADD A;

end
1. Step 1: The value 30H (48 decimal) is loaded into Register R5.

2. Step 2: The value 24H (36 decimal) is loaded into Register R7.

3. Step 3: The accumulator (A) is initialized to 00H (0 decimal).

4. Step 4: The value in Register R5 (30H) is added to the accumulator


(A).

5. Step 5: The value in Register R7 (24H) is added to the accumulator


(A).

6. Step 6: The accumulator (A) is added to itself (A + A).

7. Step 7: The accumulator (A) is added to itself again (A + A).

8. Step 8: The program ends.

Explain what the program accomplishes.

Overall, the program performs a series of additions. It loads the


values 30H and 24H into Registers R5 and R7, respectively. It then
adds these values to the accumulator (A) sequentially. Finally, the

accumulator (A) is added to its elf twice. The result of these


additions is not stored or used in any further computations.

3. (a) State:

(i) The function of a limit switch;


A limit switch is an electromechanical device used to detect the presence or absence of an
object or to determine the position of a moving part. Its main function is to provide a
discrete signal (typically an electrical contact closure) when certain physical limits or
conditions are reached. The switch is designed to be actuated by the object or moving part,
triggering the switching action when it comes into contact with the switch's actuator.

(ii) Three methods of actuating a limit switch.

1. Mechanical Actuation: In this method, the limit switch is actuated by physical contact with
an object or a moving part. When the object or part comes into contact with the switch's
actuator, it mechanically triggers the switch, causing it to change its state.

2. Magnetic Actuation: Magnetic actuation involves the use of a magnetic field to actuate
the limit switch. The switch contains a magnetically sensitive component, such as a reed
switch, that is triggered when a magnetic field of sufficient strength is applied. The presence
or absence of the magnetic field determines the state of the limit switch.

3. Proximity Actuation: Proximity actuation relies on the principle of detecting the presence
or proximity of an object without physical contact. These limit switches use technologies
such as inductive, capacitive, or optical sensing to detect the object's presence or absence.
When the object is within the sensing range, the limit switch is actuated.

(b) Explain THREE differences between reduced instruction set (RISC) and complex
instruction set (CIS).

1. Instruction Set Complexity:

- RISC: RISC architectures have a simplified and streamlined instruction set. Instructions are
designed to be simple, with a fixed length and a limited number of addressing modes.

- CISC: CISC architectures have a complex and rich instruction set that includes instructions
with variable lengths and numerous addressing modes. CISC architectures aim to provide
powerful and versatile instructions to handle complex tasks.

2. Instruction Execution:

- RISC: RISC architectures typically execute instructions in one clock cycle. Instructions are
designed to perform simple operations efficiently.

- CISC: CISC architectures may require multiple clock cycles to execute certain instructions
due to their complexity. Instructions can perform more complex operations directly,
reducing the need for multiple instructions.

3. Memory Access:
- RISC: RISC architectures rely heavily on register-based operations. Most RISC instructions
operate on data stored in registers, reducing the need for frequent memory access.

- CISC: CISC architectures often include instructions that directly access memory, allowing
operations on data stored in memory without first loading it into registers. This flexibility can
simplify programming but may result in increased memory access.

(It's important to note that the distinction between RISC and CISC architectures has
become less pronounced over time, with modern processors often incorporating features
from both approaches. The evolution of processor design has led to a convergence where
the boundaries between RISC and CISC architectures have blurred.)

(c) A conveyor is controlled by a PLC using three switches. Switch 1 controls the motor,
switch 2 presence or absence of the load, and switch 3 indicates presence or absence of an
object along the operation area. For proper operation, the conveyor motor should be ON,
load present and no obstruction.

(i) Draw a truth table for the system operation

(ii) Draw a ladder diagram for the truth table above

(iii) Write down the PLC program listing.

4. a) Describe each of the following PLC designs:

PLC (Programmable Logic Controller) designs can be categorized into different types based
on various criteria. Here are some common types of PLC designs:

A Unitary PLC contains all the features of a basic system in one compact unit,
the features include; A power supply. The main module which contains a
central processing unit (CPU). The input module. The output module. Unitary
PLC’s are fitted directly to the component or machine that they are controlling.

Compact PLC:

Compact PLCs are small-sized controllers designed for simple applications that require a
limited number of I/O (Input/Output) points. They are compact in size and often have fixed
configurations, meaning the number of I/O points and other features cannot be expanded or
modified.

Modular PLC:

Modular PLCs consist of separate modules that can be easily interconnected to form a
customized control system. These modules include the CPU module, power supply module,
I/O modules, communication modules, and more. The modular design allows flexibility in
terms of adding or removing modules to meet the specific requirements of the application.

Rack-mounted PLC:
Rack-mounted PLCs are designed to be installed in standard equipment racks. They are
typically used in larger control systems where multiple PLCs are required to control various
sections or processes. The PLC modules are mounted in rack slots, allowing for easy
expansion and replacement.

Distributed PLC:

Distributed PLCs are used in systems where the control functions are distributed across
multiple PLCs. These PLCs are connected through a communication network, enabling them
to share information and coordinate their operations. Distributed PLC designs are often
employed in large-scale industrial automation systems.

Safety PLC:

Safety PLCs are specifically designed to handle critical safety functions in industrial
applications. They are equipped with additional hardware and software features to meet
safety standards and regulations. Safety PLCs provide high levels of reliability, fault
tolerance, and advanced safety functions to ensure the safe operation of machinery and
protect personnel.

High-Performance PLC:

High-performance PLCs are designed for applications that require fast processing speeds
and complex control algorithms. These PLCs typically have powerful processors, high-speed
communication capabilities, and advanced programming features to handle demanding
control tasks and real-time applications.

Soft PLC:

Soft PLCs, also known as software PLCs, are PLC systems implemented on general-purpose
computers or embedded systems. They use specialized software to emulate the functionality
of traditional hardware-based PLCs. Soft PLCs offer flexibility, scalability, and cost-
effectiveness, making them suitable for various industrial automation applications.

(b) In an aeroplane dashboard, a RED warning light comes ON when the ignition (1) is
switched ON and the Door (D) is not closed properly, OR the seat belt (S) is not fastened. The
system is under PLC control.

(i) Draw a functional block diagram;

(ii) Write down a PLC program listing to realize the system

(c) With the aid of ONE line instruction, describe the following microcontroller instructions:
(i) Single-operand operations:

Single-operand operations in microcontrollers typically involve performing an operation on a


single operand or register without the need for a second operand. These operations can
include arithmetic, logical, or bitwise operations.

Example of a single-operand operation instruction:

- In the Intel 8051 assembly language: DEC A

This instruction decrements the value in the accumulator (A) by 1.

(ii) Two-operand operations:

Two-operand operations in microcontrollers involve performing an operation that requires


two operands or registers. These operations can include arithmetic operations (addition,
subtraction, multiplication, division), logical operations (AND, OR, XOR), or data transfer
between registers.

Example of a two-operand operation instruction:

- In the ARM assembly language: ADD R1, R2, R3

This instruction adds the contents of registers R2 and R3 and stores the result in register
R1.

It's important to note that the specific instruction formats and mnemonics can vary
depending on the microcontroller architecture and assembly language being used. The
examples provided above are general representations and may not be applicable to all
microcontrollers.

5. (a) State THREE features of a typical microcontroller.

1. Central Processing Unit (CPU): The microcontroller includes a CPU core responsible for
executing instructions and performing data processing tasks. It may have a reduced
instruction set computer (RISC) or complex instruction set computer (CISC) architecture,
with a specified clock speed.

2. Memory: Microcontrollers have integrated memory components to store program code


(ROM or flash memory) and data (RAM). ROM or flash memory holds the firmware or
program instructions, while RAM provides temporary storage for variables and stack
operations.

3. Input/Output (I/O) Ports: Microcontrollers feature multiple I/O ports for interfacing with
external devices. These ports can be configured as input or output to connect to sensors,
actuators, displays, communication interfaces (such as UART, SPI, I2C), and other
peripherals.

4. Timers/Counters: Timers and counters are essential features in microcontrollers used for
measuring time intervals, generating precise delays, and counting external events. They
facilitate tasks like PWM generation, scheduling, and synchronization of operations.

5. Analog-to-Digital Converter (ADC):Many microcontrollers include an ADC module that


enables the conversion of analog signals (such as temperature, voltage, or sensor readings)
into digital values for processing and control purposes.

6. Serial Communication Interfaces: Microcontrollers often offer serial communication


interfaces like UART, SPI, I2C, and CAN. These interfaces enable data exchange with external
devices, such as other microcontrollers, sensors, displays, or communication modules.

7. Interrupt Controller: Microcontrollers typically feature an interrupt controller, allowing


them to respond to external events or internal conditions promptly. Interrupts facilitate real-
time processing, allowing critical tasks to interrupt the regular program flow when
necessary.

8. Power Management: Microcontrollers often incorporate power management features to


optimize energy consumption. This includes power-saving modes, clock gating, and sleep
modes to conserve power when the device is idle or operating in low-power scenarios.

9. Watchdog Timer: A watchdog timer is a built-in mechanism in microcontrollers that


monitors the system's operation. It resets the microcontroller if a software or hardware
failure occurs or if the program execution fails to refresh the timer within a specified time
frame.

10. Development Tools and Support: Microcontrollers are typically supported by a range of
development tools, such as Integrated Development Environments (IDEs), compilers,
debuggers, and programming languages. These tools aid in programming, simulation,
testing, and debugging of microcontroller-based applications.

(b) Figure 1 shows a memory map of a typical microcontroller


Determine the following:

(i) Size in KB of external program memory SIZE (KB)=( FFFFH-1000H +1 )/ 1024

60KB

(ii) End address of external data memory;

FFFF H

MEMORY MAP OF 8081 MC

(iii) State THREE functions of the SFR


The Special Function Registers (SFRs) are a set of memory locations in a microcontroller that
have specific functions and are used for controlling and configuring various aspects of the
device. The specific functions of SFRs can vary depending on the microcontroller
architecture and manufacturer. However, here are three common functions of SFRs in
microcontrollers:

1. I/O Control: SFRs are often used for configuring and controlling the input/output (I/O)
ports of the microcontroller. They can be used to set the direction (input/output) of
individual pins, enable/disable internal pull-up resistors, configure interrupt settings, and
monitor the status of input signals.

2. Timer and Counter Control: Microcontrollers usually have built-in timers and counters for
performing time-related functions and generating precise time intervals. SFRs are used to
configure and control these timers and counters, including setting the timer mode, defining
the time base, enabling interrupts, and reading or writing the timer values.

3. Interrupt Control: Interrupts play a crucial role in microcontrollers, allowing the device to
respond promptly to external events or internal conditions. SFRs are used to enable or
disable interrupts, set the interrupt priority levels, and handle interrupt flags. They provide
the necessary control and configuration for efficient interrupt handling.

(c)Table 2 represents an Intel 8051 program listing.

TABLE 2

MOV A, 78 H

ADD A, # 34 H

DAA

ADD CA, # 12 H

DAA

MOV R3, A

RET

(i) Explanation of the program:

1. MOV A, 78H: This instruction moves the value 78H into the accumulator (A).

2. ADD A, #34H: The program adds the immediate value 34H to the contents of the
accumulator (A).

3. DAA: DAA stands for Decimal Adjust Accumulator. It adjusts the value in the accumulator
after addition, ensuring that the result is in the correct decimal representation.
4. ADDC A, #12H: This instruction adds the immediate value 12H to the accumulator (A) with
carry (CY) enabled.

5. DAA: Similar to step 3, the DAA instruction adjusts the value in the accumulator after the
addition with carry.

6. MOV R3, A: This instruction moves the contents of the accumulator (A) into register R3.

7. RET: This instruction returns from the subroutine and continues program execution from
the point where the subroutine was called.

Overall, the program performs two additions, adjusts the result with the DAA instruction, and
stores the final result in register R3 before returning from the subroutine.

(ii) Hand coding the program into 8051 hexadecimal machine code:

To hand code the program into 8051 hexadecimal machine code, each instruction needs to
be converted into its corresponding hexadecimal opcode. Here's the hand-coded version of
the program:

MOV A, 78H --> 7AH

ADD A, #34H --> 74H

DAA --> D4H

ADDC A, #12H --> 7CH

DAA --> D4H

MOV R3, A --> EA3H

RET --> 22H

Note: The opcodes mentioned above are specific to the Intel 8051 microcontroller. The
machine code representation can vary for different microcontrollers. It's crucial to refer to
the microcontroller's datasheet or programming manual for the accurate opcode values.

6. (a) State FOUR main sources of interrupt in a microcontroller.

1. External Hardware Interrupts: These interrupts are triggered by external hardware


signals, such as a button press, sensor input, or communication events. They allow the
microcontroller to respond to real-time events and initiate the necessary actions.

2. Timer Interrupts: Timer interrupts occur when a specific time interval or count is reached
by the internal timers of the microcontroller. They are commonly used for tasks that require
precise timing, such as generating PWM signals, measuring time intervals, or implementing
periodic tasks.
3. Serial Communication Interrupts: Serial communication interrupts are triggered when
data is received or transmitted through the microcontroller's serial communication
interfaces, such as UART, SPI, or I2C. These interrupts allow the microcontroller to handle
data communication in an event-driven manner, ensuring timely and efficient data
exchange.

4. Software Interrupts: Software interrupts, also known as software-generated interrupts or


software interrupts, are initiated by software instructions. They are used for implementing
software routines, tasks, or specific events that need to be handled by the microcontroller.

(b) In the context of SCADA systems:

(i) Data acquisition: Data acquisition refers to the process of collecting and gathering data
from various sources within a SCADA system. It involves monitoring and capturing
information from sensors, devices, and other data points. The data acquisition system in
SCADA is responsible for sampling, converting analog signals to digital (ADC), and storing the
data for further analysis and control.

(ii) Logging: Logging in SCADA systems involves recording and storing operational data and
events for future reference, analysis, and auditing purposes. It includes capturing data
related to process variables, alarms, events, and system activities. The logged data provides
a historical record that can be used for troubleshooting, performance analysis, compliance
reporting, and decision-making.

(c) (i) ADC/DAC specifications:

(i) Linearity: Linearity refers to the ability of an ADC (Analog-to-Digital Converter) or DAC
(Digital-to-Analog Converter) to provide an output that is proportional and accurately
represents the input signal over a specified range. Linearity is typically measured as a
percentage of the maximum deviation from a straight line when plotting the input versus
output relationship. A higher linearity value indicates better accuracy and faithful
representation of the input signal.

(II) Speed: Speed, in the context of ADC or DAC, refers to the conversion rate or the time
taken to complete a conversion of analog-to-digital or digital-to-analog signals, respectively.
It represents how quickly the converter can process and convert the input signal. Speed is
usually measured in terms of samples per second (SPS) or conversions per second (CPS) and
is an important consideration in applications that require real-time or high-speed data
acquisition or signal generation. Higher speed values indicate faster conversion rates.
ii) With the aid of schematic-block diagram, describe the operation of a counter-based
analogue to digital converter (ADC).

(b) (i) Differentiate between MOD 1 and MOD 2 of the 8051 microcontroller timer
operations.

MOD 1:

- In MOD 1 mode, Timer 1 of the 8051 microcontroller operates as a 16-bit timer/counter.

- The Timer 1 register (TH1 and TL1) is configured as a 16-bit register, allowing a wider range
of count values.

- The Timer 1 can be used for generating longer timing intervals compared to other modes.

- Timer 1 can be set to operate in either timer or counter mode, depending on the specific
application requirements.

- It provides more flexibility and accuracy in timing applications that require longer time
intervals or precise counting.

MOD 2:

- In MOD 2 mode, Timer 1 of the 8051 microcontroller operates as an 8-bit auto-reload


timer/counter.

- The Timer 1 register (TH1 and TL1) is configured as an 8-bit register.

- Timer 1 automatically reloads the initial value upon reaching its maximum count value
(255) and continues counting.

- MOD 2 mode is commonly used for generating fixed time delays or generating a constant
frequency signal using Timer 1 in timer mode.

- It provides simplicity and convenience in applications where a fixed time delay or


frequency generation is required.

Overall, MOD 1 mode offers a wider count range and more flexibility for longer timing
intervals, while MOD 2 mode provides simplicity and convenience for generating fixed time
delays or constant frequency signals.

ii) Table 3 shows a program listing a microcontroller. Given that the clock frequency is 12
MHz, determine the total delay time.. Assume one execution clock cycle = of crystal
frequency. 12

TABLE 3
MOV A, # 10

MOV RO, # 05 H

MOV R1, # 05 H

Loop: ADD A, A

DEC RO

JNZ LOOP

MOV @RI, A

RET

(c) Explain TWO ways of implementing the microcontroller control unit

(b) (i) Differentiation between MOD 1 and MOD 2 of the 8051 microcontroller timer
operations:

(ii) Determining the total delay time in Table 3:

Given that the clock frequency is 12 MHz, and assuming one execution clock cycle equals the
crystal frequency, we can calculate the total delay time using the provided program. Here's
the calculation:

MOV A, #10 -> 1 clock cycle

MOV RO, #05H -> 1 clock cycle

MOV R1, #05H -> 1 clock cycle

Loop: -> 0 clock cycle (Jump instruction)

ADD A, A -> 1 clock cycle

DEC RO -> 1 clock cycle

JNZ LOOP -> 2 clock cycles (Jump instruction)

MOV @RI, A -> 2 clock cycles

RET -> 2 clock cycles


Total clock cycles: 1 + 1 + 1 + 0 + 1 + 1 + 2 + 2 + 2 = 11 clock cycles

Since one clock cycle is equal to the crystal frequency (12 MHz), the total delay time can be
calculated by dividing the total clock cycles by the crystal frequency:

Total delay time = Total clock cycles / Crystal frequency

= 11 / 12 MHz

= 0.92 μs

(c) Two ways of implementing the microcontroller control unit:

1. Hardwired Control Unit: In a hardwired control unit, the control signals and sequencing
logic are implemented using dedicated hardware circuits. The control unit is designed and
built with specific gates, flip-flops, decoders, multiplexers, and other digital components to
generate the necessary control signals for the microcontroller's operations. It provides fast
and deterministic control signal generation, as the control logic is directly implemented in
hardware. However, making changes or modifications to the control unit's functionality can
be challenging and require hardware redesign.

2. Microprogrammed Control Unit: In a microprogrammed control unit, the control signals


and sequencing logic are implemented using microcode instructions stored in a control
memory or ROM (Read-Only Memory). The microcode instructions define the control signal
sequences required for different operations and instructions of the microcontroller. The
control unit fetches the microcode

instructions based on the current instruction being executed and generates the
corresponding control signals. Microprogrammed control units offer flexibility and ease of
modification, as the control behavior can be modified by updating the microcode
instructions. However, it may introduce some overhead due to the additional microcode
fetch and execution steps.

Both hardwired and microprogrammed control units have their advantages and trade-offs,
and the choice depends on factors such as performance requirements, flexibility, ease of
modification, and the complexity of the microcontroller design.

You might also like