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 :)

Introduction to LabVIEW

Hello everyone. I hope you all will be absolutely fine. Today, I am going to share an Introduction to LabView. LabView is a really exciting software and recently I have worked on many LabView Project so I thought to start this new set of series in which I am gonna explain all about LabView from beginners level to Pro Level. So, today I am gonna upload the first tutorial in this LabVIEW series so that's why I have named it Introduction to LabView and I hope you are gonna like this tutorial. :)

LabVIEW basically stands for “Laboratory Virtual Instrument Engineering Workbench”. This software is designed by the National Instruments (NI) for the control and design of the projects. You can use it for simulation purposes, can also interface hardware with LabVIEW, data acquisition is another big benefit of LabView. Moreover we can also design automation and robotics projects in LabVIEW. Before designing such projects, let's first have a look at the Introduction to LabVIEW:

Introduction to LabVIEW

  • So, let's get started with Introduction to LabView and first of all what you need to do is to open the NI LabVIEW 2015 software.
  • A small window will open up as shown in the below figure:
  • So, this newly opened LabView window will have two portions “left bar” and “right bar”.
  • If you want to design new project then you have to click on the button “Create Project”.
  • If you want to open the project which already exists then press “Open Existing” button.
Opening New VI in LabView
  • Go to the “File” menu of the software as show in the figure below
  • Click on “New VI” or you can press the short code Ctrl+N. to open up new VI in LabView.
  • So, now when you click on this NewVI then you will see that two windows will open up.
  • One of them is known as “Front Panel” and second is known as “Block Diagram”.
  • Both windows and their functionalities are explained in detail below:
Block Diagram
  • Here is the screen shot of the “Block Diagram” so when we are having the Introduction to LabVIEW then we must discuss these windows in detail. :)
  • This window is named as Block Diagram because we design our LabVIEW Block Diagram in this window.
  • It's more of a back end programming section.
  • So suppose you are designing some simulation in LabView then what features you want in your simulation depends on your code in the Block Diagram.
Front Panel
  • Here's the screen shot of “Front Panel” of LabVIEW.
  • It's also known as GUI of LabVIEW.
  • In this Front Panel of LabView, we design the presentable output.
  • For example, you are working on some simulation and you have to display some sensors' values then they are gonna be displayed in this Front Panel.
So, both of these windows are equally important and works simultaneously with each other. So, if you change anything in Front Panel then its counter part in Block Diagram will also change. So, let's have a look at How to align these two windows in LabVIEW.
Windows Alignment in LabView
  • Now we know that if we are gonna work on some LabView simulation then we have to deal with two windows and in the above section of Introduction to LabView, we have discussed both of these windows.
  • Now the problem is when we are working on two windows simultaneously then we need both of them to be rite in front of us.
  • In order to do so, press “Ctrl+T” and both of your windows will be rite in front of you.
  • It will help you to align both the windows, the “Front Panel” and the “Block Diagram”.
  • The aligned windows are shown below and you can see the are looking nice comparatively.
  • If “Front Panel is there on you screen and “Block Diagram” window is not on the screen, then just pres “Ctrl+E”.
  • You can see “Block Diagram” also appears automatically on the screen.
  • You can perform it for the vice versa purpose as well.
Description of Block Diagram Window
  • Block diagram is a window in which we can create our logic by using different blocks.
  • NI LabVIEW basically supports Field Programmable Gate Array Language (FPGA).
  • We have to select different blocks according to the requirement ad they are known as FPGA blocks.
  • Press “Right Click” on the “Front Panel” a new “Function” tab opens as shown below:
  • From this “Function Tab” you can select different blocks to create your logic according to the requirements
  • The detail about few of the blocks and functions is given below.
Numeric Toolbox in LabVIEW
  • Go to the Functions-> Programming-> Numeric and you will get all your numeric tools there.
  • You can see, the following window on your screen
  • You can see different alphanumeric blocks (operators) like addition, subtraction etc. in the above figure
  • Using these operators you can perform different mathematical operations
Graphics in NI LabVIEW
  • Graphics tool is another amazing tool in this software and I think we should discuss them in this Introduction to LabView.
  • Go to Functions-> Programming-> Graphics & Sounds and you will get all your graphics tools in there.
  • You can see a window on your screen as shown below:
  • You can make three dimensional picture and plot three dimensional graphs as well.
