• Home
  • Prakash
    • R and D
    • Smart Home
  • Basics
    • Capacitors
      • Color codeing Disc Capacitor Capacitor characterstics Polarity Non Polarity Series Connection Parallel Connection
    • Diodes
      • Zener Diode Light Emitting Diode Signal Diode Photo Diode
    • Inductors
    • Transistor
      • Silicon Germenium NPN PNP MOSFET SCR
    • Resistors
      • Color codeing 4-Band 5-Band Series Parallel Potential Meter
    • Logics
      • Analog Logic
      • Digital Logic
      • Hexa Decimal Numbers
      • Octal Numbers
      • Binary Fraction
      • Binay to Decimal
    • OP-Amplifiers
      • Basics
      • Oscillators
      • Transistor Switch
      • 555 IC circuits
      • Waveform Generators
      • 741 IC Circuits
    • Power supply
      • Transformer
      • Halfwave Rectifier
      • Fullwave Rectifier
      • Bridge Rectifier
      • 78xx Series
      • 0 to 30v Regulator
  • Modules
    • H-Bridge
      • L293D Bridge
      • Relay Bridge
    • RF 434MHz Modules
    • Relay Modules
    • Push to ON switch
    • Push to OFF switch
  • Sensors
    • Analog sensors List-1
      • LDR Photo Diode Solar Cell Transducers Temperature Humidity Sensor Soil Moisture Ranger Sensor Range Detection
    • Analog sensors List-2
      • Flame Sensor Force Sensor Flex Sensor Ambient Sensor Motion Sensor Vibration Sensor Sound Sensor UltraSonic Sensor GrayScale Sensor
    • Digital Sensors
      • Touch Sensor Tilt Sensor Signal
    • 3-Axis Sensor
    • Gyro Sensor
  • Projects
    • Embedded
      • Mini Projects 8051 Arduino NodeMCU MSP430 Raspberry IOT ARM
    • C #
      • Visual Basic Visual Studio
    • Matlab
    • VLSI
    • PHP-HTML
    • Contribute
  • Downloads
  • Technology

Matlab GUI based controlled Car

This project presents the implementation of a MATLAB based graphical user interface (GUI) to control the movement of a robotic car. The commands to move the car in forward, reverse, right and left directions are sent from the GUI and processed by Arduino Uno board mounted on top of the car.
                                         Author’s prototype of the MATLAB GUI based robotic car

Circuit and working

In this project, MATLAB based GUI communicates with Arduino through a USB data cable. You can send commands to Arduino to move the car in a specific direction by pressing the corresponding push button in the GUI. The particular push button, when pressed, executes callback function corresponding to that push button in the MATLAB program, car.m. Within that function, instructions to set/reset the digital I/O pins (10, 11, 12 and 13) of Arduino are executed to drive the car in the desired direction.
 

Block and circuit diagrams for controlling the robot are shown in Figs 2 and 3, respectively.
Arduino Uno board. Arduino Uno is an AVR ATmega328P microcontroller (MCU) based development board with six analogue input pins and 14 digital I/O pins. The MCU has 32kB of ISP flash memory, 2kB SRAM and 1kB EEPROM. The board provides serial communication capability via UART, SPI and I2C. The MCU can operate at a clock frequency of 16MHz. In this project, digital I/O pins 10, 11, 12 and 13 of Arduino are configured as output pins.L293D IC. This is a dual H-Bridge high-current motor driver IC. This IC is used since the digital pins of Arduino Uno cannot source enough current to drive the motors of the robotic car. H-bridges are also useful in controlling the direction of rotation of a motor. Enable pins (pins 1 and 9) of the IC being active high are connected to 9V.
Four input pins IN1, IN2, IN3 and IN4 of L293D have been connected to digital I/O pins 10, 11, 12 and 13, respectively, of Arduino. Four output pins (OUT1, OUT2, OUT3 and OUT4) of the IC are connected to the two motors (M1 and M2) with their terminals marked as A, B, C and D, respectively 
                                         
Software program
Circuit operation is performed using the software program loaded into the internal memory of Arduino board. The program implements all required functionalities including user inputs through MATLAB GUI interface. The steps are listed below:
1. Arduino IDE 1.6.5 is used for programming Arduino Uno. The latest IDE can be downloaded for free from Arduino’s official website. After downloading Arduino IDE, install it. Note the directory of Arduino IDE installation.
2. Download Legacy MATLAB and Simulink Support for Arduino package from MathWorks website. Extract the compressed folder named ArduinoIO. From this folder, copy pde folder and paste it in C:\Program Files (or Program files x86)\Arduino\Libraries (path may be different depending on the installation directory of the IDE).
After pasting pde folder in correct location, open Arduino IDE. If you have pasted the folder in correct location, you would find pde in File→Examples→pde. Open the code by File→Examples→pde→ adioes.
3. Connect Arduino Uno board to your PC. From Device Manager, note the COM port at which Arduino Uno board is installed. From Tools menu in Arduino IDE, select the board as Arduino Uno and select the COM Port number noted earlier. Upload adioes code to Arduino Uno board by pressing Upload button in the IDE.
4. Copy the entire contents of the extracted ArduinoIO folder to a folder in My Documents (For Windows PC).
5. Our application program has been developed in R2014a version of MATLAB. After installing this version of MATLAB in your PC, open install_arduino.m file present in the directory where you have copied the contents of ArduinoIO folder. Now, run install_arduino.m file. This code will correctly install and save the path of Arduino support package.
6. Open the source code file for this project titled car.m. Edit the COM port [in the line a=arduino(‘COM9’)] with the port number in your PC where Arduino Uno board has been installed. After running the file, MATLAB will try to communicate with the board.
After successful communication is established, you can control the robot by pressing the appropriate pushbutton in the GUI.

Matlab code
function varargout = car(varargin)
% CAR MATLAB code for car.fig
%      CAR, by itself, creates a new CAR or raises the existing
%      singleton*.
%
%      H = CAR returns the handle to a new CAR or the handle to
%      the existing singleton*.
%
%      CAR('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CAR.M with the given input arguments.
%
%      CAR('Property','Value',...) creates a new CAR or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before car_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to car_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help car
% Last Modified by GUIDE v2.5 02-Jun-2016 14:31:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @car_OpeningFcn, ...
                   'gui_OutputFcn',  @car_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 car is made visible.
function car_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 car (see VARARGIN)
% Choose default command line output for car
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
clear a;
global a;
a = arduino('COM9');
a.pinMode(10,'output');
a.pinMode(11,'output');
a.pinMode(12,'output');
a.pinMode(13,'output');
% UIWAIT makes car wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = car_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)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a.digitalWrite(10,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
a.digitalWrite(13,1);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a.digitalWrite(10,1);
a.digitalWrite(11,0);
a.digitalWrite(12,1);
a.digitalWrite(13,0);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a.digitalWrite(10,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
a.digitalWrite(13,0);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a.digitalWrite(10,0);
a.digitalWrite(11,0);
a.digitalWrite(12,0);
a.digitalWrite(13,1);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a.digitalWrite(10,0);
a.digitalWrite(11,1);
a.digitalWrite(12,0);
a.digitalWrite(13,0);

Constructing and testing

An actual-size, single-side PCB for the circuit controlling the robotic car using MATLAB based GUI using Arduino is shown in Fig. 4 and its component layout in Fig. 5. Suitable connectors are provided on the PCB for input (CON1) from Arduino and output (CON2 and CON3) for motors.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Related Posts:

  • Refer ADC Why ADC/1024 is correct, and ADC/1023 is just plain wrong! It's common to need to scale a microcontroller ADC result to give a value in some othe… Read More
  • Project List     Update ...... … Read More
  • Arduino Temprature How to connect Temperature Sensor to Arduino Uno? The LM35 IC has 3 pins-2 for the power supply and one for the analog output.It is a low voltage … Read More
  • Simple Power Supply Simple power supply This circuit is very useful in beginners circuits, since most will work on 5v, which is the voltage of this easy little cir… Read More
  • RF 434 MHZ MODULES RF BASED WIRELESS REMOTE USING RX-TX MODULES This circuit utilizes the RF module (Tx/Rx) for making a wireless … Read More
Terms and Conditions -
Privacy Policy -

Contact Us

Name

Email *

Message *