You are on page 1of 57

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES-QUEZON CITY

LABORATORY ACTIVITY
MANUAL
CPE006 – MICROPROCESSOR SYSTEMS
Engr. Cris Paulo G. Hate
Engr. Maria Cecilia A. Venal
Table of Contents
Fabricating a Simple Microcomputer ......................................................................................................... 2
Setting up Controllers ................................................................................................................................. 9
Mathematical Operations using Number Systems ................................................................................. 14
Controller Operations using Floating Point ............................................................................................ 20
Memory and Storage Reduction Using Arrays........................................................................................ 25
Digital Operations ...................................................................................................................................... 31
Analog Operations..................................................................................................................................... 37
Clocking ..................................................................................................................................................... 43
Analog Control using Pulse Width Modulation ....................................................................................... 48
Design of Experiments .............................................................................................................................. 55

1
Activity No. 1
Fabricating a Simple Microcomputer Board
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This laboratory activity aims to describe the Design and Fabrication a microcomputer main board powered
by a mid-level microcontroller device. The board will serve as the test bench for all the succeeding
laboratory activities.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
2.1 Analyze a block diagram of a microcomputer and translate it to a working schematic
diagram
2.2 Apply a software tool for designing a circuit diagram and circuit layout
2.3 Test a circuit board in terms of connectivity
2.4 Write a test program to validate the functionality of a designed circuit board.

3. Discussion :
A microcomputer is a complete computer on a smaller scale and is generally a synonym for the more
common term, personal computer or PC, a computer designed for an individual. A microcomputer contains
a microprocessor (a central processing unit on a microchip), memory in the form of read-only memory and
random access memory, I/O ports and a bus or system of interconnecting wires, housed in a unit that is
usually called a motherboard.

In an ascending hierarchy of general computer sizes:

 An embedded systems programming computer, which is embedded in something and doesn't


support direct human interaction but nevertheless meets all the other criteria of a microcomputer
 Microcomputer workstation , as used to mean a more powerful personal computer for special
applications
 Minicomputer , now restyled a "mid-range server"
 Mainframe or mainframe computer, which is now usually referred to by its manufacturers as a
"large server"
 Supercomputer, formerly almost a synonym for "Cray supercomputer" but now meaning a very
large server and sometimes including a system of computers using parallel processing
 Parallel processing system is a system of interconnected computers that work on the same
application together, sharing tasks that can be performed concurrently

As large-scale integration and then very-large-scale integration have progressively increased the number of
transistors that can be placed on one semiconductor chip, so the processing capacity of microcomputers
using such single chips has grown commensurately. During the 1980s microcomputers came to be used
widely in other applications besides electronic game systems and other relatively simple computer-based
recreations. Increasingly powerful microcomputers began to be used in personal computer systems and

2
workstations, for instance. High-performance microcomputer systems are used widely in business, in
engineering, in “smart” or intelligent machines employed in the factory and office, and in military electronics
systems.

In the early 1990s, small computers that fit in a pocket yet provide the power of a desktop personal
computer were introduced. These pocket, or palm-sized, computers, commonly known as personal digital
assistants (PDAs), are distinguished by their high portability, enhanced performance, and low cost.
Similarly, microprocessors began finding their way into cellular telephones and portable MP3 music
players.

As personal computers started including multiple processors in the 2000s, microcomputer began to be
relegated to descriptions of small “embedded” computers found in various electronic devices.
4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
Instructions:
1. Illustrate the circuit diagram of the board based on the chips pin-configuration and the
following block diagram. Illustrate the circuit in the following section.

2. Convert the schematic diagram into a circuit board layout artwork using fabrication
software. Attach the layout in the succeeding section.
3. Fabricate and assemble the circuit board. Attach an image of the fabricated board on the
section provided.
4. Test the components connectivity using multi-meter. Use the table provided in the
following section for the results.
5. Program the chip with a simple blink function using a single LED. Write the source code in
the space provided in the following section.

3
6. Test the programs timing by varying and measuring the delay intervals of each blink. Use
the table provided in the following section for the results.
7. Move the LED and rewrite the code to match the position of the LED. Identify if the pin is
functional or not. Use the table provided in the following section for the results.
6. Results
Pin Configuration

Schematic Diagram

4
Circuit Layout

Fabricated Board

5
Connectivity Test Results
Positive Probe Negative Probe Reading Remarks
Vcc Pin 1
Ground Pin 1

Test Program – BLINK

6
Timing Test Results
Programmed Delay Actual Delay Remarks
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

