0% found this document useful (0 votes)
5 views

Microcontroller Code Devolopment

The document outlines a curriculum for a module on Developing and Testing Code for Microcontroller Devices, prepared by the Ministry of Labor and Skill in Ethiopia. It covers topics such as identifying, developing, and testing microcontroller device code, along with safety measures and programming strategies. The module aims to equip trainees with the necessary skills to work with microcontrollers in various applications, including industrial and consumer electronics.

Uploaded by

Beku
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Microcontroller Code Devolopment

The document outlines a curriculum for a module on Developing and Testing Code for Microcontroller Devices, prepared by the Ministry of Labor and Skill in Ethiopia. It covers topics such as identifying, developing, and testing microcontroller device code, along with safety measures and programming strategies. The module aims to equip trainees with the necessary skills to work with microcontrollers in various applications, including industrial and consumer electronics.

Uploaded by

Beku
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 76

Industrial Electrical/Electronic

Control Technology
Level-IIV
Based on March 2023, Curriculum Version 2

Module Title: - Developing and Testing Code for


Microcontroller Devices
Module code: EIS IEC4 M02 1023
Nominal duration: 120Hour
Prepared by: Ministry of Labor and Skill
September, 2023
Addis Ababa, Ethiopia

1
Introduction to the Module..........................................................................................................................3
Unit One: Identification microcontroller device code to specifications.......................................................4
1.1 Introduction to Microcontroller.........................................................................................................5
1.2 WHS/OHS risks, and control measures in using microcontroller....................................................13
1.3 Scope of specification to be developed microcontroller code..........................................................15
1.4 Activities to meet scheduled timelines in microcontroller code development consultation.............16
1.5 Selecting development kit and software for microcontroller...........................................................17
1.6 Implementation strategies to ensure microcontroller programming code.....................................26
Self check 1.1........................................................................................................................................28
Operation sheet 1.1:...............................................................................................................................31
LAP Test 1.1..........................................................................................................................................32
Unit Two: Development of Microcontroller device code to specifications................................................33
2.1 Microcontroller functions and features............................................................................................34
2.2 Structure and syntax for developing microcontroller program specification....................................36
2.3 Key features of the assembler programming language for microcontroller.....................................38
2.4 Testing microcontroller device solutions.........................................................................................40
2.5 Analyzing approaches to provide most effective solutions for microcontroller problems...............42
2.6 Microcontroller quality of work monitoring....................................................................................44
Self check 2.1........................................................................................................................................51
Operation sheet 2.1:...............................................................................................................................54
Operation sheet 2.2:...............................................................................................................................55
LAP Test 2.1..........................................................................................................................................56
Unit Three: Testing and documenting microcontroller device code..........................................................57
3.1 Testing procedures to analyze developed microcontroller code.......................................................58
3.2 Identifying and rectifying problems, faults and bugs in microcontroller device..............................60
3.3 Writing intermediate and final work reports for microcontroller code development and testing.....62
3.4 Presenting intermediate and final work reports for microcontroller code development and testing. 64
Self check 3.1........................................................................................................................................66
Operation sheet 3.1:...............................................................................................................................67
Operation sheet 3.2:...............................................................................................................................69
LAP Test 3.1..........................................................................................................................................72
References:................................................................................................................................................73

2
Introduction to the Module

Microcontrollers are tiny computers that are embedded in various devices to perform
specific tasks. These devices range from simple appliances like microwave ovens to
complex systems like automobiles and industrial machinery. To program these devices,
developers use a variety of programming languages. The choice of language depends on
the type of microcontroller, the complexity of the task, and the developer's preferences.
Module also involves develop and test structured programming instructions for
microcontroller devices at a fundamental level for task.

This module covers the units:

 Identification microcontroller device code to specifications


 Development of microcontroller device code to specifications
 Testing and documentation microcontroller device code
Learning Objective of the Module

 Identify microcontroller device code to specifications


 Develop microcontroller device code to specifications
 Test and document microcontroller device code to the required application
Module Instruction

For effective use these modules trainees are expected to follow the following module
instruction:
1. Read the information written in each unit
2. Accomplish the Self-checks at the end of each unit
3. Perform Operation Sheets which were provided at the end of units
4. Do the “LAP test” giver at the end of each unit and
5. Read the identified reference book for Examples and exercise

3
Unit One: Identification microcontroller device code to
specifications

This unit is developed to provide you the necessary information regarding the following
content coverage and topics:
 Introduction to Microcontroller
 WHS/OHS risks, and control measures in using microcontroller
 Scope of specification to be developed microcontroller code from job
performance
 Activities to meet scheduled timelines in microcontroller code development
consultation
 Selecting development kit and software for microcontroller
 Implementation strategies to ensure microcontroller programming code
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
 Describe Introduction to Microcontroller
 Apply WHS/OHS risks, and control measures
 Determine scope of specification to be developed from job performance
 Planning activities to meet scheduled timelines in consultation
 Select development kit and software
 Implement strategies to ensure programming

4
1.1 Introduction to Microcontroller

A microcontroller also called MCUs or Microcontroller Unit is a single integrated circuit


(IC) that is used for a specific application and designed to implement certain tasks.
Products and devices that have been automatically controlled in certain situations, like
appliances, power tools, automobile engine control systems, medical equipment, high-
end consumer electronics, rugged industrial devices, and computers are great examples,
but microcontrollers reach much higher than these applications.
Essentially, a microcontroller works to gather input, process the information, and output a
particular action based on the information gathered.
Microcontrollers or MCUs can operate at lower speeds, for example, it can operate at
around in 1MHz to 200 MHz of range, and is designed to consume less power because
they’re embedded inside the other devices, which have greater power consumptions in
other areas.
Elements of Microcontroller
A microcontroller can be seen as a small computer, and this is often due to the essential
elements inside it. The elements of microcontrollers are:

 The Central Processing Unit (CPU)


 The Random-Access Memory (RAM)
 The Read-Only Memory (ROM)
 The Input/Output Ports (I/O Ports)
 Internal Oscillator
 The Electrical Erasable Programmable Read-Only Memory (EEPROM)

1. Central Processing Unit (CPU): It is essentially known as the brain of the


microcomputer. This element of the microcontroller is a microprocessor that controls and
monitors all the processes taking place inside the microcontroller unit (MCU). It’s
responsible for the reading and execution of all arithmetic and mathematical functions
that have been performed.

5
2. Random-Access Memory (RAM): It is a temporary storage memory that stores
information only when the power is on. It helps to run and calculate the programs which
the MCU is told to execute. It is continually overwritten while in use.

3. Read-Only Memory (ROM): It is a pre-written permanent storage memory that can


work even when the power is off. It essentially instructs the microcontroller on how to
execute its calculation and programs when asked.

4. Input/Output Ports (I/O Ports): The I/O ports consist of one or more
communications ports, typically in the form of connective pins. They permit the MCU to
be connected to other components and circuits for the flow of input/output data signals
and power supply.

5. Internal Oscillator: Also known as the main timer of the MCU. The Internal
Oscillator functions as the microcontroller’s core clock and controls the execution
rhythms of its internal processes. Similarly, any other kind of timer keeps track of your
time because it elapses during a given process, and helps the MCU to start and end
specific functions at specified intervals.

6. The Electrical Erasable Programmable Read-Only Memory (EEPROM): It is a


kind of non-volatile memory used by MCU. Electrical Erasable Programmable Read-
Only Memory stores amounts of data and information by allowing individual bytes to be
erased and reprogrammed.

Other supporting elements include:

1. Analog to Digital Converter (ADC): This is a single used to convert analog signals to
digital signals. It permits the processor of the MCU to interface with external analog
devices, for example – sensors. It can be used for various digital applications, e.g.
measurement devices.

2. Digital to Analog Converter (DAC): This is the reverse of ADC that means converts
digital signals to analog signals and permits the processor of the MCU to communicate its

6
outgoing signals to external analog components. It is usually used for controlling analog
devices like DC motors, various drives, etc.

3. System bus: It is a connective wire that connects all the components of the
microcontroller.
4. Serial Port: It is an example of I/O ports that permits the microcontroller to connect
to external components. It is similar to USB but differs in the way it exchanges bits.

Working Priciple

A microcontroller is embedded inside a system to regulate a singular function in a device.


It does regulate by interpreting data it receives from its Input-Output peripherals using its
central processor.
It stores temporary data and the temporary information received by a microcontroller is
stored in its data memory, where the processor can access it and uses the stored
instructions in its program memory to convert it into normal language and apply the
incoming data. Then it uses its I/O peripherals to communicate and apply the suitable
action.
Microcontrollers or MCUs are used in a wide range of systems and devices. Many
devices often used multiple microcontrollers that work together in one device to handle
their respective tasks.
For example, a car might consist of many microcontrollers that have the power to control
various individual systems within, like the anti-lock braking system, fuel injection
system, traction control, or suspension control. In this system, all the microcontrollers
communicate with each other to take the proper actions.
Some other microcontrollers may communicate with a more complex central computer
within the car, and others may communicate with other microcontrollers only. They can
send and receive data by using their I/O peripherals and process that data to perform their
designated tasks.

7
Types of microcontrollers

There are various types of microcontrollers on different bases:


Based on width-
 Bus-width: It generally refers to the parallel lines that connect the various components.
Its function is to transmit data between CPU, Memory, and Input/Output Ports.
Microcontrollers contain three types of buses inside it: data bus, address bus, and control
bus. It is divided into three types- 8,16, 32 bits microcontrollers.
 8-bits Microcontroller: The bus width of such microcontrollers is 8 bit which means 1
byte wide long. It means it can transfer & process the information of 8 bits in a single
cycle. The main hindrance of it is, it poses is in the mathematical operations because its
ALU (arithmetic logic unit) is also an 8-bit.
To process outsized data for example 16 bit, it uses multiple cycles to finish an easy
mathematical function. It results in poor performance of the general logic circuit.
Common examples of 8- bits microcontrollers are Intel 8031/8051 and PIC1x.
 16-bit Microcontroller: The bus width of such a microcontroller is 16 bits that means 2
bytes wide long. It can transfer & process information of 16 bits in a single cycle. Its 16-
bit arithmetic ALU is very efficient in its performance as compared to the 8-bit
microcontroller.
And its 16-bit timer provides a wide range of 0x0000 (0) to 0xFFFF (65535) which
provides the most effective accuracy per cost for any application or project that requires
Timer functions. Some examples of it are 8051XA, PIC2x, Intel 8096, etc.
 32-bit Microcontroller: A 32-bit microcontroller contains a bus width of 32 bits which
is 4 bytes long. The performance & accuracy of such microcontrollers is higher than any
other microcontrollers but they’re a bit expensive & consume lots of power.
It can even support multiple peripherals required in any embedded system projects or
applications like Universal Serial Bus (USB), Ethernet, Universal Asynchronous
Receiver-Transmitter devices (UARTS), and a Controller Area Network (CAN) bus.
Some common examples of 32-bit microcontrollers are Intel/Atmel 251 family, and
PIC3x, etc.
Based on Memory-

