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

Activity No.

1
Setting up and Programming Controllers
Course Code: CPE006 Program: ECE
Course Title: Microprocessor Systems Date Performed: 02/04/22
Section: ECE32S2 Date Submitted:
Name/s: Instructor:
Tangub, Ernest Matthew M. Vergara, Chelsea Kaye C. Engr. Mark Nelson E.
Tenorio, Daryl Josh D. Zarzoso, Edeline J. Pangilinan
Tomas, Maria Isabelle Arianne O.
1. Objective:
This activity aims to demonstrate the concept of programming 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 Compile and upload a processor source code
2.3 Identify errors and Debug issues in a source code for LED control.
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.

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 LEDs 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.

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

Figure 1. Schematic Diagram


Test Program (All LED’s) Circuit design Start Simulating | Tinkercad

Figure 2.1. OFF STATE

Figure 2.2. ON STATE


Figure 2.3. C++ CODE

Program 3A (Circuit design PROGRAM 3A | Tinkercad)

Figure 3.1.A. OFF STATE


Figure 3.2.A. ON STATE

Figure 3.3.A. C++ CODE


Figure 3.4.A.
Program 3B (Circuit design PROGRAM 3B | Tinkercad)

Figure 3.1.B. OFF STATE

PIN 9 PIN 5

PIN 8 PIN 4

PIN 7 PIN 3

PIN 6 PIN 2

Table 3.1 ON STATE


Figure 3.2.B. C++ CODE

Figure 3.3.B.
Program 3C (Circuit design PROGRAM 3C | Tinkercad)

Figure 3.1.C. OFF STATE

Figure 3.2.C.1. ON STATE (ODD)

Figure 3.2.C.2. ON STATE (EVEN)


Figure 3.4.C. C++ CODE
Figure 3.4.D.
Test Results

There were no errors


detected in gathering data
for current and voltage.
Furthermore, the value
result is accurate.

7. Discussion of Results

In this activity, the main objective is to simulate, demonstrate, and analyze different codes for setting
up a programmable microprocessor system and identifying an error in the program.

Each program code uses built-in functions in the TinkerCad such as pinMode, digitalWrite and delay
which were used to simulate the given tasks. In the program codes, the function pinMode was used to
assign a specific pin to operate as in input or output. On the other hand, the function digitalWrite was
used to control the output from the Arduino pins. In the simulation codes, the function was applied to
set the value of the digital pins to HIGH (5V) or LOW (0V). Another function used is the delay, this
function delays the execution of the next line of code.

For the first procedure, our group was assigned to build and simulate our own circuit with 8 L.E.D.s
and 8 resistors that are connected to a microcomputer device which is Arduino Uno R3, and to test
whether the 8 L.E.D.s will turn ON simultaneously. The difference in function between the OFF and ON
states of the LED is seen in Figures 2.1 and 2.2. Because there is no lighting in the LEDs in Figure 2.1,
there is no current or voltage flowing through the wires. Figure 2.2, on the other hand, appears to show
a change in the status of LEDs. As we simulate the software, it turns on the LEDs. The codes we used
in the program are shown in Figure 2.3.
The aim for program 3A was to turn on just the ODD lights. Because we have eight bulbs, only the
numbers 1,3,5,7 will turn on, while the EVEN numbers (2,4,6,8) will remain off. To turn the odd leds on,
we simply utilized the digitalWrite function. The LEDs blink one at a time in program 3B, and it also
cycles back once it completes the sequence. To achieve a better result, we additionally use a 500-
millisecond delay. For the void setup and void loop, we implemented increment. It enables us to
reduce the length of our program's code while also reducing the number of errors that may occur.
Program 3C is similar to program 3A, and we also used the digitalWrite function to light up the LEDs.
but we must alternately blink the EVEN and ODD numbers. When the EVEN numbers blink, the ODD
numbers are in the off state, and when the ODD numbers blink, the EVEN numbers will go in the off
state. We can adequately replicate it with the aid of C++.

Lastly, for the supplemental activity, the goal is to create a program similar to program 3B, however
this program utilizes 14 LED pins connected to the breadboard and Arduino Uno. Each pin lights up
from LED 0-13 and will be looped back to light up from LED pins 13-0. This sequence was created by
modifying the codes used in 3B and utilizing the function digitalWrite in order for the LED pins to repeat
itself back, running from pin 13-0.

The voltage measured when the pins are ON state is 4.85V while in its OFF state is 0V. Consequently,
the measured current when ON and OFF state is 2.96mA and 0mA, respectively. As for the identified
program code error, the issue encountered while creating the program is mostly the missing
semicolons that should be placed at the end of each line code, other than that, no further errors or
debugs were encountered in the program codes.

8. Conclusion

In this Simulation Activity, we were able to be familiar with the Tinkercad circuit, which was used as a
circuit editor to successfully demonstrate the concept of programming a microprocessor-based
system. The components used for this activity are as follows LED, Breadboard, Arduino Resistors.
The Breadboard was used in wiring the components such as LED, Arduino, and Resistors. The
constructed program C++ code came from the Arduino Uno circuit that is directly wired to the
breadboard which displays the output program on the LED pins.

The programs for 3A,3B, and 3C were manipulated according to their assigned performance. The
program for 3A aims to display the LED pins in ODD numbers. On the other hand, program 3B
displays the LED pins blinking one at a time from pins 2-9. For program 3C, it displays the alternate
blinking of ODD and EVEN LED pins. To easily understand the program flow and to show the
methods used in each C++ program, we made use of a flowchart that displays the process for the
program code. In addition, the difference on the ON and OFF voltage and current state of the LED
pins was determined according to the test result gathered. To conclude, this simulation illustrates the
micro-based system's software code. It also intends to introduce techniques for testing and detecting
flaws in the developed program.
9. Assessment Task

Circuit design Supplementary Code | Tinkercad

Figure 4.1. Supplementary

Figure 4.1. C++ Code


10. Task Distribution

Member Distribution

Tangub, Ernest Matthew M. Program, Discussion, Flowchart

Tenorio, Daryl Josh D. Program, Discussion, Flowchart

Tomas, Maria Isabelle Arianne O. Program, Documentation, Flowchart

Vergara, Chelsea Kaye C. Program, Conclusion, Flowchart

Zarzoso, Edeline J. Program, Documentation, Conclusion

Test All Link

https://www.tinkercad.com/things/cWRPA4HyDvo-start-
simulating/editel?lessonid=EHD2303J3YPUS5Z&projectid=OIYJ88OJ3OPN3EA&collectionid=OIYJ88
OJ3OPN3EA&sharecode=wcXHRCUNBBex9fTJt2KUT7Nl90p_Ptxd1Y6mY570bSk

Program 3A Link

https://www.tinkercad.com/things/4orBccMf6K3-magnificent-luulia-
krunk/editel?sharecode=JZHcboscOnu840cBlWKNvO5t9Rpufb9v6yqEUqqk41Q

Program 3B Link

https://www.tinkercad.com/things/dyVeMMcr8rO-smooth-wluff-
fulffy/editel?sharecode=nJ3EpmaXotefgmm2CGyrYUJZt8sa63dC8HbDXUOZ7CA

Program 3C Link

https://www.tinkercad.com/things/669HVkjR0iU-c-odd-
even/editel?sharecode=t904bVitegjDJFGonr4LgGEImtyJ1m5bTzWiWrB6vQc

Supplementary Link

https://www.tinkercad.com/things/8Nq62yPsGC4-supplemental-
code/editel?sharecode=Mab5xpS62OhRuuo5hHvJ3edDjKnunPlGIguwKP4ESdA

You might also like