Pin State Testing


Pin Number State Remarks
1
2
3

7. Observations

7
8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

8
Activity No. 2
Setting up Controllers
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to introduce the concept of programming and operation of a microprocessor based
system. Another aim of this activity is to introduce procedures in testing and identification of errors in a
program.

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:


2.1 Write a functional program for a microprocessor based system
2.2 Identify errors and Debug issues in a source code for LED control.
2.3 Test the voltage passing through an output transducer from the controller

3. Discussion :

In essence, the word programming means giving a mechanism the directions to accomplish a task. If you
are like most people, you’ve already programmed several mechanisms, such as your digital video recorder
(DVR), cell phone, or coffee maker. Like these devices, a computer also is a mechanism that can be
programmed. The directions (typically called instructions) given to a computer are called computer
programs or, more simply, programs.

Programmers use a variety of special languages, called programming languages, to communicate with the
computer. Some popular programming languages are C++, Visual Basic, C#, Java, and Python. In this
book, you will use the C++ programming language.

Designing and implementing processor programs is different and more challenging than writing typical
workstation or PC programs. The code must not only provide rich functionality, it must also often run at a
required rate to meet system deadlines, fit into the allowed amount of memory, and meet power
consumption requirements.

Designing code that simultaneously meets multiple design constraints is a considerable challenge, but
luckily there are techniques and tools that can be used to help through the design process. Making sure
that the program works is also a challenge, but once again methods and tools such as flowcharts and
pseudo codes simplify the algorithm writing procedures.

In mathematics, computer science, and related subjects, an algorithm is a finite sequence of steps
expressed for solving a problem. An algorithm can be defined as “a process that performs some
sequence of operations in order to solve a given problem”. Algorithms are used for calculation, data
processing, and many other fields.

9
In computing, algorithms are essential because they serve as the systematic procedures that computers
require. A good algorithm is like using the right tool in the workshop. It does the job with the right amount of
effort.

4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or_________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
1. Configure and connect the circuit to the microcomputer device. Each of the individual LED’s are
connected to a unique output pin as seen in the following block diagram. Draw the circuit diagram
on the Results section.

2. Test the function of each digital pin by turning ON all the LED’s in the system. Write the program in
the Results section.
3. Write a flowchart and program that controls the activity of LED bulbs. The program should be able
to perform the following, separately:
a. Turn on only the bits at the ODD position.

b. Blink one bulb at a time, and then repeat when finished.

10
c. Alternately blink odd and even bulbs with a 100 millisecond interval on a continuous loop.

4. Write the source code in the space provided in the following section and include comments in the
source code.
5. Take note of possible bugs in the program. Cite your detections in the observations.
6. Using a Digital Multi-meter, test the operating voltages and currents of the microcontrollers’ pins.
Write the findings in the table provided in the following section.

6. Results
Circuit Diagram

Test Program(All LED’s)

11
Program 3A

Program 3B

Program 3C

12
Test Results
Pin Number Voltage when HIGH Voltage when LOW Remarks
1
2
3
4
5
6
7
8

7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

13
Activity No. 3
Mathematical Operations using Number Systems
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to explain the application of mathematical operations and different number systems in
microprocessor and microcontroller based systems.

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:


2.1 Develop a number systems conversion program for a microprocessor based system
2.2 Use digital inputs as a binary data to be used as data for mathematical operations.
2.3 Test and evaluate the created program.

3. Discussion :
A numeral system (or system of numeration) is a writing system for expressing numbers; that is, a
mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent
manner. It can be seen as the context that allows the symbols "11" to be interpreted as the binary symbol
for three, the decimal symbol for eleven, or a symbol for other numbers in different bases.

The number the numeral represents is called its value. Ideally, a numeral system will:

Represent a useful set of numbers (e.g. all integers, or rational numbers)


Give every number represented a unique representation (or at least a standard representation)
Reflect the algebraic and arithmetic structure of the numbers.

For example, the usual decimal representation of whole numbers gives every nonzero whole number a
unique representation as a finite sequence of digits, beginning by a non-zero digit. However, when decimal
representation is used for the rational or real numbers, such numbers in general have an infinite number of
representations, for example 2.31 can also be written as 2.310, 2.3100000, 2.309999999..., etc., all of
which have the same meaning except for some scientific and other contexts where greater precision is
implied by a larger number of figures shown.

