Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Robot Controlled through MATLAB GUI by RF Wireless Technology

By Hai Prasaath K

A robot can be controlled wirelessly in many different ways. The wireless control for a robotic vehicle can be implemented via Bluetooth, Wi-Fi or RF. A wireless robot controlled over Bluetooth can have HC-05 Bluetooth module interfaced in its circuit by which it can pair with any other Bluetooth device. The same way, a Wi-Fi controlled robot can have ESP8266 Wi-Fi module interfaced in its circuit to connect to a remote server via Wi-Fi hotspot or to connect to a device via Wi-Fi tethering. An RF-based wireless robot has an RF receiver interfaced in its circuit to which control commands can be passed through an RF transmitter. The RF transmitter can be part of a remote control or interfaced to a PC via a controller circuit. 
 
In this tutorial, a wireless robot controlled over RF interface is designed. The RF transmitter is interfaced to a computer via controller circuit based on Arduino UNO. the computer runs a Matlab based application which controls the movement of the robot. So the motion of the robot is wirelessly controlled through a Matlab based GUI. The RF module used in the project is 433 MHz RF module. It has a typical range of 50 to 60 metre which can be extended up to 300 Metre by using antenna and proper transmission power. 
 
For designing this robotic system, a Matlab GUI is designed on computer and an Arduino Sketch which can receive command characters serially from the computer and transmit motor control logic accordingly are designed. The robot itself houses a RF receiver circuit which is capable of implementing DC motor control without use of any additional controller. The Arduino sketch is written and compiled using Arduino IDE while the GUI is designed within the Matlab platform. 
 
Prototype of Matlab GUI Controlled RF Robot
 
Fig. 1: Prototype of Matlab GUI controlled RF Robot
 

Components Required – 

List of Components Required for Matlab GUI Controlled RF Robot

Fig. 2: List of Components required for Matlab GUI controlled RF Robot

Block Diagram – 

Block Diagram of Transmitter Side of Matlab GUI Controlled RF Robot
 
Fig. 3: Block Diagram of Transmitter Side of Matlab GUI controlled RF Robot
 
 
Block Diagram of Receiver Side of Matlab GUI Controlled RF Robot
 
Fig. 4: Block Diagram of Receiver Side of Matlab GUI controlled RF Robot

Circuit Connections – 

There are two circuits designed in this robotic project – one is the transmitter circuit which is basically a controller based RF transmitter connected to a PC through serial interface and other is receiver circuit mounted on the robot which controls the motor driver IC.
 
Image of Transmitter Side of Matlab GUI controlled RF Robot
 
Fig. 5: Image of Transmitter Side of Matlab GUI controlled RF Robot
 
 
The transmitter circuit is built by assembling the following circuit sections – 
 
Arduino UNO – Arduino UNO is one of the most popular prototyping boards. It is used frequently in robotic applications as it is small in size and packed with rich features. The board comes with built-in arduino boot loader. It is an Atmega 328 based controller board which has 14 GPIO pins, 6 PWM pins, 6 Analog inputs and on board UART, SPI and TWI interfaces. In this project, the Arduino board is connected to a PC via USB port and 4 GPIO pins of the board are utilized to interface HT12E RF encoder IC with it. 
 
RF Transmitter – The RF transmitter is used to transmit the input signals for motor control. The RF transmitter module is a small PCB sub assembly. The RF module, as the name suggests, operates at Radio Frequency. The corresponding frequency range varies between 30 kHz & 300 GHz. In this RF system, the digital data is represented as variations in the amplitude of carrier wave. This kind of modulation is known as Amplitude Shift Keying (ASK). This RF module operates over 433 MHz frequency and uses ASK modulation technique. The  pin configuration of transmitter module is as follows- 
 
Table Listing Pin Configuration of RF Transmitter
 
Fig. 6: Table listing pin configuration of RF Transmitter
 
The serialized data from the encoder is received at pin 2 of the module and passed onto the antenna from pin 4 of the module. 
 