8
 Embedded Memory Microcontroller: Embedded memory means all the memory
blocks and modules are in a single package. This functional block includes program &
data memory, Timers & counters, interrupts, etc. Memory blocks are fixed and can not be
expandable but in microcontrollers, ROM can extend its memory.
 External Memory Microcontroller: This kind of microcontroller doesn’t have one
among the essential memory blocks inside its chip & it has to be connected externally to
function properly. The use of external modules increases the dimensions of the overall
device.
Based on Instruction Set Architecture-
 CISC (Complex Instruction Set Computer): In this kind of microcontroller, the CPU is
designed to execute one or single complex command. It can execute multiple instructions
by using a single instruction. It has a small-sized program and that is its advantage. But
because of the large size of its instruction set with many addressing modes, it takes a
multiple machine cycle to execute & result in a long time to perform.
 RISC (Reduced Instruction Set Computers): In this kind of microcontroller, the CPU
is designed to execute small and simple complex commands. It takes only one machine to
execute a single instruction hence, the instruction can be reduced to execute complex
instructions.
Based on Microcontroller Architecture-
 Harvard Architecture Microcontroller: It is a type of microcontroller that has
complete instruction in one machine cycle. It has two separate bus lines and separate
memory storage for program code (instructions), the data, program memory & the data
memory respectively. Its cost is higher due to its complex design.
 Von Neumann (or Princeton) Architecture Microcontroller: It uses single memory
for the program and data storage. It is a widely used architecture in various computers,
desktops, and laptops. It required two machine cycles to complete an instruction. Its cost
is very low as compared to Harvard architecture because it uses a single bus and its
design is also simple.

9
Various Other Types of Microcontrollers used are-

 PIC Microcontroller: Features of PIC Microcontroller are-


o No internal oscillator
o 40 pin IC in DIP packaging with 33 pins available for I/O
o Uses external clock up to 20 MHz as there is no internal clock
o Smaller instructions set of 35
o Operating voltage ranges from 4.2v to 5.5v.
 8051 Microcontroller: Features of 8051 Microcontroller are-
o 8bit microcontroller available in 40 pin DIP
o 4Kb on-chip programmable ROM for storing program code
o 128 bytes on-chip RAM for temporary data storage
o 40 pin IC in DIP packaging with 32 pins available for I/O
 AVR Microcontroller: Features of AVR Microcontroller are-
o Having an internal oscillator of 8MHz
o 1Kb on-chip programmable ROM for storing program code
o 32Kb on-chip RAM for temporary data storage
o 4 PWM channels for generating pulses
o It contains three timers which include two 8-bit timers & one 16-bit timer.
 ARM Microcontroller: Features of ARM Microcontroller are-
o 32-bit RISC processor
o energy efficient having higher performance
o Cortex M0 processor that offers low speed at low cost
o Based on Harvard architecture
 RENESAS Microcontroller: Features of RENESAS Microcontroller are-
o Based on CISC Harvard architecture
o 8-bit & 16-bit microcontroller whereas RX is a 32-bit microcontroller
o Low power microcontroller is RL78 while RX offers high performance & efficiency

10
o RX family RAM ranges in the form of 2KB to 128KB

The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628


Microcontroller. The Nano board is defined as a small and flexible microcontroller board.
The board includes the mini USB jack to connect computer and the Nano board. The DC
power jack is absent in Arduino Nano board.
The Pinout of the Arduino Nano board is shown below:

Microcontrollers are tiny computers that are embedded in various devices to perform
specific tasks. These devices range from simple appliances like microwave ovens to
complex systems like automobiles and industrial machinery. To program these devices,
developers use a variety of programming languages. The choice of language depends on
the type of microcontroller, the complexity of the task, and the developer's preferences.
Here are some of the most common programming languages used in microcontrollers:

a) C: C is one of the most popular programming languages used in microcontrollers.


It is a low-level language that provides direct access to hardware resources such
as memory, I/O ports, and timers. C is widely used in embedded systems due to
its efficiency, flexibility, and portability. Many microcontrollers come with built-
in C compilers, making it easier to develop and debug code.

11
b) C++: C++ is an extension of the C programming language and is also commonly
used in microcontrollers. It offers object-oriented programming features that make
it easier to write complex code and reuse existing code. C++ is particularly useful
in developing applications that require high performance, such as real-time
systems and multimedia processing.
c) Assembly Language: Assembly language is a low-level programming language
that uses symbolic representations of machine code instructions to program
microcontrollers. It provides direct access to hardware resources and is often used
for developing low-level firmware and device drivers. Assembly language is
typically used when high-performance and low-power consumption are critical
factors, such as in battery-powered devices.
d) Python: Python is a high-level programming language that has gained popularity
in recent years due to its ease of use and versatility. MicroPython is a variant of
Python specifically designed for microcontrollers. It provides a simpler syntax
and supports many libraries and frameworks for developing IoT applications,
machine learning, and web development.
e) BASIC: BASIC (Beginner's All-purpose Symbolic Instruction Code) is a high-
level programming language that is easy to learn and use. It is commonly used in
hobbyist projects and educational institutions. BASIC is available for many
microcontrollers, including Arduino and Raspberry Pi.
f) Java: Java is a popular programming language used in many applications,
including Android apps and enterprise software. It is also used in
microcontrollers, particularly those based on ARM processors. Java provides a
platform-independent environment, which makes it easier to develop cross-
platform applications.
g) MPLAB XC8: MPLAB XC8 is a programming language and development
environment specifically designed for Microchip microcontrollers. It provides a
graphical user interface and supports both C and assembly language
programming. MPLAB XC8 is ideal for developing applications that require
high-speed communication protocols, such as USB and Ethernet.

12
In conclusion, there are several programming languages used in microcontrollers, each
with its strengths and weaknesses. Developers should choose a language based on their
project requirements, experience level, and the resources available for their chosen
microcontroller.

1.2 WHS/OHS risks, and control measures in using microcontroller

Microcontrollers are widely used in various industries, including manufacturing,


healthcare, and automotive, to name a few. However, the use of microcontrollers can
pose potential risks to the health and safety of workers, as well as the environment. In this
section, we will discuss the WHS/OHS risks associated with the use of microcontrollers
and the control measures that can be implemented to mitigate these risks.

a) Electrical Risks: One of the primary risks associated with the use of microcontrollers is
electrical shock. The circuit boards and components of microcontrollers can carry high
voltage and current, which can cause serious injury or death if not handled properly. To
mitigate this risk, it is essential to follow proper electrical safety procedures, such as
wearing protective equipment, using insulated tools, and ensuring that the work area is
well-ventilated and free from any flammable materials.

b) Fire Risks: Another risk associated with the use of microcontrollers is the potential for
fires. Overheating components, short circuits, and other electrical malfunctions can cause
fires, which can spread quickly and cause significant damage. To minimize this risk, it is
crucial to ensure that the work area is well-ventilated, and that any malfunctions or
overheating components are addressed promptly.

c) Physical Risks: The use of microcontrollers can also pose physical risks to workers, such
as strains and sprains from lifting and handling heavy components, and eye strain from
prolonged use of computer monitors. To mitigate these risks, it is essential to provide
proper lifting and handling equipment, and to encourage workers to take regular breaks to
avoid eye strain.

13
d) Chemical Risks: Some microcontrollers may contain hazardous chemicals, such as lead
and mercury, which can pose health risks to workers. To minimize this risk, it is essential
to ensure that all components are properly labeled and handled, and that workers are
provided with appropriate personal protective equipment (PPE).

e) Ergonomic Risks: The use of microcontrollers can also pose ergonomic risks, such as
repetitive strain injuries from prolonged use of computer monitors and keyboards. To
mitigate these risks, it is essential to provide proper ergonomic equipment, such as
adjustable chairs and keyboards, and to encourage workers to take regular breaks to avoid
fatigue.

f) Psychological Risks: The use of microcontrollers can also pose psychological risks, such
as stress and anxiety from working with complex technology. To mitigate these risks, it is
essential to provide proper training and support, and to encourage workers to take regular
breaks to avoid burnout.

g) Environmental Risks: The use of microcontrollers can also pose environmental risks,
such as the disposal of hazardous waste and the potential for electronic pollution. To
minimize these risks, it is essential to ensure that all components are properly disposed
of, and that the work area is clean and free from any hazardous materials.

In conclusion, the use of microcontrollers in various industries can pose a range of


WHS/OHS risks, including electrical, fire, physical, chemical, ergonomic, psychological,
and environmental risks. To mitigate these risks, it is essential to implement proper
control measures, such as proper electrical safety procedures, regular maintenance and
inspection of equipment, proper lifting and handling equipment, appropriate PPE, proper
ergonomic equipment, regular training and support, and proper disposal of hazardous
waste. By implementing these control measures, organizations can ensure a safe and
healthy work environment for their employees, while also minimizing the potential for
environmental damage.

14
1.3 Scope of specification to be developed microcontroller code

The scope of specification to be developed for microcontroller code in job performance


refers to the detailed requirements and guidelines that need to be followed when writing
code for a microcontroller in a professional setting. This specification outlines the
specific functionality, performance, and design considerations that the code should
adhere to.
When developing microcontroller code for job performance, it is essential to have a clear
understanding of the project requirements and objectives. The specification should
include details such as the target microcontroller platform, programming language,
memory constraints, input/output requirements, and any specific industry standards or
regulations that need to be followed.
The scope of specification typically includes the following aspects:

a) Functionality: This section defines the desired behavior of the microcontroller code. It
outlines the specific tasks and operations that the code should perform, including input
handling, data processing, control algorithms, communication protocols, and output
generation.
b) Performance: The performance section specifies the expected performance metrics for the
microcontroller code. This includes factors such as execution speed, response time,
power consumption, memory usage, and any other relevant performance indicators.
c) Design Considerations: This part of the specification focuses on the design principles and
guidelines that should be followed when writing the code. It may include
recommendations for modular code structure, coding style conventions, error handling
mechanisms, software architecture patterns, and any other design considerations specific
to the project.
d) Input/Output Requirements: The specification should clearly define the input/output
requirements of the microcontroller code. This includes details about the types of sensors
or actuators that will be interfaced with the microcontroller and how they should be
connected and controlled.
e) Memory Constraints: Microcontrollers often have limited memory resources. Therefore,
it is crucial to specify any memory constraints that need to be considered during code

