DC Motor Speed Control in LabVIEW

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge with all of you guys, about how to make a simple Virtual Instrument (VI) for DC Motor Speed Control in LabVIEW. In my previous tutorials, I have worked on DC Motor Speed Control using Arduino, in which I have controlled the DC Motor Speed using Arduino and after that I made some advancements in it and then created DC Motor Speed Control in Matlab in which commands were sent from Matlab. So, now we are gonna do the DC Motor Speed Control in LabVIEW.If you are working on DC Motor then you should also have a look at DC Motor Direction Control using Arduino. In this tutorial, I am going to work on the program for DC Motor speed Control using NI LabVIEW. So, before going into the detail of this tutorial, you must go through my previous tutorials because I am going to use the same hardware setup and Arduino source code with a bit modification. I will made a simple GUI (Graphical User Interface) for DC Motor Speed Control in LabVIEW. There will be five different buttons on the GUI for clockwise rotation, counter clockwise rotation, stopping  the stepper motor, accelerating and deaccelerating the stepper motor respectively.

DC Motor Speed Control in LabVIEW

In the tutorial DC Motor Speed Control in LabVIEW, I will explain you a complete step by step procedure to control the clockwise and counter clockwise direction of the DC motor as well as accelerating and deacelerating it with the help of the buttons on the GUI created in NI LabVIEW using serial communication between Arduino and NI LabVIEW.
  • You can download the complete simulation for DC Motor Speed Control in LabVIEW here:
Download LabView Simulation

  • Download .rar file, extract the files from the folder and enjoy the complete DC Motor Speed Control in LabVIEW simulation.
Flow Chart
  • First of all I would like you to explain the algorithm of DC Motor Speed Control in LabVIEW with the help of a flow chart.
  • Flow chart for this project is shown in the figure below.
  • The figure given above can help you to understand the entire algorithm for DC Motor Speed Control in LabVIEW.
Block Diagram
  • You can see the assembling of all the components used in DC Motor Speed Control in LabVIEW, in the block diagram.
  • Block diagram for this particular tutorial is shown in the figure below.
  • Initially commands are exchanged from NI LabVIEW to the Arduino using serial communication.
  • Then Arduino transfers these commands to L98 motor controller, hence in this way the DC motor.
  • LCD displays the executed commands.
Vitual Instrument's (VI's) Description
  • First of all open NI LabVIEW software on your laptop or PC.
  • Go to the Block Diagram window and Right Click on it.
  • Go to Functions-> Instrument I/O-> Serial and you can see different serial blocks like VISA Write, VISA Read, VISA Serial etc.
  • Choose the encircled VISA Configure Serial Port and place it on the Block Diagram window.
  • VISA Configure Serial Port block will help us to open the Serial Port before executing the algorithm.
  • The screen shot of the Block Diagram is shown in the figure below.
  • Go to the first input terminal of the VISA Configure Serial Port block and go to Create-> Control.
  • Above step will be helpful to select the COM port of the Arduino board in order to run the program properly.
  • Updated Block Diagram window is shown in the figure below.
  • Now go to Functions-> Instrument I/O-> Serial, you can see there different serial blocks.
  • Choose the encircled VISA Close block and place it on the Block Diagram window.
  • The VISA Close block is shown in the figure below and it will be help in closing the Serial Port if needed.
  • Now, go to the Functions-> Programming-> Structures and you can see the different structures there like For Loop, While Loop, Case Structure etc.
  • Choose the encircled block as shown i the figure below.
  • Place all the above blocks in a way shown in the figure below.
  • Now, go to the Functions-> Programming-> Structures-> Flat Sequence.
  • Flat sequence block is encircled and is shown in the figure below.
  • Put your cursor and go to Add Frame After.
  • Similarly ad another case after this as shown in the figures below.
  • Newly added frame is shown in the figure below.
  • Now, go to Functions-> Instrument I/O-> Serial, you can see different serial blocks there.
  • Choose the encircled VISA Write Block and place it on the Block diagram window.
  • The figure shown below elaborates the above steps.
  • Make the connections as shown in the figure below.
  • Now, go the Functions-> Programming-> Structures and you can see different types of structures like for loop, while loop, flat sequence etc.
  • Choose he encircled block as shown in the figure below.
  • Select the Case Structure block and place it on the block diagram window.
  • The figure shown below displays the above step.
  • Now, go to the input terminal of the write block and go to Create-> Control.
  • Change the name of this  block to Command box as shown in the figure below.
  • The block diagram window is shown in the figure below.
  • Now, go to Functions-> Programming-> Structures and you can see different structures blocks there.
  • Choose the encircled block as shown in the figure below.
  • Select the Local Variable Block and place it on the Front Panel.
  • Right click on it and select Command box as shown in the figure below.
  • Go to the input terminal of this local variable and go to Create-> Constant.
  • Place inside that constant.
  • The figure below elaborates the above step.
  • The above case structure is for the clock wise rotation of the stepper motor.
  • Similarly make four further case structures for counter clockwise rotation, accelerating, de-accelerating and stopping the rotation of the stepper motor.
  • All the three case structures are shown in the figure below.
  • You can see three different case structures in above figure.
  • The command box variable having command will rotate the stepper motor in clockwise direction.
  • A command box variable having command will rotate the stepper motor in counter clockwise direction.
  • The command box variable having command will rotate the stepper motor at higher and higher speed if it is rotating with a lower speed.
  • A command box variable having command will rotate the stepper motor with slower and slower speed if it is rotating at a higher speed.
  • .
  • The command box variable having command will stop the rotation of the stepper motor.
  • Now, go to the Front Panel and Right Click on it.
  • Go to Controls-> Modern-> Boolean and you can see there different Boolean blocks.
  • Choose the encircled block as shown in the figure below.
  • Select the Round LED block and place it on the front panel.
  • Similarly select two more round LED blocks and place them on the front panel as well.
  • Change their names from default to Clockwise, Anti clockwise,Stop Motor, Accelerate and Deaccelerate.
  • All of the above steps are explained visually in the figure shown below.
  • The LED shown in the above figure will control the stepper motor on clock wise, counter clock wise direction and will stop the motor as well.
  • Now go to the block diagram window and connect these blocks as shown in the figure below.
  • At the end, after sending all the commands we must need to close the serial port so that unnecessary exchange of commands could be avoided.
  • So I have cleared the all the commands in third frame of the case structure i.e I am sending no commands through the serial port.
  • This will be helpful in closing the serial port.
  • The figure show below explains all of the above steps visually.
  • Now add another case structure to start the program when you want so.
  • The figure below shows the newly added case structure.
  • Now, go to the Front Panel, the button encircled in the figure shown below is used to start the program when needed.
  • Now add a Stop button in order to terminate the program whenever you want so.
  • The complete output of the program is shown in the figure below.
  • A complete NI LabVIEW Virtual Instrument (VI) is shown in the figure below.
  • I have decorated the front panel to make it attractive for the users.
  • The final look of the Front panel is shown in the figure below.
  • Go to Controls, Modern-> Decorations you can see different decoration blocks there.
  • All these blocks are shown in the figure displayed below.
  • I have used three decoration blocks encircled with the blue color, to decorate my program.
  • Red boundary shows all of the decoration blocks to make your program attractive.
  • You can also decorate your programs using this amazing tools.
That is all from the tutorial DC Motor Speed Control in LabVIEW. I hope you enjoyed this tutorial. If you face any sort of problem you can ask me anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in some better way, if possible. I will explore NI LabVIEW, will make different projects on it and will share them with all of you as well. Till then, Take care :)

