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. :)
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.
- 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.
- 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.
- 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 :)
Water Level Detector in LabVIEW
Hello friends! Hope you all will be absolutely fine. Today I am going to share my knowledge with you about how to create an algorithm for
Water Level Detector in LabVIEW 2015. LabVIEW is an excellent software for simulation purpose as well as for the hardware interfacing (interfacing with the external devices). I support the "Graphical Language" which is usually known as "Field Programmable Gate Array (FPGA) " based language. In other software we have to create logic first and then we need to write a complete syntax for the created logic. This software is very easy to use and is quite helpful. Because, we don't have to write the complete complex syntax, instead we have to just create our logic and implement this logic using FPGA blocks. In this tutorial we will learn to make a simple water level detector in LabView. The simulation is given below for download and if you guys have any problem in it then ask in comments and I will resolve them. This simulation is tested on LabView 2015.
Water Level Detector in LabView
Here I am going to elaborate you that how to make a simple
Water Level Detector in LabVIEW 2015. First of all we will look at the important LabVIEW components or you can say tools, required to design a water level detector. You can see the list of these components below
- Tank
- Vertical Pointer
- Upper Level Indicator
- Lower Level Indicator
- Graph to observe the results
You can download this simulation of Water Level Detector in LabView by clicking the below button:
Download LabView Simulation
Vertical pointer is used to control the level of the water in the tank. Upper level indicator shows when the tank is about to completely fill. Lower level indicator shows indication by turning "ON" the LED when the level of the water in the tank is too low and we need to fill it. Graphs shows the graphical visualization as the vertical pointer moves up ow down.
- Go to the "Front Panel" and press "Right Click" from your personal computer or laptop.
- Now, go to the Controls-> Modern-> Numeric-> Tank.
- By doing this, you can see the following figure in your PC's screen.
- You can see different blocks in the above figure
- Select the encircled "Tank" and place it on the "Front Panel"
- It looks like the below figure
- Now, put the "Cursor" on the tank and press "Click" you can see that the water level changes with each different click on the tank
- You can see the above step in the figure below:
- Blue color show the level of the water in the tank.
- Now go to the "Front Panel" and then go to the Controls-> Modern-> Numeric-> Vertical Pointer.
- By doing this, you can see the following figure in your PC's screen:
- You can see different blocks in the above figure.
- Select the encircled block i.e. "Vertical Pointer".
- Place this block on the "Front Panel".
- It is looking like the figure below:
- Put the "Cursor" on the "Vertical Pointer", press click and then move up and down.
- It looks like the figure below:
- Blue color indicates the value or rate at which we want to fill the tank
- So now, you have selected both the tank and the vertical pointer and you can see that it looks like the figure below:
- Now press "Ctril+T"
- You can see the "Block Diagram" window is looking like the below figure
- Now, since we want to control the level of the water in the tank with the help of the vertical pointer by adjusting it at different positions
- So, we have to build a connection between them
- Take a wire from the output terminal of the vertical pointer (Slide) and connect it to the input terminal of the tank
- The figure below exhibits the above steps
- No we have to set the upper and lower level for the less and high amount of water indication
- We need to put two LED's, one for the upper level ndication and the second for the lower level indication
Upper Level Indicator
- Press "Click" on the "Block Diagram" window
- Go to the Functions-> Programming-> Comparison-> Greater or Equal?
- Figure displays the above steps
- Select and place this block on the "Block Diagram" window
- Connect its first input terminal with the output terminal of the "Vertical Pointer"
- Go to the second input terminal of the "Greater or Equal" press "Right Click"
- Go to the Create->Constant
- The figures below displays the above steps
- Set the value of the constant as "9"
- The figure shows the adjusted value of the "Constant"
- Now we have to put an LED in the "Front Panel" for the upper level indication
- Press "Right Click" on the "Front Panel"
- Go to the Controls-> Modern-> Boolean-> Square LED
- The figure below shows all of the above steps
- Select the LED and place it onto the "Front Panel" with the top right corner of the tank
- Figure elaborates a bit more
- Now, Go to the "Block Diagram" window again
- Connect the output terminal of the "Greater or Equal" to the input terminal of the "LED" as shown below
- Now go back to the "Front Panel"
- You can see, as the vertical pointer moves up from the desired upper which is "9" in this case, limit LED turns on
- Here is the screenshot of the "ON" LED
Lower Level Indicator
- As the upper limit is adjusted above.
- Similarly set the lower limit.
- Go to the "Block Diagram" window and press "Right Click".
- Go to Functions-> Programming-> Comparison-> Less or Equal.
- select this block and connects one of its inputs to the "Vertical Pointer".
- Go to the second input and press "Right Click".
- Go to Create-> Constant.
- Set the constant, in this case I have set it to "2" as shown below:
- Place and LED in " Front Panel"
- In "Block Diagram" window connect the LED with the "Less or Equal" block
- If you want that your program should no terminate until you did it by your self then follow the below steps
- Now, Go to the "Front Panel" and press "Right Click"
- Go to Functions-> Programming-> Structures-> While Loop
- Select and place it on the "Block Diagram" window
- Place the whole program inside the "While Loop"
- Now, go to the "Front Panel" and press "Right Click"
- Go to Controls-> Modern-> Boolean-> Stop Button
- Select and place it on the "Front Panel"
- Now, go to the "Block Diagram" window
- Connect this button with the "RED" small circle at the bottom right corner of the "While Loop" as shown below in the figure
- Complete "Block Diagram" logic of making water level detector is shown below
- Complete output of the water level detector is shown below
So, That's all from today's tutorial of Water Level Detector in LabVIEW 2015. I hope you have enjoyed my effort. I will share a new project on LabView soon. Till then take care :)
Creating First Project using LabVIEW Programming
Hello everyone! I hope you all will be fine. Today, I am going to elaborate that how to create your
First Project using NI LabVIEW Programming. This software is very easy to use in comparison to the other software. You do not have to write the complete source code for the desired output, like in other software e.g. Arduino, MATLAB, Dev C++, Eclipse etc. instead you have to just implement your logic using Field Programmable Gate Array (FPGA) blocks. The program is designed with the help of the FPGA blocks, is usually known as “
Virtual Instruments”.
Normally we used to call it as VI’s. We create in “Block Diagram” window as described in our previous tutorial on
Introduction to LabView. If you haven't read that tutorial then I owuld suggest you to read that one first because I have given a detailed introduction to LabView software and today's we are gonna have the same introduction but about LabView Programming. So, today we are gonna design our first project using LabView Programming and you will see how easy it is in LabView Programming. If you ask me then when I was a beginner on LabView Programming then it seems to me the most difficult programming Language but now I can say that LabView Programming is the most easiest and flexible one. Labview has a great online support, yu should also have a look at this online
LabView Community because its very extensive and has great projects and tutorials. Here I am going to guide all of you, about creating your first program using
NI LabVIEW Programming.
Creating First Project using LabVIEW Programming
- First of all create a new project as we have done in our previous tutorial Introduction to LabView.
- Now once you created the project you will have two windows in front of you named as Front Panel and Block Diagram.
- I will start the very first step by simple adding two parameters in our Block Diagram.
- So, open your “Block Diagram” window and go to Functions-> Programming-> Numeric.
- By doing this, you can see the following window on your screen:
- Select the very first block named as “Add”, its an addition operator in LabView Programming.
- Drag and place it on the “Block Diagram” window.
- You can see that it has two input terminals (x and y) and only a single output terminal (x+y) which shows that this block gives only one result by manipulating the two different parameters simultaneously.
- Inputs are known as “Controls” and outputs are known as "indicators".
- Since we want to manipulate the two parameters by changing them according to our requirement so we will make the input terminals as “Control”.
- Place the cursor on one of the input terminal and right click it.
- Go to the Create-> Control as shown in the figure below:
- By pressing the “Control” option, one input of this block can be controlled manually by you.
- Similarly, perform the same procedure on the second input terminal.
- The figure shows both of the manually controlled inputs:
- Now we have to observe the output of the block, which is now manipulating the two input parameters.
- Place the cursor on the output terminal of the block and make a click on it.
- Now, go to Create-> Indicator because we have to display the output.
- The figure below shows a bit detail:
- Press the “Indicator” option and you will get an indicator on your output pin.
- You can see that output has also been created now as show in the figure below:
- Now our first project using LabView programming is completed in the “Block Diagram” window.
- Since we have create our project with the help of FPGA blocks.
- So, what we have to do is to observe the output of the designed algorithm.
- So now, we need to go to the “Front Panel” which helps us to show the output of the program as described in detail in our previous tutorial Introduction to LabView.
- Open the “Front Panel” window and it will be something like the image shown below:
- On the left side of the “Add” block there are two inputs represented by as “x” and “y”.
- And on the right side there is a single output represented by “x+y” to perform the addition operation.
- Now adjust the both of the input parameters to obtain the desired output according to the adjusted parameters.
- Here I have adjusted “x” input by assigning it with a value “2”.
- And I have adjusted “y” input by assigning it with a value “5”.
- You can see both of the adjusted inputs in the figure below:
How to Run LabView Simulation ???
- You have to see the output of the program according to the adjusted parameter
- Go to the “Run” button on the top left corner of the “Front Panel” window, and just run the program
- The figure shown below will explain a bit about both of the above two steps
- You can see the output of the program has been successfully obtained according to the adjusted input parameters.
- So that is how you can perform the simple addition of the two parameters in LabVIEW.
- You can also use the all of the other operators in the Functions-> Programming-> Numeric similarly to perform different operations for the different input parameters according to your own requirements.
For Loop using LabView Programming
- In previous part, you can see that as you compile (run) your program it shows the desired output and then terminates.
- That means if you have to change input parameters then you have to run your program again as well.
- Now I am going to explain you that what to do with this program, if you want that this should run for a number of iterations.
- There is “For Loop” option which helps us to run our designed algorithm for number of iterations we want.
- You can select the “For Loop” by following the below procedure:
- Select the “For Loop”, drag and place it in the “Block Diagram”.
- It will look like the figure shown below:
- You can see that there is a “N” symbol on the top left corner of the “For Loop”.
- Basically the symbol “N” shows the number of iterations for which we want to run our program.
- Go to the input terminal of the symbol “N” and click on it.
- Now, go to Create Constant as shown below:
- So, set the number of iterations according to the requirement.
- Here, I am going to set the iterations value to 5 as shown in below figure:
- Now place the designed algorithm inside the “For Loop” to run the program five times in this case as shown in the figure below:
- Now your program will run for five iterations.
While Loop using LabView Programming
- If you want that your program should have continue to run until you terminate then it is also possible.
- “While Loop” option will be helpful for us in such a condition.
- Here I will tell you how to select the “While Loop” in this software. It is quite similar to the selection of the “For Loop” described in previous section.
- Go to Functions-> Programming-> Structures-> While Loop as shown in below figure:
- Select the “While Loop” drag and place it on the “Block Diagram” window.
- Now, place the designed algorithm inside the “While Loop” like shown below:
- You can see there the “Run” button is not in a normal condition which shows that there is some problem with the program.
- It is due to the fact because we have not yet defined the terminating condition of the program.
- Now, go to the “Front Panel” window and right click on it.
- Go to Controls-> Modern-> Boolean-> Stop Button as shown in the figure below:
- Connect the “Stop Button” with the red dot surrounded with the green boundary at the bottom right corner of the “While Loop” as shown in the figure below:
- Now you can see that the “Run” button is now again in normal state which shows that the everything is going fine with the program.
- Now, run the program and it will continue to run until you press the “Stop Button” in the “Front Panel” window.
- Running Program is shown in the figure below:
- You can change the input according to the requirements and you can see output immediately and you do not have to run the program again and again for the different inputs
- If you press the stop button you can see that the program terminates only then
That's all from this tutorial. I hope you enjoyed that and it will help you in learning Labview Programming. If you face any sort of problem then you can ask us without feeling any kind of hesitation. I will explain the further details of NI LabVIEW in the later tutorials. Take care till then :)