15
development. This may include limitations on program size, data storage requirements, or
any other memory-related considerations.
f) Industry Standards and Regulations: Depending on the application domain, there may be
specific industry standards or regulations that need to be followed when developing
microcontroller code. The specification should outline any relevant standards or
regulations and ensure that the code complies with them.
g) Testing and Validation: The specification should also include guidelines for testing and
validating the microcontroller code. This may involve defining test cases, expected
results, and any specific testing methodologies or tools that should be used.
In summary, the scope of specification for developing microcontroller code in job
performance encompasses various aspects such as functionality, performance, design
considerations, input/output requirements, memory constraints, industry standards, and
testing/validation guidelines. This specification ensures that the code meets the project
requirements and performs optimally in its intended environment.

1.4 Activities to meet scheduled timelines in microcontroller code


development consultation

When it comes to meeting scheduled timelines in microcontroller code development


consultation, there are several key activities that can be implemented to ensure efficient
and timely completion of the project. These activities include proper planning, effective
communication, thorough testing, and continuous monitoring.
a) Proper Planning: The first step in meeting scheduled timelines is to establish a well-
defined plan for the microcontroller code development project. This involves identifying
the project requirements, setting clear objectives, and breaking down the tasks into
manageable units. A detailed project plan should include milestones, deadlines, and
resource allocation to ensure that all aspects of the project are accounted for.
b) Effective Communication: Communication plays a crucial role in ensuring that all team
members involved in the microcontroller code development are on the same page and
working towards the common goal of meeting scheduled timelines. Regular meetings and
discussions should be held to provide updates on progress, address any issues or
concerns, and make necessary adjustments to the plan if required. Clear communication

16
channels should be established to facilitate quick and efficient information exchange
among team members.
c) Thorough Testing: Testing is an essential activity in microcontroller code development
as it helps identify and rectify any bugs or errors in the code before deployment. By
conducting comprehensive testing at different stages of development, such as unit testing,
integration testing, and system testing, potential issues can be identified early on and
resolved promptly. This ensures that the final product meets the desired functionality and
quality standards within the scheduled timeline.
d) Continuous Monitoring: Throughout the microcontroller code development process, it
is important to continuously monitor progress against the planned schedule. This can be
done by tracking key performance indicators (KPIs) such as task completion rates,
resource utilization, and overall project progress. By regularly reviewing and analyzing
these metrics, any deviations from the planned timeline can be identified and appropriate
actions can be taken to get back on track.

In addition to these activities, it is also important to consider factors such as resource


allocation, risk management, and contingency planning to mitigate any potential delays
or obstacles that may arise during the microcontroller code development process.

1.5 Selecting development kit and software for microcontroller

Selecting the right development kit and software for a microcontroller is a crucial step in
any embedded systems project. The choice of development tools can greatly impact the
efficiency, productivity, and success of the project. In this comprehensive guide, we will
discuss the factors to consider when selecting a development kit and software for a
microcontroller, as well as provide recommendations for the top options available. When
it comes to choosing a development kit for a microcontroller, there are several key factors
to consider:
a) Compatibility: Ensure that the development kit is compatible with the specific
microcontroller you are using. Different microcontrollers have different architectures,
instruction sets, and peripherals, so it is important to choose a kit that supports your target
device.

17
b) Features and Functionality: Evaluate the features and functionality offered by the
development kit. Look for features such as debugging capabilities, integrated
development environments (IDEs), libraries, code examples, and support for various
communication protocols. These features can significantly simplify the development
process and enhance productivity.
c) Documentation and Support: Check the availability and quality of documentation and
support resources provided by the manufacturer. Good documentation, user guides,
application notes, and online forums can be invaluable in helping you understand and
utilize the full potential of the development kit.
d) Cost: Consider your budget constraints when selecting a development kit. Prices can
vary significantly depending on the brand, features, and capabilities of the kit. It is
important to strike a balance between cost and functionality to ensure that you get the
best value for your investment.
e) Ecosystem: Evaluate the ecosystem surrounding the development kit. A strong
ecosystem includes a vibrant community of developers, third-party libraries, tools, and
resources that can further enhance your development experience.

Once you have selected a suitable development kit, it is essential to choose the right
software tools to complement it. Here are some factors to consider when selecting
software for your microcontroller project:
a. Integrated Development Environment (IDE): An IDE is a software application that
provides a comprehensive set of tools for writing, compiling, debugging, and deploying
code. Look for an IDE that is compatible with your chosen microcontroller and offers
features such as code editor, compiler, debugger, and project management capabilities.
b. Programming Language Support: Consider the programming languages supported by
the software tools. C and C++ are commonly used languages for microcontroller
programming, but some tools may also support other languages such as Python or
JavaScript.
c. Libraries and Frameworks: Check if the software tools provide libraries and
frameworks that can simplify common tasks and accelerate development. These libraries

18
can include functions for handling communication protocols, interfacing with peripherals,
or implementing specific algorithms.
d. Debugging and Testing: Ensure that the software tools offer robust debugging and
testing capabilities. Features such as breakpoints, watch windows, real-time variable
monitoring, and simulation can greatly aid in identifying and fixing issues during
development.
e. Community and Support: Consider the availability of a strong community and support
resources for the software tools you choose. Online forums, documentation, tutorials, and
sample projects can be invaluable in helping you overcome challenges and learn from
others' experiences.

In conclusion, selecting the right development kit and software for a microcontroller
requires careful consideration of factors such as compatibility, features, documentation,
cost, ecosystem, IDE support, programming language support, libraries/frameworks
availability, debugging/testing capabilities, and community/support resources.

Programming with Arduino

19
20
21
22
23
24
25
1.6 Implementation strategies to ensure microcontroller
programming code

Microcontroller programming code is the backbone of any embedded system, and its
quality can make or break the system's performance, reliability, and security. To ensure
that the code is of high quality, there are several implementation strategies that can be
employed. These strategies can help developers write better code, reduce errors and bugs,
and improve the overall development process.
a. Code Organization: One of the most important implementation strategies is to organize
the code in a logical and structured manner. This can be achieved by breaking down the
code into smaller, more manageable modules or functions, and by using meaningful
variable and function names. This approach makes it easier to understand and maintain
the code, and it also helps to reduce errors and bugs.
b. Commenting and Documentation: Commenting and documenting the code is another
crucial implementation strategy. Comments should be used to explain the purpose and
functionality of each module or function, and to provide information about the variables
and constants used. This helps other developers understand the code and makes it easier
to maintain and modify.
c. Error Handling: Error handling is an essential implementation strategy that should not
be overlooked. Developers should use try-catch blocks to handle errors and exceptions,
and they should also include error messages that provide information about the nature of
the error. This helps to identify and fix errors quickly, and it also improves the overall
reliability of the system.
d. Code Reuse: Code reuse is a valuable implementation strategy that can help to reduce
the amount of code and improve the development process. Developers should aim to
reuse code wherever possible, and they should also use libraries and frameworks to
simplify the development process.
e. Code Review: Code review is an important implementation strategy that can help to
identify errors and improve the quality of the code. Developers should review each

26
other's code and provide feedback, and they should also use automated tools to check the
code for errors and inconsistencies.
f. Testing: Testing is a critical implementation strategy that should not be overlooked.
Developers should test the code thoroughly to ensure that it works as expected, and they
should also use automated testing tools to speed up the testing process.
g. Version Control: Version control is an essential implementation strategy that helps
developers to manage changes to the code and collaborate on the development process.
Developers should use version control systems such as Git to track changes to the code
and to collaborate with other developers.

In conclusion, implementing these strategies can help developers to write better code,
reduce errors and bugs, and improve the overall development process. By following these
strategies, developers can ensure that their microcontroller programming code is of high
quality and meets the needs of the embedded system.

27
Self check 1.1

PART I. Choose the correct answer for the following question


1. A microcontroller works
A. To gather input B. Process the information C. Output a particular action D. All
2. Microcontrollers or MCUs can operate at lower speeds, for example, it can operate at
around in 1MHz to 200 MHz of range, and is designed to consume less power because
they’re
A. Embedded inside the other devices, which have greater power consumptions in other
areas
B. Embedded outside the other devices, which have greater power consumptions in
other areas
C. Embedded inside the other devices, which have lower power consumptions in other
areas
D. All
3. One of the elements of microcontrollers.
A. Central Processing Unit (CPU) C. The Input/Output Ports (I/O Ports)
B. The Read-Only Memory (ROM) D. All
4. It is essentially known as the brain of the microcomputer.
A. Central Processing Unit (CPU) C. The Input/Output Ports (I/O Ports)
B. The Read-Only Memory (ROM) D. Random-Access Memory (RAM)
5. It is a connective wire that connects all the components of the microcontroller.
A. Serial Port C. The Input/Output Ports (I/O Ports)
B. System bus D. The Read-Only Memory (ROM)
6. A type microcontroller based on Instruction Set Architecture, the CPU is designed to
execute one or single complex command
A. RISC C. Embedded Memory Microcontroller
B. CISC D. External Memory Microcontroller
7. A type microcontroller based on Microcontroller Architecture, that has complete
instruction in one machine cycle.
A. RISC C. Harvard Architecture Microcontroller
B. CISC D. Von Neumann Architecture Microcontroller

28
8. Which one of the following is not Features of PIC Microcontroller?
A. No internal oscillator C. Operating voltage ranges from 4.2v to 5.5v.
B. Smaller instructions set of 35 D. Has internal oscillator
9. Which one of the following is not Features of 8051 Microcontroller?
A. 8bit microcontroller available in 40 pin DIP C. 32-bit RISC processor
B. 128 bytes on-chip RAM for temporary data storage D. All
10. Which one of the following is Features of ARM Microcontroller?
A. 32-bit RISC processor C. 32Kb on-chip RAM for temporary data storage.
B. No internal oscillator D Based on CISC Harvard architecture
11. Which one of the following common programming languages used in microcontrollers is
a low-level programming language that uses symbolic representations of machine code
instructions to program microcontrollers
A. C++ B. Assembly language. C. Python D BASIC
12. Which one of the following common programming languages used in microcontrollers is
a high-level programming language that is easy to learn and use. It is commonly used in
hobbyist projects and educational institutions.
A. C++ B. Assembly language. C. Python D. BASIC
13. Which one of the following common programming languages used in microcontrollers a
popular programming language used in many applications, including Android apps and
enterprise software
A. Java B. Assembly language. C. Python D. BASIC
14. Which one of the following risks associated with the use of microcontrollers
A. Electrical Risks B. Fire Risks. C. Ergonomic Risks D. All
15. Which one of the following aspects included in the scope of specification to be developed
for microcontroller code
A. Functionality B. Memory Constraints. C. Design Considerations D. All

29
Part II: Matching
Direction: match column A with column B. writes your answer on the space provided
before the number.

No Column A Column B

1 A. DAC
known as the main timer of the
MCU
2 B.Repetitive strain injuries from
convert analog signals to digital
signals prolonged use of computer
monitors and keyboards
3 converts digital signals to analog C.Internal Oscillator
signals
4 D.As stress and anxiety from
Ergonomic Risks
working with complex
technology

5 E. ADC
Psychological risks

PART III. Short answer question


1. List and explain aspects included in the scope of specification to be developed for
microcontroller code
2. List and explain activities include microcontroller code development consultation
3. List and explain several key factors to consider to choosing a development kit for a
microcontroller
4. List and explain several implementation strategies that can be employed To ensure that
the microcontroller code is of high quality

30
Operation sheet 1.1:

 Operation title: Perform microcontroller implementation strategies


 Purpose: The purpose of these operation for students to be able to:
a. Write better code,
b. Reduce errors and bugs, and
c. Improve the overall development process.
 Instruction: Using the LED blinking code with comment written below and given
equipment’s to perform wiring the circuit. You have given 50 minutes for the task.

 Tools and equipment:


Arduino
LED
Resistor
Connecting wire
 Steps in doing the operation
1. Organize the code
2. Commenting and documenting
3. Error handling

31
4. Code reuse .
 Quality Criteria: Correct use of pneumatic component specification
 Precautions: use PPE and follow OHS.

LAP Test 1.1

Practical Demonstration (key activities that can be implemented to


ensure efficient and timely completion of microcontroller code
development project)
Name: _______________________ Date: ____________
Time started: __________________ Time finished: _________
Instruction I: Given necessary templates, tools and materials you are required to
perform the following tasks within 1 hours.

 Task-1: Perform planning of the project.


 Task-2: Perform effective communication about the project
 Task-3: Describe testing strategies of the project
 Task-4: Describe monitoring methods of the project

32
Unit Two: Development of Microcontroller device code to
specifications
This unit is developed to provide you the necessary information regarding the following
content coverage and topics:
 Microcontroller functions and features
 Structure and syntax for developing microcontroller program specification
 Key features of the assembler programming language for microcontroller
 Testing microcontroller device solutions
 Analyzing approaches to provide most effective solutions for microcontroller
problems
 Microcontroller quality of work monitoring
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
 Apply microcontroller functions and features
 Apply structure and syntax for developing microcontroller program specification
 Identify key features of the assembler programming language for microcontroller
 Test microcontroller device solutions
 Analyze approaches to provide most effective solutions for microcontroller
problems
 Monitoring microcontroller quality of work

33
2.1 Microcontroller functions and features

A microcontroller is a small computer on a single integrated circuit (IC) that contains a


processor core, memory, and programmable input/output peripherals. It is designed to
perform specific tasks and is commonly used in embedded systems, such as consumer
electronics, industrial automation, automotive applications, and more.
Microcontrollers offer various functions and features that make them suitable for
different applications. Some of the key functions and features of microcontrollers
include:

1. Processing Power: Microcontrollers come with different processor cores, ranging from
simple 8-bit cores to more advanced 32-bit cores. The processing power determines the
speed and efficiency of executing instructions.
2. Memory: Microcontrollers have built-in memory for storing program instructions
(flash memory) and data (RAM). The size of the memory varies depending on the
microcontroller model and can be expanded using external memory devices if needed.
3. Input/Output (I/O) Peripherals: Microcontrollers are equipped with a range of I/O
peripherals to interact with the external world. These peripherals include digital
input/output pins, analog-to-digital converters (ADCs), digital-to-analog converters
(DACs), timers/counters, serial communication interfaces (UART, SPI, I2C), interrupt
controllers, and more. These peripherals enable microcontrollers to interface with
sensors, actuators, displays, communication modules, and other external devices.
4. Power Management: Microcontrollers often feature power management capabilities to
optimize energy consumption. They may include low-power modes or sleep modes that
allow the microcontroller to operate at reduced power levels when idle or not performing
critical tasks.
5. Real-Time Capabilities: Many microcontrollers are designed to handle real-time tasks,
where precise timing and response are crucial. They may include dedicated hardware for

34
real-time operations, such as timers, watchdog timers, and interrupt controllers.
6. Communication Protocols: Microcontrollers support various communication protocols
to enable data exchange with other devices or systems. Common protocols include
Universal Asynchronous Receiver-Transmitter (UART), Serial Peripheral Interface (SPI),
Inter-Integrated Circuit (I2C), Controller Area Network (CAN), Ethernet, USB, and
wireless protocols like Bluetooth and Wi-Fi.
7. Development Tools and Ecosystem: Microcontrollers are supported by a wide range of
development tools, including integrated development environments (IDEs), compilers,
debuggers, and simulators. These tools facilitate the programming, testing, and
debugging of microcontroller applications. Additionally, microcontrollers often have a
vast ecosystem of libraries, frameworks, and community support that aid in the
development process.
8. Security Features: With the increasing connectivity of embedded systems,
microcontrollers now incorporate security features to protect against unauthorized access
or tampering. These features may include encryption/decryption modules, secure boot
mechanisms, memory protection units (MPUs), and secure communication protocols.

It is important to note that the specific functions and features of microcontrollers can vary
significantly depending on the manufacturer, model, and intended application. Different
microcontroller families from companies like Microchip Technology (PIC), Atmel
(AVR), Texas Instruments (MSP430), STMicroelectronics (STM32), and others offer
unique sets of functions and features tailored to specific requirements.

35
2.2 Structure and syntax for developing microcontroller program
specification

When developing a microcontroller program specification, it is essential to consider the


structure and syntax to ensure the program functions correctly and efficiently. The
structure refers to the organization and arrangement of the code, while the syntax defines
the rules and conventions for writing the code.
Here is a general outline of the structure and syntax for developing a microcontroller
program specification:
1. Header Files:
- Include necessary header files that provide access to predefined functions and macros
specific to the microcontroller being used.
- Commonly used header files include "stdint.h" for standard integer types, "stdbool.h"
for boolean types, and specific microcontroller-specific header files.
2. Global Variables:
- Declare global variables that will be used throughout the program.
- Global variables are accessible from any part of the code and can store data that needs
to be shared between different functions or modules.
3. Function Prototypes:
- Declare function prototypes before their actual implementation.
- Function prototypes specify the function name, return type, and parameters without
providing the function's implementation details.
- This allows other parts of the code to use these functions before they are defined.
4. Interrupt Service Routines (ISRs):
- Define interrupt service routines if your microcontroller supports interrupts.
- ISRs handle specific events or interrupts generated by external devices or internal
peripherals.
- These routines are executed when an interrupt occurs, allowing immediate response to
time-critical events.
5. Main Function:
- The main function is the entry point of the program execution.
- It contains the program's primary logic and controls the flow of execution.

36
- The main function may call other functions, handle interrupts, and interact with
peripherals.
6. Supporting Functions:
- Define additional functions that are required for the program's functionality.
- These functions can be called from the main function or other supporting functions.
- It is good practice to break down complex tasks into smaller, modular functions for
better code organization and reusability.

7. Comments:
- Include comments throughout the code to provide explanations and improve code
readability.
- Comments are non-executable statements that are ignored by the compiler but help
programmers understand the code's purpose and functionality.
8. Constants and Macros:
- Define constants and macros that represent fixed values or preprocessor directives.
- Constants are variables whose values cannot be changed once defined.
- Macros are preprocessor directives that allow you to define reusable code snippets or
perform compile-time computations.
9. Control Structures:
- Use control structures like if-else statements, loops (for, while), and switch-case
statements to control the flow of execution based on specific conditions.
- These structures enable conditional branching and repetitive execution, allowing for
more complex program behavior.
10. Peripheral Configurations:
- Configure microcontroller peripherals such as timers, UARTs, SPI, I2C, ADC, etc., as
per the program requirements.
- Each peripheral has its own set of registers and configuration options that need to be
properly initialized for correct operation.
11. Memory Management:
- Manage memory resources efficiently, especially in microcontrollers with limited
memory.

37
- Avoid memory leaks by properly allocating and deallocating memory when necessary.
- Use appropriate data types and structures to optimize memory usage.
12. Error Handling:
- Implement error handling mechanisms to detect and handle unexpected situations or
errors during program execution.
- This can include error codes, error flags, exception handling, or logging mechanisms.

13. Testing and Debugging:


- Perform thorough testing and debugging of the program to ensure its correctness and
reliability.
- Use debugging tools, simulators, or hardware debuggers to identify and fix any issues or
unexpected behavior.

It is important to note that the specific structure and syntax may vary depending on the
programming language, microcontroller architecture, and development environment
being used. The above outline provides a general framework that can be adapted to
different scenarios.

2.3 Key features of the assembler programming language for


microcontroller

Assembler programming language is a low-level programming language that is


specifically designed for programming microcontrollers. It allows developers to write
code that directly controls the hardware of a microcontroller, making it highly efficient
and suitable for applications that require precise control over hardware resources. In this
response, we will discuss the key features of the assembler programming language for
microcontrollers.

1. Low-level Programming: Assembler is considered a low-level programming


language because it provides a direct representation of machine code instructions. Each
instruction in assembler corresponds to a specific machine instruction, allowing

38
programmers to have fine-grained control over the microcontroller's hardware resources.
This level of control enables developers to optimize their code for performance and
memory usage.
2. Efficiency: Assembler programs are highly efficient as they can directly access and
manipulate the microcontroller's registers, memory, and other hardware resources. This
efficiency is crucial in applications where real-time processing or resource-constrained
environments are involved. By writing code at such a low level, developers can minimize
overheads and maximize the utilization of the microcontroller's capabilities.
3. Direct Hardware Access: One of the primary advantages of using assembler
programming language for microcontrollers is the ability to directly access and control
hardware peripherals. Microcontrollers often have various built-in peripherals such as
timers, UARTs (Universal Asynchronous Receiver/Transmitter), ADCs (Analog-to-
Digital Converters), and GPIOs (General Purpose Input/Output). Assembler allows
programmers to interact with these peripherals at a low level, enabling precise control
over their functionality
4. Interrupt Handling: Microcontrollers often rely on interrupts to handle time-critical
events or external signals. Assembler provides efficient support for handling interrupts by
allowing programmers to define interrupt service routines (ISRs) directly in their code.
ISRs can be written in assembler to respond quickly to interrupts and perform necessary
actions without any unnecessary overhead.
5. Memory Management: Assembler programming language provides direct control
over memory management in microcontrollers. Programmers can allocate and deallocate
memory as per their requirements, ensuring efficient utilization of limited memory
resources. This level of control is particularly important in resource-constrained
environments where memory usage needs to be optimized.
6. Portability: Assembler programs are highly specific to the microcontroller
architecture they are written for. While this specificity allows for fine-tuning and
optimization, it also limits the portability of the code. Assembler programs written for
one microcontroller may not work on another microcontroller with a different
architecture. Therefore, portability is a challenge when using assembler programming
language.

39
7. Debugging and Testing: Debugging assembler programs can be challenging due to
the low-level nature of the language. However, modern development tools provide
features like simulators and emulators that help in debugging and testing assembler code.
These tools allow developers to step through the code, inspect registers and memory, and
simulate hardware behavior to identify and fix issues.
In conclusion, the assembler programming language for microcontrollers offers several
key features such as low-level programming, efficiency, direct hardware access, interrupt
handling, memory management, and debugging capabilities. These features make it a
powerful tool for developing applications that require precise control over hardware
resources and efficient utilization of limited system resources.

2.4 Testing microcontroller device solutions

When it comes to testing microcontroller devices, there are several aspects to consider.
These include functional testing, boundary testing, power supply testing, communication
interface testing, and timing analysis. Let's explore each of these aspects in detail:

1. Functional Testing:
Functional testing involves verifying the correct operation of the microcontroller device
by executing its intended functions. This can be done by writing test cases that cover all
possible scenarios and expected outcomes. The test cases can be executed using software-
based simulation tools or by connecting the microcontroller device to a test setup that
emulates real-world conditions.
During functional testing, various aspects of the microcontroller device can be evaluated,
such as input/output operations, interrupt handling, memory access, timers/counters,
analog-to-digital converters (ADCs), digital-to-analog converters (DACs), and other
peripherals integrated into the device.
2. Boundary Testing:
Boundary testing focuses on evaluating the behavior of the microcontroller device at its
operational limits. This involves testing inputs and outputs at extreme values or near the
boundaries of their specified ranges. By doing so, potential issues related to overflow,
underflow, saturation, or unexpected behavior can be identified.

40
For example, if a microcontroller device has an ADC with a specified input voltage range
of 0-5V, boundary testing would involve testing the ADC's behavior at 0V and 5V input
voltages, as well as values close to these limits.
3. Power Supply Testing:
Power supply testing is essential to ensure that the microcontroller device operates
reliably under different power supply conditions. This includes testing the device's
behavior during power-up, power-down, and various power supply voltage levels.

During power supply testing, parameters such as current consumption, voltage regulation,
and response to power supply transients or interruptions can be evaluated. This helps
identify any issues related to power supply stability, noise immunity, or abnormal
behavior during power-related events.
4. Communication Interface Testing:
Microcontroller devices often include various communication interfaces such as UART
(Universal Asynchronous Receiver-Transmitter), SPI (Serial Peripheral Interface), I2C
(Inter-Integrated Circuit), USB (Universal Serial Bus), Ethernet, and more. Testing these
interfaces ensures their proper functionality and compatibility with other devices or
systems they interact with.
Communication interface testing involves verifying data transmission/reception, protocol
compliance, error handling, baud rate accuracy, signal integrity, and timing requirements.
It may also involve stress testing the interfaces by sending data at maximum rates or in
non-standard patterns to assess their robustness.
5. Timing Analysis:
Timing analysis is crucial for microcontroller devices that require precise timing for tasks
such as real-time control or synchronization with external events. This involves
evaluating the accuracy of internal timers/counters, pulse width modulation (PWM)
outputs, interrupt latency, and other time-critical operations.
Timing analysis can be performed by measuring the actual timing characteristics of the
microcontroller device using oscilloscopes or logic analyzers. It helps ensure that the
device meets its timing requirements and performs as expected in time-sensitive
applications.

41
In conclusion, testing microcontroller devices involves various aspects such as functional
testing, boundary testing, power supply testing, communication interface testing, and
timing analysis. By thoroughly evaluating these aspects, the functionality, reliability, and
performance of microcontroller devices can be ensured.

2.5 Analyzing approaches to provide most effective solutions for


microcontroller problems

Microcontrollers are widely used in various applications such as automotive, medical


devices, consumer electronics, and industrial control systems. However, designing and
developing microcontroller-based systems can be challenging due to the complexity of
the hardware and software components involved. To address these challenges, engineers
need to adopt a systematic approach to analyzing and solving problems related to
microcontrollers. In this article, we will discuss some techniques for analyzing
approaches to provide the most effective solutions for microcontroller problems.

1. Identify the Problem: The first step in analyzing approaches to solve microcontroller
problems is to identify the problem itself. This involves understanding the symptoms of
the problem, its root cause, and the impact it has on the system's performance. Engineers
should gather information about the problem using various tools such as oscilloscopes,
logic analyzers, and data loggers. They should also consult with other team members and
stakeholders to get a better understanding of the problem.

2. Break Down the Problem: Once the problem has been identified, the next step is to
break down the problem into smaller sub-problems. This involves identifying the key
components of the system that are affected by the problem and understanding how they
interact with each other. By breaking down the problem, engineers can gain a deeper
understanding of the issue and develop targeted solutions.

3. Analyze the System Requirements: To develop an effective solution for


microcontroller problems, engineers must analyze the system requirements. This includes

42
understanding the performance requirements, power consumption, memory constraints,
and other factors that affect the system's behavior. By analyzing the system requirements,
engineers can determine the appropriate hardware and software components needed to
solve the problem.

4. Evaluate Alternative Solutions: After breaking down the problem and analyzing the
system requirements, engineers should evaluate alternative solutions. This involves
comparing different approaches and selecting the one that best meets the system
requirements. Engineers should consider factors such as cost, complexity, and scalability
when evaluating alternative solutions.

5. Implement and Test the Solution: Once the best solution has been selected, engineers
must implement and test it. This involves writing code, configuring hardware
components, and integrating the solution into the larger system. Engineers should
thoroughly test the solution to ensure that it meets the system requirements and does not
introduce any new issues.

6. Monitor and Optimize the Solution: After implementing and testing the solution,
engineers must monitor and optimize it. This involves tracking the system's performance,
identifying areas for improvement, and making adjustments as needed. By continuously
monitoring and optimizing the solution, engineers can ensure that it remains effective and
efficient over time.

In conclusion, analyzing approaches to provide the most effective solutions for


microcontroller problems requires a systematic approach. By identifying the problem,
breaking it down into smaller sub-problems, analyzing the system requirements,
evaluating alternative solutions, implementing and testing the solution, and monitoring
and optimizing the solution, engineers can develop targeted solutions that meet the needs
of their systems.

43
2.6 Microcontroller quality of work monitoring

Monitoring the quality of work in microcontroller development is crucial for ensuring the
reliability and functionality of these devices. Microcontrollers are integrated circuits that
contain a processor core, memory, and programmable input/output peripherals. They are
widely used in various applications such as consumer electronics, automotive systems,
industrial automation, and medical devices.
To monitor the quality of work in microcontroller development, several approaches and
techniques can be employed. These include:

1. Testing and Validation: Testing is an essential part of microcontroller development to


ensure that the device functions correctly under different conditions. This involves
designing test cases and executing them on the microcontroller to verify its behavior.
Various types of testing can be performed, including functional testing, performance
testing, stress testing, and reliability testing.
Functional testing involves verifying that the microcontroller performs its intended tasks
correctly. Performance testing assesses the speed and efficiency of the microcontroller's
operations. Stress testing evaluates how well the microcontroller handles extreme
conditions such as high temperatures or voltage fluctuations. Reliability testing aims to
determine the lifespan and robustness of the microcontroller under normal operating
conditions.
Validation is another important aspect of quality monitoring in microcontroller
development. It involves comparing the behavior of the microcontroller against a set of
predefined specifications or standards. This ensures that the device meets all necessary
requirements and performs as expected.
2. Code Review: Conducting thorough code reviews is crucial for identifying potential
bugs or vulnerabilities in the software running on the microcontroller. Code reviews

44
involve analyzing the source code line by line to identify any coding errors,
inefficiencies, or security flaws. This process helps improve code quality, maintainability,
and overall system reliability.
Code reviews can be performed manually by experienced developers or through
automated tools that analyze the code for potential issues. The review process should
focus on factors such as code readability, adherence to coding standards, proper error
handling, and efficient resource utilization.
3. Documentation and Traceability: Maintaining comprehensive documentation
throughout the microcontroller development process is essential for quality monitoring.
Documentation should include detailed specifications, design documents, test plans, and
reports. This ensures that all aspects of the microcontroller's development are well-
documented and traceable.
Traceability refers to the ability to track and verify the relationships between different
artifacts in the development process. It helps ensure that changes made at any stage can
be traced back to their origin and evaluated for their impact on the overall system.
In addition to these techniques, it is also important to follow industry best practices and
standards in microcontroller development. These practices include using reliable
development tools, following coding guidelines, implementing version control systems,
and conducting regular audits.
Overall, monitoring the quality of work in microcontroller development involves a
combination of testing, validation, code review, documentation, and adherence to best
practices. By employing these techniques, developers can ensure that microcontrollers
meet the required standards of reliability and functionality

Example 1: LED Blinking Code for Arduino


To make an LED blink on an Arduino board, you can use the following code:
```scss
int ledPin = 13; // choose a pin on your Arduino to control the LED
void setup() {
pinMode(ledPin, OUTPUT); // set the pin as an output
}
void loop() {

45
digitalWrite(ledPin, HIGH); // turn the LED on
delay(500); // wait for 500 milliseconds (1/2 second)
digitalWrite(ledPin, LOW); // turn the LED off
delay(500); // wait for 500 milliseconds (1/2 second)
}
```

Here's an example code snippet in C language that demonstrates how to control


temperature using a DAC with an AVR microcontroller:
```c
#include
#include
// Define the DAC and ADC pins
#define DAC_PIN PB0
#define ADC_PIN A0
// Define the temperature range and resolution
#define TEMPERATURE_RANGE 0..100
#define RESOLUTION 10bit
// Define the DAC output voltage range
#define DAC_VOLTAGE_RANGE 0..5V

void setup() {
// Set up the ADC and DAC pins as inputs and outputs respectively
DDRB |= (1 << DAC_PIN);
DDRB |= (1 << ADC_PIN);
// Set up the ADC and DAC for temperature measurement and control
ADMUX = (REFS0|REFS1|ADLAR); // Select reference voltage and enable ADC
ADCSRA |= (1 << ADEN) | (1 << ADSC); // Enable ADC and set the sample rate
// Set up the DAC for temperature control
DACCR |= (1 << DACEN) | (1 << DACR); // Enable DAC and set the resolution
}
void loop() {

46
// Read the temperature from the ADC
int temperature = ADC;
// Calculate the desired DAC output voltage based on the temperature
int desired_voltage = (temperature - 50) * 2 / 1023;
// Set the DAC output voltage
OCR0B = desired_voltage;
}
```
In this example, the ADC measures the temperature of the environment and the DAC
controls the temperature by generating an analog voltage output. The desired DAC output
voltage is calculated based on the measured temperature and the desired temperature
range.

To control the speed of a DC motor using a microcontroller, there are several techniques
that can be employed. One common method is to use a pulse-width modulation (PWM)
signal to control the motor's speed. PWM is a technique that involves rapidly switching
the voltage applied to the motor on and off, with the duty cycle (the ratio of on-time to
total time) determining the average voltage applied to the motor. By adjusting the duty
cycle, the motor's speed can be controlled.

Here is an example of how this might be implemented in code for a microcontroller:


```
#include
#include
#include
#include "motor.h"
// Motor speed control function
void motorSpeedControl(int speed) {
// Calculate the PWM duty cycle based on the desired speed
int dutyCycle = speed * 100 / 255;
// Set the PWM output to the calculated duty cycle
analogWrite(motorPWM Pin, dutyCycle);

47
}
int main() {
// Initialize the motor
motorInit();
// Set the motor speed to 50%
motorSpeedControl(50);
// Wait for 5 seconds
delay(5000);
// Increase the motor speed to 75%
motorSpeedControl(75);
// Wait for another 5 seconds
delay(5000);

// Decrease the motor speed to 25%


motorSpeedControl(25);
// Wait for the final 5 seconds
delay(5000);
// Disable the motor
motorDisable();
return 0;
}
```
This code uses the `analogWrite()` function to set the PWM output to the calculated duty
cycle, which in turn controls the motor's speed. The `motorInit()` function is used to
initialize the motor, and the `motorDisable()` function is used to disable the motor when
it is no longer needed.

To create an automatic bottle filling system using Arduino Uno, you can follow these
steps:

Step 1: Gather Required Materials

* Arduino Uno board

48
* Bottle filling machine (you can purchase one online or make one yourself)
* Ultrasonic sensor (to detect the presence of a bottle)
* Servo motor (to control the filling process)
* LCD display (to show the filling level and other information)
* Breadboard and jumper wires (for prototyping)

Step 2: Connect the Components

* Connect the ultrasonic sensor to digital pin 2 of the Arduino Uno board.
* Connect the servo motor to digital pin 3 of the Arduino Uno board.
* Connect the LCD display to the Arduino Uno board (use the I2C library to
communicate with the display).

Step 3: Write the Code

* Define the variables for the ultrasonic sensor and servo motor.
* Write a loop that reads the distance from the ultrasonic sensor and adjusts the servo
motor position accordingly.
* Write a function to fill the bottle with the desired amount of liquid.
* Use the LCD display to show the filling level and other information.

Here's an example code to get you started:

```scss
#include
#include
#include

// Define the pins for the ultrasonic sensor and servo motor
const int trigPin = 2;
const int echoPin = 3;
const int servoPin = 3;

// Define the variables for the ultrasonic sensor and servo motor
float distance = 0;
int servoPosition = 0;

// Define the LCD display


LiquidCrystal_I2C lcd(I2C_ADDR, 20, 4);

void setup() {

49
// Initialize the ultrasonic sensor and servo motor
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(servoPin, SERVO);

// Initialize the LCD display


lcd.begin(20, 4);
}
void loop() {
// Read the distance from the ultrasonic sensor
distance = pulseIn(echoPin, HC_SR04_TRG_PIN, HC_SR04_ECHO_PIN);
// Adjust the servo motor position based on the distance
servoPosition = map(distance, 0, 100, 0, 180);
servoWrite(servoPin, servoPosition);

// Fill the bottle with the desired amount of liquid


fillBottle(distance);
// Show the filling level on the LCD display
lcd.setCursor(0, 0);
lcd.print("Filling Level: ");
lcd.print(distance);
lcd.print(" cm");

// Wait for a short period of time before taking the next reading
delay(1000);
}
void fillBottle(float distance) {
// Calculate the amount of liquid to fill the bottle
int amount = (distance * 100) / 10;

// Fill the bottle with the calculated amount of liquid


// (you can use a pump or a pouring mechanism to fill the bottle)
}
```
Note: This code is just an example and may need to be modified to suit your specific
needs. Also, the filling level calculation may need to be adjusted based on the size of the
bottle and the amount of liquid you want to fill.

50
Self check 2.1

PART I. Choose the correct answer for the following question


1. One of the key functions and features of microcontrollers determines the speed and
efficiency of executing instructions.
A. Memory B. Processing Power C. Security Features D. Power Management
2. One of the key functions and features of microcontrollers used to enable microcontrollers
to interface with sensors, actuators, displays, communication modules, and other external
devices
A. Memory B. Processing Power C. Security Features D. Input/Output Peripherals
3. Embedded of the key functions and features of microcontrollers determines capabilities
to optimize energy consumption
A. Power Management B. Processing Power C. Memory D. Security Features
4. Are accessible from any part of the code and can store data that needs to be shared
between different functions or modules.
A. Header Files B. Function Prototypes C. Global Variables D. Main Function
5. Allows other parts of the code to use these functions before they are defined
A. Header Files B. Function Prototypes C. Global Variables D. Main Function
6. Are executed when an interrupt occurs, allowing immediate response to time-critical
events
A. ISRs B. Function Prototypes C. Global Variables D. Main Function
7. Is the entry point of the program execution and it contains the program's primary logic
and controls the flow of execution
A. Comments B. Function Prototypes C. Global Variables D. Main Function
8. Are non-executable statements that are ignored by the compiler but help programmers
understand the code's purpose and functionality
A. Supporting Functions B. Function Prototypes C. Comments D. Main Function
9. Are preprocessor directives that allow you to define reusable code snippets or perform
compile-time computations.
A. Constants B. Macros C. Control Structures D. Peripheral Configurations

51
10. Enable conditional branching and repetitive execution, allowing for more complex
program behavior
A. Control Structures B. Macros C. Main Function D. Peripheral Configurations
11. The first step in analyzing approaches to solve microcontroller problems is to
A. Break Down the Problem C. Analyze the System Requirements
B. Identify the Problem D. Evaluate Alternative Solutions
12. Which step in analyzing approaches to solve microcontroller problems, involves
identifying the key components of the system that are affected by the problem and
understanding how they interact with each other.
A. Analyze the System Requirements C. Break Down the Problem
B. Evaluate Alternative Solutions D. Implement and Test the Solution
13. Which step in analyzing approaches to solve microcontroller problems, understanding the
performance requirements, power consumption, memory constraints, and other factors
that affect the system's behavior
A. Break Down the Problem C. Implement and Test the Solution
B. Evaluate Alternative Solutions D. Analyze the System Requirements
14. Which step in analyzing approaches to solve microcontroller problems, involves
comparing different approaches and selecting the one that best meets the system
requirements.
A. Break Down the Problem C. Implement and Test the Solution
B. Evaluate Alternative Solutions D. Analyze the System Requirements
15. Which one is the application area of microcontroller
A. Consumer electronics B. Automotive systems C. Industrial automation D. All

52
Part II: Matching
Direction: match column A with column B. writes your answer on the space provided
before the number.

No Column A Column B

1 A. "stdint.h"
Structure refers
2 B. "stdbool.h"
Syntax
3 For standard integer types C. Identify the Problem

4 D. Organization and arrangement


For boolean types
of the code

5
Understanding the symptoms of the E. Defines the rules and
conventions for writing the
problem
code.
F. Break Down the Problem

PART III. Short answer question


1. List and explain the key features of the assembler programming language for
microcontrollers.
2. List and explain general outline of the structure and syntax for developing a
microcontroller program specification
3. List and explain several aspects to consider when testing microcontroller devices
4. What are the approaches and techniques can be employed To monitor the quality of work
in microcontroller development?

53
Operation sheet 2.1:

 Operation title: Operating a LED start blinking.


 Purpose: The purpose of these operation for students to be able to:
1. Develop codes for microcontroller to blink the LED
2. Wire the circuit and components.
Instruction: Using the figure below and given equipment’s to Wire the circuit and
components and Develop codes for microcontroller to blink the LED practically..
You have given 50 minutes for the task.

 Tools and equipment:


 Arduino UNO
 Breadboard
 LED
 Resistor, R=270Ω
 Wires (Jumper Wires)
Steps in doing the operation
5. Connect the components with Arduino board using bread board
6. Develops the codes for LED blinking
7. Upload the developed codes to Arduino hardware
8. Powered the Arduino board and observe the LED blinking operation
 Quality Criteria: Correct wiring of component and use calibrated multimetere
 Precautions: use PPE and follow OHS.

54
Operation sheet 2.2:

 Operation title: Operating a LED start blinking with switch.


 Purpose: The purpose of these operation for students to be able to:
1. Develop codes for microcontroller to blink the LED
2. Wire the circuit and components.
Instruction: Using the figure below and given equipment’s to Wire the circuit and
components and Develop codes for microcontroller to blink the LED practically..
You have given 50 minutes for the task.

 Tools and equipment:


 Arduino UNO
 Breadboard
 LED
 Switch
 Resistor, R=270Ω
 Wires (Jumper Wires)
Steps in doing the operation
a. Connect the components with Arduino board using bread board
b. Develops the codes for LED blinking
c. Upload the developed codes to Arduino hardware
d. Powered the Arduino board and observe the LED blinking operation
 Quality Criteria: Correct wiring of component and use calibrated multimetere
 Precautions: use PPE and follow OHS.

55
LAP Test 2.1

Practical Demonstration (Microcontroller Code development for LED start


blinking with LM35 temperature sensor)

Name: _______________________ Date: ____________


Time started: __________________ Time finished: _________
Instruction I: Given necessary templates, tools and materials you are
required to perform the following tasks within 1 hours.

 Task-1: Draw the wiring diagram for Arduino.


 Task-2: Develop the codes for LED Blinking using LM35 temperature sensor.
 Task-3: Upload the developed codes to Arduino hardware
 Task-4: Record the result
 Task-5: Write down your report

56
Unit Three: Testing and documenting
microcontroller device code
This unit is developed to provide you the necessary information regarding the following content
coverage and topics:
 Testing procedures to analyze developed code
 Identifying and rectifying problems, faults and bugs
 Writing and presenting intermediate and final work reports
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
 Develop testing procedures to analyze developed code
 Identify and rectify problems, faults and bugs
 Write and present intermediate and final work reports

57
3.1 Testing procedures to analyze developed microcontroller code

Testing procedures for analyzing developed microcontroller code are crucial to ensure the
reliability, functionality, and performance of the code. These procedures involve various
techniques and tools that help identify and rectify any potential issues or bugs in the code.
In this comprehensive response, we will discuss the different testing procedures
commonly used to analyze developed microcontroller code.
Unit Testing: Unit testing is a fundamental testing procedure that focuses on testing
individual units or components of the microcontroller code. It involves writing test cases
for each unit to verify its functionality in isolation. The goal is to identify any defects or
errors within the unit and ensure that it performs as expected. Unit testing can be done
using specialized unit testing frameworks and tools, such as Unity, CppUTest, or Google
Test.
Integration Testing: Integration testing is performed to test the interaction between
different units or components of the microcontroller code. It aims to identify any issues
that may arise due to the integration of these units. Integration testing ensures that the
units work together seamlessly and produce the desired output. This type of testing can
be done using techniques like top-down integration, bottom-up integration, or sandwich
integration.
Functional Testing: Functional testing verifies whether the microcontroller code meets
the specified functional requirements. It ensures that the code performs its intended
functions accurately and reliably. Functional testing involves creating test cases based on
the functional specifications and executing them to validate the behavior of the code.
Techniques such as boundary value analysis, equivalence partitioning, and decision table
testing can be used for effective functional testing.
Performance Testing: Performance testing evaluates how well the microcontroller code
performs under specific conditions and workload. It helps determine whether the code
meets performance requirements such as response time, throughput, and resource
utilization. Performance testing can involve techniques like load testing, stress testing,
endurance testing, or scalability testing. Tools like JMeter or LoadRunner can be used to
simulate various scenarios and measure performance metrics.