HT12E IC – The HT12E IC converts the parallel data into serial data for passing it to the RF transmitter. HT12E encoder IC belongs to the 212 series of encoders. It is paired with 212 series of decoders having the same number of addresses and data format. HT12E is capable of encoding 12 bits, out of them 8 are address bits and 4 are data bits. Thus the encoded signal is a serialized 12-bit parallel data comprising of 4-bit data to be transferred appended with the address byte.
 
The data pins D0, D1, D2, and D3 of the IC are connected to the pins 2, 3, 7 and 8 of the Arduino board respectively. All the address pins of the encoder IC are hardwired to ground, so it has an address byte of 0x00. The pin 17 of the IC is connected to pin 2 of the RF transmitter. So, the serialized data is passed from pin 2 of the IC to data input pin of the RF transmitter. 
 
HT12E has a transmission enable pin which is active low. When a trigger signal is received on TE pin, the programmed addresses/data are transmitted together with the header bits via an RF or an infrared transmission medium. HT12E begins a 4-word transmission cycle upon receipt of a transmission enable. This cycle is repeated as long as TE is kept low. As soon as TE returns to high, the encoder output completes its final cycle and then stops.
 
Power Supply – The Arduino board draws power from the USB interface itself. The VCC and ground pins of the RF transmitter and the encoder IC are connected to the common VCC and ground respectively. 
 
The receiver circuit is built by assembling the following components together – 
 
Image of Receiver Side of Matlab GUI Controlled RF Robot
 
Fig. 7: Image of Receiver Side of Matlab GUI controlled RF Robot
 
 
RF Receiver – The RF receiver detects the radio signal carrying the motor control signals. The RF receiver module has 8 pins and has following pin configuration – 
 
Table Listing Pin Configuration of RF Receiver
 
Fig. 8: Table listing pin configuration of RF Receiver
 
The RF receiver passes the serial data received over RF frequency from its pin 2 to pin 16 of the decoder IC.  
 
HT12D Decoder – The signal detected from the RF receiver is passed to the HT12D decoder. It converts the serial data back to the parallel data after separating data and addresses. HT12D belongs to the 212 series of decoders and can be paired with 212 series of encoders having the same number of addresses and data format. HT12D is capable of decoding 12 bits, out of them 8 are address bits and 4 are data bits. The 4-bit data is of latch type and when passed to the output data pins it remains unchanged until the new data is received.
 
The serial data received by the RF receiver is parallel output from its data pins as it is. The data pins of the decoder IC are interfaced with input pins of the L293D motor driver IC. So the digital logic at the data pins of the decoder control the rotation of the DC motors. All the address pins of the decoder IC are connected to ground to match the address byte to 0x00 same as of the transmitter circuit. 
 
L293D DC Motor Driver IC– The L293D is a dual H-bridge motor driver integrated circuit (IC). The Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors. It has 16 pins with following pin configuration: 
 
Table Listing Pin Configuration of L293D Motor Driver IC
 
Fig. 9: Table listing pin configuration of L293D Motor Driver IC
 
There are two DC motors used for making the robotic car. The DC motors are interfaced between pins 3 and 6 and pins 14 and 11 of the motor driver IC. 
 
The L293D IC controls the DC Motors according to the following truth tables: 
 
Truth Table of L293D Motor Driver IC
 
Truth Table of L293D Motor Driver IC
 
Fig. 10: Truth Table of L293D Motor Driver IC
 
The pin 4, 5, 13 and 12 of the L293D are grounded while pin 1, 16 and 9 are connected to 5V DC and pin 8 is connected to 12V DC. The pins 15, 2, 7 and 10 of the motor driver IC are connected to pins 8, 2, 3 and 7 of the Arduino board. The DC motor attached to right wheel is connected to pins 11 and 14 while motor attached to left wheel is connected to pins 3 and 6 of the motor driver IC.
 
Geared DC Motors – In this robot, 12V geared DC motors are attached to the wheels. Geared DC motors are available with wide range of RPM and Torque, which allow a robot to move based on the control signal it receives from the motor driver IC. 
 
Power Supply – In the circuit, RF transmitter and decoder IC need a 5V regulated DC for their operation while the motor driver IC needs 12V DC. A 12V NIMH battery is used as the primary source of power. The supply from the battery is regulated to 5V and 12V using 7805 and 7812 ICs. The pin 1 of both the voltage regulator ICs is connected to the anode of the battery and pin 2 of both ICs is connected to ground.
 