Comparator in LabView
  • Go to Functions-> Programming-> Comparison and there's a big list of comparator waiting for you there.
  • You can see a window on the screen as shown below
  • These blocks are used for the comparison of two or more than two operators.
  • These blocks are used in the projects where there are some restrictions i.e. if temperature exceeds the threshold, fire alarm or buzzer turns into “ON” state then.
Loops in LabView
  • Go to Functions-> Programming-> Structures and here lie the most important functions of LabView programming.
  • The below window will appear on the screen:
 
  • If you want to run your created logic for different no of iterations, these loops will be helpful.
  • You have to just set the number of iterations and your program will according to the adjusted number of iterations.
Timing Toolbox in LabVIEW
  • Go to the Functions-> Programming-> Timing and you will find all the timing blocks in there.
  • You can see the following window on the screen:
 
  • If you want that your program should run with some delay.
  • These timing clock bocks will be helpful.
  • Usually their values are in milliseconds but you can adjust them accordingly by setting their properties.
Driver Support in NI LabVIEW
  • One of the amazing functions of the NI LabVIEW is that, it supports the external device drivers.
  • The device which we want to use and interface with the NI LabVIEW, we have to just install the driver of that device.
  • After the successful installation you can see that device in "Functions" Palette.
  • For example, go to the Functions-> Programming at the end of the window you can see the installed drivers or toolkits.
  • I have installed Arduino interface for NI LabVIEW 2015.
  • The figure below describes all of the above steps.
NI LabVIEW Supported Devices
Here's the list of most commonly used NI LabVIEW devices:
  1. compactRIO.
  2. myRIO (Re-configureable Input Output Device).
  3. sbRIO (Single Board Reconfigureable Input Output Device).
  4. Arduino.
  5. Raspberry PI.
  • NI LabVIEW suppors different devices.
  • You have to just install the drivers or toolkit of these devices.
  • After successful installation you will be able to use these devices.
Description of Front Panel
  • Press “Right Click” on the “Front Panel” window
  • You can see the output of your designed algorithm on the “Front Panel” window.
  • We can make our output’s look more and more beautiful.
  • For this purpose NI LabVIEW provides us with the “Decorations” section.
  • Go to the Controls-> Modern-> Decorations and the following window will be appeared on your screen.
 
  • These blocks are helpful while giving the better external look to the Front Panel.
  • Now go to the Controls-> Modern-> Boolean and you will have a look at the Boolean Buttons which are different in shapes and sizes.
  • You can see a new window on the screen as shown in below figure:
  • Round LED, Square LED are used for some indication purposes.
  • You can use a “Stop” button to terminate the program.
  • You can use radio buttons for “checking” and un-checking purposes.
Graphical Visual Display
  • Graphical Visual display is also a good function in NI LabVIEW.
  • You can display your output on different graphs.
  • Go to Controls-> Modern-> Graph and all the graphical Visual Displays open up.
  • The figure shown below will be appeared on the screen.
  • Select the graph you want and display your output on a particular graph.
  • 3D graphs is a very good option for the good looking output.
Searching Desired Blocks
  • Press “Right Click” in the front panel
  • Go to the “Search” option as shown in the figure below
  • Press the “Search” option
  • You can see following window on the screen
  • Type the name of the block you want to find.
  • Sometimes the “simple search” method takes a lot of time in finding the desired blocks.
  • So, I prefer to use the quick search method.
  • So, you should use “Quick Search” method, it will be helpful in time saving perspective.
  • Go to the “Front Panel” and press “Ctrl+Space Bar”.
  • You can see a new window on the screen.
  • You can see the window in the figure below.
  • For example, I want to search the “Simulate Signal” block.
  • So, I typed “Simulate Signal” in the search bar.
  • The desired blocks are appeared as shown in the figure below.
So, that's all form today's tutorial on Introduction to LabView. I hope that it will be helpful for all of you. I have tried my level best to share in detail, my knowledge on Introduction to LabVIEW, with all of guys. I'll share further knowledge about this software soon, till then take care :)

Eye Ball Detection in MATLAB