58
Static Code Analysis: Static code analysis is a technique that examines the
microcontroller code without executing it. It helps identify potential issues, such as
coding standards violations, security vulnerabilities, or potential bugs. Static code
analysis tools analyze the code's syntax, structure, and logic to provide insights into its
quality and maintainability. Tools like SonarQube, Coverity, or PVS-Studio are
commonly used for static code analysis.
Code Review: Code review is a manual process where experienced developers review
the microcontroller code to identify defects, improve code quality, and ensure adherence
to coding standards. It involves analyzing the code for readability, maintainability,
efficiency, and correctness. Code reviews can be conducted using various techniques like
pair programming, formal inspections, or informal walkthroughs.
Hardware Testing: Hardware testing involves testing the microcontroller code on the
actual hardware platform to ensure its compatibility and functionality. It verifies whether
the code interacts correctly with the hardware peripherals and external devices. Hardware
testing may include techniques like boundary scan testing, in-circuit testing, or functional
testing using hardware-in-the-loop (HIL) setups.
Regression Testing: Regression testing is performed to ensure that changes or
modifications in the microcontroller code do not introduce new defects or break existing
functionality. It involves retesting previously tested functionalities to validate their
correctness after modifications. Regression testing can be done manually or automated
using regression testing frameworks or tools.

59
3.2 Identifying and rectifying problems, faults and bugs in
microcontroller device

Microcontroller devices are widely used in a variety of applications, from simple


appliances to complex systems. However, like any other electronic device,
microcontrollers can sometimes experience problems, faults, or bugs that can affect their
performance or functionality. Identifying and rectifying these issues is crucial to ensure
the proper functioning of the device. In this section, we will discuss the steps to identify
and rectify problems, faults, and bugs in a microcontroller device.

1. Troubleshooting Techniques: The first step in identifying and rectifying problems,


faults, and bugs in a microcontroller device is to use troubleshooting techniques. These
techniques involve systematically testing the device to identify the source of the problem.
Some common troubleshooting techniques include:
* Power-on self-test (POST): This involves testing the device's power supply, memory,
and input/output (I/O) pins to ensure they are functioning properly.
* Functional testing: This involves testing the device's functionality by running a series of
tests to ensure that it is performing as expected.
* Logic analysis: This involves analyzing the device's logic to identify any errors or
inconsistencies.
* Signal analysis: This involves analyzing the device's signals to identify any issues with
the signal integrity.
2. Debugging Tools: Debugging tools are software tools that help identify and rectify
problems, faults, and bugs in a microcontroller device. These tools provide a range of
features, such as:
* Debugging interfaces: These interfaces allow developers to connect their devices to a
computer and debug their code in real-time.
* Debugging software: This software provides a range of tools for debugging, such as
breakpoints, watchpoints, and data tracing.
* Debugging protocols: These protocols provide a standardized way of communicating
with the device during debugging.

60
Some common debugging tools for microcontroller devices include:
* GDB (GNU Debugger): This is a popular debugging tool for C and C++ programs.
* Visual Studio Code: This is a versatile integrated development environment (IDE) that
includes a built-in debugger.
* Keil µVision: This is a comprehensive debugging tool for ARM-based
microcontrollers.
3. Common Problems and Faults: Some common problems and faults that can occur in
microcontroller devices include:
* Hardware faults: These can include issues with the device's hardware, such as faulty
components or damage to the circuit board.
* Software bugs: These can include issues with the device's software, such as errors in
the code or compatibility issues with other software.
* Power-related issues: These can include issues with the device's power supply, such as
overvoltage or undervoltage.
To rectify these issues, developers can use a range of techniques, such as:
* Replacing faulty components: This can involve replacing components that are damaged
or not functioning properly.
* Updating software: This can involve updating the device's software to the latest version
to fix bugs or compatibility issues.
* Adjusting power settings: This can involve adjusting the device's power settings to
ensure that it is receiving the correct amount of power.
In conclusion, identifying and rectifying problems, faults, and bugs in a microcontroller
device requires a systematic approach using troubleshooting techniques and debugging
tools. By understanding the common problems and faults that can occur in these devices,
developers can take steps to rectify them and ensure the proper functioning of their
devices.

61
3.3 Writing intermediate and final work reports for microcontroller
code development and testing

Writing work reports for microcontroller code development and testing is an essential
part of the software development process. These reports serve as documentation of the
work done, providing a detailed account of the development process, testing procedures,
and results obtained. They are crucial for maintaining transparency, facilitating
collaboration among team members, and ensuring the reproducibility of the work.
When writing intermediate and final work reports for microcontroller code development
and testing, it is important to follow a structured approach. Here are some key steps to
consider:

1. Introduction:
- Provide a brief overview of the project and its objectives.
- Explain the significance of microcontroller code development and testing in achieving
those objectives.
- Clearly state the scope and limitations of the report.
2. Methodology:
- Describe the tools, programming languages, and frameworks used in the development
process.
- Explain the overall architecture of the microcontroller system.
- Detail the steps taken to develop and test the code.
- Discuss any specific methodologies or algorithms employed.
3. Implementation:
- Present a high-level overview of the implemented code structure.
- Provide code snippets or pseudocode to illustrate key functionalities.
- Explain any design patterns or best practices followed during implementation.
- Discuss any challenges encountered during implementation and how they were
addressed.

62
4. Testing:
- Describe the testing strategy employed, including unit tests, integration tests, and
system tests.
- Present test cases used to validate different aspects of the code.
- Discuss test results, including both successful outcomes and any identified issues or
bugs.
- Explain how issues were debugged and resolved.
5. Results and Analysis:
- Summarize the overall performance of the microcontroller code.
- Present quantitative and qualitative results obtained from testing.
- Analyze the results in relation to the project objectives.
- Discuss any limitations or areas for improvement identified during the testing phase.
6. Conclusion:
- Summarize the key findings and achievements of the project.
- Reflect on the overall success of the microcontroller code development and testing
process.
- Discuss any lessons learned or recommendations for future work.
7. References:
- Include a list of all references cited throughout the report, following a consistent citation
style (e.g., APA, MLA).
When writing work reports, it is important to maintain clarity, conciseness, and accuracy.
Use appropriate technical terminology and provide sufficient details to allow readers to
understand and reproduce the work. Additionally, consider including visual aids such as
diagrams, charts, or graphs to enhance understanding.
In conclusion, writing intermediate and final work reports for microcontroller code
development and testing is crucial for documenting the development process, facilitating
collaboration, and ensuring reproducibility. By following a structured approach and
including all relevant information, these reports serve as valuable resources for both
current and future projects.

63
3.4 Presenting intermediate and final work reports for microcontroller
code development and testing

When it comes to presenting a technical report on microcontroller code development and


testing, there are several key elements that should be included to ensure that the report is
comprehensive and effective. In this article, we will explore the essential components of
a technical report on microcontroller code development and testing, as well as some tips
for presenting the report in a clear and concise manner.

Introduction: The introduction section of the report should provide background


information on the project, including the purpose and objectives of the code development
and testing. This section should also include a brief overview of the microcontroller
hardware and software used in the project.

Theory: The theory section of the report should provide a detailed explanation of the
algorithms and techniques used in the code development and testing. This section should
also include a discussion of any challenges or obstacles encountered during the
development process, and how these were overcome.

Methodology: The methodology section of the report should describe the approach taken
to develop and test the microcontroller code. This section should include a detailed
description of the tools and equipment used, as well as any testing procedures or
protocols followed.

Results: The results section of the report should present the findings of the code
development and testing, including any data or performance metrics collected. This
section should also include a discussion of the results, including any successes or failures,
and how they relate to the project objectives.

Conclusion: The conclusion section of the report should summarize the main findings of
the code development and testing, and provide recommendations for future
improvements or enhancements. This section should also include a discussion of any
limitations of the study, and any potential applications or implications of the research.

64
References: The references section of the report should list all of the sources used in the
development of the code and the preparation of the report. This should include any
technical papers, books, or online resources used in the development process.

Appendices: The appendices section of the report should include any supplementary
materials that were not included in the main body of the report. This could include source
code, circuit diagrams, or other technical documents that support the findings of the
report.
Tips for Presenting a Technical Report on Microcontroller Code Development and
Testing:
When presenting a technical report on microcontroller code development and testing,
there are several key things to keep in mind to ensure that the report is effective and easy
to understand. Here are some tips to help you present your report in a clear and concise
manner:
1. Use clear and concise language throughout the report, avoiding technical jargon or
complex terminology that may be difficult for non-technical readers to understand.
2. Use headings and subheadings to break up the report into logical sections, making it
easier for readers to follow along.
3. Include plenty of visual aids, such as diagrams, flowcharts, and graphs, to help
illustrate the concepts and ideas discussed in the report.
4. Use bullet points or numbered lists to present multiple items or ideas in a clear and
organized manner.
5. Provide clear and concise explanations of any technical terms or concepts that are used
in the report.
6. Use active voice instead of passive voice to make the report more engaging and easier
to read.
7. Proofread the report carefully to ensure that there are no errors or typos.
By following these tips, you can create a clear and concise technical report on
microcontroller code development and testing that effectively communicates the results
of your research and development efforts.

65
Self check 3.1

PART I. Choose the correct answer for the following question


1. One of testing procedures commonly used to analyze developed microcontroller code that
focuses on testing individual units or components of the microcontroller code
A. Integration testing B. Unit testing C. Functional testing D. Performance testing
2. A testing procedures commonly used to analyze developed microcontroller code which is
performed to test the interaction between different units or components of the
microcontroller code is?
A. Integration testing B. Unit testing C. Functional testing D. Performance testing
3. One of testing procedures commonly used to analyze developed microcontroller code that
testing evaluates how well the microcontroller code performs under specific conditions
and workload
A. Hardware testing B. Regression testing C. Unit testing D. Performance testing
4. A testing procedures commonly used to analyze developed microcontroller code that
verifies whether the microcontroller code meets the specified functional requirements.
A. Hardware testing B. Regression testing C. Functional testing D. Unit testing
5. A testing procedures commonly used to analyze developed microcontroller code that is a
technique that examines the microcontroller code without executing it
A. Static code analysis C. Code review
B. Hardware testing D. Regression testing
PART II. Short answer question
1. List and explain some common troubleshooting techniques in a microcontroller device.
2. For what purpose regression testing is performed to analyze developed microcontroller
code?
3. List and explain some common debugging tools for microcontroller devices include
4. List and explain Some common problems and faults that can occur in microcontroller
devices include?
5. List and explain key steps to consider when writing intermediate and final work reports
for microcontroller code development and testing
6. Describe some tips for presenting the report in a clear and concise manner to presenting a
technical report on microcontroller code development and testing