The respective voltage outputs are drawn from pin 3 of the respective voltage regulator ICs. An LED along with a 10K Ω pull-up resistor is also connected between common ground and output pin to get a visual hint of supply continuity. Despite using 12V battery, 7812 is used to provide a regulated and stable supply to the motor driver IC. 

How the circuit works – 

As the battery is attached to the robot, the RF receiver is configured to pair with the RF transmitter and start receiving the data. On the transmitter side, the arduino board must be connected to the PC via USB cable and the Matlab based GUI must be launched to realize the application. The GUI has directional buttons given to move the robot in forward, backward, left and right direction. On pressing a button, specific string command is passed to the Arduino board. The following strings are passed to transfer the control commands from the Matlab GUI – 
 
Table Listing String Commmands used for controlling Movement of Arduino Robot
 
Fig. 11: Table listing string commmands used ffor controlling movement of Arduino Robot
 
The Arduino sketch running on the Arduino UNO receives the command strings serially through virtual serial communication. Each string command is tested in decision making statements and appropriate motor control signals are passed at the controller pins connected to the data pins of the decoder IC. The same digital logic is reflected at the data pins of the encoder IC as it is.  The robot can be moved forward, backward, left or right by implementing the following input logic at the motor driver pins – 
 
Logic Table of L293D Motor Driver IC for Arduino Robot
 
Fig. 12: Logic Table of L293D Motor Driver IC for Arduino Robot
 
Check out the programming guide to learn how the Matlab GUI has been designed. Read through the Arduino sketch to learn how serially received command strings are detected and interpreted to change input control signals for the motor driver IC. 

Programming Guide – 

GUIs (also known as graphical user interfaces or UIs) provide point-and-click control of software applications, eliminating the need to learn a language or type commands in order to run the application. MATLAB apps are self-contained MATLAB programs with GUI front ends that automate a task or calculation. The GUI typically contains controls such as menus, toolbars, buttons, and sliders. Many MATLAB products, such as Curve Fitting Toolbox, Signal Processing Toolbox, and Control System Toolbox include apps with custom user interfaces. One can also create custom apps that include UI for others to use.
 
The project’s functioning is performed by 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 designing of GUI as well as Arduino sketch can be understood in the following steps – 
 
1. Arduino IDE 1.6.5 is used for programming Arduino Uno. The latest IDE can be downloaded 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)ArduinoLibraries (path may be different depending on the installation directory of the IDE).
 
After pasting pde folder in correct location, open Arduino IDE. If the file is pasted in correct location, one would find pde in File → Examples → pde. Open the code by File→ Examples → pde → adioes.
 
3. Connect Arduino Uno board to the 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. The application program has been developed in R2008a version of MATLAB. After installing this version of MATLAB in the PC, open install_arduino.m file present in the directory where one has 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. Once done with the above procedure, creating a GUI involves the few steps.  Just type guide in the command window of the MATLAB, there will be a popup window (GUIDE quick start) with options. Select or click on the Blank GUI (Default) to create a new GUI.
 
Screenshot of Matlab GUI Guide
 
Fig. 13: Screenshot of Matlab GUI Guide
 
 
7. The new window to create GUI appears, on the left side where one can find many options to create buttons, text box, sliders and much more. Click on the push button and draw on the editor window. Once done double click on the button and there one can edit button name.
 
Screenshot of Matlab UI Elements
 
Fig. 14: Screenshot of Matlab UI Elements
 
 
8. One can design the GUI depending on the application and desired UI appearance. This GUI designed for controlling the Robot looks as shown below – 
 
Screenshot of Matlab GUI for Robot Control
 
Fig. 15: Screenshot of Matlab GUI for Robot Control
 
 
 9. After designing the GUI save it and once saved a window appears with some body of codes where one can edit the robot control code in it. 
 
The window appears like as the image as shown below.
 
Screenshot of ArduinoIO Program Generated from Matlab GUI
 