Numeral systems are sometimes called number systems, but that name is ambiguous, as it could refer to
different systems of numbers, such as the system of real numbers, the system of complex numbers, the
system of p-adic numbers, etc.
In a positional base-b numeral system (with b a natural number greater than 1 known as the radix), b basic
symbols (or digits) corresponding to the first b natural numbers including zero are used. To generate the
rest of the numerals, the position of the symbol in the figure is used. The symbol in the last position has its
own value, and as it moves to the left its value is multiplied by b.

For example, in the decimal system (base 10), the numeral 4327 means (4×103) + (3×102) + (2×101) +

14
(7×100), noting that 100 = 1.

In general, if b is the base, one writes a number in the numeral system of base b by expressing it in the
form anbn + an − 1bn − 1 + an − 2bn − 2 + ... + a0b0 and writing the enumerated digits anan − 1an − 2 ...
a0 in descending order. The digits are natural numbers between 0 and b − 1, inclusive.

If a text (such as this one) discusses multiple bases, and if ambiguity exists, the base (itself represented in
base 10) is added in subscript to the right of the number, like this: numberbase. Unless specified by
context, numbers without subscript are considered to be decimal.

By using a dot to divide the digits into two groups, one can also write fractions in the positional system. For
example, the base-2 numeral 10.11 denotes 1×21 + 0×20 + 1×2−1 + 1×2−2 = 2.75.

In general, numbers in the base b system are of the form:

The numbers bk and b−k are the weights of the corresponding digits. The position k is the logarithm of the
corresponding weight w, that is . The highest used position is close to the order of
magnitude of the number.

Note that a number has a terminating or repeating expansion if and only if it is rational; this does not
depend on the base. A number that terminates in one base may repeat in another (thus 0.310 =
0.0100110011001...2). An irrational number stays aperiodic (with an infinite number of non-repeating digits)
in all integral bases. Thus, for example in base 2, π = 3.1415926...10 can be written as the aperiodic
11.001001000011111...2.

Putting overscores, n, or dots, ṅ, above the common digits is a convention used to represent repeating
rational expansions. Thus:

14/11 = 1.272727272727... = 1.27 or 321.3217878787878... = 321.32178.

If b = p is a prime number, one can define base-p numerals whose expansion to the left never stops; these
are called the p-adic numbers.

4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

15
5. Procedures:
1. Create an MCU program that is able to convert a number to its binary equivalent. Display the
operation and the result serially tins a computer. Write the source code in the following section.

2. Test the program using different data types and values as input. Modify the code to fit different data
types that are needed. Cite your findings using the table found in the following section.

3. Configure and connect the circuit to the microcontroller device. Each of the individual LED’s are
connected to a unique output pin as seen in the following block diagram. Draw the circuit diagram
on the Results section.

4. Note your observations in the section provided.

6. Results
Conversion Program for Integer

16
Conversion Program for Character

Conversion Program for Float

17
Conversion Program for Byte

Program Testing 1
Data Resulting Value Remarks
15
24.1
11.8
11.9
25
-17.5
53
99102

Program Testing 2
Data Type Value Resulting Value
Integer
Integer
Char
Char
Float
Float
Byte
Byte

18
7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

19
Activity No. 4
Controller Operations using Floating Point
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to emphasize the substance of floating point numbers when utilized in a microprocessor
based system. It also introduces how floating point is applied in the manipulation of analog data.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Write a code for a microprocessor based system that uses analog devices
2.2 Build a circuit which accepts analog data from an analog device
2.3 Store analog data to a floating point variable, and perform operations involving these
numbers.
2.4 Compare floating point and integer data type in terms of accuracy.

3. Discussion :
Floating-point arithmetic is arithmetic using formulaic representation of real numbers as an approximation
so as to support a trade-off between range and precision. For this reason, floating-point computation is
often found in systems which include very small and very large real numbers, that of which require fast
processing times. A number is, in general, represented approximately to a fixed number of significant digits
(the significand) and scaled using an exponent in some fixed base; the base for the scaling is normally two,
ten, or sixteen. A number that can be represented exactly is of the following form:

significand x baseexponent

where significand is an integer (i.e., in Z), base is an integer greater than or equal to two, and exponent is
also an integer. For example:

1.2345 = 12345 x 10-4

The term floating point refers to the fact that a number's radix point (decimal point, or, more commonly in
computers, binary point) can "float"; that is, it can be placed anywhere relative to the significant digits of the
number. This position is indicated as the exponent component, and thus the floating-point representation
can be thought of as a kind of scientific notation.

