Your SlideShare is downloading. ×
ESL report
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

ESL report

502
views

Published on

DC motor control using MATLAB

DC motor control using MATLAB

Published in: Education, Technology, Business

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
502
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. College of Engineering Course: ESL CId: 10938 Prepared by Salman Khaliq Bajwa (3746) Project Advisor Engr. Mohazzab College of EngineeringPAF – Karachi Institute of Economics and Technology Karachi 1
  • 2. PREFACEThis project is a comprehensive study of the MATLAB, a programming language. It tells us theuse and commands of MATLAB. This project is intended to use in engineering and computerscience. This project utilizes electronic concepts that can be helpful in understanding theelectronic principles and the use of MATLAB. This project deals with the various numbercircuits and used in electronic systems. This project provides a very deep understanding ofMATLAB software with standard circuit designing.ACKNOWLEDGEMENTI would like to express my gratitude to all those who gave me the possibility to complete thisproject. I want to thank my course instructor Mr. Mohazzab Jawaid for giving me permission towork on this project. Furthermore thanks to my engineering lab staff that gave and confirmedthis permission and encouraged me to go ahead with my project. I am bound to the Honorabledirector of engineering for giving me such opportunity to work with our capabilities freely. I amdeeply indebted to Mr. Mohazzab Jawaid whose help, stimulating suggestions andencouragement helped me in all the time of making this project. My friends from the Departmentof engineering supported me in my project. I want to thank them for all their help, support,interest and valuable hints. Especially I am obliged to my seniors. I also want to thank to our labin charge for all his assistance on the ministerial computer. Our teachers was of great help indifficult times I will like to thanks each and every person, who helped and supported me andgave time to this project. 2
  • 3. Table of ContentsPREFACE ....................................................................................................................................... 21. Objective & Puposes: .................................................................................................................. 4 Objective: ……………………………………………………………………………4 Purpose:………………………………………………………………………………42. Description:…………………………………………………………………………………..4-5 DC Motor………………...…………………………………………………………..4 Parallel Port Interfacing:……………………………………………………………..43. Working……………………………………………………………………………………..….54. MATLAB Program Code…………………………………………………………………….7-65. GUI……………………………………………………………………………………………..8Conclusion 3
  • 4. 1. Objective & Purpose:Objective:To design an application in order to control the DC motor and LEDs using GUI based MATLABprogram through Parallel Port.Purpose:To understand and be familiar of the commands of MATLAB software and the need andimportance of this software in industry.2. Description:A small description of this project is that we would be interfacing the dc motor and some LEDsthrough parallel port using MATLAB software. Most of the coding will be done throughMATLAB. We will turn on and off the dc motor & LEDs. Some information about the ports andcomponents that I am using in this software is given below;DC Motor:A DC motor is an electric motor that runs on direct current (DC) electricity. DC motors are fairlysimple to understand. They are also simple to make and only require a battery or dc supply tomake them run.Parallel Port Interfacing:Parallel port is a simple and inexpensive tool for building computer controlled devices andprojects. The simplicity and ease of programming makes parallel port popular in electronicshobbyist world. The parallel port is often used in Computer controlled robots, Atmel/PICprogrammers, home automation etc. It takes 5 volts. It can send a large amount of data at a timebut when we talk about the larger distances we have to look at the serial port. This is actually thedrawback of parallel port that we cannot use it for large data transmission, but wirelessly we cando it.. 4
  • 5. Figure 1- Parallel Port Figure 3- data transmission3. Working: I have made a GUI based project. How it works is that it actually takes the input from the user and on and offs the DC motor and 3 LEDs. I am going to use four ports; port 1, port 2, port 3, port 4 and port 5 for that. It is actually a series circuit. Port 2 is for DC motor and Port 3, 4 and 5 are for LEDs. Step one of this project was to design a GUI for this project and then the second step was to interface that GUI with my hardware. 5
  • 6. 4. MATLAB Program Code: function varargout = pin_by_pin(varargin) %--------------------------------------| % Programmer: Salman Khaliq Bajwa | % Course: ESL | % Id: 3746 | % CId: 10938 | % E-mial: damigo88@yahoo.com | % Project: Parallel Port Interfacing | %--------------------------------------| gui_Singleton = 1; gui_State = struct(gui_Name, mfilename, ... gui_Singleton, gui_Singleton, ... gui_OpeningFcn, @pin_by_pin_OpeningFcn, ... gui_OutputFcn, @pin_by_pin_OutputFcn, ... gui_LayoutFcn, [] , ... gui_Callback, []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before pin_by_pin is made visible. function pin_by_pin_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to pin_by_pin (see VARARGIN) %*-*-*-*-*-*-*-*-*-*-*-*- pp=digitalio(parallel,LPT1); handles.dato=addline(pp,0:3,out); putvalue(handles.dato,0); %-*-*-*-*-*-*-*-*-*-*-**- % Choose default command line output for pin_by_pin handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes pin_by_pin wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = pin_by_pin_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) 6
  • 7. % Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in pin_2.function pin_2_Callback(hObject, eventdata, handles)a=get(handles.pin_2,Value);b=get(handles.pin_3,Value);c=get(handles.pin_4,Value);d=get(handles.pin_5,Value);m=[a b c d];out=binvec2dec(m);set(handles.text1,String,out)putvalue(handles.dato,out);% --- Executes on button press in pin_4.function pin_4_Callback(hObject, eventdata, handles)a=get(handles.pin_2,Value);b=get(handles.pin_3,Value);c=get(handles.pin_4,Value);d=get(handles.pin_5,Value);m=[a b c d];out=binvec2dec(m);set(handles.text1,String,out)putvalue(handles.dato,out);% --- Executes on button press in pin_3.function pin_3_Callback(hObject, eventdata, handles)a=get(handles.pin_2,Value);b=get(handles.pin_3,Value);c=get(handles.pin_4,Value);d=get(handles.pin_5,Value);m=[a b c d];out=binvec2dec(m);set(handles.text1,String,out)putvalue(handles.dato,out);% --- Executes on button press in pin_5.function pin_5_Callback(hObject, eventdata, handles)a=get(handles.pin_2,Value);b=get(handles.pin_3,Value);c=get(handles.pin_4,Value);d=get(handles.pin_5,Value);m=[a b c d];out=binvec2dec(m);set(handles.text1,String,out)putvalue(handles.dato,out); 7
  • 8. 5. GUI of the project: Figure 3- GUI Conclusion I can conclude that this project can be used for various purposes like for the interfacing of many other things like home appliances, Industries etc. This project helped me a lot in improving my typing skills and also my understanding the need MATLAB in market. References: [1 ] http://www.mathswork.com Topic: Parallel Port Interfacing | Visiting Date: 05/Feb/2011 © 1999-2010 mathswork.com Hong Kong Limited and licensors. All rights reserved. [2] http://www.wikipedia.com Topic: Parallel Port | Visiting Date: 11/March/2011 ©2002-2011, Wikipedia . All rights reserved. 8