Stepper Motor Speed Control in Matlab

Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to tell you guys that how to design a simple algorithm for Stepper Motor Speed Control in MATLAB by simply sending different commands to the serial port from Matlab to Arduino. You should first read Stepper Motor Speed Control using Arduino because I am gonna take that tutorial further and will do the Stepper Motor Speed Control in Matlab. So, I would suggest you to first have a look at that tutorial before reading this one. Moreover, you should also have a look at DC Motor Direction Control in MatlabDC Motor Speed Control using Arduino. Stepper Motor Direction Control Direction Control in Matlab, Stepper Motor Direction Control using NI LabVIEW and Stepper Motor Speed Control using Arduino in which I have discussed in detailed about how to make simple and easy programs to control the direction of DC motor in both clockwise and anti clockwise direction and how to control the stepper motor direction and speed as well. So, you must go through my previous tutorials before going into the detail of today's tutorial because I have used the same hardware setup and a bit changed Arduino source code. Now, in this tutorial I will elaborate you that how can you send different commands through serial port from Matlab to the Arduino. I will create a simple GUI having different buttons on it through the direction as well as the speed of the DC motor can easily be controlled. So, let's have a look at Stepper Motor Speed Control in MATLAB.

Stepper Motor Speed Control in Matlab

Here, in this tutorial I will explain about how can make a program for Stepper Motor Speed Control in Matlab by creating a GUI having different buttons on it to control the direction of rotation of the stepper motor as well as the speed of the stepper motor by sending different commands through the serial port.
  • Here, you can download the complete simulation for Stepper Motor Speed Control in Matlab by clicking on the button below.

Download MATLAB Simulation

  • Download .rar file, extract it and enjoy the complete Matlab simulation.
Block Diagram
  • First of all I would like to elaborate the algorithm for Stepper Motor Speed Control in Matlab with the help of a block diagram.
  • Block diagram is shown in the figure below:
  • Fist of all power is supplied to the whole system to run it.
  • Matlab sends commands towards the Arduino UNO through the serial port using serial communication.
  • Arduino transfers those commands to the L298 motor controller andL298 drive the motor.
  • Arduino prints the executed commands on the LCD as well.
Initial GUI
  • First of all I have created a very simple GUI (Graphical User Interface) for Stepper Motor Speed Control in Matlab.
  • GUI has two different panels, Serial Port and Motor Controls. 
  • Serial Port panel has two buttons for opening and closing the serial port.
  • Motor Controls panel has five buttons for clockwise and anti clockwise rotation, accelerating and deaccelerating the Stepper motor and stopping the stepper motor.
  • Screen shot of the simple GUI for Stepper Motor Speed Control in Matlab is shown in the figure below.
  • Then I made few of the changes by double clicking on all the buttons to make the GUI beautiful.
  • The updated GUI is shown in the figure below.
  • The figure shown above is the starting GUI when you just run the program.
  • You can see below, after entering different commands GUI updates its text according to the command sent to the serial port.
Source Code Description
  • First of all you must have to open the serial port by clicking on the button Start Serial. 
  • Go to the callback function of Start Serial button in the Matlab code.
  • Just copy and paste the source code given below, in its callback function.
clc
global tep;
disp('Welcome to TEP');
disp('');
disp('www.TheEngineeringProjects.com');
disp('');
tep=serial('COM5'); % assign serial port object
set(tep, 'BaudRate', 9600); % set BaudRate to 9600
set(tep, 'Parity', 'none'); % set Parity Bit to None
set(tep, 'DataBits', 8); % set DataBits to 8
set(tep, 'StopBit', 1); % set StopBit to 1
%display the properties of serial port object in MATLAB Window
disp(get(tep,{'Type','Name','Port','BaudRate','Parity','DataBits','StopBits'}));
fopen(tep); % Open Serial Port Object
disp('Serial port is opened');
set(handles.text3, 'String','Serial port is opened');
  • Now, as you press this button GUI will update its text as Serial port is opened.
  • The updated GUI is shown in the figure below.
  • Now, go the callback function of Clockwise button inside the Matlab source code.
  • Just copy and paste the code given below in its call back function.