A floating-point system can be used to represent, with a fixed number of digits, numbers of different orders
of magnitude: e.g. the distance between galaxies or the diameter of an atomic nucleus can be expressed
with the same unit of length.

The result of this dynamic range is that the numbers that can be represented are not uniformly spaced; the
difference between two consecutive representable numbers grows with the chosen scale.

20
Over the years, a variety of floating-point representations have been used in computers. However, since
the 1990s, the most commonly encountered representation is that defined by the IEEE 754 Standard.

The speed of floating-point operations, commonly measured in terms of FLOPS, is an important


characteristic of a computer system, especially for applications that involve intensive mathematical
calculations.

A floating-point unit (FPU, colloquially a math coprocessor) is a part of a computer system specially
designed to carry out operations on floating-point numbers.
4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
Instructions:
1. Build a circuit that accepts and analog devices (i.e potentiometers or sensors), and represent
the data in an LCD or Serial Monitor.

2. Illustrate the circuit diagram at the following section. Refer to the following architecture as a
reference:

3. Code an algorithm that accepts the input of a single sensor. Use INT as the data type for the
data measured. Test the code multiple times by varying the resistance of the potentiometer.
Write down the source code in the INT data section.

4. Code an algorithm that accepts the input of a single sensor. Use floating point as the data type
for the data measured. Test the code multiple times by varying the resistance of the
potentiometer. Write down the source code in the FLOAT data section.

5. Compare the readings of each mode and take note of the differences in the behavior of both
codes.

6. Rewrite the source code such that it accepts and displays the actual value of the potentiometer
using the measured ratio. Record your data in the table located in the results and compare the
accuracy with multi-meter.

21
6. Results
Schematic Diagram

Source Code for Tester Reading(INT)

Table of Results for Function Test(INT)


Trial Tester Reading Controller Reading Remarks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Average

22
Source Code for Tester Reading(FLOAT)

Table of Results for Function Test(FLOAT)


Trial Tester Reading Controller Reading Remarks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Average
Source Code for Accuracy Test

23
Table of results for Accuracy Test
Trial Tester Reading Controller Reading %Difference
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Average

7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

24
Activity No. 5
Memory and Storage Reduction Using Arrays
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity is aimed to introduce the concept of improving memory and storage states of programs using
an array data structure. The activity also aims to show the comparison between different data types used in
arrays.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
2.1 Write a program that can operate using an Array Data Structure for data storage
2.2 Compare the size of source codes implementing arrays from codes that does not.
2.3 Differentiate the storage and memory consumption of different data types in arrays.

3. Discussion :
An array is a data structure, which can store a fixed-size collection of elements of the same data type. An
array is used to store a collection of data, but it is often more useful to think of an array as a collection of
variables of the same type.

Instead of declaring individual variables, such as number1, number2, ..., number99, you just declare one
array variable number of integer type and use number1[0], number1[1], and ..., number1[99] to represent
individual variables. Here, 0, 1, 2, .....99 are index associated with var variable and they are being used to
represent individual elements available in the array.

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and
the highest address to the last element.

To create an array variable in C, a programmer specifies the type of the elements and the number of
elements to be stored in that array. Given below is a simple syntax to create an array in C programming −

type arrayName [ arraySize ];

25
This is called a single-dimensional array. The arraySize must be an integer constant greater than zero and
type can be any valid C data type. For example, now to declare a 10-element array called number of type
int, use this statement −

int number[10];

Here, number is a variable array, which is sufficient to hold up to 10 integer numbers. You can initialize an
array in C either one by one or using a single statement as follows −

int number[5] = {10, 20, 30, 40, 50};

The number of values between braces { } cannot be larger than the number of elements that we declare for
the array between square brackets [ ]. If you omit the size of the array, an array just big enough to hold the
initialization is created. Therefore, if you write −

int number[] = {10, 20, 30, 40, 50};

You will create exactly the same array as you did in the previous example. Following is an example to
assign a single element of the array

number[4] = 50;

The above statement assigns element number 5th in the array with a value of 50. All arrays have 0 as the
index of their first element which is also called the base index and the last index of an array will be the total
size of the array minus 1. The following image shows the pictorial representation of the array we discussed
above –

An element is accessed by indexing the array name. This is done by placing the index of the element within
square brackets after the name of the array. For example −

int var = number[9];

The above statement will take the 10th element from the array and assign the value to var variable.
4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:

26
Instructions:
1. Configure and connect the circuit to the microcomputer device. Each of the individual LED’s are
connected to a unique output pin as seen in the following block diagram. Draw the circuit diagram
on the Results section.