Buy This Project Hello friends, I hope you all are doing great. In today's tutorial, I am going to share Eye Ball Detection in MATLAB. I have designed this simulation in MATLAB and I have designed a GUI in which I am detection the Eye Balls from Images. Our team has worked quite hard in designing this project so we haven't shared the code for free. Instead we have placed a very small amount and you can buy it from our shop via PayPal. Click the above button in order to buy the project. If you are having any difficulty in buying this project then you can also ask in comments and we will surely help you out. Moreover, this algorithm has a small restriction that the person's eyes must be open in the image and his/her eye balls must be clearly visible otherwise this algo won't work on it. I have added 10 images in the database which will help you in understanding the main algorithm of this project. So, let's get started with Eye Ball Detection in MATLAB:

Eye Ball Detection in MATLAB

  • So, first of all, click the below button in order to buy this Eye Ball Detection Project in MATLAB.

Buy This Simulation

  • Once you download the files, then open the files named as MainGUI.m.
  • Note, you must have MATLAB 2015 or higher in order to run this program correctly.
  • It will open up a window which will look something as shown in below figure:
  • One thing you should remember that MATLAB is not much good with graphics so you may have to change your axes' sizes.
  • Anyways now click the button which says Browse and open any of the images present in the folder and then click Load Image button.
  • I have opened the below image:
  • If everything goes fine then you will get results something as shown in below figure:
  • So, you can see in the above figure that I have labelled all the images of Eye Ball Detection in MATLAB.
  • These labels are actually the steps in which we are doing our Eye Ball Detection.
  • So, first of all I cropped the Pair of eyes and shown it in the Figure 2.
  • After that I gray scaled the image and it is shown in Figure3.
  • Next thing we need to do is to crop single eye from the pair of eyes which is done in Figure 4.
  • In Figure 5, I have simply converted my gray scale image into binary image.
  • In Figure 6, I have applied some filters to make it more smooth and to ignore noises.
  • In Figure 7, I have taken the inverse of image in Figure 6. That's why now Eye Ball is showing in white color and rest of the background is in black.
  • In Figure 8 and 9, I have applied filters, filters are always used to remove noise and to make figure more visible.
  • In figure 10, I have taken the edges of the previous image.
  • Finally in Figure 11, I have detected the circular region and then plotted a circle around it and I have done the same thing in Figure 12.
  • Here's the results of another image for Eye Ball Detection in MATLAB:
  • As, I have told earlier that our team has done a lot of effort in designing this project that's why we haven't shared its code but you can buy it quite easily from our shop by clicking the above button.
  • Moreover, I have designed this video which will help you better in understanding this project.
  • So, please must watch this video before buying this simulation so that you are sure what you are buying. you can also contact us if you are having any problems in buying it.
  • Here's the video for EyeBall Detection in Matlab:
So, that's all about Eye Ball Detection in MATLAB. I hope you guys have enjoyed today's post. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)

Automatic Street Light Project in Proteus

Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share a semester project which is named as Automatic Street Light Project. I have designed this project in Proteus ISIS and the simulation is also given below for download. Btw this was my first project during my engineering course. :D I had really enjoyed while working on this project as I was new to electronics then.

This project is about Automatic Street Light. You must have examined on your streets that the street lights turn ON at night while they turn OFF in the day. When I was a child then I think that someone turns ON the switch in the day and then turns it OFF at night but that's really not the case. :P

In fact, these lights are automatic and have a sensor in them which is known as LDR sensor. This sensor is used to detect the light intensity so if there's sun light in the surroundings then it simply turn OFF the street light and if there's no sun light then it turns ON the street light and that's how Automatic Street Light works. I have designed its simulation in Proteus ISIS software which you can download below. So, let's get started with Automatic Street Light Project in Proteus ISIS.

Note:

Automatic Street Light Project in Proteus ISIS

  • You can download the working simulation of Automatic Street Light Project designed in Proteus ISIS by clicking the below button:

Download Proteus Simulation

  • You can download the Proteus simulation by clicking the above button but I would recommend you to design it on your own so that you get maximum knowledge out of it.
  • So, let's design it on our own. :)
  • First of all, design a simple circuit as shown in below figure:
  • You can see in the above figure that I have designed two circuits. Both of these circuits are exactly same but they have different LDR sensors.
  • Proteus has two LDR sensors in its database that's why I have designed two circuit diagrams and have used both of them.
  • Moreover, I have used LM324 IC in it which is getting the input from the LDR sensor at its negative pole and the LED is attached at its output.
  • LDR is a Light Dependent Resistance which gives output when it detects light.
  • The output of LDR is analog and it depends on the light intensity.
  • If the light intensity is HIGH then LDR value will be HIGH if its LOW then value will be LOW.
  • That's why I have placed a variable resistance which is used for setting the threshold value for LDR.
  • Rite now when there is full light only then the LED will go HIGH otherwise it will remain LOW.
  • So, let's now simulate this simulation of Automatic Street Light and have a look at the results:
  • You can see in the above figure that in the OFF state the LED is OFF when LDR is not detecting light.
  • Now in the ON state, when LDR detected the Light then the LED goes ON automatically.
  • You must be wondering that its working on opposite logic i.e. when there's light then the Light goes HIGH and when there's no light then the Light goes LOW.
  • Moreover, the output is just of 5V but the street lights are of normally 220V AC or 12V DC.
  • So, let's add a simple Relay in front of this circuit so that we can add some lamp as shown in below figure:
  • Now let's have a look at the OFF state of this Automatic Street Light Project, shown in below figure:
  • You can see in the above figure that the LDR is detecting the light but the Lamp is OFF, so its like a day time. There's light and that's why street light is OFF.
  • Now, let's have a look at its ON state in the below figure:
  • Now you can see the LDR is not detecting any Light which means its a night time and that's why our lamp is ON.
  • The below video will give you a better idea of How it works:

So, that's all for today. I hope you have enjoyed this Automatic Street Light Project in Proteus ISIS. Will meet you guys in next tutorial. Till then take care and have fun !!! :)

Getting Started with Cayenne - Arduino

Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new and very exciting service with you guys which is named as myDevices Cayenne, we will have a look at getting started with Cayenne. Its really an awesome platform for students and hobbyist who wants to work on embedded systems but are afraid of programming codes.

Cayenne is an online project building platform using drag and drop. Currently it supports Arduino and Raspberry Pi. In simple words, you can design any of your Arduino or Raspberry Pi project simply by drag and drop different components. You don't need to write any code, you just need to place your blocks and upload it to your Arduino board. Its also known as the Graphical coding.

I came to know about Cayenne a few days ago and I have really enjoyed working on it so I thought to share it with you guys so that you can also get benefit from it. In today's tutorial, I am just gonna give an overview of Cayenne and we will design a simple Arduino LED project on it. In the coming tutorials I will share different projects on Cayenne, which will help you guys in your projects. Moreover, first we will cover the Arduino Project on Cayenne and later we will work on Raspberry Pi as well. So, let's have a look at Getting Started with Cayenne.

Getting Started with Cayenne

  • First of all, what you need to do is to open this myDevices Cayenne Website.
  • Now on this myDevices Cayenne Website you have a to create a free account so click on the Green Button which says Get Started for Free.
  • So, fill out the form on the Registration page and then it will ask you which one you want to use as shown in below figure:
  • Now as we are gonna work on Arduino so I will select Arduino among them.
  • You must have the Arduino IDE installed on your computer and you should also install the Cayenne Library for Arduino.
Note:
  • When I first started working on Cayenne, I had an older version of Arduino software and when I compiled the code then it generated errors, so I updated my Arduino software and it worked fine.
  • So, you just make sure to have the latest Arduino IDE.
  • Next thing you need is the Arduino Ethernet or Arduino Wifi Shield, which will be used for uploading the code to Arduino board from Cayenne website.
  • So, now plug your Ethernet or Wifi shield on the Arduino board.
  • I have plugged Arduino Wifi shield with Arduino UNO.
  • So, now once you selected the Arduino then on the nex page you will get some instructions, which I have already disscused.
  • Now you should plug your Arduino board with your computer and click Next.
  • In this step you need to select your device as shown in below figure:
  • In the above figure, you can see first of all, I have selected the Arduino UNO shield becasue I want to upload the code in this shield and then I have selected the Wifi Shield using which the code will be uploaded.
  • Now when you click on the Sketch button you will get a small sketch which you need to upload in your Arduino board.
  • This is the only code which you need to upload, this code is acting as a bridge between Arduino and Cayenne.
  • Once you uploaded that code then Cayenne will automatically detect your board, you just need to wait.
  • As soon as your board is detected, you will be redirected to your Dashboard, where you can design your first project as shown in below figure. :)

Arduino LED Blinking Project in Cayenne

  • Now Click on the Create new Project button and give it a name, I have given it Arduino LED and click OK.
  • The new project will be created, now we need to add the LED Control in it.
  • So, in order to do so you need to click on the Add new button and then Device/ Widget as shown in below figure:
  • You can see in the above figure, that all the devices are now visible.
  • As we are working on the LED, so you need to click the Light icon, which is among Actuators.
  • When you click it you will get something as shown in below figure:
  • So, I have selected the Light switch and in its properties, I have selected the D8 which is 8th digital Pin of Arduino.
  • Now click on the Add Actuator button and you are done.
  • You first LED Blinking Project is done on Cayenne and it will look something as shown in below figure:
  • So, now when you click this light switch your LED on pin 8 will go ON and if you click it again then it will go OFF.
  • I have plugged an LED on Pin # 8 on my hardware.
  • In the below video, I have explained this Arduino LED project in more detail, so must watch it:
I hope you guys have enjoyed today's tutorial and are gonna like this Cayenne online Platform. I will post more tutorial on it in which I will interface all these devices with Arduino. So, stay tuned and have fun !!! :)

ECG Simulation using MATLAB

Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new project which is ECG Simulation using MATLAB. In this project, I have designed a complete simulation in MATLAB which is acting as ECG Simulator. This ECG Simulation also extracts ECG features and performs different functions which are explained in detail below. We have put a lot of effort in designing this project that's why its not free and we have placed a very small amount of $50 so that engineering students can buy it easily. You should also have a look at ECG Averaging in MATLAB.

Moreover, I have also designed a user friendly GUI which is quite easy to operate and you can simulate any kind of ECG data on this ECG Simulator. I have also extracted ECG features and then showed them separately. I have taken ECG data from PhsioBank website. Before buying this project must read this tutorial completely and also watch the video given at the end of this tutorial so that you are sure what you are buying. So, let's get started with ECG Simulation using MATLAB:

ECG Simulation using MATLAB

  • You can buy this ECG Simulation using MATLAB by clicking the below button:

  • When you buy this Simulation then you will get a lot of files and you need to run the ECGFinalGUI.m file.
  • When you run this file, a GUI will open up as shown in below figure:
  • As you can see this GUI contains two portions, the first portion is the Common ECG Diseases section:
  • In this section, I have designed some basic ECG diseases signals.
  • From the ECG curve, doctors find the disease so I have designed few curves which will show different ECG diseases.
  • Like if the patient is suffering from Atrial Flutter then its curve will be something as shown in below figure and it comes when you click the Atrial Flutter button:
  • I have designed curves of six ECG Diseases which are as follows:
    • Normal Sinus Rhythm
    • Junctional Rhythm
    • Atrial Fibrillation
    • Ventricular Fibrillation
    • Ventricular Tachycardia
    • Sinus Tachycardia
    • Sinus Bradycardia
    • Atrial Flutter
  • You can check their ECG graphs by clicking each of these buttons.
  • The last button in the common ECG Diseases is for filtering of ECG Signals.
  • When you click this button then the program will filter the real ECG signal and remove noise from it as shown in below figure:
  • Now let's have a look at the feature extraction from ECG Signal.
  • I have downloaded around 12 signals from PhsioBank Website and here's my settings on this website:
  • I have downloaded each signal of 10 sec duration as shown in above figure and saved it in txt form and then copied the data in txt files.
  • So, this simulation contains total 12 signals.
  • Now once you saved your signal in txt format now you need to use the Load ECG Signal button on the GUI and it will ask for browse.
  • So, select your ECG signal and it will show its features like Heart Rate, R-R interval, QRS interval etc as shown in below figure:
  • You can see in the above figure that as I selected the ECG signal, first of all GUI extracted the first ECG curve and shown it separately in the above window.
  • After that I have extracted the P, Q, R, S and T peaks.
  • After that I have also extracted the Heart Rate, R - R interval and QRS interval.
  • Next phase is to diagnose the disease, which is Normal in this case.
  • If this patient had some disease then it will be displayed in this Diagnosis section.
  • Next section is Severity section, in which I have displayed the Condition of the Patient i.e. its severe or mild etc.
  • So, let me load some other ECG signal and let's have a look at its results:
  • Now in this set of ECG data we have detected that the patient is suffering with Sinus Bradycardia.
  • The below video will give you a better idea of How this project works, so before buying it must watch this video first:
So, that's all for today. I hope you guys have enjoyed today's tutorial on ECG Simulation using MATLAB. Till next tutorial, take care and have fun !!! :)

How to Configure NI MyRio on Wifi

Hello friends, hope you all are fine and having fun with your lives. In today's tutorial, I am gonna show you How to Configure NI MyRio on Wifi. In our previous tutorial, Getting Started with NI MyRio I have show you how to get started with NI MyRio and control LEDs of NI MyRio but you have seen that we have done that over USB. In simple words, we have controlled the LEDs and gyroscope of MyRio over USB but in today's tutorial, first of all, we are gonna configure NI MyRio on Wifi and then we are gonna control all those things over Wifi instead of USB.

If you have a project on MyRio then its my recommendation to use Wifi instead of USB for upload and testing your codes because Wifi is quite flexible in use and you no more restricted to use the USB wire. I was working on a robot project in which I have to controlled the motors using MyRio so when I was using the USB then it was really very difficult to design the algo because I have to connect my laptop to MyRio but when I shifted to Wifi then it was quite easy for me and I can easily upload the code and test it without connecting my laptop to MYRio. So, that's why before starting your project you should configure NI MyRio on Wifi. So, let's get started with How to configure NI MyRio on Wifi.

How to Configure NI MyRio on Wifi ???

  • First of all, connect your NI MyRio to your computer via USB and a window box will open up as shown in below figure:
  • Now click on the third button which says Configure NI myRIO.
  • When you click this button, a new link will open up in your default browser which in my case was Firefox.
  • In my case, this link doesn't open up and it may happen to you as well, so no need to be panic instead install the Microsoft Silverlight.
  • After installing the Microsoft Silverlight, it still doesn't open up in my browser :) and then I tried different browser and finally the Windows Explorer worked. :P
  • So, what you need to do is to paste this ip address in your Windows Explorer http://172.22.11.2/ and it will surely work. :)
  • When this ip address opens up it will show you a page as shown in below window:
  • Now, in this page click on the third button on your left side which says Network Configuration.
  • When you click it a new window will open up as shown in below figure.
  • Now in this window there will be two sections one is Ethernet and the second one is Wireless.
  • So, in the wireless section you have to fill the required boxes. First of all select the country which in my case is Pakistan.
  • Next select your Wireless network and then give your password as I have done in the below figure:
  • Once you are done then click on the Save button at the bottom and it will save your settings and will assign an IP adress to your NI MyRio.
  • This IP address will be used now instead of that previous one and you can easily upload your code in your NI MyRIO as its now configured with your laptop's Wifi.
  • You can see more details over this below video:
That's all for today. I hope I have conveyed some knowledge. In the coming lecture, we are gonna design our first program on NI MyRio and then will test it over Wifi. :) So take care and have fun !!! :)

Color Detection in MATLAB Live Video

Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to show you Color Detection in MATLAB Live Video. In this project I am gonna take a live video feed from a camera and then will detect a specific color in that video feed. I have posted a project before in which I have done the same Color Detection in Images using MATLAB but that color detection was for images but in today's post I am gonna do the color detection in MATLAB for live video feed. I have designed this project in MATLAB 2009 and have also tested it on MATLAB 2015 and it works fine. So, I think it will work on any version of MATLAB. You must have the image processing toolbox in your MATLAB. If you got any questions then ask in comments and I will try to resolve them. So, let's get started with Color Detection in MATLAB Live Video: Few Image Processing Projects:

Color Detection in MATLAB Live Video

  • First of all, download the code from clicking the below button and open it in your MATLAB.

Download MATLAB Code

  • Now let me explain this code in detail.
  • One important thing, if you encountered some MATLAB project and you don't know how it works then the best way of testing is to paste commands one by one in your Command Window.
  • In this way you will understand the working of each command and will give you a better idea of how it works.
  • The complete MATLAB cofor Color Detection in MATLAB Live Video is as follows:
obj=videoinput('winvideo',1);
obj.ReturnedColorspace = 'rgb';
B=getsnapshot(obj);