global tep
fwrite(tep,'C'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “C”.');
set(handles.text1, 'String','Motor is rotating in clockwise direction'); %setting static text's text
  • Now, if you press the Clockwise button the command will be sent from Matlab to arduino via serial port.
  • The GUI will update its text as Motor is rotating in clockwise direction.
  • The screenshot of the updated GUI is shown in the figure below.
 
  • Go to the callback function of Accelrate button and copy paste the code given below, in its callback function.
global tep
fwrite(tep,'H'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “H”.');
set(handles.text1, 'String','Motor is accerating slowly'); %updating text on GUI
  • As you press the Accelrate button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is accelerating.
  • If you press this button again and again, motor will continue to rotate at higher and higher speed.
  • The screenshot of the updated GUI is shown in the figure below.
  • Now, go the callback function of the Deaccelrate button in the Matlab source code.
  • Just copy and paste the code given below in the callback function of this button.
global tep
fwrite(tep,'L'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “L”.');
set(handles.text1, 'String','Motor is deaccerating slowly'); %updating GUI text
  • As you press the Deaccelrate button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is deaccelerating.
  • If you press this button again and again, motor will continue to rotate at slower and slower speed.
  • The screenshot of the updated GUI is shown in the figure below.
  • Now, go the callback function of the Anti Clockwise button in the Matlab source code.
  • Just copy and paste the code given below in the callback function of this button.
global tep
fwrite(tep,'A'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “A”.');
set(handles.text1, 'String','Motor is rotating in anti clockwise direction'); %updating the text onto the GUI
  • As you press the Anti Clockwise button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is rotating in anti-clockwise direction.
  • If you press this button again and again, motor will continue to rotate in anti clockwise direction.
  • The screenshot of the updated GUI is shown in the figure below.
  • Go to the call back function of the Stop Motor button inside the Matlab source code.
  • Copy and just paste the code given below in its all back function.
global tep
fwrite(tep,'S'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “S”.');
set(handles.text1, 'String','Motor is stopped');%Updating text on the GUI
  • Now, if you press the Stop Motor button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is stopped.
  • The screenshot of the updated GUI is shown in the figure below.
  • Go to the call back function of the Stop Serial button in the Matlab code.
  • Copy and just paste the code given below in its call back function.
global tep;
fclose(tep);
set(handles.text1, 'String','Serial port is closed');%updating the text on the GUI
  • At the end you must need to close the serial port.
  • As you press the Stop Serial button the serial port will be closed.
  • The GUI will update its text as Serial port is closed.
  • The screenshot of the updated GUI for Stepper Motor Speed Control in Matlab is shown in below figure.
That's all from the tutorial Stepper Motor Speed Control in Matlab. I hope you enjoyed this tutorial. If you face any sort of problem anytime, you can ask me freely without even feeling any kind of hesitation. I will try my level best to solve your problem in a better way, if possible. I will explore Matlab by making different projects and I will share them with you as well in my later tutorials. Till then, take care :)

Stepper Motor Direction Control using Matlab

Hello friends! I hope you will be absolutely fine and having fun. Today, I am going to share that how to make a program for Stepper Motor Direction Control using Matlab. I am going to share this tutorial on demand. I have also make different programs for DC Motor Direction Control using Arduino, DC Motor Direction Control in Matlab, DC Motor Direction Control using LabVIEW, DC Motor Speed Control using Arduino, DC Motor Speed Control using Matlab and Stepper Motor Direction using Arduino in my previous tutorials.  So before going into the detail of this tutorial you must have to go through these tutorial because I will use the same hardware and a bit changed Arduino source code. In this tutorial I will make an algorithm to send different commands from the Matlab to Arduino using the serial port. I have created a simple GUI (Graphical User Interface) in Matlab having two different panels. The first panel contains two and the second panel contains three buttons respectively. Each button sends the corresponding command through the serial port from Matlab to the Arduino and hence the corresponding action takes place.

Stepper Motor Direction Control using Matlab

Here's the tutorial on Stepper Motor Direction Control using Matlab, I will elaborate you that how can you make a Matlab program to send different commands from Matlab to Arduino using serial communication. I have made a simple GUI first containing two different panels having five buttons in total for different purposes.
Initial GUI
  • The initial diagram of the GUI for Stepper Motor direction control using Matlab,  is shown in the figure below.
  • Here you can download the complete Matlab Simulation.

Download Matlab Simulation

  • Once the code is downloaded, simply extract the zip file and copy past the code in you Matlab software and enjoy the results. :)
  • I have changed some of the properties of the GUI to make its external look better.
  • The updated GUI is shown in the figure below.
Matlab Code Description
  • Here I am going to explain the logic designed for this project Stepper Motor Direction Control using Matlab.
  • Go to the callback function of the Start Serial button in the Matlab code.
  • Copy and just paste the source code given below in its callback function.
clc
disp('Welcome to TEP');
disp('');
disp('www.TheEngineeringProjects.com');
disp('');
global tep
tep=serial('COM5'); % assign serial port object
set(tep, 'BaudRate', 9600); % set BaudRate to 9600
set(tep, 'Parity', 'none'); % set Parity Bit to None
set(tep, 'DataBits', 8); % set DataBits to 8
set(tep, 'StopBit', 1); % set StopBit to 1
%display the properties of serial port object in MATLAB Window
disp(get(tep,{'Type','Name','Port','BaudRate','Parity','DataBits','StopBits'}));
fopen(tep); % Open Serial Port Object
set(handles.text1,'String','Serial port os opened');
  • The code given above first of all creates an object for the serial port named as tep.
  • tep is made global so that it can be used in all the functions.
  • Then it, opens the serial port and then sends command through the serial port.
  • This code also prints baud rate, data bits, stop bit etc on the serial port as mentioned in the comments of the code given above.
  • After sending the commands it also prints the commands executed on the GUI as well.
  • The GUI with the printed command is shown in the figure below.
  • Go to the callback function of the Clockwise button in the Matlab code.
  • Copy and just paste the source code given below in its callback function.
global tep   %making the serial port vaiable global
fwrite(tep,'C'); %sending C through the serial port
disp('Character C is sent to the serial port'); %displaying on the serial port
set(handles.text1,'String','Clockwise rotation'); %prints on the GUI
  • The code given above send the command C through the serial port in order to rotate the motor in clockwise direction.
  • It prints the command on the serial port as well as on the GUI created in Matlab.
  • The GUI with the updated text for Stepper Motor Direction Control using Matlab is shown in the figure below.
  • Now, go to the callback function of the Anti Clockwise button in the Matlab code.
  • Copy and just paste the source code given below in its callback function.
global tep
fwrite(tep,'A'); %sending command to the serial port
disp('Character A is sent to the serial port'); %displaying on the serial port
set(handles.text1,'String','Anti clockwise rotation'); %prints on the GUI
  • The code given above send the command A through the serial port in order to rotate the motor in anti clockwise direction.
  • It prints the command on the serial port as well as on the GUI created in Matlab.
  • The GUI with the updated text is shown in the figure below.
  • Now, go to the callback function of the Stop button in the Matlab code.
  • Copy and just paste the source code given below in its callback function.
global tep
fwrite(tep,'S'); %sends S to the serial port
disp('Character S in sent to the serial port'); %prints on the serial port
set(handles.text1,'String','Motor is stopped'); %prints on the GUI as well
  • The code given above send the command S through the serial port in order to stop the rotation of the motor.
  • It prints the command on the serial port as well as on the GUI created in Matlab.
  • The GUI with the updated text is shown in the figure below.
  • Now, go to the callback function of the Stop Serial button in the Matlab code.
  • Copy and just paste the source code given below in its callback function.
global tep
fclose(tep);%Close Serial Port Object
set(handles.text1,'String','Serial port is closed');%prints the executed command on the GUI
  • The code given above prints the command Serial port is closed on the serial port as well as on the GUI created in Matlab.
  • The GUI with the updated text is shown in the figure below.
  • Was it difficult! I do not think so ;)
  • So, try to make the same project and observe the results, are they closed to me?
That's all from the tutorial Stepper Motor Direction Control using Matlab. I hope you enjoyed this tutorial. If you face any sort of problem you an ask me any time without feeling any kind of hesitation. I will try my level best to solve your issue in a better way way if possible. I will explore Matlab and will share with all of you, by making different projects on it in my later tutorials. Till then, Take care :)

DC Motor Speed Control in Matlab

Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to tell you guys that how to design a simple algorithm for DC Motor Speed Control in MATLAB by simply sending different commands to the serial port from Matlab to Arduino. In my previous tutorials, DC Motor Direction Control using Arduino, we have seen the direction control of DC Motor via Arduino. So, I would suggest you to first have a look at that tutorial before reading this one. Moreover, you should also have a look at DC Motor Direction Control in Matlab and DC Motor Speed Control using Arduino in which I have discussed in detailed about how to make simple and easy programs to control the direction of DC motor in both clockwise and anti clockwise direction. I have also given a detailed discussion about the PWM (Pulse Width Modulation) concept as well as about the duty cycle of the digital signal. I have also discussed that how to control the speed of the DC motor using PWN pins of the motor controller L298 in Arduino software. So, you must go through my previous tutorials before going into the detail of today's tutorial because I have used the same hardware setup and a bit changed Arduino source code. Now, in this tutorial I will elaborate you that how can you send different commands through serial port from Matlab to the Arduino. I will create a simple GUI having different buttons on it through the direction as well as the speed of the DC motor can easily be controlled. So, let's have a look at DC Motor Speed Control in MATLAB:

DC Motor Speed Control using Matlab

Here, in this tutorial I will explain about how can make a program for DC Motor Speed Control in Matlab by creating a GUI having different buttons on it to control the direction of rotation of the DC motor as well as the speed of the DC motor by sending different commands through the serial port. Note: Since you are working on the DC motor so you must also go through my previous tutorials, they will be helpful for you to simulate this project as well: Here, you can download the complete simulation for DC Motor Speed Control in Matlab by clicking on the button below.

Download MATLAB Simulation

GUI Design and Matlab logic Description
  • First of all I have created a very simple GUI (Graphical User Interface) in Matlab.
  • GUI has two different panels, Serial Port and Motor Controls. 
  • Serial Port panel has two buttons for opening and closing the serial port.
  • Motor Controls panel has five buttons for clockwise and anti clockwise rotation, accelerating and deaccelerating the DC motor and stopping the DC motory.
  • Screen shot of the simple GUI is shown in the figure below.
  • Then I made few of the changes by double clicking on all the buttons to make the GUI beautiful.
  • The updated GUI is shown in the figure below.

  • The figure shown above is the starting GUI when you just run the program.
  • You can see below, after entering different commands GUI updates its text according to the command sent to the serial port.
Source Code Description
  • First of all you must have to open the serial port by clicking on the button Start Serial. 
  • Go to the callback function of Start Serial button in the Matlab code.
  • Just copy and paste the source code given below, in its callback function.
clc
global tep;
disp('Welcome to TEP');
disp('');
disp('www.TheEngineeringProjects.com');
disp('');
tep=serial('COM5'); % assign serial port object
set(tep, 'BaudRate', 9600); % set BaudRate to 9600
set(tep, 'Parity', 'none'); % set Parity Bit to None
set(tep, 'DataBits', 8); % set DataBits to 8
set(tep, 'StopBit', 1); % set StopBit to 1
%display the properties of serial port object in MATLAB Window
disp(get(tep,{'Type','Name','Port','BaudRate','Parity','DataBits','StopBits'}));
fopen(tep); % Open Serial Port Object
disp('Serial port is opened');
set(handles.text3, 'String','Serial port is opened');
  • Now, as you press this button GUI will update its text as Serial port is opened.
  • The updated GUI is shown in the figure below.

  • Now, go the callback function of Clockwise button inside the Matlab source code.
  • Just copy and paste the code given below in its call back function.
global tep
fwrite(tep,'C'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “C”.');
set(handles.text3, 'String','Motor is rotating in clockwise direction');
  • Now, if you press the Clockwise button the command will be sent from Matlab to arduino via serial port.
  • The GUI will update its text as Motor is rotating in clockwise direction.
  • The screenshot of the updated GUI is shown in the figure below.

  • Go to the callback function of C_Accelrate button and copy paste the code given below, in its callback function.
global tep
fwrite(tep,'H'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “H”.');
set(handles.text3, 'String','Motor is accerating slowly');
  • As you press the C_Accelrate button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is accelerating.
  • If you press this button again and again, motor will continue to rotate at higher and higher speed.
  • The screenshot of the updated GUI is shown in the figure below.
  • Now, go the callback function of the C_Deaccelrate button in the Matlab source code.
  • Just copy and paste the code given below in the callback function of this button.
global tep
fwrite(tep,'L'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “L”.');
set(handles.text3, 'String','Motor is deaccerating slowly');
  • As you press the C_Deaccelrate button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is deaccelerating.
  • If you press this button again and again, motor will continue to rotate at slower and slower speed.
  • The screenshot of the updated GUI is shown in the figure below.
  • Go to the call back function of the Stop Motor button inside the Matlab source code.
  • Copy and just paste the code given below in its all back function.
global tep
fwrite(tep,'S'); %Print character ‘a’ to the serial port
disp('Charater sent to Serial Port is “S”.');
set(handles.text3, 'String','Motor is stopped');
  • Now, if you press the Stop Motor button the command will be sent from Matlab to Arduino via serial port.
  • The GUI will update its text as Motor is stopped.
  • The screenshot of the updated GUI is shown in the figure below.
  • Go to the call back function of the Stop Serial button in the Matlab code.
  • Copy and just paste the code given below in its call back function.
global tep;
fclose(tep);
disp('Serial port is closed');
set(handles.text3, 'String','Serial port is closed');
  • At the end you must need to close the serial port.
  • As you press the Stop Serial button the serial port will be closed.
  • The GUI will update its text as Serial port is closed.
  • The screenshot of the updated GUI for DC Motor Speed Control in Matlab is shown in below figure:
That's all from the tutorial DC Motor Speed Control in Matlab. I hope you enjoyed this tutorial. If you face any sort of problem anytime, you can ask me freely without feeling any kind of hesitation. I will try my level best to solve your problem if possible. I will explore the Matlab by making different projects on it in my later tutorials. Till then, take care :)

DC Motor Direction Control in MATLAB

Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge with all of you guys about how to do the DC Motor Direction Control in Matlab using serial communication with Arduino UNO. Serial communication is a very common and fast mean of communication now a days. In almost every engineering related projects we need to continuously send and receive data from micro controller to the computer and vice versa. So, I used this type of communication between Matlab and Arduino UNO. You must have a look at my previous tutorial DC Motor Direction Control using Arduino because I am gonna use the same hardware and Arduino code and in today's tutorial I am gonna interface that hardware project with MATLAB so it will be like you will be sending commands from MATLAB and controlling your DC Motor. So, in this tutorial I will explain you that how can you make a simple program in Matlab to control DC motor direction via serial communication between Matlab and Arduino. I have performed this serial communication with the help of different buttons created in the Matlab GUI. You can send commands to the Arduino UNO with the help of these buttons. So, let's have a look at DC Motor Direction Control in MATLAB:

DC Motor Direction Control in MATLAB

In this tutorial I will explain that how to make a simple program in Matlab, to send the data through serial port and do the DC Motor Direction Control in MATLAB. Before going into the detail of this tutorial I would like to suggest you to first go through my previous tutorial DC Motor Direction Control using Arduino because without reading that tutorial, you won't understand today's tutorial.
  • You can download the complete Matlab simulation by clicking the below button:

Download MATLAB Simulation

Note: If you are working on DC Motor then you should also have a look at these Proteus Simulations: Its a very simple project which helps us to control the DC motor direction using serial communication between Arduino and Matlab. Step by step detailed discussion is given below, you can easily make this project by following these steps. Moreover, if you haven't worked on GUI before than I would suggest you to have a look at How to create a GUI in MATLAB.
  • I made a simple Graphical User Interface (GUI) consisting of two different panels named as Serial Port Controls and Motor Control.
  • Serial Port Controls handles the serial port functions and this panel consists of two buttons Start and Stop which are helpful to start and stop the serial port respectively.
  • Motor Controls handles DC motor direction and this panel consists of three buttons Clockwise rotation, Stop and Anti Clockwise rotation which are helpful to rotate the DC motor in clockwise and anti clockwise direction respectively.
  • I have added a text box at the bottom to show the running commands when any of the buttons is pressed while the program is running.
  • When you press any of the button, you can see the corresponding command on the text box.
  • The simple GUI created in Matlab is shown in the figure below.
 
  • After making this simple GUI shown in the figure above, I have made some changes to make its look better by changing the properties of the buttons and Static text box.
  • The updated GUI with some changes for DC Motor Direction Control in MATLAB is shown in the figure below.
 
  • Put your cursor on the Start Serial button and click on it and go to its call back function in the Matlab code.
  • Just copy and paste the code given below in its call back function.
  • If you haven't worked on Serial Port in MATLAB before then you should have a look at Send Data to Serial Port in MATLAB.
  • So, now let's start working on the code for DC Motor Direction Control in MATLAB:
clc
global tep
disp('Welcome to TEP');
disp('');
disp('www.TheEngineeringProjects.com');
disp('');
tep=serial('COM5'); % assign serial port object
set(tep, 'BaudRate', 9600); % set BaudRate to 9600
set(tep, 'Parity', 'none'); % set Parity Bit to None
set(tep, 'DataBits', 8); % set DataBits to 8
set(tep, 'StopBit', 1); % set StopBit to 1
%display the properties of serial port object in MATLAB Window
disp(get(tep,{'Type','Name','Port','BaudRate','Parity','DataBits','StopBits'}));
fopen(tep); % Open Serial Port Object
set(handles.text3, 'String','Srial port is opened. Please send your commands!');
  • The variable tep is made global because we have to use in different functions, if we do not make it global we can not use it out of a particular function then.
  • The code given above sets different properties e.g. baud rate, parity bits, stop bits, data bits etc.
  • Then it is opening the serial port after making its variable named as tep and prints the text in the Static box created on GUI.
  • The GUI with the updated text is shown in the figure below.
 
  • Go to the call back function of Clockwise button.
  • Copy and paste the sample of the source code given below, in the call back function of the clockwise button.
global tep
fwrite(tep,'C'); %Print character ‘C’ to the serial port
disp('Charater sent to Serial Port is “C”.');
set(handles.text3, 'String','Motor is rotating in clockwise direction');
  • The code given above send the character C to the serial pot in order to rotate the motor in clockwise direction and displays this character as well on the serial port.
  • In the second step, it is updating the text of the Static text box and displays it on the GUI created in Matlab.
  • The GUI with the updated text is shown in the figure below.
  • Now, go to the call back function of the Stop button in the Matlab GUI code.
  • Just copy and paste the code given below in its call back function.
global tep
fwrite(tep,'S'); %Print character ‘S’ to the serial port
disp('Charater sent to Serial Port is “S”.');
set(handles.text3, 'String','Motor is stopped');
  • The code given above is sending the character to the serial port in order to stop the DC motor and also displays this character on the serial port as well.
  • Then, it updates the text of the static text box in Matlab GUI.
  • The GUI with the updated text is shown in the figure below.
  • Now, go to the call back function of the Anti Clockwise button in the Matlab code.
  • Copy and paste the code given below, in its call back function.
global tep
fwrite(tep,'A'); %Print character ‘A’ to the serial port
disp('Charater sent to Serial Port is “A”.');
set(handles.text3, 'String','Motor is rotating in anti clockwise direction');
  • The code given above is sending the character to the serial port in order to rotate the DC motor in anti clockwise direction and also displays this character on the serial port as well.
  • Then, it updates the text of the static text box in Matlab GUI as .
  • The GUI with the updated text is shown in the figure below Motor is rotating in anti clockwise direction .
  • The GUI with the updated text is shown in the figure below.
  • Now go the call back function of Stop Serial in the Matlab code.
  • Just copy and paste the code given below in the call back function of stop serial button.
global tep
fclose(tep);
set(handles.text3, 'String','Srial port is closed');
  • The code given above is closing the serial port and printing the text Serial port is closed on the GUI created in Matlab.
  • The updated text printed in the Static text box is shown in the figure below.
  That's all from the tutorial DC Motor Direction Control in Matlab. I hope you enjoyed this tutorial. If you face any sort of problem regarding anything, you can freely ask me without feeling any kind of hesitation. I will try my level best to help you if possible. I will explore the Matlab software by making different projects in my later tutorial. Till then, Take care :)

Area and Volume Calculation in LabVIEW

Hello friends! I hope you all will be absolutely and having fun. Today, I am going to share my knowledge with all of you on Area and Volume Calculation of different shapes with the given radius in NI LABVIEW. First of all I want to tell you that the area basically shows the space inside an object having two dimensions. Where as, Volume is the parameter which shows the space occupied by a three dimensional object. So, we can roughly say that the volume is the area of a three dimensional object. For example you want to go for a trip and you have to pack your bags. So, in this case you have to make some space in your bag to put the clothes inside it. The space that you make for the clothes is basically an application of volume. We can also called it as a capacity of an object. Area is usually measured in and volume is measured in according to their System International (SI) units. In this tutorial we will do the area and volume Calculation of two different shapes, and they are circle and cylinder. Its just a simple LabView Project and the sole purpose of this project is to let you guys know how to do simple calculations in LabView. I hope you guys are gonna enjoy it. So, let's get started with Area and Volume Calculations in LabView:

Area and Volume Calculation in LabVIEW

Here I am going to elaborate you about the different formulas to calculate the area and volume of the different shapes e.g. circle, cylinder, square, triangle etc. I will focus to calculate the area and volume of two different shapes with the given radius. The basic formulas for the area and volume of the square or rectangle are given below.
  • Area = length × width
  • Volume = length × width × height
But we will find the area and volume of circle and cylinder with the given radius. You can use the formulas given below for the area and volume calculation with the given radius.
  • Area of circle = pr²
  • Area of cylinder = 4pr²
  • Volume of cylinder = (4/3)pr³

Youn can download a complete NI LabVIEW simulation here.

Download LabVIEW Simulation

I am using above formulas to calculate these parameters using NI LabVIEW. I will make a very simple program in NI LabVIEW which will take radius as an input and calculates the area and volume of circle and cylinder after manipulating the given area. You can also select the maximum limit of the radius. When the radius approaches its maximum limit an LED will glow showing the notification reduce the radius. So, let's start with the NI LabVIEW to make this program for Area and Volume Calculation.
Steps to Follow
  • Go to the Front Panel and Right Click on it.
  • Go to Controls-> Silver-> Numeric, you can see different numeric blocks here e.g. numeric control, numeric indicator etc.
  • Choose the encircled block shown in the below.
  • Select and place the encircled block on the Front Panel and change its name to Set the radius limit.
  • Similarly select another Numeric Indicator and change its name to Radius.
  • Now, go to Controls-> Silver-> Numeric-> Indicator, select this block and place it on the Front Panel.
  • Copy this block and paste it two time on the Front Panel.
  • Change their names to Area of Circle, Area of Cylinder and Volume of Cylinder respectively.
  • The figure shown below describes all of the above steps.
  • Set the radius limit block will help you to set the maximum value of the radius.
  • You can enter the required radius the Radius block and the other three blocks will show the desired results depending upon the radius.
  • Now go to Controls-> Silver-> Boolean, you can see different Boolean blocks here.
  • Choose the encircled block as shown in the figure below.
  • Select the encircled block and place it on the Front Panel.
  • LED is used to show the indication when the radius reaches its maximum limit.
  • Here is the screenshot of the updated Front Panel.
  • Now, go to the Block Diagram window, here you can that the blocks are automatically placed there.
  • Here is the screenshot of the Block Diagram window.
  • Now, let's make the logic to find the area of the circle.
  • Go to Functions-> Programming-> Numeric, you can see different numeric blocks here.
  • Choose the encircled block as shown in the figure below.
  • Select the Multiply block and place it on the Block Diagram window.
  • Now go to Functions-> Programming-> Numeric-> Math Constants, you can see different types of numeric constants here.
  • Choose the encircled math constant as shown in the figure below.
  • Select the encircled Field Programmable Gate Array (FPGA) block and place it on the Block Diagram window.
  • Now, make a simple logic to find the area of the circle by adjusting the radius.
  • Algorithm is shown in the figure below.
  • I have set the value the radius as and run the program, you can see the area calculated by NI LabVIEW there.
  • The calculated area with the given radius is shown in the figure below.
  • Now, go to the Block Diagram window.
  • Go to Functions-> Programming-> Comparison, you can see different comparison blocks here.
  • Choose the encircled block as shown in the figure below.
  • Now make a simple logic for the indication when the radius reaches its maximum limits.
  • The logic for this particular purpose is shown in the figure below.
  • Now, go to the Front Panel you can see, I have adjusted the maximum limit of the radius as 5, you can see when radius approaches its maximum limit LED shows indication.
  • The above step is elaborated in the figure below.
  • Now, put your cursor on the LED and right click on it.
  • Go to the properties and make the changes shown in the figure below.
  • Updated indication is shown in the figure below.
  • Now, I will make an algorithm to find the area and volume of the cylinder according to the formulas written at the start of this tutorial.
  • The virtual instrument (VI) for the desired algorithm is shown in the figure below.
  • Now, go to the Functions-> Programming-> Structures, here you can see different structures blocks.
  • Choose the encircled block only, as shown in the figure below.
  • Select the For Loop and place it on the Block Diagram window.
  • Place the whole program inside the For Loop as shown in the figure below.
  • Now go Red button at the bottom of the For Loop and click on it.
  • Go to Create-> Constant, and make a connection between them, it helps to terminate program.
  • The updated Block Diagram window is shown in the figure below.
Adding Background Image
  • Go to the scroll bar at right side of the Front Panel and right click on it.
  •  Go to the Properties-> Background, as shown in the figure below.
  • Go to the background and here you can easily browse any image at the background image of  your program.
  • I have added the image shown in the figure below.
  • You can see the area of circle, area and volume of cylinder for the adjusted value of Radius. So, the complete output is shown in above figure.
  • In the below video, I have explained how to use this LabView VI:
That all from the tutorial Area and volume calculation with the radius in LabVIEW. I hope you enjoyed this tutorial. If you face any sort of problem you can ask me anytime without feeling any kind of hesitation. I will further explore NI LabVIEW in my later tutorials. Till then, Take care :)

Communication Signals Generation in LabView

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge with all of you guys, about Communication Signals Generation in LabVIEW. In the previous tutorial, we have seen the Introduction to LabView and after that we have designed our First Project using LabView Programming so if you haven't read them yet then I would suggest you to read them so that you have the basic knowledge of LabView. In earlier days people used to convey their messages or some important notifications using a piece of paper and by delivering it to the other places with the help of the pigeons. It took a lot of time for the message conveying procedure because there are some notifications or messages in which such a huge delay could be dangerous e.g. someone’s death news or emergency. With the passage of time people started thinking to make this process faster. Graham Bell took the very first step to make this process faster. Now a days the process has become much quicker as compared to the earlier days. Signals are very important to convey our messages, greetings and some other important notifications for the people who live far away from us. Even you use these signals in your daily lives but may be you are unaware of it. As you make a phone call, you are actually using these signals which help you to take your voice to longer distances. Television, Microwave, Internet e.g. are also working on this principle. In short, we do each and every communication with the help of these signals now a days. They play a vital role in our daily lives for the better and quicker communication with minimum delay and maximum accuracy level. So, let's get started with Communication Signals Generation in LabView: Note: I would also recommend you to have a loook at these basic LabView Projects. Simulations are given in them for download.

Communication Signals Generation in NI LabVIEW 2015

Here, I am going to start and elaborate you that how to generate simple Communication Signals in LabVIEW and how to play with them in this software.
Step 1

  • First of all we start with the generation of a very simple communication signal which is usually known as “Sinusoidal” or an “Analog” signal.
  • Open your LabVIEW software.
  • Go to the “Block Diagram” window and press “Right Click” on it
  • Go to the Functions-> Programming-> Waveform-> Analog Waveform-> Generation-> Simulate signal.
  • The figures below illustrate all of the above steps
  • Put you cursor on “Waveform”.
  • You can see the following window on your screen.
  • Now put your cursor on the encircled block.
  • You can see the window below on your screen.
  • Now, select this “Simulate signal” and place it on the “Block Diagram” window.
  • You can see this in a figure below.
  • As you place this block on the “Block Diagram” window, you can see a new window on your screen
  • Here is the screen shot of that window.
  • From this window we can set the properties of this window e.g. signal type, frequency, amplitude, duty cycle, offset etc.
  • Now, you do not need to change any of its properties.
  • Just press “OK” button.
  • Now, the signal is generated.
Step 2
  • We have now generated an analog signal by using "Simulate" signal block and by setting the signal type to "Sine".
  • The above figure shows this step.
  • Now, we need to visualize the generated analog signal.
  • We can visualize the generated signal with the help of the "Graph".
  • Go to the "Front Panel" and press "Right Click".
  • Go to Controls-> Modern-> Graph-> Waveform Graph.
  • The figure below shows the illustration of all of the above steps.
  • Select this block and place it on the "Front Panel".
  • You can see this figure on your window after selecting this block.
Step 3
  • Now go to the "Block Diagram" window.
  • You can see it is looking like the window below.
 
  • Now put your cursor on the bottom edge of the "Simulate Signal" block.
   
  • Press and stretch it towards downward the direction.
  • You can see that the block becomes like the figure below.
 
  • You can see, "Signal" is also appeared at the bottom of the "Simulate Signal" block.
  • Now, connect the output terminal (Signal) of the "Simulate Signal" block with the input terminal of the "Waveform Graph".
  • The figure below displays the above steps.
Step 4
  • Now, go to the "Front Panel" window.
  • Press the run button as the the figure below displays it .
  • After running the program you can see the generated signal on the "Graph" placed on the "Front Panel".
  • Here is the screenshot of the figure showing the generated analog signal.
Step 5
  • You can also change properties of the "Graph" to make its look better.
  • Press "Right Click" on the graph and go to the "Properties".
  • The figure below illustrates the above steps.
  • You can see the following window on you screen.
  • The different properties of the "Graph" e.g. length, width etc. are also changeable via this window.
  • You can also the color of the plotted graph.
  • Go to the "Plots" option of the above figure.
  • The figure below shows some steps.
  • You can change the color of the "Graph" by following these steps.
  • After performing these steps "Run" the program.
  • You can see the color of the graph is now changed.
 
  • You can also change the label of "x" and "y" axis.
  • Go to the properties of the "Graph" and then go to "Scale".
  • Set the properties according to the figure below.
  • The figure below shows different label of "y" axis.
  • Now, go again to the properties and go to the "Appearance".
  • The figure below shows some encircled options.
  • Now, go to the "Front Panel".
  • You can see the "Graph" is looking exactly like the figure below.
Step 6
  • You can also plot two different signals on the same "Graph".
  • Go to the "Block Diagram" window and select another "Simulate Signal" block and place it on the window.
  • Change the signal type to "Triangle"
  • The figure below explains the above all steps.
 
  • Now, go to Functions-> Express-> Signal Manipulation-> Merge Signals.
  • Select and place this block on the "Block Diagram" window.
  • Select and place this block on the "Block Diagram" window.
  • Make a connection between "Merge Signals" and "Simulate Signals".
  • The figure below shows the above steps.
Step 7
  • Now, go to the "Front Panel" and run the program.
  • You can see both of the signals are generated on the same "Graph".
  • The figure below shows the illustration of above steps.
That's all from the tutorial named Communication Signals Generation in LabVIEW 2015. I hope you enjoyed this tutorial and now you can easily do the Communication Signals Generation in LabView. I will explain the further details in my later tutorials. Till then take care. :)

Quadratic Roots Calculation in LabVIEW

Hello friends! I hope you all will be absolutely fine and having fun. Today I am going to share my knowledge with all of you guys that how to make a simple program for Quadratic Roots Calculation in LabVIEW. Quadratic equation is a second order basic equation. It plays a vital role for a lot of mathematical problems. The answer obtained from this equation is knows as its roots (also called quadratic roots). It can not have more than two roots. Roots can be 0,1 or maximum 2 and not more than that. We can solve quadratic equation in three different ways, but in this tutorial we will focus on one of them only. Here, I am going to tell you about form and the different ways of Quadratic Roots Calculation.

Ways to Solve Quadratic Equation

The quadratic equation is of the form ax²+bx+c. Where "x" is unknown variable and we have to find it. "a", "b" and "c" are known as the constants of quadratic equation. It has three different ways to solve as described below.
  1. By factorization: It can be much quicker. The resulting equation are simple and easy to solve when each factor is set to "0". But his method has a lot of of limitations. Sometimes it is very difficult to solve some of the polynomials by factorization and sometimes it becomes impossible with this particular method.
  2. By completing square: It is very easy to solve when the constant "b" is even. This method includes more steps as compared to the other methods. So, it can make the calculations complicated.
  3. Using quadratic formula: It is basically a generic formula and it can solve any of the quadratic equation.
From all of the above described rules to solve a quadratic equation and to find quadratic roots, we will use only one of them which is named as "Using Quadratic Formula". In this tutorial we will design an algorithm which helps us to solve the quadratic equation and to find the quadratic roots due to its vast applications in mathematics department. The design algorithm is based only on solving the quadratic equation using quadratic formula. Because, it is a generic formula and has a capability to solve each and every quadratic equation. We will design the algorithm on Quadratic Roots Calculation in LabVIEW:

Quadratic Roots Calculation in LabVIEW

  • You can download this LabView Simulation for Quadratic Roots Calculation by clicking the below button:

Download LabView Simulation

  • Go to the "Front Panel" and press "Right Click".
  • Go to Controls-> Modern-> Numeric-> Numeric Control. You can see the different numeric block here.
  • Select the encircled block and place it on the "Front Panel".
  • The figure below shows the selected blocks.
  • Similarly place two more blocks on the "Front Panel" and change their names as "a", "b" and "c". These are basically the coefficients of quadratic equation.
  • The figure below shows the illustration of all of the above steps.
Selection of Numeric Indicator
  •  Now, again go to Controls-> Modern-> Numeric-> Numeric Indicator.
  • Select the encircled block and place it on the "Front Panel".
  • Similarly place two more blocks and change their names to "y", "x1" and "x2" respectively.
  • The figure below shows all of the above steps.
  • In above figure "x1" and "x2" are two quadratic roots of the quadratic equation. These roots can be real as well as imaginary. It depends upon the coefficients of quadratic equation.
  • Now go to the "Block Diagram" window.
  • You can see it is looking like a figure below.
Selection of Formula Node
  • Arrange all the block, as the above figure shows the arrangement.
  • Now, go to Functions-> Programming-> Structures-> Formula Node. You can see different structure blocks there.
  • The figure below shows the selection of the "Formula Node".
  • Select the encircled one and place it on the "Font Panel".
  • The figure below shows the "Formula Node" on the "Block Diagram" window.
 
  • Now put you cursor on inside the "Formula Node" and write the code for calculating the roots of quadratic equation.
  • Here is the screen shot of the written algorithm to find quadratic roots.
  • Now put your cursor on the "Formula Node" and press "Right Click", you can see a new window on you screen.
  • Go to "Add Input"  and press click.
  • After clicking on this option you can see a new input is added to the "Formula Node".
  • The below shows the adjusted input.
  • Similarly add two more inputs and change their names to "b" and "c".
  • Make their connections with the "Numeric Controls".
  • The figure below illustrates the above steps.
  • Now, put your cursor on the "Formula Node" again an  press "Right Click" and go to the "Add Output".
  • Similarly add three outputs to the "Formula Node".
  • Change their names to "y", "x1" and "x2".
  • Make the connections between outputs of the "Formula Node" and "Numeric Indicator".
  • The figure below shows the illustration of all of the above steps.
For Loop selection
  • Go to the "Block Diagram" window and press "Right Click".
  • Go to Functions-> Programming-> Structures-> For Loop. you can see different structures blocks.
  • The figures below shows the selection of "For Loop".
  • Select the desired block and place it on the "Block Diagram" window.
  • The figure below shows the selected "For Loop".
  • Now, place the entire program inside the "For Loop".
  • Go to the bottom right of the "For Loop" and press "Right Click" on it.
  • Go to Create->Control.  You can see a stop button is now generated.
  • The figure below shows the entire algorithm.
  • The figure above shows the complete algorithm for "Calculating Quadratic Roots using NI LabVIEW".
  • Now go to "Front Panel". Here you can see the whole output of the designed algorithm.
  • "Run" the program and change the values of the quadratic coefficients, you can obtain the corresponding output.
  • The program will continue to start until you terminate it.
  • If you press the stop button then the program will terminate.
  • The figure below shows the screen shot of the complete output of the designed algorithm.
Making better External Look
  • Press "Double Click" on the "Front Panel" and start typing the name of the project.
  • Go to the upper Toolbar (18pt application form) and change the color, style and size of the text.
  • The figure below shows the illustration of all of the above steps.
  • Go to the "Front Panel" and press "Right Click".
  • Go to Controls-> Modern-> Decoration. You can see different "Decoration" blocks there.
  • Select the encircled blocks and place them on the "Front Panel".
  • Arrange them in way shown in the figure below.
  • Extend the placed blocks so that you can put the whole program inside these blocks.
  • Now select the entire program and drag it over these blocks.
  • You can see the figure below on your screen.
  • Now, go to the upper toolbar and perform the following steps.
  • The figure shows the steps to perform.
  • Press "Move to Front" your program will appear clearly on the front side of these blocks.
  • Here is the screen shot of the above step.
Tools Palette
  • You can use this tools to change the color of your output.
  • Go to the upper toolbar and go to View-> Tools Palette.
  • Screen shot is shown in the figure below.
 
  • When you select this option, you can see a new window on your screen.
  • Here is the scree shot of the new window appeared on the screen.
  • You can change the color of your output according to your own choice.
  • I have changed them according to  my choice.
  • Here is the screen shot of the final output with different colors.
  • The above figure shows the complete output of the designed algorithm.
  • Here's the video in which I have explained how to use this LabView VI:
This is all from the tutorial Quadratic Roots Calculation in LabVIEW. I hope you have enjoyed this tutorial Quadratic Roots Calculation in LabVIEW. I will explain the further details in my later tutorials so you must watch them too. Till then, take care. :)  

Temperature Sensing in LabVIEW

Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how to create program for "Temperature Sensing using NI LabVIEW". To sense the temperature is compulsory at a lot of the places e.g. refrigerators, air conditioners, storage rooms, kitchen etc. At these places to sense the temperature and its proper indication is compulsory because it can cause serious problems otherwise. For example, if the temperature in the food storage room is higher than an adjusted threshold, it will be harmful for all of the food items. You can also consider "Fire Alarm" as an example of temperature sensor. First of all it measures the level of the temperature. If it founds that the temperature is higher than the adjusted threshold, it starts to beep, which is very helpful in order to avoid a lot of disasters. So, let's get started with designing a Temperature sensing Project in LabView:

Temperature Sensing in LabView

Here,I am going to elaborate the steps, which help in designing a "Temperature Sensing using NI LabVIEW"  program. The program basically consists of three LED's which play a vital role in temperature level sensing. Three different threshold ranges are adjusted for sensing low, moderate and high temperature level. You can change theses threshold ranges manually. Thresholds have usually different values for the different environment.
Horizontal Pointer  Selection
  • First of all, you can download the simulation Temperature Sensing in LabView by clicking the below button:

Download LabView Simulation

  • Go to the "Front Panel" and press "Right Click".
  • Now, go to Controls-> Modern-> Numeric-> Horizontal Pointer Slide, you can see different pointers. Select the encircled pointer.
  • The figure below shows, which pointer we have to select.
  • Select the encircled block and place it on the "Front Panel".
  • Change it range from "10" to "15".
  • You can stretch this block after placing, you can see it looks like a figure below.
 
Round LED Selection
  • Go to the Controls-> Classic-> Classic Boolean-> Round Light 
  • You can see the different types of lights and LED's.
  • Select the encircled block and place it on the "Front Panel".
  • You can see the figure below looks like your screen.
  • Similarly select three "Round Lights" and place it on the "Front Panel".
  • Change their names to "Low Temp", "Moderate Temp" and "High Temp" respectively.
  • The figure presents the above steps clearly.
Changing Properties of Round LED
  • Now, put your cursor on the "Round Light" and press "Right Click" and go to the "Properties" menu.
  • The figure below gives a bit illustration of the above steps.
 
  • As you go to the "Properties"  menu you can see the window below on your screen.
 
  • Change the properties of this window for the high temperature indication, according to the steps in the figure below.
  • Now, change the properties of this window for the low temperature indication purpose according to the figure below.
  • For the moderate temperature indication you can change the properties of this window by following the steps of the figure below.
  • Now we have to show the digital and analog values for the manually adjusted temperature.
  • Go to Controls-> Modern-> Numeric-> Meter. You can see different numeric blocks here.
  • Select the desired one. The figure below shows the desired block.
  • Select the encircled block and place it on the "Front Panel".
  • You can see the figure below on your screen now.
  • Now again go to Controls-> Modern-> Numeric-> Numeric Indicator. Select the encircled block.
  • The figure below displays the desired block.
  • Select this block and place it on the "Front Panel" and you can see that the "Front Panel" looks like the figure below.
  • This block is used to show the digital values of the temperature.
  • Now, go to the "Block Diagram" window. You can see that this window in looking like a figure below.
  • Connect the output of the "Slide" block with input terminals of the both "Meter" and "Temp" blocks.
  • The figure below shows this connection.
  • Now we have to make the logic for the different temperature level indications e.g. high, moderate and low temperatures.
High Temperature Indication
  • Go to the "Block Diagram" window and press "Right Click". You see a new window on your screen.
  • Go to Functions->Programming-> Comparison-> Greater or Equal.
  • You can see here different comparison blocks.
  • Select the encircled block. The figure shows the desired block.
  • Select this block and place it on the "Block Diagram" window.
  • Connect one first input terminal of this block with the "Slide".
  • Press "Right Click" on the second input terminal and go to Create-> Constant. 
  • We have to set this constant in order to indicate the high temperature.
  • I have adjusted its vale as "10" i.e. when the temperature exceeds the threshold of "10" LED indicates the that the temperature is high now.
  • The figure shows the logic for the "High Temperature Indication".
  • Now, go to the "Front Panel" and "Run" the program.
  • You can see when the temperature exceeds the threshold LED gets turned "ON".
  • The figure below shows the illustration of all of the above steps.
 
Moderate Temperature Indication
  • Go to the "Block Diagram" window and press "Right Click". You see a new window on your screen.
  • Go to Functions->Programming-> Comparison.
  • You can see here different comparison blocks.
  • Select the encircled blocks. The figure shows the desired blocks.
  • Now, go to Functions->Programming-> Boolean. You can see different blocks here.
  • Select the encircled block named as "And" and place it on the "Block Diagram" window.
  • The "Block Diagram" window looks like the figure below by following the above steps.
  • Now, we have create a logic for moderate temperature level indication.
  • I am adjusting the parameters in such a way that if temperature is between "5" and "8" then there should be "Moderate" indication.
  • The figure below the logic for this purpose.
  • Now, go to the "Front Panel" and "Run" the program.
  • You can see that when the temperature is in between "5" and "8" the LED indicates the moderate temperature.
  • The figure below elaborates the above steps.
 
Low Temperature Indication
  • Go to the "Block Diagram" window and press "Right Click". You see a new window on your screen.
  • Go to Functions->Programming-> Comparison-> Less or Equal.
  • You can see here different comparison blocks.
  • Select the encircled block. The figure below shows the desired block.
 
  • Select this block and place it on the "Block Diagram" window.
  • Connect one first input terminal of this block with the "Slide".
  • Press "Right Click" on the second input terminal and go to Create-> Constant. 
  • We have to set this constant in order to indicate the low temperature.
  • I have adjusted its vale as "2" i.e. when the temperature exceeds the threshold of "10" LED indicates the that the temperature is high now.
  • The figure shows the logic for the "Low Temperature Indication".
 
  • Now, go to the "Front Panel" and "Run" the program.
  • You can see that when the temperature is less than "2" the LED indicates the low temperature.
  • The figure below illustrates the above steps.
  • Now put the whole program inside the "For Loop".
  • The complete Virtual Instrument (VI) is shown in the figure below.
 
  • Now go to the "Front Panel" and here you can see the output of the whole program.
  • The figure below shows the complete output of the "Temperature Sensing using NI LabVIEW".
   
Decorations of the Output
  • You can provide better external look to the output using decorations tool of the LabVIEW.
  • Let's make its look better. Follow the steps given below.
  • Go to the "Front Panel" and press "Right Click" you can see here different options.
  • Go to Controls-> Modern-> Decorations, here you can see different decorations blocks.
 
  • Select the encircled blocks and place them on the front panel and arrange like the figure below.
  • You can see the "Front Panel" is looking like the figure below.
 
  • Now copy the entire program and drag it on the "Decoration" box as shown in the figure below.
 
  • Now, go to the upper toolbar of the LabVIEW and go to Reorder-> Move to Front
  • The figure below illustrates all of the above steps.
 
  • You can see that when you press  Move to Front the output is looking like the figure below on your screen.
 
  • You can also change the color of each item you want by using tool palette.
  • Go to the View->Tool Palette and select this option
  • The elaboration of the above step is shown in the figure below.
 
  • As you go to this option and press "Right Click" on it a new window named as "Tool Palette" will be appeared on your screen.
  • The figure below shows the "Tool Palette" window.
 
  • I have changed the colors of different item according to my choice.
  • You can do it, as you want. The figure below shows the complete output with much better look as compared to the earlier.
  • Here's the video in which I have explained hoe to use this LabView VI:
This is all from the tutorial "Temperature Sensing using NI LabVIEW". I hope you enjoyed this tutorial. I will explain the further details in the later tutorials. Till then take care :)  

Temperature Conversion in LabVIEW

Hello friends! I hope you all will be absolutely fine. Today, I am going to share my knowledge with all of you guys, on how to make a Temperature Conversion in LabVIEW. Temperature is actually measured with different units at different places all across the world. However, there are three basic standard units for measuring the temperature i.e. Celsius, Fahrenheit and Kelvin. We can convert them in each other by performing some mathematical operations. In this tutorial I am going to elaborate only one of these conversions. I would like to tell the standards of these scales with reference to the freezing and boiling point of water. "Celsius" scale is basically the scale based on 0 degrees for the freezing point of water and 100 degree for the boiling point of water. "Fahrenheit" scale is based on 32 for the freezing point and 212 for the boiling point of water. Kelvin scale is based on 273 for the freezing point and 373 for the boiling point of the water.Fahrenheit, Celsius and Kelvin are denoted by "F", "C" and "K" respectively. There are mathematical expressions to convert the temperature from one scale to another scale.

Temperature Conversion Formulas

Here are the three formulas for temperature conversion.
Celsius to Fahrenheit Conversion
  • To convert "Celsius" to "Fahrenheit" use the expression below.

F = 9/5 °C + 32

Fahrenheit to Celsius Conversion
  • If you want to convert "Fahrenheit" to "Celsius" use the expression below.

C = 5/9 ( F - 32 )

Celsius to Kelvin Conversion
  • You can convert "Celsius" to "Kelvin" by using the expression below.

K = C + 273

By using all of the above expressions you can convert easily one scale to another one. Here, I am going to elaborate the steps which will help you to design Temperature Conversion in LabVIEW 2015. Click on the below button to download this LabView Simulation for Temperature conversion. So, now let's get started with the the designing of Temperature Conversion in LabView:

Download LabView Simulation

Temperature Conversion in LabVIEW

  • Go to the Front Panel and right click on it.
  • Now, go to the Controls -> Modern -> Numeric -> Numeric Control as shown in below figure:
  • Select this block and place it on the Front Panel.
  • Change its name to "Celsius" as shown in below figure:
  • Now, go to Controls -> Modern -> Numeric -> Numeric Indicator.
  • Select this block and place it on the Front Panel.
  • The figure below explains it:
  • Name it as a Fahrenheit.
  • Select another Numeric Control and place it similarly on the Front Panel and name it Kelvin.
  • All these numeric controls are shown in below figure:
  • Now let's move to the block diagram and design our small algorithm.
  • Your block diagram will look something as shown in below figure:
  • Now, we have to apply some technique so that the conversion from one scale to another becomes possible in an easy manner.
  • Go to Functions -> Express -> Arithmetic & Comparison -> Formula.
  • Select this block and place it on the "Front Panel" window.
  • Here is the figure in which you can see how to do this:
  • As you place this block on the "Front Panel" , you will see the figure below on your laptop's screen.
  • Now Change the formula according to your requirements.
  • I have changed the formula in order to convert "Celsius" to "Fahrenheit".
  • After changing the formula press "OK".
  • And now, the "Block Diagram" window looks like the figure below.
  • Now, connect the "Celsius" with the "X1" terminal of the "Formula" block and connect "Result" with the "Fahrenheit" block.
  • The figure below shows the display of the above step.
  • Now, the "Celsius" scale is converted into the "Fahrenheit " scale.
  • We have to convert "Celsius" to "Kelvin" now.
  • Go to Functions -> Programming -> Numeric -> Add.
  • Select this block and place it on the Front Panel.
  • Connect the input terminal of the Add block to the Celsius.
  • And go to the second input terminal of the Add block.
  • Go to Create -> Constant.
  • And set the value of the constant as 273.
  • The figure below explains all of the above steps.
  • Go to the "Front Panel".
  • Run the Program and you can see by changing the values of the "Celsius" the change occurs in the values of the "Fahrenheit" and "Kelvin" as well.
  • You can see for 0°C the "Fahrenheit" scale shows 32 and the "Kelvin" scale show the value of 273.
  • Here is the screen shot of the "Front Panel".
  • You can also see the different temperatures by using other FPGA blocks.
  • Go to Controls -> Modern -> Numeric -> Thermometer.
  • Select this block and place it on the "Front Panel".
  • Change its name from "Thermometer" to "Fahrenheit".
  • Similarly select the same block again an place it on the "Front Panel".
  • Change its name from "Thermometer" to "Kelvin".
  • Change its upper limit from "100" to "300" in order to observe the results more accurately.
  • The figure below shows the above steps.
  • Go to the "Front Panel" and connect these blocks with "Fahrenheit" and "Kelvin" as in below figure:
  • Now "Run" the program and change the value of the "Celsius" scale.
  • You can see the change in the temperature on both "Fahrenheit" and "Kelvin" scale. Red color shows the temperature.
  • Here is the screen shot of the above steps.
  • You can observe the temperature on "Gauge".
  • Go to the Controls -> Modern -> Numeric -> Gauge.
  • The figure below shows the gauge selection:
 
  • Select this block and place it on the "Front Panel".
  • Change its name from "Gauge" to "Fahrenheit".
  • Similarly select another block and change its name from "Gauge" to "Kelvin".
  • Change its range from "100" to "300".
  • The figure below illustrates all of the above steps.
  • Go to the "block Diagram" window and connect these blocks with "Fahrenheit" and "Kelvin".
  • Here is the screen shot of the above step.
  • Now, go to the "Front Panel".
  • Run the program and change the value of the "Celsius" scale.
  • You can see the corresponding changes on both the blocks.
  • The figure below elaborate all of the above steps.
  • This is the temperature conversion program from the "Celsius" scale to both the "Fahrenheit" and the "Kelvin".
  • If you want, that your program should continue to run until you terminate it, "For Loop" is helpful in this condition.
  • Go to the "Block Diagram" window and press "Right Click".
  • Go to Functions -> Programming -> Structures -> For Loop.
  • The figure below illustrates the above steps:
  • Select this block and place it on the "Block Diagram" window.
  • Place the complete program inside this loop as shown below
  • Go to the bottom right button and go to Create -> Control as shown below.
  • Complete output of the system is shown below.
  • Here's the video demonstration of this Temperature Conversion Project in LabView, it will explain How to use this simulation:
That's all from the tutorial "Temperature Conversion in LabVIEW. I hope you enjoyed this tutorial. I will share few more LabView Tutorials soon. Till then, take care :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir