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

MAPUA UNIVERSITY

SCHOOL OF MECHANICAL AND MANUFACTURING ENGINEERING

ME160P/OL51

CONTROL SYSTEMS ENGINEERING

WRITTEN REPORT ON

MICROCONTROLLERS

EXPERIMENT NO. 4

SUBMITTED BY:

DE RAMOS, RENEE

FEDERIS, JOSHUA PILLIP

MILLARES, JOSSEL MATTHEW

RODRIGUEZ, SHERWIN-RAIDEN JR.

SUMALBAG, MOON LOUIS

SUNMITTED TO:

ENGR. JULIAN ALBERT NOHAY

AUGUST 4, 2021

i
ABSTRACT
A microcontroller is an integrated circuit chip that is used to control various devices and
machines. The CPU, memory, input and output ports, serial ports, timers and controllers, ADC,
DAC, interrupt control, and special functional block are among the chip's nine essential
components. In this experiment, students used TinkerCad, an online software program, to complete
six activities that dealt with diverse mechanical and manufacturing systems that included the use
of microcontrollers. Some of the components used throughout the exercises are light-emitting
diode (LED), resistor, pushbutton, potentiometer, micro servo, and an Arduino connected to a
breadboard. The experiment also involved the use of coding, specifically code blocks which helped
students to accomplish the exercises easier. Thus, they were able to familiarize themselves with
the basic programming involved in applications of microcontrollers, specifically with the use of
code blocks. They were also able to construct basic electric circuits in the breadboard using the
beforementioned components. Lastly, upon completion of the placement of components and the
code blocks, they were able to use the microcontroller to control the circuit (breadboard) where
the mentioned components are placed.
Keywords: Microcontroller, Arduino, TinkerCad

ii
OBJECTIVES:
1. To be familiar with the basic microcontroller programming using Arduino
2. To construct basic electric circuits in a breadboard
3. To use a microcontroller to control circuits with LEDs, sensor, and motors

iii
TABLE OF CONTENTS

ABSTRACT .................................................................................................................................................. ii
OBJECTIVES: ............................................................................................................................................. iii
THEORIES AND PRINCIPLES .................................................................................................................. 1
DISCUSSION ............................................................................................................................................... 2
FINAL DATA SHEET / SET-UP ................................................................................................................. 3
CONCLUSION ............................................................................................................................................. 6
RECOMMENDATION ................................................................................................................................ 6
REFERENCES ............................................................................................................................................. 7
APPENDIX I. Tinkercad CircuitsText Codes .............................................................................................. 8

iv
THEORIES AND PRINCIPLES
Control System
Control engineering is a relatively recent field of study that expanded in prominence as
technology advanced during the twentieth century. It can be defined as the application of control
theory to real-world situations.
Its goal is to use mathematical modeling to understand physical systems in terms of inputs, outputs,
and various components with various behaviors; to design controllers for those systems using
control system design tools; and to integrate controllers into physical systems using available
technology. Calculating the error signal and then adjusting the system to achieve the intended
direction or impact are the core principles of a control system. If the system deviates too quickly,
the regulating mechanism is unable to contain the deviations, and the control system is unable to
adjust the trajectory or effect.
Industrial automation control systems are used to keep track of how machines are doing in
real time. The controller's input signal (RTU, PLCS, DCS) is used to update the control vector of
a closed loop system so that the device continues to try to follow the fixed point of operation.
The device controller is the graphical user interface described here. To adapt and maintain a
consistent procedure, the controller requires a suitable dynamic solution. If the handler cannot be
changed to a stable state, the control loop is said to be 'out of control' (i.e. with limited hunting).
A single closed loop control mechanism cannot sustain the process in highly complex systems.
When the process is moderately complicated and time-based, cascaded control loops can be used,
but for slow-moving processes like distillation, bioreactors, and so on, advanced process controls
are needed.

Graphical User Interface


A graphical user interface (GUI) is a set of visual components that interact with computer
programs. A graphical user interface (GUI) displays items that communicate data and represent
actions the user can perform. The color, scale, and visibility of the items vary as the user interacts
with them. GUI artifacts include things like icons, cursors, and buttons. These graphical elements
may also include sounds or visual effects such as transparency and drop shadows. These items
allow a user to use the system without having to know any commands.
A GUI uses windows, icons, and menus to carry out actions like opening, deleting, and
transferring data. Although a cursor is commonly used to control a GUI operating system, it is also
possible to use keyboard shortcuts or the arrow keys. On a GUI device, for example, you can move
the mouse pointer to the program's icon and double-click it to launch it. To navigate to the
program's directory, list the files, and then launch the file using a command line interface, you'll
need to know the commands.
A graphical user interface, such as MS-DOS or the shell of Unix-like operating systems, is
thought to be more user-friendly than a text-based command-line interface. To communicate with
virtually all aspects of the GUI, a pointing device, such as a mouse, is used. A touch screen is also
used on more modern (and mobile) devices.

1
DISCUSSION

For the Blinking LEDs, this circuit was created with the use of breadboard with Arduino.
The LEDs are well connected with their resistors to control the flow of current on each of the LED
preventing to be damaged. The LEDs have their respective colors assigned as indicators. In Button
Indication, the push button plays an important role in circuit for it indicated whether the other
components are functioning as well. It indicates whether the components are on when used and off
when not used. While in the next exercise, this program allows you to simulate the monitoring of
air properties with the help of breadboard simulation program to monitor temperature. In speed
control, this speed controller circuit was created with the use of breadboard with Arduino, 9v
battery with 5v regulator to prevent circuit explosion, push buttons for the control of its forward
and reverse motion, a potentiometer to control the speed of servo motor, a led bulb to indicate if
the circuit is running or not. And lastly a continuous servo motor that is under control of those
components that I’ve mentioned before. And lastly, for the Servo Motor Control, in this part we
use to add two servo motors for precision and control in movement. It symbolizes a steering wheel
where we put the potentiometer to control its movement. In the simulation, the two-servo motor
follows the direction of rotation of the potentiometer indicating its precision in control. Also, as a
bonus we are tasked to include more LEDs to help indicate the rise and drop of temperature when
run from the simulation. In our case we have put 9 LED’s 3 green, 3 yellow, and 3 red. Where
when we simulate in the tinker lab. When we slide the bar for the increase and decrease of
temperature, the light will follow the slider making it easier for the user to see if the temperature
is rising and declining in respect to the slider.

2
FINAL DATA SHEET / SET-UP

• Blinking LEDs

• Button Indication

3
• Temperature Measurement

• Speed Controller

4
• Servo Motor Controll

• Temperature Gauge

5
CONCLUSION
With the final data sheet, program codes, and basic electric circuits developed for
the given exercises, using Arduino Uno in Tinkercad, the researchers were able to
demonstrate and successfully complete the given objectives of the experiment, namely:
(1) To be familiar with the basic microcontroller programming using Arduino, (2) To
construct basic electric circuits in a breadboard, and (3) To use a microcontroller to
control circuits with LEDs, sensor, and motors

With the class demonstration of the first five (5) exercises and the help of the
provided laboratory manual, the researchers were able to create the sixth exercise which
functions as a temperature gauge. Despite the inability to conduct physically the
programming and utilization of actual Arduino Uno, breadboard, LEDs, sensors, and
motors, the ability of developing circuits on Tinkercad and being able to copy the code
and use it for programming an actual Arduino is deemed useful and beneficial, not just
for distance learning but also for simulation of circuits before building them on actual.

RECOMMENDATION
The most difficult aspect of performing exercises is becoming familiar with codes
function and techniques. Every coding or block purpose should be understood, as well as
what should be added to a component to complete a task because wrong configuration or
algorithm might hinder the desired output values.

The researchers should be able to familiarize the components to complete the


exercise accurately, especially if the researchers are new in terms of utilizing Tinker Cad,
and to grasp the algorithm techniques, conduct research on the things you don't
understand and apply the basic principles of the components. To be able to achieve good
outcomes, organize their work and follow the step-by-step approach.

6
REFERENCES

Wulff, A. (2019). Hackster.io. Retrieved from https://www.hackster.io/news/using-arduino-


microcontrollers-with-matlab-c5aaae2fc4c2

7
APPENDIX I. Tinkercad Circuit Text Codes

1. Blinking LEDs
// C++ code
//
int timeDelay = 0;

void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
timeDelay = 500;
digitalWrite(13, HIGH);
delay(timeDelay); // Wait for timeDelay millisecond(s)
digitalWrite(13, LOW);
delay(timeDelay); // Wait for timeDelay millisecond(s)
digitalWrite(12, HIGH);
delay(timeDelay); // Wait for timeDelay millisecond(s)
digitalWrite(12, LOW);
delay(timeDelay); // Wait for timeDelay millisecond(s)
digitalWrite(11, HIGH);
delay(timeDelay); // Wait for timeDelay millisecond(s)
digitalWrite(11, LOW);
delay(timeDelay); // Wait for timeDelay millisecond(s)

8
2. Button Indication
// C++ code
//
int timedelay = 0;

void setup()
{
pinMode(10, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(9, INPUT);
pinMode(11, OUTPUT);
}

void loop()
{
if (digitalRead(10) == 1) {
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
} else {
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
if (digitalRead(9) == 1) {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
} else {
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}
}
delay(10); // Delay a little bit to improve simulation performance
}

9
3. Temperature Measurement
// C++ code
//

void setup()
{
pinMode(10, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(A5, INPUT);
Serial.begin(9600);

pinMode(9, INPUT);
pinMode(11, OUTPUT);
}

void loop()
{
if (digitalRead(10) == 1) {
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");
delay(500); // Wait for 500 millisecond(s)
} else {
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
if (digitalRead(9) == 1) {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");
delay(500); // Wait for 500 millisecond(s)

10
} else {
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}
}
}

4. Speed Controller
// C++ code
//
#include <Servo.h>

Servo servo_8;

void setup()
{
Serial.begin(9600);

pinMode(10, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(A5, INPUT);
pinMode(A4, INPUT);
servo_8.attach(8, 500, 2500);

pinMode(9, INPUT);
pinMode(11, OUTPUT);
}

void loop()
{
Serial.println("hello world");

if (digitalRead(10) == 1) {
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");

11
servo_8.write((90 + map(analogRead(A4), 0, 1023, 0, 20)));
} else {
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
servo_8.write(90);
if (digitalRead(9) == 1) {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");
servo_8.write((90 - map(analogRead(A4), 0, 1023, 0, 20)));
} else {
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
servo_8.write(90);
}
}
delay(10); // Delay a little bit to improve simulation performance
}

5. Servo Motor Control


// C++ code
//
#include <Servo.h>

Servo servo_7;

Servo servo_8;

void setup()
{
pinMode(A3, INPUT);
servo_7.attach(7, 500, 2500);

pinMode(10, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(A5, INPUT);
Serial.begin(9600);

12
pinMode(A4, INPUT);
servo_8.attach(8, 500, 2500);

pinMode(9, INPUT);
pinMode(11, OUTPUT);
}

void loop()
{
servo_7.write((90 - map(analogRead(A3), 0, 1023, 1, 179)));
if (digitalRead(10) == 1) {
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");
servo_8.write((90 + map(analogRead(A4), 0, 1023, 0, 20)));
} else {
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
servo_8.write(90);
if (digitalRead(9) == 1) {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
Serial.print(-40 + 0.488155 * (analogRead(A5) - 20));
Serial.print("C|");
Serial.print(-40 + 0.878679 * (analogRead(A5) - 20));
Serial.print("F|");
Serial.print((273 + -40 + 0.488155 * (analogRead(A5) - 20)));
Serial.print("K|");
Serial.print((460 + -40 + 0.878679 * (analogRead(A5) - 20)));
Serial.println("R");
servo_8.write((90 - map(analogRead(A4), 0, 1023, 0, 20)));
} else {
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
servo_8.write(90);
}
}
delay(10); // Delay a little bit to improve simulation performance
}

13
6. Temperature Gauge
// C++ code
//

void setup()
{
pinMode(2, INPUT);
pinMode(A5, INPUT);
Serial.begin(9600);

pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
}

void loop()
{
if (digitalRead(2) == 1) {
Serial.println(-40 + 0.488155 * (analogRead(A5) - 20));
delay(100); // Wait for 100 millisecond(s)
if (-40 + 0.488155 * (analogRead(A5) - 20) <= -21.67) {
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= -3.35) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);

14
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 14.97) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 33.31) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 51.65) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 69.99) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);

15
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 88.33) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) <= 106.67) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
digitalWrite(3, LOW);
} else {
if (-40 + 0.488155 * (analogRead(A5) - 20) > 106.68) {
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
digitalWrite(3, HIGH);
}
}
}
}
}
}
}
}
}
}
}

16

You might also like