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 :)
Stepper Motor Direction Control using Arduino
Hello friends! I hope you all will be absolutely fine and having fun. Today, I will elaborate you that how can we make a simple algorithm for
Stepper Motor Direction Control using Arduino. In my previous tutorials I made algorithm for
DC Motor Direction Control using Arduino,
DC Motor Direction Control using Matlab,
DC Motor Speed Control using Arduino and
DC Motor Speed Control using Matlab. Now, in this tutorial I will control a stepper motor using Arduino by entering the different commands through its serial port.
Before going into the detail of this tutorial, you must know the basic difference between stepper and DC motors. DC motors have only two input terminal one is positive and the other one is negative. You just have to provide the power supply and it will start rotating but this is not the case in stepper motor. The stepper motor which I will use in this tutorial, has six pins out of which four pins provide pulses or steps and the other two pins are power pins. So, in this tutorial I will control this six pins stepper motor using L298 motor controller and Arduino UNO board. Basically we can use stepper motor where precision is required. Stepper motor has wide range of applications e.g robotics, CNC machines, home automation etc. In simple word, we can say that stepper motor can be used where there is a need to move at particular angle. So, let's get started with Stepper Motor Direction Control using Arduino:
Stepper Motor Direction Control using Arduino
In this tutorial we will learn how to make a program for
Stepper Motor Direction Control using Arduino by sending dfferent commands from the serial port. First of all, I am going share the list of components used for this mini project.
- Arduino UNO
- Stepper motor (6 wire)
- L298 Motor Controller (H-Bridge)
- Voltage Regulator (7805)
- 1000uF
- Jumper Wires
- Solderig Iron
- Soldering Wire
I want to tell you a bit about the stepper motor because all the other components are discussed in detail in
DC Motor Direction Control using Arduino.
Stepper Motor
Basically, stepper motors are like the DC motors that rotate in discrete steps. They have multiple arranged coils and they are usually known as phases. Motor will rotate one step at a time if we energize each phase sequence. High levels of precision can be achieved by controlling the stepper motor with computer. Steppers motors are available in the market in many different sizes. The speed of the stepper motor is controlled by frequency of pulses generated. They have wide range of applications like hard disk drives, robotics, telescope, antenna, toys etc. A six wire stepper motor is shown in the figure below.
- You can download complete source code for Stepper Motor Direction Control using Arduino by clicking the below button:
Download Arduino Source Code
Selection of Wires
- I have used 6 wire stepper motor and each wire has its own function.
- I have first divided these six wires into two pair.
- Each pair is consisting of three wires out of which one wire is common and the other two generate pulses.
- The two pair of three wires are shown in the figure below.
- Then, I have chosen a common wire in each pair from which the resistance to the other two wires is common.
- I have checked the resistance from the common wire to the both of the other wires of the same pair.
- I found that the resistance from the common wire to both of the other wires is same.
- We can see in the figure above the blue, pink and white wires belong to the same pair out of which white is a common wire.
- Here is the screen shot of the figure when I found the resistance between white and blue wire and I found it to be 8.0 ohms.
- The screen shot of the above steps is shown in the figure below.
- After that. I checked the resistance between white and pink wire and found it to be 8.1 which is almost the same as 8.0 so, this shows that the white wire is common to both of the blue and pink wire.
- Here is the screen shot of the above step.
- Then I found the resistance between pink and blue wire and it was 15.6 which is exactly the double of the earlier resistance.
- It is shown in the figure below.
- I have connect the both common wires as shown in the figure below.
- Here's the video in which I have discussed it in detail How to identify the wires of Stepper Motor:
- The remaining four wires are used to generate pulses which are also know as steps
- I have connected theses four wires to the output pins OUT1, OUT2, OUT3 and OUT4 of the L298 micro controller.
- Input pins of L298 micro controller In1, In2, In3 and In4 are connected to the pin no 7, 6, 5 and 4 of the Arduino UNO's board respectively.
Note:
I have also controlled the stepper motor using PIC micro controller so I would suggest all of you to first go through that tutorial before going into the details of this tutorial.
Block Diagram
- I have made a simple block diagram for Stepper Motor Direction Control using Arduino, which will be helpful to clearly understand the algorithm and the assembling of the components of Stepper Motor Direction Control using Arduino.
- The screenshot of the block diagram is shown in the figure below.
- First of all we need a power supply to run the project properly.
- Arduino reads the commands from the serial port and sends to the L298 motor driver to rotate the stepper motor.
- The commands got printed on the LCD (Liquid Crystal Display).
Arduino Source Code Description
- The main function of the Stepper Motor Direction Control using Arduino is given below.
#include <LiquidCrystal.h>//Library for LCD
#include <Stepper.h> //Library for Stepper motor
const int stepsPerRevolution = 255;
// initialize the stepper library on pins
Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);
char data;
//LCD pins assigning
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
// set the speed at 60 rpm
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
lcd.begin(20, 4);//LCD type
lcd.setCursor(3,0);//setting LCD cursor and printing on it
lcd.print("Stepper Motor");
lcd.setCursor(5,1);
lcd.print("Direction");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");
delay(3000);
lcd.clear ();//Clearing the LCD screen
lcd.setCursor(0,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
}
void loop() {
if(Serial.available())
{
data = Serial.read(); //Reading the data from serial port
}
if(data == 'C'){Clockwise();}//Clockwise rotation
if(data == 'A'){AntiClockwise();}//Anti-clockwise rotation
if(data == 'S')//stopping the stepper motor
{
data = 0;
lcd.setCursor(3,0);
lcd.print("No rotation");}
}
- In the code given above we have first initialized the LCD and Stepper motor libraries.
- Then, I assigned stepper motor pins at which it is connected to the Arduino.
- After that I initialized the LCD pins at which it is connected to Arduino UNO.
- Then I have made three different if statements, C for the clockwise, A for the anti clockwise rotation and S for the no rotation.
- Then in the loop I called clock wise and anti clockwise functions whose source code will be give and explained below.
- Then, I cleared the serial data in order to stop the rotation of the motor.
- The source code of the clockwise function is given below.
void Clockwise()//function for clockwise rotation
{
Serial.println("clockwise"); //printing on the serial port
Serial.println("");//prints blank line on the serial port
myStepper.step(stepsPerRevolution);//counter clockwise rotation
lcd.setCursor(3,0);//setting LCD cursor
lcd.print("Clockwise"); //printing on LCDa
}
- The source code for the anti clockwise function is given below.
void AntiClockwise()//function for anti clockwise rotation
{
Serial.println("anti-clockwise");//print on the serial
Serial.println("");//prints a blank line on the serial
myStepper.step(-stepsPerRevolution);//clockwise movement
lcd.setCursor(3,0);//setting LCD cursor
lcd.print("Anti-clockwise");//printing on LCD
}
- Now, open your Arduino software, just copy and paste the source code given above.
- Run the program and open the Serial Port at the top right of the Arduino software.
- Now, when you enter the command C stepper motor will start running in clockwise direction.
- If you send the command A through the serial port stepper motor will start to rotate in counter clockwise direction.
- If you send the command S the rotation of the stepper motor will be stopped.
Actual Hardware Setup
- The actual hardware operating setup for Stepper Motor Direction Control using Arduino is given in the figure below:
- Now, if you send the command C through the serial port the stepper motor will start to rotate in clockwise direction and the command will also be printed on the LCD.
- The screenshot of the printed command on LCD is shown in the figure below.
- Now, if you send the command A through the serial port the stepper motor will start to rotate in anti clockwise direction and the command will also be printed on the LCD.
- The screenshot of the printed command on LCD is shown in the figure below.
- Now, if you send the command S through the serial port the stepper motor will show no more rotation and the command will also be printed on the LCD.
- The screenshot of the printed command on LCD is shown in the figure below.
- Here's the complete video demonstration of Stepper Motor Direction Control using Arduino, I hope it will help as well:
That's all from the tutorial
Stepper Motor Direction Control using Arduino. 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 try my level best to solve your problem in a better way if possible. I will explore Arduino by making different projects on it. 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 C 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 H 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 L 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 S 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 :)
Starting a SEO Consulting Business
Hello friends, I hope you all are doing great and having fun. Today, I am going to share a new tutorial in which I am gonna show you How to start a new
SEO Consulting Business. SEO is a particular type of Internet marketing that makes websites reach a higher rank when it comes both to organic and paid online services. Naturally, search keywords and key phrases change over time, which makes this business truly dynamic. As such, experts have to learn all the time and to perfect their manner of knowing ranking and advertising each year.
There are lots of SEO experts around, and one option, besides working for a company, is to offer consulting services to other businesses too. However, if you choose this path, you will have to invest in education,
marketing and business organization if you want to obtain some profit too.
I am sharing this tutorial for computer Engineering students because starting a SEO consulting business is an excellent option for Computer Software Engineers. One of my friends started this business around 2 years ago and rite now he is earning a handsome amount plus he has quite big staff working under him. So, if you understand the basics behind SEO then you can also do the same. Now I am gonna briefly explain some steps which are essential for starting a SEO Consulting Business:
Step 1: Learn SEO skills
You would think this goes without saying, but you’d be surprised to know how many people want to start a SEO consulting business without knowing SEO that well. It takes a couple of years of working with websites, analyzing web traffic and writing articles in order to become proficient in SEO. There are some basic skills you should already have, such as identifying and analyzing keywords, writing quality content, using Google Analytics or other similar analytic programs, writing meta tags and meta descriptions etc.
Step 2: Be an expert in SEO Consulting Business
Before starting your own business, it is advisable to work at least one year offering SEO solutions. In this way you can improve your expertise by attending conferences (such as Pubcon, MozCon and SEMPDX), optimizing your websites, write a blog and even an eBook. This is particularly useful for the marketing process, but you can also practice your research and get to know more about SEO.
Moreover, you can approach other businesses and experts and “steal” from their knowledge. A simple Google query for the Chicago area shows a lot of useful results for someone looking for
seoservicesusa seo chicago agency.
Step 3: Take business courses
Naturally, not everybody is good with business. You may have a degree in marketing or lots of experience in this domain, but you will still need some skills in order to run your own business. Take courses on tax preparation, finance, bookkeeping, business plan writing and any other topic that you don’t master. In this way, you will have a couple of advantages when you will start up the business.
Step 4: Write your business plan
After you took the special course (or not), you should write a business plan. Knowing beforehand what your goals and objectives are will make everything easier. Write down your plans on 5 years for management, marketing, finance and staff. Moreover, think about the fact that you could use these plans in order to get a loan or obtain an investment.
So, that's all about starting a SEO Consulting Business. I hope you guys get someknowledge out of it. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)
DC Motor Speed Control using Arduino
Hello friends! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how can you make a simple program for
DC Motor Speed Control using Arduino UNO. In my previous tutorial,
DC Motor Direction Control using Arduino, I have just controlled the DC motor in both directions at constant speed using Arduino. I have also performed the
DC Motor Direction Control in Matlab by sending different commands through serial port from Matlab and LabVIEW to the Arduino and then controlled the direction of rotation of DC motor. But in this tutorial I will rotate the same DC motor at variable speed in both clockwise and anti clockwise directions.
In my previous tutorial, we have seen that input pins
In1 &
In2 of motor control driver L298 (H-Bridge) are useful to control the direction of rotation of the DC motor. In this tutorial, I have controlled its speed as well by providing different voltage levels at the
enable pin of the DC motor control driver L298. It will be helpful to vary the speed of the DC motor in either clockwise or in anti clockwise direction. So, let's get started with
DC Motor Speed Control using Arduino UNO:
DC Motor Speed Control using Arduino UNO
In this tutorial we will learn that how to make an algorithm for DC Motor Speed Control using Arduino UNO. Speed control of any motor is always done y Pulse Width Modulation, abbreviated as PWM. PWM pulse can be generated using Arduino and L298 Enable Pin is used to get that PWM pulse and then it controls the motor speed accordingly. Before going into the further details I would like to tell you about the concept of PWM for controlling DC motor. Moreover, you can download the complete Arduino code for DC Motor Speed Control using Arduino by clicking the below button:
Download Arduino Source Code
Pulse Width Modulation (PWM)
PWM stands for Pulse Width Modulation. It basically describes the type of the digital signal. PWM technique is an excellent technique to control the analog circuits with microcontroller's digital PWM output. In this technique we can get analog results with the digital means. Digital control is used to create square wave. This pattern can vary voltages between full on i.e.
5V and full off i.e.
0V. The duration of on time i.e. when the the signal is present is known as
pulse width. PWM waves for the different duty cycles are shown in the figure below.
Duty cycle is basically the proportion of the time during which a system is operated. It can be expressed as a percentage. For example motor rotates for 1 second out of 100 seconds, it duty cycle can be represented as 1/100 or as 1%. For Arduino software coding the command
analogWrite(255) shows the maximum i.e. 100% duty cycle. To achieve 50% duty cycle we have to update this command to
analogWrite(127). Arduino UNO's pin no
3, 5, 6,10 and
11 are used as PWM pins. In this project we can control the speed of the DC motor by providing
high and
low voltages to the
enable pin of the motor control driver L298. For example, if a motor rotates with the maximum speed and 100% duty cycle at
12V and we provide it with the
6V then it will rotate with the half of the initial speed having 50% duty cycle.
Motor Controller L298
The pins
EnA and
EnB of the motor controller L298 are used as the PWM pins. We can rotate the DC motor at different speed providing different high and low voltage levels to these pins of the motor control driver. If we start to reduce the maximum voltage at which the motor rotates at maximum speed, the speed of the motor also starts to reduce. In this way these enable pins are helpful to control the speed of the DC motor.
Algorithm design and descrition
In this section of the tutorial
DC Motor Speed Control using Arduino UNO, I am going to explain you about designing as well as a detailed description of the designed algorithm. I will tell you about the entire algorithm in step by step procedure.
Note:Since you are working on the DC motor so you must also have a look at my previous tutorials, they will be helpful for you to simulate this project as well.
Open your Arduino software, copy and paste the source code given below in your software.
#include <LiquidCrystal.h>
//Keyboard Controls:
//
// C - Clockwise
// S - Stop
// A - Anti-clockwise
// Declare L298N Controller pins
// Motor 1
int count=255;
int dir1PinA = 2;
int dir2PinA = 5;
int speedPinA = 6; // PWM control
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
Serial.begin(9600); // baud rate
lcd.begin(20, 4);
lcd.setCursor(5,0);
lcd.print("DC Motor");
lcd.setCursor(5,1);
lcd.print("Direction");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");
delay(3000);
lcd.clear ();
lcd.setCursor(0,2);
lcd.print("www.TheEngineering");
lcd.setCursor(4,3);
lcd.print("Projects.com");
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);
analogWrite(speedPinA, 255);//Sets speed variable via PWM
}
void loop() {
// Initialize the Serial interface:
if (Serial.available() > 0) {
int inByte = Serial.read();
int speed; // Local variable
switch (inByte) {
case 'C': // Clockwise rotation
//analogWrite(speedPinA, 255);//Sets speed variable via PWM
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
Serial.println("Clockwise rotation"); // Prints out “Motor 1 Forward” on the serial monitor
Serial.println(" "); // Creates a blank line printed on the serial monitor
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Clockwise rotation");
break;
case 'S': // No rotation
//analogWrite(speedPinA, 0); // 0 PWM (Speed)
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, LOW);
Serial.println("No rotation");
Serial.println(" ");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("No rotation");
break;
case 'H': //Accelrating motor
count=count+20;
if (count>255)
{
count =255;
}
analogWrite(speedPinA,count);
delay(50);
//digitalWrite(dir1PinA, LOW);
//digitalWrite(dir2PinA, HIGH);
Serial.println("Motor is accelrating slowly");
Serial.println(" ");
Serial.println(count);
lcd.setCursor(0,0);
lcd.print("Motor is accelrating");
break;
case 'L': //Deaccelrating motor
count=count-20;
if (count<20)
{
count=20;
}
analogWrite(speedPinA,count);
delay(50);
//digitalWrite(dir1PinA, LOW);
//digitalWrite(dir2PinA, HIGH);
Serial.println("Motor is deaccelrating slowly");
Serial.println(" ");
Serial.println(count);
lcd.setCursor(0,0);
lcd.print("Motor Deaccelrates");
break;
case 'A': // Anti-clockwise rotation
//analogWrite(speedPinA, 255); // Maximum PWM (speed)
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
Serial.println("Anti-clockwise rotation");
Serial.println(" ");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Anti-clockwise");
break;
default:
// Turn off the motor if any other key is being pressed
for (int thisPin = 2; thisPin < 11; thisPin++) {
digitalWrite(thisPin, LOW);
}
Serial.println("Wrong key is pressed");
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wrong key is pressed");
}
}
}
- In the previous tutorials, DC Motor Direction Control using Arduino and DC Motor Direction Control using Matlab we have learnt that how to control the direction of the DC motor.
- We used the commands C, A and S for the clockwise rotation, anti clockwise rotation and stopping the motor respectively.
- In this tutorial, we have added two further commands H and L for accelerating and de-accelerating the DC motor.
- If we send the command H different times consecutively the speed of the motor will increase continuously.
- If we send the command L different times consecutively, the speed of the motor will start to decrease.
- Now, upload the source code to your Arduino UNO's board.
- Open the serial monitor at the top right of the Arduino Software.
- And enter the commands in serial monitor periodically as explained above.
Actual Hardware Setup
- When we enter the command C in the serial monitor of the Arduino software. Motor will start rotating in the clockwise direction and a statement Clockwise rotation will be printed on serial port.
- The same statement will be printed on the LCD as well as shown in the figure below.
- When we enter the command A in the serial monitor of the Arduino software. Motor will start rotating in the anti clockwise direction and a statement Anti clockwise rotation will be printed on serial port.
- The same statement will be printed on the LCD as well as shown in the figure below.
- When we enter the command H in the serial monitor of the Arduino software. Motor will start accelerating and a statement Motor is accelerating will be printed on serial port.
- The same statement will be printed on the LCD as well as shown in the figure below.
- When we enter the command L in the serial monitor of the Arduino software. Motor will start to deaccelerate and a statement Motor Deaccelerates will be printed on serial port.
- The same statement will be printed on the LCD as well as shown in the figure below.
Thats all from the tutorial
DC Motor Speed Control using Arduino UNO. I hope you have 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 my knowledge about
Arduino projects 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 S 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 A 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 :)
DC Motor Direction Control using Arduino
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 about how to make a simple program for
DC Motor Direction Control using Arduino. The word DC
is basically an abbreviation of
Direct current. So, a direct current motor is commonly used motor having two input terminals, one is positive and the other one is negative. If we connect these terminals with the voltage supply the motor will rotate. If you change the polarity then motor will rotate in opposite direction. You should also have a look at
Difference between DC & AC Motors to get a better idea about these motors.
DC motor has a lot of applications. You can use it in automation projects, for controlling static as well as mobile robots, in transport system, in pumps,fans,bowers and for industrial use as well. In this tutorial, I will do the
DC Motor Direction Control using Arduino and L298 motor controller. Moreover, I have also used LCD which will give us the status of our DC Motor i.e. whether its moving in clockwise direction or anticlockwise. In my later tutorial I will control the same DC motor using NI LabVIEW 2015 and MATLAB. I have added the next tutorial on this project in which I have done the
DC Motor Direction Control in MATLAB so in that project, I have used the same hardware but instead of controlling it from Arduino I have controled it using MATLAB so you must have a look at that tutorial.
DC Motor Direction Control using Arduino
In this tutorial, I will make a simple program to do the DC Motor Direction Control using Arduino. Arduino is basically an amazing micro controller and is very easy to use because it is an open source device. So, it is a student friendly device. You can also write Arduino programs for different purpose. Arduino is also a cost efficient device in comparison to the other micro-controllers e.g. raspberyy pi, NI-myRIO, galileo, single board RIO etc. First of all I prepared my complete hardware setup. Then I made a program and interfaced it with the hardware. We will discuss all the steps in detail below. The logic is pretty simple i.e. Arduino has to send commands to L298 motor controller and then L298 decides the DC Motor Direction Control by manipulating the Arduino commands. Before going into the detail, I want to show you the list of components required. You can download complete Arduino source file here:
Download Arduino Source Code
Note:
If you are working on DC Motor then you should also have a look at these Proteus Simulations:
Components List & Description
Here's the complete list of the components required for designing DC Motor Direction Control using Arduino:
So, now let's discuss the main components for this project individually so that you get better idea of why these components are used in this DC Motor Direction Control using Arduino:
Arduino UNO
Arduino UNO is basically the back bone of this DC Motor Direction Control Project. It controls and leads the whole project. In this project, Arduino reads the commends from serial port and sends to
L298 motor controller IC in order to control the direction of rotation of the DC motor. So, the Arduino has overall major control over the whole project.
Motor Controller L298
Motor Controller is used to control the direction of DC motor. It consists of an L298 motor driver IC which is capable of rotating the motor in both clockwise and anti clockwise directions by switching its pins from
HIGH to
LOW and vise versa. Moreover, it needs +12V, GND and +5V in order to power it up. So, we will design a voltage regulator which will step down 12V to 5V. So, let's have a look at this voltage driver in next part:
Voltage Regulator
Voltage regulator is also the part of this design. In our daily life, we need to step up or to step down the voltages according to the requirements. Requirements vary with the different purpose. Small electronics components like micro-controller, LED, LCD etc. So the main purpose of voltage regulator is to step down the voltage from 12V to just 5V in order to fulfill the requirements of the electronic components. Step down transformer can also be used instead of voltage regulator. Due to the huge structure and cost we prefer to use voltage regulator.
You should read How to
Design a 5V Power Supply in Proteus to get better idea about this voltage regulator. The circuit diagram of the designed voltage regulator is shown in the figure below.
DC Motor
DC motor is the essential part of the different projects and our daily life. for example if we want to automate our house doors i.e if we want to open and close the doors automatically by detecting the person, motor plays a vital role here. Similarly in robotics, vacuum, blowers and air conditioners, DC motor has a wide range of applications.
LED is used here to show whether the designed circuit is working properly or not. Like in mobile phones and laptops as we connect the charger it shows the charging indication. So, we must need some indication that everything is going fine and the circuit is working properly.
Jumper Wires
Jumper wires are used to make the connections between all of the components. Use small pieces of the jumper wires in order to give a better look to the designed circuit. If you are using longer wires for the connections, it will create complexity and causes many problems while operating the circuits.
Power Supply
12V power supply is used as the main power supply. As we know, to operate any of the electronic components or electronic appliances we must need the main power supply. Power supply can vary according to the power consumption of the electronic equipment. Here I am using a 12V DC power supply because it is a small and simple project with minimum power requirements.
LCD 20x4
LCD is used to visualize the commands sent to the serial port. It basially display us that which function is being performed at a particular time. A 20×4 LCD is used and is shown in the figure below. If you haven't worked on LCD before, then you should have a look at
Circuit Designing of LCD with Arduino in Proteus ISIS.
Assembling of the Components
Here are the few steps followed while designing this DC Motor Direction Control using arduino:
- Connect the terminals of the DC motor with the output pins (OUT1 and OUT2) of L298 motor controller.
- Connect L298 motor controller's pin IN1 and IN2 with the Arduino UNO's pin 2 and 5 respectively.
- Now, connect ENA pin of L298 motor controller to the Arduino's pin 9.
- Connect the power supply to turn on the circuit.
- Make sure that you have supplied 12V, 5V and GND properly to the L298 motor controller.
Circuit Diagram
Completely Assembled Diagram
Arduino Code Designing
After making all the connections properly, open your Arduino source code. If you are using Arduino for the first time then you should have a look at
Installation of Arduino Driver in Windows.
- Attach the Arduino board with your PC and go to Search->Device Manager as shown in the figure below.
- Select the device manger and you can see different options here like Batteries, bluetooth radios, keyboards, monitors, ports etc.
- Open the Ports(COM & LPT) as shown in the figure below.
- See the COM Port supported by Arduino Board which COM5 in this case.
- Now open the Arduino software and go to Tools and select the Arduino board and the COM port properly.
- The description is shown in the figure given below.
- Just copy and paste the source code given below.
#include <LiquidCrystal.h>
//Keyboard Controls:
//
// C - Clockwise
// S - Stop
// A - Anti-clockwise
// Declare L298N Controller pins
// Motor 1
int dir1PinA = 2;
int dir2PinA = 5;
int speedPinA = 7; // PWM control
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
Serial.begin(9600); // baud rate
lcd.begin(20, 4);
lcd.setCursor(5,0);
lcd.print("DC Motor");
lcd.setCursor(5,1);
lcd.print("Direction");
lcd.setCursor(5,2);
lcd.print("Control");
lcd.setCursor(2,3);
lcd.print("via Arduino UNO");
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);
}
void loop() {
// Initialize the Serial interface:
if (Serial.available() > 0) {
int inByte = Serial.read();
int speed; // Local variable
switch (inByte) {
case 'C': // Clockwise rotation
analogWrite(speedPinA, 255);//Sets speed variable via PWM
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
Serial.println("Clockwise rotation"); // Prints out “Motor 1 Forward” on the serial monitor
Serial.println(" "); // Creates a blank line printed on the serial monitor
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Clockwise rotation");
break;
case 'S': // No rotation
analogWrite(speedPinA, 0); // 0 PWM (Speed)
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, LOW);
Serial.println("No rotation");
Serial.println(" ");
//lcd.clear();
lcd.setCursor(5,1);
lcd.print("No rotation");
break;
case 'A': // Anti-clockwise rotation
analogWrite(speedPinA, 255); // Maximum PWM (speed)
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
Serial.println("Anti-clockwise rotation");
Serial.println(" ");
//lcd.clear();
lcd.setCursor(3,2);
lcd.print("Anti-clockwise");
break;
default:
// Turn off the motor if any other key is being pressed
for (int thisPin = 2; thisPin < 11; thisPin++) {
digitalWrite(thisPin, LOW);
}
Serial.println("Wrong key is pressed");
//lcd.clear();
lcd.setCursor(0,3);
lcd.print("Wrong key is pressed");
}
}
}
- Now, upload the source code onto the Arduino UNO board as shown below.
- In the above figure shows that the source code is uploading to the Arduino board.
- Done uploading shows that the source code has been uploaded successfully to the Arduino borad.
- Now, go to the Serial Monitor on the top right corner of the Arduino software.
- Press C, you can see the DC motor is rotating in the clockwise direction and statement Clockwise rotation will be printed on the Serial Monitor.
- Now, press S, the DC motor will stop and a statement No rotation will be print on the Serial Monitor.
- If you want to rotate DC motor in anti-clockwise direction, press A then, the statement Anti-Clockwise rotation will be printed on the Serial Monitor.
- I have made the logic in such a way that if you press any of the other buttons the DC motor will stop in reaction to that and the statement Wrong key is pressed will be printed on the Serial Monitor.
- All of the above steps are shown in the figure shown below.
Final Testing of DC Motor Direction Control using Arduino
- The screenshot of the actual circuitry for DC Motor Direction Control using Arduino is shown in the below figure:
- You can see in the above figure that we have attached Arduino UNO board with L298 Motor Driver and then we have attached DC Motor with Arduino UNO and LCD is used to show the current movement of Motor.
- Moreover we have also designed a small circuit which I have mentioned above and named as Voltage regulator, and it is used to step down 12V into 5V.
So, that's all from the tutorial
DC motor Direction Control using Arduino. I hope you enjoyed this tutorial. In my next tutorials, I will interface this project with LabView and MATLAB. If you face any sort of problem, you can freely ask me
anytime without feeling any kind of hesitation. So, will see you guys in next 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
m² and volume is measured in
m³ 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 2 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 :)
Tutorial2: Earn with Primedice
Hello everyone, I hope you all are doing great. Today, I am going to share a new tutorial in which we will have a look at How to
Earn with Primedice. If you remember the
Tutorial1: Earn with Freebitco.in in which I have shared how to earn with freebitco site and earn bitcoins. Today, I am gonna share a new bitcoin site and I must say that Primedice is quite better then Freebitco. I will share why its better then the previous one in detail.
AS I have discussed this in my previous tutorial that Engineers normally don't do well when it comes to earning so they must find some way through which they can earn some money. And online earning is the best way to earn money. In online earning, bitcoins are really very precious because if you have a look at its conversion rate then 1 BTC = 1000$. So, I think you should be smart and try to get some real BTC. In future, I will surely share more tutorials on how to earn Bitcoin online. Anyways, coming towards today's tutorial, let's have a look at how to
earn with PrimeDice.
Earn with Primedice
- First of all, what you need to do is to Create an account on PrimeDice.
- So, once you created your account then click on the Faucet link given in the top menu.
- If you have worked on the Freebitco then you must have the idea that Freebitco gives you around 177 Santoshi after every one hour.
- But that's not the case with Primedice. Primedice gives you 150 Santoshi after every 3 minutes (only if its 0 in your account :P ) and that's really a great thing about PrimeDice.
- Moreover, PrimeDice also have an online betting game through which you can multiply your BTC.
- Now the strategy on PrimeDice is that you have to earn some BTC with just betting and even if you lose then you can again get the Faucet.
- So, I would suggest you to give it a try like alteast 50 times and keep betting and I am sure that you will be lucky at least once.
- Now if you got lucky and able to get like 2000 Santoshi on it then you can play its Betting game as we discussed in the FreeBitco.
- So now click on the Automated Betting and make the Payout to 3 something so that you earn big.
- Moreover, change the ON Loss section and increase it to 100%.
- That's the same trick which I have discussed in the Freebitco site so I hope you will start earning something.
So, that's all about how to earn with PrimeDice. But again its a betting site so you are on your own, you can also deposit BTC but there's always risk when you are betting. Keep that in mind. So, thanks for reading and have fun !!! :)
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. :)