2. Test the function of each digital pin by turning ON all the LED’s in the system. Use separate
variables for identifying the individual output pins. Write the program in the Results section.

3. Compile and assemble the source code. Identify the size consumed by the machine code on the
storage.

4. Rewrite the source code such that it uses a single array, and loops recursively through the array to
identify the digital pins using the array index.

5. Write the source code in the space provided in the following section.

6. Compare the storage consumption of the two source codes.

7. Vary the source code such that the program manipulates different types of data. Refer to the table
in the succeeding section as reference. Note your observations in the space provided in the
activity.

6. Results
Schematic Diagram

27
Source Code(Without Array)

Source Code(Using Array)

28
Variations in Data type and Array size
Data Type Array Length Contents File Size
Integer 2
Integer 5
Integer 8
Integer 10
Integer 13
Byte 2
Byte 5
Byte 8
Byte 10
Byte 13
Float 2
Float 5
Float 8
Float 10
Float 13

7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

29
30
Activity No. 6
Digital Operations
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to demonstrate the different simple and complex digital I/O operations in a microcontroller
based system. Included in the activity is the programming of a source code for processing digital data.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Write a code for a microprocessor based system that implements digital input activities in a
microcontroller based system.
2.2 Design a circuit that accepts digital transducer data, process and then display digital
output.

3. Discussion :
Digital I/O stands for Digital Input and Output. Digital Inputs allow a microcontroller to detect logic states,
and Digital Outputs allow a microcontroller to output logic states.

A digital input detects if a voltage is above/below a specific threshold. If the voltage is higher than some
value, the computer will detect the digital input as high/set/1. If the voltage is lower than some value, the
computer will detect the digital input as low/clear/0.

A digital output allows you to control a voltage with a computer. If the computer instructs the output to be
high, the output will produce a voltage (generally about 5 or 3.3 volts). If the computer instructs the output
to be low, it is connected to ground and produces no voltage.

In contrast to analog transducers that sense continuous variables such as pressure and temperature, many
transducers provide an output that is one of two states: high or low, open or closed. A pressure might be
too high or a temperature too low, triggering closure of a switch. Outputs, too, are not strictly analog-
solenoid valves typically are opened or closed, many pumps and heaters are simply turned on or off. Pulse
signals are another form of digital I/O, with one rotation of a turbine flowmeter or tachometer corresponding
to a single, countable event. Digital I/O also can be used for parallel communications among plug-in
expansion cards, and to generate clock and other timing signals.

Already in the binary language of computers, these types of digital, or discrete, inputs and outputs (I/O) are
much easier for microprocessor-based data acquisition systems to deal with than analog signals. Similar to
analog-to-digital converters used for analog I/O, digital I/O is designed to deal directly with transistor-to-
transistor logic (TTL) level voltage changes. TTL typically sets the low voltage level between 0 and 0.8 V
and the high voltage level between 2.0 and 5.0 V. Voltage levels between 0.8 and 2.0 V are not allowed. A
voltage change, then, from the high range to the low range (or vice versa) represents a digital change of
state from high to low, on to off, etc.

31
And because acquiring an analog signal is more complex than acquiring a digital one, analog I/O channels
also are more expensive. Hence, if digital I/O is adequate, do not bother with analog.

Many types of digital input signals from switch closures, relay contacts, or TTL-compatible interfaces can
be read directly by digital I/O cards. Other types of inputs may require some signal conditioning, most likely
to reduce higher-level voltage changes to TTL levels. A variety of signal conditioning modules are available
to provide isolation and other digital conditioning functions.

4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
1. Identify which segments of the seven segment display transducer should be set active for
the number range 0 to F.

2. Build a microcontroller based computer based on the following system architecture. Draw
the schematic diagram in the succeeding section.

32
3. Program the code such that it is able to display data from 0 to F in hexadecimal format,
based on the numerical equivalent of the switches. Write down the source code in the
succeeding section.

4. Modify the source code such that it is able to map digital sensor values from a proximity
sensor into a set of discrete, hexadecimal values( 0-F) Write down the source code in the
following section.

5. Identify which is the range for each discrete value and write down your findings in the
succeeding section.

6. Results
Seven Segment Checklist
Digit A B C D E F G
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

33
Switch & Seven Segment Schematic Diagram

Switch & Seven Segment Code

Digital Sensor & Seven Segment Schematic Diagram

34
Digital Sensor and Seven Segment Range Testing
Digit MIN MAX Range Size
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
7. Observations

8. Conclusions and Lessons Learned

35
9. Assessment (Rubric for Laboratory Performance):

36
Activity No. 7
Analog Operations
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to demonstrate the different simple and complex analog input and apply various
mathematical operations using on a microcontroller system. Covered in this activity also is the
implementation and programming of source code that can process data from analog sensors.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Write a program for a microprocessor based system that is compatible with digital sensors
and transducers.
2.2 Design a circuit that accepts analog transducer data, process and then display digital
output.
2.3 Compare actual readings from analog devices to values being processed by the program.
2.4 Write a simple analog-to-digital program capable of encoding analog data to a set of
discrete sets of digital values.
3. Discussion :
Digital computers and other microprocessor-based devices have replaced analog recording and display
technologies in all but the simplest data acquisition applications. And while computers have had an
undeniably positive impact on the practice of data acquisition, they speak only a binary language of ones
and zeroes. Manufacturing processes and natural phenomena, however, are still by their very nature
analog. That is, natural processes tend to vary smoothly over time, not discontinuously changing states
from black to white, from on to off.

To be meaningfully recorded or manipulated by a computer then, analog measurements such as pressure,


temperature, flow rate, and position must be translated into digital representations. Inherently digital events,
too, such as the tripping of a motor or a pulse generated by a positive displacement flowmeter, must be
made interpretable as a transistor-to-transistor logic (TTL) level changes in voltage. Hence, the origination
and ongoing development of input/output (I/O) systems (Figure 1-1) for converting analog and digital
information about real-world processes and events into the language of computers.

37
Most sensors for measuring temperature, pressure, and other continuous variables provide a continuously
varying electrical output to represent the magnitude of the variable in question. To make this signal
interpretable by a microprocessor, it must be converted from a smooth continuous value to a discrete,
digital number.

This analog-to-digital (A/D) conversion process poses two primary challenges: one of quantization and one
of sampling in time. Quantization refers to the uncertainty introduced upon conversion of an analog voltage
to a digital number. Measurement transducers or transmitters typically provide continuously varying signals
between 0-10 V dc, ±5 V dc, 0-100 mV dc, or 4-20 mA dc. Thermocouples and resistance temperature
devices (RTDs) are other common low voltage inputs.

When this analog value is represented as a digital number, however, this essentially continuous resolution
is limited to discrete steps. This resolution of an A/D conversion often is stated in terms of bits-the more bits
the finer the resolution. The number of bits determines the number of divisions into which a full-scale input
range can be divided to approximate an analog input voltage. For example, 8-bit resolution of a 0-10 V
input signal means that the range is divided into 28 = 256 steps. This yields a step, or interval, size of 10
V/256 = 0.039 V. Thus, a 10-V input is equal to the digital number 255 and a 0-V input corresponds to 0.
Each 0.039-V change in the input is indicated by adding or subtracting 1 from the previous number. (For
example, 9.961 V is digitally represented by 254.)

38
Digital data acquisition systems not only quantize data in terms of magnitude; time, too, is parceled into
discrete intervals. In general, there is no information about the behavior of the process between data points
gathered. Special precautions, then, must be taken to ensure no meaningful data is lost and interpolation
between recorded points remains a valid assumption.

4. Resources:
The activity will require the following software, tools and equipment:
2.1 Desktop Computer
2.2 Dev C/C++/Processing
2.3 Multisim or _________________________________________________
2.4 Other tools: __________________________________________________
5. Procedures:
1. Design the circuit such that it matches the following architecture. Draw your schematic
diagram of the circuit on the space provided.

2. Write a program that can accept a data input from a single analog device. Store the data in
an integer variable. Write your source code in the following section.

3. Vary the actual value of the device and record the values in the table provided in the
following section. Identify the ratio between the actual value and the measured value.

4. Connect the analog transducer to an oscilloscope probe. Illustrate the readings in the
space provided in the section below.

5. Rewrite the program and include the conversion process for the controller to display the
actual values of the analog device. Write the source code in the following section.

6. Results
Schematic Diagram

39
Source code for Analog Input

Test Results for Analog Input


Trial Actual Value Measured Value Ratio
1
2
3
4
5
6
7
8
9
10
AVERAGE
Modified Source Code with Conversion

40
Oscilloscope Readings

Test Results for Analog Input with Conversion


Trial Actual Value Measured Value % Difference
1
2
3
4
5
6
7
8
9
10
AVERAGE
7. Observations