Fig. 16: Screenshot of ArduinoIO Program Generated from Matlab GUI
   
 
10. From the image shown below declare the COM PORT number (serial port) in which one has connected the arduino to the PC, after that declare pin modes as (a.pinMode (5, Output)), which defines the serial port connected to the arduino board.
 
Screenshot of ArduinoIO Program Generated from Matlab GUI Including Modifications made in it
 
Fig. 17: Screenshot of ArduinoIO Program Generated from Matlab GUI including modifications made in it
 
 
Check out the attached code for more details. 
 
Note: Find the file for Robot Control App attached below.

Project Source Code

###

//Program to 



function varargout = RobotControl(varargin)

% ROBOTCONTROL M-file for RobotControl.fig

%      ROBOTCONTROL, by itself, creates a new ROBOTCONTROL or raises the existing

%      singleton*.

%

%      H = ROBOTCONTROL returns the handle to a new ROBOTCONTROL or the handle to

%      the existing singleton*.

%

%      ROBOTCONTROL('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in ROBOTCONTROL.M with the given input arguments.

%

%      ROBOTCONTROL('Property','Value',...) creates a new ROBOTCONTROL or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before RobotControl_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to RobotControl_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 RobotControl


% Last Modified by GUIDE v2.5 19-May-2017 12:05:25


% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @RobotControl_OpeningFcn, ...

                   'gui_OutputFcn',  @RobotControl_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 RobotControl is made visible.

function RobotControl_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 RobotControl (see VARARGIN)


% Choose default command line output for RobotControl

handles.output = hObject;


% Update handles structure

guidata(hObject, handles);


% UIWAIT makes RobotControl wait for user response (see UIRESUME)

% uiwait(handles.figure1);

delete(instrfind({'port'},{'COM17'}))

clear a;

global a;

a = arduino('COM17');

a.pinMode(2, 'OUTPUT');

a.pinMode(3, 'OUTPUT');

a.pinMode(7, 'OUTPUT');

a.pinMode(8, 'OUTPUT');


% --- Outputs from this function are returned to the command line.

function varargout = RobotControl_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 Front.

function Front_Callback(hObject, eventdata, handles)

% hObject    handle to Front (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(2,1);

a.digitalWrite(3,0);

a.digitalWrite(7,1);

a.digitalWrite(8,0);


% --- Executes on button press in Back.

function Back_Callback(hObject, eventdata, handles)

% hObject    handle to Back (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(2,0);

a.digitalWrite(3,1);

a.digitalWrite(7,0);

a.digitalWrite(8,1);



% --- Executes on button press in Right.

function Right_Callback(hObject, eventdata, handles)

% hObject    handle to Right (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(2,0);

a.digitalWrite(3,0);

a.digitalWrite(7,1);

a.digitalWrite(8,0);



% --- Executes on button press in Left.

function Left_Callback(hObject, eventdata, handles)

% hObject    handle to Left (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(2,1);

a.digitalWrite(3,0);

a.digitalWrite(7,0);

a.digitalWrite(8,0);



% --- Executes on button press in Stop.

function Stop_Callback(hObject, eventdata, handles)

% hObject    handle to Stop (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(2,0);

a.digitalWrite(3,0);

a.digitalWrite(7,0);

a.digitalWrite(8,0);
 

###

 


Circuit Diagrams

Circuit-Diagram-Transmitter-Side-Matlab-GUI-Controlled-RF-Robot
Circuit-Diagram-Receiver-Side-Matlab-GUI-Controlled-RF-Robot

Project Datasheet

https://www.engineersgarage.com/wp-content/uploads/2019/10/RobotControl.zip


Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • How did they made the old manuals or magazines sketches?
  • Bandpass filter why we are cascading HPF+LPF why not LPF +HPF,both are LTI systems
  • MAX5389 resetting by noise
  • Verilog/SV: Using an array as a set of individual registers and not RAM
  • the mysterious emitter follower

RSS Electro-Tech-Online.com Discussions

  • MOSFET gets hot and burns
  • LCD display on PICDEM 2 Plus board
  • Relaxation oscillator with neon or...
  • software PWM
  • Positive and negative sides of voltage source
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering