20RA210 Internal 2 Answer Key

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

SRI RAMAKRISHNA ENGINEERING COLLEGE

[Educational Service: SNR Sons Charitable Trust]


[Autonomous Institution, Reaccredited by NAAC with ‘A+’ Grade]
[Approved by AICTE and Permanently Affiliated to Anna University, Chennai]
[ISO 9001:2015 Certified and all eligible programmes Accredited by NBA]
VATTAMALAIPALAYAM, N.G.G.O. COLONY POST, COIMBATORE – 641 022.

Department of Robotics and Automation


Internal Test – II ANSWER KEY
Date 12.10.2023 Department R&A
Semester V Class/section III
Duration 2:00 Hours Maximum marks 50
Course Code &Title: 20RA210 & MICROCONTROLLERS &EMBEDDED SYSTEMS
Course Outcomes Addressed:
CO3: Program the ARM processor through instruction set.
CO4: Program the Arduino using C language for various applications
CO5:Develop the raspberry pi processor by python programming

Questions Cognitive
PART – A (Answer All Questions) (10*1 =10 Marks) Level/CO
1. Choose the ARM instruction used for conditional branching.
a) MOV b) ADD c) SUB d) LDR R/ CO3

2. Identify the role of the 'CMP' instruction in ARM assembly U/ CO3


a) Concatenate b) Compute the c) Copy the value d) Compare two
two registers product of two of one register to registers and set
registers another condition flags
3. Select a characteristic of ARM instruction encoding from the following options.
a) Fixed length b) Variable- c) No support for d) Only supports R/ CO3
instructions length branching integer arithmetic
instructions instructions
4. Choose the size of a single Thumb instruction in Thumb instruction encoding.
a) 8 bits b) 16 bits c) 32 bits d) 64 bits U/CO3

5. Identify the function used to send data to the serial monitor for debugging in
Arduino. U/ CO4
a) sendData() b) writeData() c) print() d) display()
6. Choose the purpose of the pinMode() function in Arduino programming.
a) It initializes b) It sets the c) It configures a d) It defines user- R/ CO4
the serial operating digital pin as an defined functions.
communication voltage of the input or output.
Arduino board.
7. Select the most common communication protocol used to interface a digital
pressure sensor with Arduino. R/ CO4
a) SPI (Serial b) I2C (Inter- c) UART d) PWM (Pulse Width
Peripheral Integrated (Universal Modulation)
Interface) Circuit) Asynchronous
Receiver-
Transmitter)
8. Raspberry Pi Imager tool is commonly used to flash Raspberry Pi OS onto a R/CO5
microSD card
9. RPi.GPIO is python library is commonly used for interacting with the Raspberry
R/ CO5
Pi's GPIO pins
10. To set the voltage level of a GPIO pin as HIGH or LOW the purpose of the R/ CO5
GPIO.output() function in Python when working with GPIO pins

PART – B (Answer All Questions) (5*2 =10 Marks) Cognitive


Level/CO
11. List the advantages and disadvantages of using multiple register transfer
ARM instructions in embedded systems programming.(2 Marks)
Advantages:
Code Efficiency: Multiple register transfer instructions (e.g., LDM and STM)
allow you to load or store multiple registers in a single instruction. This can lead
to more compact and efficient code compared to using single-register instructions,
reducing code size and improving execution speed.
Reduced Memory Access: By transferring multiple values between memory and
registers in a single instruction, you can reduce the number of memory accesses, U/CO3
which can be particularly advantageous in embedded systems with limited
memory bandwidth or high-latency memory access.
Disadvantages:
Limited Flexibility: Multiple register transfer instructions are specific to ARM
architecture and may not be available on all processor architectures. This limits
the portability of code and makes it less versatile in heterogeneous environments.
Complex Operand Management: Managing multiple operands in a single
instruction can be challenging, leading to more complex code and potentially
increasing the risk of programming errors.
12. Differentiate between immediate and register operands in data processing
instructions (2 Marks)
Immediate operands are constants embedded within instructions, used for simple
operations without accessing registers. Register operands refer to specific
processor registers and operate on the data stored in those registers, allowing for R/CO3
more complex and dynamic data manipulation. Immediate operands are fixed at
compile time, while register operands can hold varying data at runtime. The choice
depends on the simplicity and dynamic nature of the operation.

Write an Arduino program for interfacing a buzzer. (2 Marks)


// Define the pin to which the buzzer is connected
const int buzzerPin = 9; // You can use any digital pin

void setup() {
// Initialize the buzzer pin as an OUTPUT
13. pinMode(buzzerPin, OUTPUT); Ap/ CO4
}

void loop() {
// Generate a tone of 1000 Hz for 2 seconds
tone(buzzerPin, 1000); // Play a 1000 Hz tone on the buzzer
delay(2000); // Wait for 2 seconds (2000 milliseconds)
// Stop the tone (optional, but it's good practice)
noTone(buzzerPin);

// Pause for 1 second


delay(1000);
}
14. Compare the use of a real-time operating system (RTOS) differ from a
standard Linux-based operating system on Raspberry Pi (2 Marks)

RTOS: Provides deterministic and predictable real-time performance, ideal for


tasks with strict timing requirements.
Linux-Based OS: Lacks inherent real-time capabilities, and achieving real-time
behavior may require additional configuration and is not as deterministic.
Complexity and Resource Usage: U/CO5

RTOS: Typically lightweight, with a smaller footprint and faster boot times,
suitable for resource-constrained embedded systems.
Linux-Based OS: More complex, offers extensive features and services, but
consumes more system resources and has a longer boot time.
Multitasking and Scheduling:

15. Illustrate the GPIO pins on a Raspberry Pi with appropriate labels. (2


Marks)

U/CO5

PART – C (3*10 = 30 Marks)


16. Compulsory Question:
In a smart home automation project, an Arduino is used to control the heating and
cooling in the room based on temperature readings from an LM35 sensor. Sketch
the architecture for interfacing the LM35 temperature sensor with the Arduino.
Architecture- 5 Marks

Ap/CO4

Theory- 5 Marks
Any Two Questions
17. (a)Write an ARM assembly code snippet that uses data processing instructions to
perform addition and subtraction operations on registers. (5 Marks)

.data
result: .word 0 @ Define a variable to store the result

.text
.global main

main:
@ Initialize registers
mov r0, #10 @ Load 10 into r0
mov r1, #5 @ Load 5 into r1

@ Addition
add r2, r0, r1 @ Add r0 and r1, store the result in r2

@ Subtraction
sub r3, r0, r1 @ Subtract r1 from r0, store the result in r3

@ Store the results in memory


str r2, [result] @ Store the addition result in the 'result' variable
str r3, [result+4] @ Store the subtraction result after the addition result

@ End the program


mov r7, #1 @ ARM exit syscall code U/ CO3
swi 0 @ Invoke the syscall to exit
(b)Explain the difference between Swap and Thumb instruction sets in terms
of instruction word length and execution modes. (5 Marks)

Instruction Word Length:

ARM Instruction Set:

ARM instructions are typically 32 bits (4 bytes) in length.


This longer instruction word allows for a more extensive and complex set of
instructions.
It is well-suited for performance-critical applications where code density is not the
primary concern.
Thumb Instruction Set:

Thumb instructions are typically 16 bits (2 bytes) in length.


These shorter instructions are designed to improve code density, making them
suitable for memory-constrained environments or when code size optimization is
important.
Thumb instructions are more compact but offer a subset of the features available
in the full ARM instruction set.
Execution Modes:

ARM Instruction Set:


The ARM instruction set operates in ARM mode, which is the standard mode for
most ARM processors.
ARM mode provides access to the full range of 32-bit ARM instructions and
features.
It is commonly used for high-performance applications where code size is not a
critical concern.
Thumb Instruction Set:
The Thumb instruction set operates in Thumb mode, a subset of ARM mode.
Thumb mode is designed for reduced code size and power-efficient execution.
It offers a more limited set of instructions, focusing on common operations found
in most programs.
Some ARM processors also feature Thumb-2 technology, which combines Thumb
and ARM instruction sets to provide a broader range of instructions while
maintaining code density benefits.
Develop a Python script that reads data from a digital sensor connected to a
18. Raspberry Pi and displays the sensor readings on the screen.
(10 Marks)
import RPi.GPIO as GPIO
import time

# Define the GPIO pin used to connect to the sensor


sensor_pin = 17 # Change this to the actual GPIO pin number

# Initialize GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor_pin, GPIO.IN)

try:
while True: Ap/ CO5
# Read data from the sensor
sensor_value = GPIO.input(sensor_pin)

# Display the sensor reading


print(f"Sensor Reading: {sensor_value}")

# Add a delay between readings (adjust as needed)


time.sleep(1)

except KeyboardInterrupt:
print("Measurement stopped by the user")

finally:
GPIO.cleanup() # Cleanup GPIO configuration when the script exits
19. Explain the sequence of steps to install the Raspberry Pi operating system onto a
microSD card

Step 1: Download the Raspberry Pi OS Image:


U/CO5
Visit the official Raspberry Pi website (https://www.raspberrypi.org/downloads/)
and download the latest version of the Raspberry Pi OS (formerly known as
Raspbian). Choose the version that matches your Raspberry Pi model.
Step 2: Install Etcher (if not already installed):
If you haven't already, download and install Etcher
(https://www.balena.io/etcher/), a tool for flashing OS images onto microSD
cards.
Step 3: Insert the microSD Card:

Insert the microSD card into your computer's SD card reader or a USB SD card
reader adapter.
Step 4: Use Etcher to Flash the OS Image:

Launch Etcher on your computer.

Click on the "Select Image" button in Etcher and choose the Raspberry Pi OS
image you downloaded in Step 1.

Etcher should automatically detect your microSD card. If it doesn't, use the "Select
Drive" button to choose your microSD card.

Double-check that you've selected the correct drive because all data on the selected
drive will be overwritten.

Click the "Flash!" button to start the flashing process. Etcher will write the OS
image to the microSD card. This process may take a few minutes.

Once the flashing process is complete, Etcher will validate the write to ensure it's
successful.

When both writing and validation are finished, Etcher will show a message
indicating the process is complete, and it will safely eject the microSD card.

Step 5: Safely Remove the microSD Card:

If Etcher hasn't already ejected the microSD card, safely eject it from your
computer.
Step 6: Insert the microSD Card into the Raspberry Pi:

Insert the microSD card into the microSD card slot on your Raspberry Pi.
Step 7: Power Up Your Raspberry Pi:

Connect the necessary peripherals (keyboard, mouse, monitor, power supply) to


your Raspberry Pi.

Connect the power supply to the Raspberry Pi to boot it up.

Step 8: Follow the Initial Setup Wizard:

The first time you boot your Raspberry Pi, it will launch the initial setup wizard.
Follow the on-screen instructions to set your preferences, create a user account,
and configure your Wi-Fi .

S.No. Cognitive Level addressed Marks Percentage


1. Remember (R)
2. Understand (U)
3. Apply (Ap)
4. Analyze (An) - -
5. Evaluate (E) - -
6. Create (C) - -
Total 50 100

You might also like