41
8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

42
Activity No. 8
Clocking
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity intends to introduce the function of clock circuits in computing systems and their effect in the
operation of a program. The activity also aims to introduce an alternative for standard clock systems such
as oscillators and resonators.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Assemble a circuit that can use either a crystal oscillator or a ceramic resonator for timing.
2.2 Write a code for a microprocessor based system that can be used to test the clock-related
operations of a system.
2.3 Compare and contrast the function of crystal oscillators and ceramic resonators through
different testing procedures.

3. Discussion :
A clock generator is a circuit that produces a timing signal (known as a clock signal and behaves as such)
for use in synchronizing a circuit's operation. The signal can range from a simple symmetrical square wave
to more complex arrangements. The basic parts that all clock generators share are a resonant circuit and
an amplifier.

The resonant circuit is usually a quartz piezo-electric oscillator(a), although simpler tank circuits and even
RC circuits(b) may be used.The amplifier circuit usually inverts the signal from the oscillator and feeds a
portion back into the oscillator to maintain oscillation.

Other such optional sections include frequency divider or clock multiplier sections. Programmable clock
generators allow the number used in the divider or multiplier to be changed, allowing any of a wide variety
of output frequencies to be selected without modifying the hardware.

The clock generator in a motherboard is often changed by computer enthusiasts to control the speed of
their CPU, FSB, GPU and RAM. Typically the programmable clock generator is set by the BIOS at boot

43
time to the selected value; although some systems have dynamic frequency scaling, which frequently re-
programs the clock generator.

Most integrated circuits (ICs) of sufficient complexity use a clock signal in order to synchronize different
parts of the circuit, cycling at a rate slower than the worst-case internal propagation delays. In some cases,
more than one clock cycle is required to perform a predictable action. As ICs become more complex, the
problem of supplying accurate and synchronized clocks to all the circuits becomes increasingly difficult. The
preeminent example of such complex chips is the microprocessor, the central component of modern
computers, which relies on a clock from a crystal oscillator. The only exceptions are asynchronous circuits
such as asynchronous CPUs.

A clock signal might also be gated, that is, combined with a controlling signal that enables or disables the
clock signal for a certain part of a circuit. This technique is often used to save power by effectively shutting
down portions of a digital circuit when they are not in use, but comes at a cost of increased complexity in
timing analysis.

Some sensitive mixed-signal circuits, such as precision analog-to-digital converters, use sine waves rather
than square waves as their clock signals, because square waves contain high-frequency harmonics that
can interfere with the analog circuitry and cause noise. Such sine wave clocks are often differential signals,
because this type of signal has twice the slew rate, and therefore half the timing uncertainty, of a single-
ended signal with the same voltage range. Differential signals radiate less strongly than a single line.
Alternatively, a single line shielded by power and ground lines can be used.

In CMOS circuits, gate capacitances are charged and discharged continually. A capacitor does not
dissipate energy, but energy is wasted in the driving transistors. In reversible computing, inductors can be
used to store this energy and reduce the energy loss, but they tend to be quite large. Alternatively, using a
sine wave clock, CMOS transmission gates and energy-saving techniques, the power requirements can be
reduced.
4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
1. Assemble the circuit such that it meets the specifications based on the following block diagram.
Use a crystal oscillator for clocking the system. Illustrate your schematic diagram in the space
provided in the following section.

44
2. Write a source code such is able to control and toggle an LED bulb at a fixed interval of 1000
milliseconds. Write the source code in the space provided in the succeeding section.

3. Measure the actual time consumed by each interval using an oscilloscope or stopwatch. Record
your findings in the table provided in the results section.

4. Increment the intervals by 1000 and repeat step 3 until the table provided is accomplished.

5. Replace the Crystal oscillator circuit with a ceramic resonator of the same frequency. Draw the
schematic diagram in the, and then repeat step 3 and 4 respectively.

6. Note your observations in the space provided.

6. Results
Schematic Diagram for Crystal Oscillator Circuit

45
Source Code

Timing Results using Crystal Oscillator


Program Interval Actual Interval % Difference
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

Schematic Diagram for Resonator Circuit

46
Timing Results using Resonator Circuit
Program Interval Actual Interval % Difference
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

47
Activity No. 9
Analog Control using Pulse Width Modulation
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:
This activity aims to explore the control of analog devices using the Clock Duty Cycle technique. The
activity covers the Pulse Width Modulation function in computing systems.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Assemble a circuit that accepts analog input, process it, and produce analog output.
2.2 Write a code for a microprocessor based system that implements a controllable analog
output transducer.