66
Operation sheet 3.1:

 Operation title: Testing the codes to control the speed of a DC motor using
microcontroller.
 Purpose: The purpose of these operation for students to be able to:
1. Test the developed codes for microcontroller to control the speed of a DC motor
2. Wire the circuit and components.
 Instruction: Using the codes below and given equipment’s to Wire the circuit and
components and test codes for microcontroller to control the speed of a DC motor using
microcontroller. You have given 90 minutes for the task.
#include
#include
#include
#include "motor.h"
// Motor speed control function
void motorSpeedControl(int speed) {
// Calculate the PWM duty cycle based on the desired speed
int dutyCycle = speed * 100 / 255;
// Set the PWM output to the calculated duty cycle
analogWrite(motorPWM Pin, dutyCycle);
}
int main() {
// Initialize the motor
motorInit();
// Set the motor speed to 50%
motorSpeedControl(50);
// Wait for 5 seconds
delay(5000);
// Increase the motor speed to 75%
motorSpeedControl(75);
// Wait for another 5 seconds
delay(5000);

67
// Decrease the motor speed to 25%
motorSpeedControl(25);
// Wait for the final 5 seconds
delay(5000);
// Disable the motor
motorDisable();
return 0;
}
```

 Tools and equipment:


 Arduino UNO
 Breadboard
 DC motor
 PWM
 Wires (Jumper Wires)
Steps in doing the operation
d. Connect the components with Arduino board using bread board
e. Write the codes for control the speed of a DC motor
f. Simulate the code for checking free of errors
g. Upload the developed codes to Arduino hardware
e. Powered the Arduino board and observe the operation of control the speed of a
DC motor
 Quality Criteria: Correct wiring of component and use calibrated multimetere
 Precautions: use PPE and follow OHS.

68
Operation sheet 3.2:

 Operation title: To create an automatic bottle filling system using Arduino Uno
Purpose: The purpose of these operation for students to be able to:
1. Test the developed codes for microcontroller to automatic bottle filling system
2. Wire the circuit and components.
 Instruction: Using the codes below and given equipment’s to Wire the circuit and
components and test codes for microcontroller to automatic bottle filling system using
microcontroller (Arduino Uno). You have given 180 minutes for the task.
```scss
#include
#include
#include

// Define the pins for the ultrasonic sensor and servo motor
const int trigPin = 2;
const int echoPin = 3;
const int servoPin = 3;

// Define the variables for the ultrasonic sensor and servo motor
float distance = 0;
int servoPosition = 0;

// Define the LCD display


LiquidCrystal_I2C lcd(I2C_ADDR, 20, 4);

void setup() {
// Initialize the ultrasonic sensor and servo motor
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(servoPin, SERVO);

69
// Initialize the LCD display
lcd.begin(20, 4);
}

void loop() {
// Read the distance from the ultrasonic sensor
distance = pulseIn(echoPin, HC_SR04_TRG_PIN, HC_SR04_ECHO_PIN);

// Adjust the servo motor position based on the distance


servoPosition = map(distance, 0, 100, 0, 180);
servoWrite(servoPin, servoPosition);

// Fill the bottle with the desired amount of liquid


fillBottle(distance);

// Show the filling level on the LCD display


lcd.setCursor(0, 0);
lcd.print("Filling Level: ");
lcd.print(distance);
lcd.print(" cm");

// Wait for a short period of time before taking the next reading
delay(1000);
}

void fillBottle(float distance) {


// Calculate the amount of liquid to fill the bottle
int amount = (distance * 100) / 10;

// Fill the bottle with the calculated amount of liquid


// (you can use a pump or a pouring mechanism to fill the bottle)

70
}
```

 Tools and equipment:


 Arduino UNO
 Breadboard
 Servo motor
 Ultrasonic object sensor HC_SR04
 Wires (Jumper Wires)
Steps in doing the operation
a. Connect the components with Arduino board using bread board
b. Write the codes for control the speed of a DC motor
c. Simulate the code for checking free of errors
d. Upload the developed codes to Arduino hardware
e. Powered the Arduino board and observe the operation of control the speed of a
DC motor
 Quality Criteria: Correct wiring of component and use calibrated multimetere
 Precautions: use PPE and follow OHS.

71
LAP Test 3.1

Practical Demonstration (Develop and test code for an automatic bottle filling
system using Arduino Uno)

Name: _______________________ Date: ____________


Time started: __________________ Time finished: _________
Instruction I: Given necessary templates, tools and materials you are
required to perform the following tasks within 1 hours.

 Task-1: Gather Required Materials.


 Task-2: Connect the Components.
 Task-3: Write the Code
 Task-4: Test the Code
 Task-5: Write down your own report

72
References:

1. "Microcontroller Programming Languages" by Circuit Basics


(<https://circuitbasics.com/microcontroller-programming-languages/>)
2. "Programming Microcontrollers: An Overview of Popular Languages" by Hackster.io
(<https://www.hackster.io/news/programming-microcontrollers-an-overview-of-popular-
languages-1a9c8e8e68ee>)
3. "The Best Programming Languages for Microcontrollers" by Make:
(<https://makezine.com/projects/the-best-programming-languages-for-microcontrollers/
>)
4. International Electrotechnical Commission. (2017). Safety requirements for electrical
equipment and systems. IEC 60079-0:2017.
5. Occupational Safety and Health Administration. (n.d.). Electrical safety. Retrieved from
<https://www.osha.gov/SLTC/electricalstandards/electrical_safety.html>
6. National Institute for Occupational Safety and Health. (2018). Workplace safety and
health topics: Electrical hazards. Retrieved from
<https://www.cdc.gov/niosh/topics/electrical-hazards.html>
7. "Best Practices for Microcontroller Programming" by Microchip Technology. (n.d.).
Retrieved from <https://www.microchip.com/wwwproducts/en/microcontroller-best-
practices>
8. "Coding Standards for Embedded Systems" by Embedded Systems Academy. (n.d.).
Retrieved from <https://embeddedsystemsacademy.com/coding-standards-for-embedded-
systems/>
9. "Microcontroller Programming: Best Practices and Techniques" by Circuit Basics. (n.d.).
Retrieved from <https://circuitbasics.com/microcontroller-programming-best-practices-
techniques/>
10. "Microcontroller Basics" by John Crisp
- This book provides a comprehensive introduction to microcontrollers, covering their
functions, features, architecture, programming techniques, and applications.
11. "The 8051 Microcontroller and Embedded Systems" by Muhammad Ali Mazidi, Janice
Gillispie Mazidi, and Rolin D. McKinlay

73
- This book focuses on the 8051 microcontroller, one of the most widely used
microcontrollers in the industry. It covers its functions, features, programming, and
interfacing with external devices.
12. "Embedded Systems: Introduction to Arm Cortex-M Microcontrollers" by Jonathan W.
Valvano
- This book specifically focuses on Arm Cortex-M microcontrollers, providing a detailed
understanding of their functions, features, programming, and real-time applications.
13. "Embedded Systems - Architecture, Programming, and Design" by Raj Kamal
- This book provides comprehensive information on embedded systems, including
microcontroller programming and design principles.
14. "The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors" by Joseph Yiu
- This book focuses on ARM Cortex-M processors commonly used in microcontroller
applications and provides detailed insights into their architecture, programming, and
development tools.
15. "Microcontroller Programming: The Microchip PIC" by Julio Sanchez and Maria P.
Canton
- This book specifically covers microcontroller programming using Microchip's PIC
microcontrollers, offering practical examples and explanations of the programming
concepts involved.
16. "The Art of Assembly Language Programming" by Randall Hyde - This book is widely
regarded as a comprehensive guide to assembly language programming and covers
various aspects including microcontroller programming using assembler.
17. "Embedded Systems - Introduction to Microcontrollers" by Texas Instruments
(www.ti.com)
18. "Microcontroller Testing and Debugging" by Colin Walls (www.embedded.com)
19. "Microcontroller Testing: A Comprehensive Guide for Beginners" by Circuit Digest
(www.circuitdigest.com)
20. "Designing Microcontroller Systems" by Frank Vahid and Tony Givargis. This book
provides a comprehensive guide to designing microcontroller systems, including
techniques for analyzing and solving problems.

74
21. "Microcontroller Programming and Applications" by J. R. K. Prasad. This book covers
the basics of microcontroller programming and provides examples of how to apply
microcontrollers in various applications.
22. "Embedded Systems: A Contemporary Design Tool" by Frank Vahid and Tony
Givargis. This book provides a comprehensive guide to embedded systems design,
including techniques for analyzing and solving problems.
23. "Microcontroller Testing and Validation Techniques" - IEEE Xplore
24. "Code Review Best Practices" - Stack Overflow
25. "Traceability in Software Development" - International Journal of Computer Science
and Information Technologies
26. "Microcontroller Troubleshooting and Debugging" by R. L. Jamison and J. E. F. F. B.
M. Oliveira, published in the Proceedings of the 2017 International Conference on
Control, Automation and Information Sciences (CAIS).
27. "Debugging Techniques for Microcontrollers" by A. K. Singh and P. K. Singh,
published in the International Journal of Advanced Research in Computer Science and
Software Engineering.
28. "Microcontroller Debugging Using GDB" by S. K. Singh and A. K. Singh, published in
the International Journal of Scientific Research in Computer Science and Technology.

Web sites

1. www.embedded.com
2. www.microcontrollertips.com
3. www.eetimes.com
4. www.microchip.com - Microchip Technology Inc., a leading provider of microcontroller
solutions.
5. www.st.com - STMicroelectronics, a global semiconductor company offering a wide
range of microcontrollers.
6. www.nxp.com - NXP Semiconductors, a major player in the microcontroller market with
a diverse portfolio of products.

75
7. www.atmel.com - Atmel Corporation is another prominent manufacturer of
microcontrollers and provides comprehensive information about assembler programming
on their website.
8. Embedded.com: Embedded.com is a leading online resource for embedded systems
professionals. It provides articles, tutorials, and technical information related to
microcontrollers, embedded software development, and testing procedures.
9. Microchip Technology: Microchip Technology is a renowned semiconductor
manufacturer specializing in microcontrollers and other embedded systems solutions.
Their website offers comprehensive documentation, application notes, and whitepapers
on microcontroller development and testing.
10. IEEE Xplore: IEEE Xplore is a digital library that provides access to a vast collection
of technical articles, conference papers, and standards related to various engineering
disciplines. It includes valuable resources on microcontroller testing methodologies and
best practices.

76

You might also like