framesAcquired = 0;
while (framesAcquired <= 10) 
    
      data = getsnapshot(obj); 
      framesAcquired = framesAcquired + 1;    
      
      diff_im = imsubtract(data(:,:,1), rgb2gray(data)); 
      diff_im = medfilt2(diff_im, [3 3]);             
      diff_im = im2bw(diff_im,0.18);                   
      %stats = regionprops(diff_im, 'BoundingBox', 'Centroid'); 
      
  
      % Remove all those pixels less than 300px
      diff_im = bwareaopen(diff_im,300);
    
    % Label all the connected components in the image.
     bw = bwlabel(diff_im, 8);
    
    % Here we do the image blob analysis.
    % We get a set of properties for each labeled region.
    stats = regionprops(bw, 'BoundingBox', 'Centroid');
    
    % Display the image
    imshow(data)
    
    hold on
    
    %This is a loop to bound the red objects in a rectangular box.
    for object = 1:length(stats)
        bb = stats(object).BoundingBox;
        bc = stats(object).Centroid;
        rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
        plot(bc(1),bc(2), '-m+')
        a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), '    Y: ', num2str(round(bc(2))), '    Color: Red'));
        set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'red');
    end  
 
    hold off
    
end

clear all
  • I have also added the comments in the code so that you can understand it in a better way.
  • But if you still got any problems then as k in comments and I will resolve them.
  • Now run your simulation and bring any red color object in front of your camera and you will see a bounding box will be formed around red color and it will also show the coordinated of that red color.
  • The results are shown in the below figure:
  • You can see in the above figure that I am holding a bottle cap which is of red color and our code is detecting that red color.
  • Moreover it has created a bounding box around that bottle cap and then showing the X and Y coordinates of that cap.
  • I have also mentioned the Color Red infront of it and the color of these coordinates is also RED.
  • You can change these colors as you want and can detect any color using this code.
  • Let me explain this code a little bit.
Code Explanation
  • First of all, I created an object for the video camera and then took images from that video using the below code.
  • In this code I have used 1 for video input. 1 is default for your webcams and if you have any external camera connected via usb then you have to use 2 instead of 1.
  • The code is as follows:
obj=videoinput('winvideo',1);
obj.ReturnedColorspace = 'rgb';
B=getsnapshot(obj);
  • After that I have created a while loop of 100 framesso it will keep on detecting the color for 100 frames and then it will stop you can increase or decrease it.
  • In this while loop, first of all I have subtracted the red color from each frame using the imsubtract command.
  • You can see the input of imsubtract is data( : , : , 1 ), where data is our image and 1 is used for red color subtraction, if you use 2 then it will subtract the green color so using these values you can subtract any color and infact you are detecting that color.
  • After that I have applied filter to remove the noise and have also removed the pixels less than 300px.
  • Then I have connected the dots of red color to create a single red object.
  • This code is as follows:
      data = getsnapshot(obj); 
      framesAcquired = framesAcquired + 1;    
      
      diff_im = imsubtract(data(:,:,1), rgb2gray(data)); 
      diff_im = medfilt2(diff_im, [3 3]);             
      diff_im = im2bw(diff_im,0.18);                   
      %stats = regionprops(diff_im, 'BoundingBox', 'Centroid'); 
      
  
      % Remove all those pixels less than 300px
      diff_im = bwareaopen(diff_im,300);
    
    % Label all the connected components in the image.
     bw = bwlabel(diff_im, 8);
    
    % Here we do the image blob analysis.
    % We get a set of properties for each labeled region.
    stats = regionprops(bw, 'BoundingBox', 'Centroid');
    
    % Display the image
    imshow(data)
  • Finally after the detection of this red color, I have created a bounding box around it and have also printed its coordinates.
  • The code is as follows:
for object = 1:length(stats)
        bb = stats(object).BoundingBox;
        bc = stats(object).Centroid;
        rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
        plot(bc(1),bc(2), '-m+')
        a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), '    Y: ', num2str(round(bc(2))), '    Color: Red'));
        set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'red');
    end
  • So, that's how I ma doing the color detection in MATLAB Live Video.
  • The below video will explain this Color Detection in MATLAN Live Video in more detail:
I hope you guys have enjoyed this Color Detection in MATLAB and are gonna use it your projects. That's all for today, will see you guys in the coming tutorials. Till then take care and have fun. :)