3. Discussion :
A duty cycle is the fraction of one period in which a signal or system is active. Duty cycle is commonly
expressed as a percentage or a ratio. A period is the time it takes for a signal to complete an on-and-off
cycle. As a formula, a duty cycle (%) may be expressed as:

D = PW/T x 100

Equally, a duty cycle (ratio) may be expressed as:

D = PW/T

Where D is the duty cycle, PW is the pulse width (pulse active time), and T is the total period of the signal.
Thus, a 60% duty cycle means the signal is on 60% of the time but off 40% of the time. The "on time" for a
60% duty cycle could be a fraction of a second, a day, or even a week, depending on the length of the
period.

Duty cycles can be used to describe the percent time of an active signal in an electrical device such as the
power switch in a switching power supply or the firing of action potentials by a living system such as a
neuron.

Duty cycle is the percentage of the ratio of pulse duration, or pulse width (PW) to the total period (T) of the
waveform. It is generally used to represent time duration of a pulse when it is high (1). In digital electronics,
signals are used in rectangular waveform which are represented by logic 1 and logic 0. Logic 1 stands for
presence of an electric pulse and 0 for absence of an electric pulse. For example, a signal (10101010) has
50% duty cycle, because the pulse remains high for 1/2 of the period or low for 1/2 of the period. Similarly,
for pulse (10001000) the duty cycle will be 25% because the pulse remains high only for 1/4 of the period
and remains low for 3/4 of the period. Electrical motors typically use less than a 100% duty cycle. For
example, if a motor runs for one out of 100 seconds, or 1/100 of the time, then, its duty cycle is 1/100, or 1

48
percent.

Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a modulation technique used to


encode a message into a pulsing signal. Although this modulation technique can be used to encode
information for transmission, its main use is to allow the control of the power supplied to electrical devices,
especially to inertial[definition needed] loads such as motors. In addition, PWM is one of the two principal
algorithms used in photovoltaic solar battery chargers, the other being maximum power point tracking.

The average value of voltage (and current) fed to the load is controlled by turning the switch between
supply and load on and off at a fast rate. The longer the switch is on compared to the off periods, the higher
the total power supplied to the load.

The PWM switching frequency has to be much higher than what would affect the load (the device that uses
the power), which is to say that the resultant waveform perceived by the load must be as smooth as
possible. The rate (or frequency) at which the power supply must switch can vary greatly depending on
load and application.

The average analog output from a PWM device can be calculated by using the expression:

Y = (D x Ymax) + Ymin(1 - D)

Where Y is the average output of the system, D is the duty cycle. Ymax and Ymin are the upper and lower
extremities of the output transducer.

4. Resources:
The activity will require the following software, tools and equipment:
4.1 Desktop Computer
4.2 Dev C/C++/Processing
4.3 Sketch/Flowcode
4.4 Multisim or _________________________________________________
4.5 Other tools: __________________________________________________

5. Procedures:
1. Configure and connect the components such that it fit sthe following diagram. Illustrate the circuit in
the following section.

2. Write a program that utilizes PWM to programmatically dim an LED bulb. Utilize a duty cycle of
50% in the program. Write the program in the space provided in the succeeding section.

49
3. Use an oscilloscope to observe the waveform being generated by the controller. Take note of your
observations.

4. Rewrite the source code such that the device accepts an input of 0% to 100% duty cycle. Write the
source code in the space provided in the following section.

5. Vary the duty cycle and illustrate the waveform generated. Take note of your observations.

6. Results
Circuit Diagram

Basic PWM Source Code

50
Illustration of Oscilloscope Readings

Variable PWM Source Code

51
Test Results for PWM
PWM % Duty Cycle Ratio Waveform

10

20

30

40

50

52
60

70

80

90

100

7. Observations

53
8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

54
Activity No. 10
Design of Experiments
Course Code:CPE006 Program:
Course Title: Microprocessor Systems Date Performed:
Section: Date Submitted:
Name/s: Instructor:

1. Objective:

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
1. Design a Microprocessor based embedded system capable of multiple inputs and outputs.
2. Write a functioning program for the system to accept, process, and display the data.
3. Conduct experimentation procedures to determine the validity of the system.

3. Discussion:

4. Resources:

5. Procedures:

6. Results

7. Observations

8. Conclusions and Lessons Learned

9. Assessment (Rubric for Laboratory Performance):

55
56

You might also like