You are on page 1of 38

SRI RAMAKRISHNA ENGINEERING COLLEGE

[Educational Service : SNR Sons Charitable Trust]


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

Microprocessor & Microcontroller


12EI2606
Prepared by
Mr.S.Kaushik
AP/EIE
Mr.P.Arun Mozhi Devan
AP/EIE
Microcontroller ?

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 2


Microcontroller

• A microcontroller is a small computer on a single


integrated circuit.

• A microcontroller contains
– one or more processor
– memory and
– programmable input/output peripherals.

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 3


Microcontroller

• Microcontrollers are "embedded" inside some other


device (often a consumer product)

• Microcontrollers are dedicated to one task and run


one specific program.

• Microcontrollers are often low-power devices.

• A microcontroller is often small and low cost.


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 4
Computer Vs Microcontroller

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 5


Computer parts

Figure 1 Computer parts

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 6


CMOS & BIOS

Monitor

Hard Disk

Keyboard & Mouse


Mother Board
RAM

Printer & Speaker


CPU
Figure 2 Function of a computer
SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 7
Microcontroller

Figure 3 Function of a microcontroller

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 8


Microprocessor and Microcontroller

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 9


VS

Figure 4 Comparison between Microprocessor and Microcontroller


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 10
Microcontroller in a Control System

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 11


Simple feed back control
(Velocity control of flight jet)

Figure 5 F16 Flight jet


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 12
Open loop System

Pilot

Input : Output
Fuel flow rate for jet engine Velocity
Flight
Actuator
Engine
Figure 6 Open loop system for velocity control of flight jet

Velocity of flight is varied by adjusting thrust force

Thrust force may be varied by adjusting the fuel flow rate

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 13


Closed loop system
Input : Fuel flow rate

Flight Engine
Actuator
Set point : Velocity

Error

Controller

Output : Velocity
PV
Velocity :
Sensor

Figure 7 Closed loop system for velocity control of flight jet

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 14


Microcontroller
Input : Fuel flow rate

Flight Engine
Actuator
Set point : Velocity

Controller

Output : Velocity
Measured Velocity
Velocity :
Sensor

Figure 8 Function of a microcontroller in a closed loop system


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 15
Microcontroller : Arduino UNO

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 16


Arduino : PIN Diagram

Figure 9 Arduino pin diagram


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 17
Arduino : Specification

Table 1 Specification of Arduino UNO


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 18
Interfacing MATLAB & Arduino

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 19


Install Arduino support package

Figure 10 Install Arduino support package


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 20
UPLOAD ADIOES.PDE TO THE ARDUINO BOARD

1. Connect the Arduino, make sure that the


right board and serial port are selected in the
IDE, (Tools/Board and Tool/Serial Port) then
select

2. File -> Upload to I/O Board and wait for the


"Done Uploading" message

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 21


Step 1 :From the Arduino IDE, go to
File -> Open, locate the file adioes.pde

Figure 11 Open file adioes.pde in Arduino IDE


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 22
Step 2: Connect the Arduino, make sure that the right
board and serial port are selected in the IDE

Figure 12 Install adioes.pde using Arduino IDE


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 23
Matlab Command Window
• a=arduino('COM4')

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 24


Arduino UNO programming
in MATLAB

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 25


Connecting MATLAB & Board
a=arduino('COM4') // type in matab command window

Figure 13 Connecting Arduino IDE with MATLAB in COM4 port


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 26
Defining PIN mode : Input / Output
• Configure a pin no 13 as output
– pinMode(a,13,'output');

Figure 14 Configuring PinMode 13 of Arduino UNO to output


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 27
Turning on LED
• output the digital value (0 or 1) to pin 13
– digitalWrite(a,13,1);

Figure 15 Turning LED in 13th pin

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 28


Program procedure in MATLAB
% connect the board

% specify pin mode for selected pins

% read digital input

% output the digital value (0 or 1) to the


selected pin

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 29


Analog input

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 30


Connecting a potentiometer with
Arduino

Potentiometer PIN 1 : 5 V

Potentiometer PIN 2 : Analog


pin 2

Potentiometer PIN 3 : GND

Figure 16 Connecting potentiometer to Arduino UNO board


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 31
Program
clear all;
clc;
a=arduino('COM4'); % Connecting Arduino Uno board
pinMode(a,2,'input'); % defining 2 pin as analog input
interv= 1000; % Maximum time in seconds for data acquisition
passo=1; % Increment time
t=1; % initialize time
x=0;
while(t<interv)
Rref = 10000;
Vin = 5;
av=analogRead(a,2); % Reading the analog value at pin 2
Vout = (Vin * av) / 1023; % Converting to voltage value
R = (Rref * (1 / ((Vin / Vout)-1)))/1000;
x=[x,R];
plot(x);
axis([0,interv,0,10]);
grid
t=t+passo; % increment seconds
drawnow;
end

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 32


Analog Value

Value of the resistance in Ω 

Time in sec 

Figure 17 Output of the potentiometer plot with respective time in MATLAB


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 33
MATLAB GUI

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 34


SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 35
SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 36
SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 37
Thank you

SREC - EIE - 13/SEP/17 MATLAB for Aeronautical Engineers 38

You might also like