Motion Detection in MATLAB

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a new project which is Motion Detection in MATLAB. In this project, I am gonna detect the motion in MATLAB. This project was designed for security purposes and the condition was to use MATLAB instead of PIR Sensor. We all know that PIR sensor is used for motion detection but for that we have to design a hardware but using this software we can easily detect any motion using MATLAB. In this project, I have used the webcam and then applied a simple image processing algorithm, designed in MATLAB. Using this algorithm I have detected the motion in the environment. That's a quite simple project and you are gonna like this one. The code and complete simulation is given below for download. So, let's get started with Motion Detection in MATLAB: You may also like:

Motion Detection in MATLAB

  • First of all download the Motion Detection in MATLAB simulation by clicking the below button:

Download the MATLAB Simulation

  • Once you downloaded the rar file, you will get two files in it, named as:
  • Comparison.m
  • Comparison.fig
  • Now open the Comparison.m file and run your simulation.
  • When you run the file a GUI will open up as shown in below figure:
  • Now you can see it has three buttons on it.
  • Press the first button which says Capture Image, so click this button and an image will be saved in the same directory and will also be shown in the first zone as shown in below figure:
  • Now, click on the Start Comparison button and the software will start and will start capturing from the webcam.
  • It will also show the captured image in the second zone and if there's no change then the text below will show No Change, as shown in below figure:
  • You can see as there's no motion in the room that's why it says No change in above figure.
  • Now, let's create some motion, so I am taking my hand in front of the cam and let's see what results we got in the below figure:
  • You can see in the above figure that as I placed my hand in the range of webcam, the below text changed to Change Detected. Btw it should be motion detected. :P
  • Once the software captures the motion it will indicate as well as stop and if there's no motion then it will keep on monitoring.
  • If you want to stop the comparison then simply click the Stop Comparison button and it will automatically stop.
  • Moreover, the software will also send character to the serial port, if you want you can receive it on any serial port.
  • Now let's discuss the codes behind these buttons.
MATLAB Codes
  • The code behind Capture Image button is as follows:
obj=videoinput('winvideo',1);
obj.ReturnedColorspace = 'rgb';

A=getsnapshot(obj);
axes(handles.axes1);
imshow(A);
imwrite(A,'A.jpg');
delete(obj);
  • In the above code, first of all, I created an object of the webcam and then took a screenshot from that webcam.
  • After that I saved that image in the project directory and named it as A.jpg.
  • If you check your project directory then you will find this image.
  • Now let's have a look at the code behind Start Comparison Button:
global go;
    go = true;
  while go

obj=videoinput('winvideo',1);
obj.ReturnedColorspace = 'rgb';
B=getsnapshot(obj);
axes(handles.axes2);
imshow(B);
imwrite(B,'B.jpg');
delete(obj);

global I1;
global I2;

I1 = imread('A.jpg');
I2 = imread('B.jpg');
%  convert images to type double (range from from 0 to 1 instead of from 0 to 255)
Imaged1 = im2double(I1);
Imaged2 = im2double(I2);

% reduce three channel [ RGB ]  to one channel [ grayscale ]
Imageg1 = rgb2gray(Imaged1); 
Imageg2 = rgb2gray(Imaged2);  

% Calculate the Normalized Histogram of Image 1 and Image 2
hn1 = imhist(Imageg1)./numel(Imageg1); 
hn2 = imhist(Imageg2)./numel(Imageg2); 

% Calculate the histogram error/ Difference
f1 = sum((hn1 - hn2).^2);  
%set(handles.text1,'String',f1)
serialOne=serial('COM1', 'BaudRate', 9600);
fopen(serialOne);
if f1 > 0.009
    fprintf(serialOne,'a');
    set(handles.text1,'String','Change Detected')
    go = false;
end
if f1 < 0.009
    fprintf(serialOne,'b');
    set(handles.text1,'String','No change')
   
end
fclose(serialOne);
  • This is the main code of this Motion detection in MATLAB project.
  • Here, again I am creating an object of the webcam and taking a screenshot.
  • After that I am saving this screenshot in the project's directory and I have renamed it as B.jpg.
  • So, now I have two images A and B.
  • After that I have converted both of these images to grey scale and calculated their histogram error and on the basis of this error I have detected the motion.
  • Finally I have created a Serial Port object, if you don't wanna use serial port then simply remove this code.
So, that's all for today, I hope you have enjoyed the motion detection in MATLAB. If you have any questions, then ask in comments and I will resolve them.
Syed Zain Nasir

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

Share
Published by
Syed Zain Nasir