Getting Started With Microcontrollers

No. Proteus Tutorials
Give Your Suggestions !!!
1. Getting Started With Microcontrollers
2. Getting Started with PIC Microcontrollers
3. Functions Available in PIC18F452
4. How to Install MPLAB Software
5. How to Install MPLAB C18 Compiler
6. Getting Started with MPLAB
7. LED Blinking Project on PIC Microcontroller

Hey guys hope you all are fine and healthy. Today I am going to start a new tutorial, about PIC Microcontrollers. I will start from the very basics of PIC Microcontroller so that the beginner can also learn from it and can easily work on their projects and I will also post some projects in which I will use PIC Microcontroller and will control different modules using it.

The only thing I hate about PIC Microcontroller is the designing of its basic circuit, which we will discuss in coming tutorials, that's why I prefer to work on Arduino which is way more user-friendly than PIC Microcontroller but if look at the brighter side of PIC Microcontroller than it is much more flexible in option as compared to Arduino. Let's start today's tutorial, today I will just give an overview of what actually Microcontroller is and why to use it. So, let's begin with getting started with microcontrollers.

What is Microcontroller?

Microcontrollers are used to put the brain in your projects. Let's take an example, you have seen different light patterns at weddings or different functions where it seems like lights are walking, sometimes they show some characters glowing on and off quickly, etc. Before microcontrollers such patterns of light were very difficult you need a a lot of circuitry (serial & parallel combinations of lights) and then have to decide which light to on and which to off. A big messy thing but with the invention of the microcontroller, now you just have to add a microcontroller and put in some coding and you are done. That's the benefit of the microcontroller. and second thing in order scenario if something goes wrong then you have to change the hardware connections but in the microcontroller just change the code and you are done with no need for soldering etc.

Types of Microcontrollers

There are different microcontrollers manufactured by different companies these days. A few of them are:

  • PIC
  • ATMEL
  • AVR
  • FPGa
  • Arduino (Board actually, I will explain later)
  • & a lot more

but all of them have the same function. Let's look at their function.

Function of Microcontroller

A microcontroller is a simple chip (IC). We are not discussing its internal architecture as it's beyond the scope of this tutorial. We are here just concerned with its output. So a microcontroller is just a simple hardware chip. Now how to operate that chip is a question. A microcontroller has different no of pins some have 8 pins some 16 and some 40 even have 80 pins. Each pin has its function and we tell the microcontroller what function each pin will perform by adding a code in the microcontroller.

PIC Microcontrollers

PIC microcontrollers are manufactured by a company named Microchip. There is a wide variety of PIC microcontrollers. They are named PIC16F877A or PIC 18F452. The first two numbers show the series like the PIC16F series and PIC18F series. Each series has its own functions and qualities and the number of pins also varies. In my tutorial, I am gonna use the PIC18 F452 which is shown in the above figure too.

That's all for right now. I will continue it after afternoon. Stay blessed .... :))

Display Serial Data on Real Time Graph in Labview

Hello friends, hope you all are fine and having fun with your life. Today's post, as the name suggests is about How to Display Serial Data on Real Time Graph in Labview. In our previous post, we have seen that how to Get Continuous Data From COM Port in Labview. Today's post is a sequel of this previous post so I would recommend that if you haven't had a look on that post then first visit it as I am gonna start today's post from where I stopped the previous one.

In the last post, we were able to get the continuous data from COM port using Labview and we have also separated the data based on a character which I have used this one "," i.e. comma. Now, suppose you are sending 3 values from your COM port and these are the sensors' values so tthe best way to display these value is by using a graph. In the last post we separated the values and displayed them in a 1D array, so today we are gonna display those values in a graph. As I have taken three values so today I am gonna plot 3 graphs. Each graph will show one of the values and display them in real time. Let's start it.

Display Serial Data on Real Time Graph in Labview

  • In the last post, we have the below vi at the end. This vi get continuous data from the COM Port and then display it in the Response and the 1D array.
  • In the above image, the Data 1D displays the values separately and differentiate it on the basis of a characters "," i.e. comma.
  • In other words, Data 1D has a array, which consists of three values coming from the serial port.
  • So if like we have sent the values 120,221,312, then the array(0) will have 120, array(1) will have 221 and finally the array(2) will have 312.
  • In order to plot the values on the graph separately, what we need to do is to simply get array(0) and then plot it vs time and so on, which is shown in below figure:
  • As you can see in the above figure, the logic we used is quite simple, what we did is we simply get the array just before Data 1D and then broke it into parts i.e. array(0), array(1) and array(2) and then fed it to the Graph plots.
  • In this particular example I am using accelerometer IMUv2 and displaying its values on the graph.
  • After adding these blocks you are done. Now press Ctrl+T and open the Front Panel. My front Panel looks like as shown in below figure:
  • Now first of all select the COM port from which you are receiving the data. If you can't find yours, then click on the Referesh, you will find in the drop down.
  • Now, run the vi and then click on the Start button and you will start receiving the values. The values will be displayed in the Response as it is and then in the Data 1D and will also display on these graphs separately as shown in the below figure:
  • Now, you can see the data is displayed. In this vi, we have displayed the data in three formats:
  1. Response: It shows the complete data coming from the Serial Port.
  2. Data1D: It separates the data and then displays it in digital format.
  3. Graphs: They plot the real time graph of the coming data.
I have attached the vi below for download but I would recommend you guys to design it by yourself so that you learn the most out of it.

Download the Labview vi

 

Get Continuous Data From COM Port in LabView

Hello friends, hope you all are fine and enjoying good health. Today's post is my first post on LabView Software. I have worked on LabView quite a lot in past but these days I am continuously working on LabvView so I thought to write some tutorials on it. In today's tutorial, I will explain in detail How to get continuous data from COM Port in LabView software. LabView is a very handy tool for the engineers. One can easily plot graphs and can work on different hardware modules with it. One of the best feature of LabView is its extensive help desk. There are many examples present in it which are ready to run and can help a lot, moreover their online is also very extensive. I got into many problems while working on it and I never get stuck, I just searched online and got the solutions for my problems. So, my suggestion is, if you are working on LabView then give Google a chance to help you out, if you stuck in something.

Let's start today's post, in today's post we will receive data from serial port and show it in LabView software. In order to do so, first of all you need to download LabView software, you can easily download it from their official website. They offer a trial period of around 45 days for the students and after that you have to buy it. Now, follow the below steps carefully and if you find any trouble anywhere, let me know in comments and I will try my best to sort them out.

Steps to Follow

  • First of all, you need to download the NI VISA driver.
  • NI VISA driver is used for serial communication, without downloading this software you can't communicate with the serial port of your computer in LabView.
  • LabView has extensive list of drivers, whenever you want to communicate with any hardware in LAbview then you have to download its driver, NI VISA is the driver for communicating with serial port.
  • After downloading this driver, install it and now run your LabView software.
  • When you run LabView, it will appear as shown in the below figure:
Note:
  • I have given the complete working vi to download at the end but I suggest that you should design it by yourself so that you learn how to design.
  • Now, click on the Create Project Button and the below Window will pop up.
  • Now click on the Blank VI Template and click Finish.
  • A blank vi will open up, we will design the complete project in this vi.
  • These are two windows, one is called the Block Diagram, where we will place all the components and the second one is Front Panel, where user can interact with LabView i.e. the Serial data coming will be displayed in the Front Panel.
  • Another small window will also be there, this window is used for getting blocks.
  • Now design a vi as shown in the below figure:
  • In this vi, we are receiving data from Serial port and then separating it on the basis of "," character and then placing it in a Data 1D and as well as in Response box.
  • The Front Panel is shown in the below figure:
  • Before running the vi, first of all select the COM Port from which your data is coming.
  • Now click on RUN button in top toolbar, but still you won't receive anything, now hit the Start Reading button and you will start receiving the data, as shown in the below figure.
Note:
  • If you don't select the correct Com Port then it will give error and won't run so select the correct COM Port name.
    • Now, the COM Port I am using is COM5 and you can see Start Reading button is also ON.

Response is showing the complete data whatever is coming from the Serial Port, while the Data 1D is splitting the data and showing each data in each box and the separation character I selected is "," (comma).That's all for today, now play with the vi and I hope you will find it really amusing. In order to download the complete working vi click on the below button.

Download Labview Simulation

In the next post, I have discussed how to Display Serial Data on Real Time Graph in Labview.Displaying data on graph is usually required in most of the projects. So have a look at it.

Circuit Designing of LCD with Arduino in Proteus ISIS

Hello friends, I hope you all are doing great. Today, I am going to share Circuit Designing of LCD with Arduino in Proteus ISIS. In my previous tutorial, I have posted a tutorial on How to use Arduino Library in Proteus. Using that library, we can easily test Arduino code in Proteus to check whether its working or not. If you haven't read that post then before starting it, first read it, as without adding the arduino library we can't use Arduino in Proteus.

Coming to today's post, as we have done adding the Arduino Library in Proteus, so I thought to do some projects on it and the first one I chose is quite simple one i.e. Circuit Designing of LCD with Arduino in Proteus ISIS. So we will have a look on how to show some characters on LCD using Arduino in Proteus. If you are working on LCD then you should also have a look at my new post Scrolling Text on LCD using Arduino. Let's get started with Circuit Designing of LCD with Arduino in Proteus ISIS:

Circuit Designing of LCD with Arduino in Proteus ISIS

  • First of all, design a circuit of LCD and Arduino in Proteus ISIS, if you have already added the Arduino Library then you won't find any problem in finding the Arduino in components library of Proteus.
  • You should also download this New LCD Library for Proteus.
  • Design the circuit as shown in below figure:
  • Now, we need to design Arduino sketch for LCD, so open Arduino software and place below code into it.
  • You should have a look at How to get Hex File from Arduino.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{

lcd.begin(16, 2);
lcd.print("www.TheEngineer");
lcd.setCursor(0,1);
lcd.print("ingProjects.com");
}
void loop() {}
Note:
  • For Arduino code, I have used Liquid Crystal Arduino Library, which you can download from the below link and add it in the libraries folder of Arduino software.

Download LiquidCrystal Arduio Library

  • If you haven’t bought your Arduino UNO and LCD yet, then you can buy it from this reliable source:

  • Now compile the code, and get the Arduino hex file which will be in the tmp folder, you can read Arduino Library for Proteus to know in detail how to get the hex file of Arduino sketch.
  • Now double click the Arduino in Proteus ISIS and properties window will pop up.
  • In properties panel, under the Program File section, browse to Arduino hex file as shown in below figure and upload it.
  • Now click Ok and Run your simulation, if everything goes fine then your LCD will start showing the characters as shown in below figure:
  • You should also have a look at these Arduino Projects for Beginners.
  • That's all, was it difficult ??? I dont think so :) Anyways, if you got into any trouble, do ask in comments.
  • In the coming posts, we will explore Arduino in Proteus ISIS more. Till then take care !!!

Training Error: Recognition Failed in EasyVR

Hello friends, hope you all are fine and enjoying life. Today's post is about removing a small error named as Recognition Failed in EasyVR, which I encountered while working with EasyVR shield with Arduino UNO. I have posted a complete project on EasyVR shield around a year ago in which I haven't mentioned this error because at that time I didn't encountered it. But today while working with EasyVR shield, I encountered this problem so I thought to share it with you guys.

EasyVR shield is a voice recognition module which is used for recognizing voices and operating accordingly. Using this module, one ca quite easily control anything using voice. In the previous project, I have controlled a robot using voice commands like when I say Forward then it starts moving forward, when I say REVERSE then it start moving backward and so on. So, its quite a cool feature to be added in projects but its not the perfect one as the efficiency of this module is not even 50%, if you are operating in a noise environment then it won't work as you want it to work.So ,let's get started with How to solve Training Error: Recognition Failed in EasyVR.

Training Error: Recognition Failed in EasyVR

  • First of all, I connected my EasyVR with Arduino UNO and run the EasyVR Commander.
  • I selected the Com Port of my Arduino UNO and hit Connect.
  • After that, I added a new command in EasyVR Commander and hit Train Command and it asked for Phase 1.
  • Everything was working perfect but when I train my command i.e. said the word which I wanted to save in the command, I got the error written as "Training Error: Recognition Failed", shown in below figure:
  • I tried again and again to train the command but the error keeps on continuing, which creates quite a problem for me.
  • So, below are the steps, which I have taken in order to remove this error, its kind of a troubleshooting which is quite important to learn for an engineer.

How to solve Training Error: Recognition Failed in easyvr

  • First of all, what you need to check is whether your EasyVR shield is working or not, which I did exactly. So, I remove the EasyVR shield from the Arduino UNO and upload a sketch in Arduino UNO. The sketch I uploaded in Arduino UNO is the test EasyVR sketch comes with the EasyVR library.
  • After uploading the sketch, I connected my EasyVR shield with Arduino UNO and check its output and I got a sigh of relief that my EasyVR shield is working fine, so there's no problem with EasyVR.
  • Now I again opened the EasyVR commander and this time I placed the J12 jumper no SW instead of PC, and start the training procedure and I was like surprised, it worked great.
  • I think the new versions of EasyVR shield doesn't need the jumper to be on PC for training mode.
  • In the project, I have mentioned it that place the Jumper J12 on PC while working with EasyVR Commander and place it on SW while working with Arduino UNO, which is now not applicable for the new version of EasyVR.
  • So, simply, place your jumper J12 on SW position and it will work smoothly.
Note:
  • EasyVR shield doesn't give the 100% result, it got impressed by the noise in the surroundings very quickly so whenever you are using EasyVR shield, make sure that you use it in a calm place. I even turn off my fan in order to make it work properly.
Finally, after resolving this issue, I trained five commands into it for moving a robot, which are shown below:
  • That's all for today, hope it will help you guys in some way. Thanks !!!

Send SMS with Arduino UNO and SIM900D using AT Commands

Hello friends, today's post as the name suggests is about how to send SMS with Arduino UNO and SIM900D using AT Commands. There are different types of SIM900D modules available in the market, so it doesn't matter which module you are using. All SIM900D modules work at AT commands basically so today I am going to show you how to send an SMS via AT commands without using any Arduino library. You should first read the AT commands manual which will give you an idea about AT commands. AT commands are special sets of commands which are used for communicating with SIM900 module. Using these AT commands we let our GSM work for us. Like if you want to send SMS then there's a specific AT command for sending the SMS similarly if you want to change the PIN code for your GSM module then you have a different AT command. So, there are lots of AT commands available. We can interface this GSM module with any microcontroller like PIC Microcontroller or 8051 Microcontroller but here I have interfaced it with an Arduino board. You should also check How to Send SMS with PIC Microcontroller if you wanna use PIC Microcontroller instead of Arduino board.

You must also check GSM Library for Proteus, using this library you can easily simulate your GSM module in Proteus ISIS. Moreover, also have a look at Send SMS with Sim900D in Proteus ISIS in which I have designed a simulation of SMS sending in Proteus ISIS.

Note:

Where To Buy?
No.ComponentsDistributorLink To Buy
1SIM900AmazonBuy Now
2Arduino UnoAmazonBuy Now

Components Used

I have shared the list of components used in this project. I am giving a comparison of three vendors below, you can buy from any of them:
Components List Amazon Ali Express
Give Your Suggestions !!!
Arduino UNO R3 Click Here to Buy Price: $10.99 Click Here to Buy Price: $2.79
GSM Module Sim900 Click Here to Buy Price: $28.99 Click Here to Buy Price: $10

Connect Arduino UNO with SIM900D

  • First of all, connect Arduino UNO with SIM900D module, which isn't much difficult. If you have the module in hand then the first thing you need to do is to power it up and wait for the module to get connected.
  • Usually, an LED is placed on the SIM900D module which keeps on blinking. If it's blinking fast, it means the modules haven't yet captured the signal. When the module captures the signal then the LED keeps on blinking but at lower speed.
  • Now find the TX and RX pins of your SIM900D module and connect the TX of module with RX of Arduino UNO, which is pin # 0 and similarly RX of module with TX of Arduino UNO, which is pin # 1.
  • The module, which I have used for my project is shown in the below figure, with labelled pin configurations and if you want to buy it in Pakistan then click here.
  • One other thing mentioned in above figure is pKey, connect it with ground.
  • Once your connections are ready, then upload the below sketch in your Arduino UNO and start sending messages.
    void setup()
    {
    Serial.begin(9600);
    }
    void loop()
    {
    delay(1200);
    Serial.print("AT");
    delay(1200);
    bool bOK = false;
    while (Serial.available() > 0)
    {
    char inChar = (char)Serial.read();
    bOK = true;
    }

    if(bOK)
    {
    index = 0;
    Serial.println();
    Serial.println("AT+CMGF=1"); // sets the SMS mode to text
    delay(100);
    delay(1200);
    bool bOK = false;
    while (Serial.available() > 0) {
    //Serial.write(Serial.read());
    char inChar = (char)Serial.read();
    bOK = true;
    }
    if(bOK)
    {
    Serial.println();
    Serial.print("AT+CMGS=""); // send the SMS number
    Serial.print("+923004772379");
    Serial.println(""");
    delay(1000);
    Serial.print("A new post is created by Zain."); // SMS body

    delay(500);

    Serial.write(0x1A);
    Serial.write(0x0D);
    Serial.write(0x0A);

    }
    }
    }
  • Change the mobile number with the number, on which you want to send the SMS, I have written mine.
  • You should also change the body of the SMS and can write anything you wanna send as an SMS.
  • The AT commands are required to send the SMS. I have added the comments in front of these commands but still if you get into any trouble, ask in comments.
  • That's all for today, in the coming post, we will have a look how to receive SMS with SIM900 and Arduino.

Introduction to Arduino YUN

Hello everyone, I hope you all are doing great. In today's tutorial, I am going to give you a detailed Introduction to Arduino YUN, and we will also have a look at its basic functionalities. Arduino YUN is a latest microcontroller board, manufactured by Arduino. It's the most advanced and highly stylish arduino board. The beauty of Arduino YUN lies in having two on board processors, which I haven't seen yet in any other Microcontroller board. One of them is simple Arduino processor which is similar to that of Arduino Leonardo while the second processor is Atheros AR9331. Atheros supports Linux server, which is the new thing in Arduino YUN. Because of these two processors, one now can do anything in the world of automation as well as web servers. You can say it's kind of a replica to Raspberry Pi 3.

Arduino YUN can be used as a server, you can also run python scripts quite easily on it, which we will cover in coming posts of this tutorial. You can run the Telnet session on it, can access the FTP servers, in short you can do anything with it quite easily. Let me give you an example, around 3 months ago I have designed a project on Arduino YUN in which the sensors data attached to the YUN were uploading directly on the web server via FTP and were saved in the sql database and I did all of it, just by using Arduino YUN alone. No computer was attached for FTP connection as python scripts in the Arduino YUN were doing this task. Now, I think you have gotten better idea of capability of Arduino YUN.Arduino YUN also have built in Wifi, Ethernet, USB host and SD card slot.

One another unique feature of Arduino YUN is that you can upload Arduino sketches in it wirelessly without any cable connection, if your computer and Arduino YUN are connected with the same Wifi connection. Now, let's have a look at how to manually connect the Arduino YUN with available wifi connection, which should be your first step after buying an Arduino YUN.

Manually Connect Arduino YUN with Available Wifi Connection

Now I suppose that you have got your Arduino YUN. After getting the Arduino YUN, open your box and plug the mini usb cable into your Arduino YUN and the other side of cable in your computer. I am also assuming that you are plugging it first time with your computer via usb cable.

Note:

  • You should download the Arduino software version 1.5.5 instead of 1.0.3 because Arduino sketches will be only compiled in 1.5.5 version which is specifically designed for Arduino YUN. In this tutorial, we will not use Arduino software.
  • After plugging the Arduino YUN, open your Wireless Network connections and wait for the Arduino YUN to appear as shown in below figure. It will take some time to appear so be patient.

  • In the above figure, you can see YUN connection is available, now the question is why is it available?? It is available because it is not connected to any wifi connection rite now and is acting as an access point. In other words, its just similar to a Wifi router having no wifi connection.
  • So, what we need to do is to connect with this YUN so click on YUN wifi connection and hit connect, so you will get disconnected with previous connection and will get connected with Arduino YUN as shown in below figure.
  • After connecting with Arduino YUN, yur computer has came in the same network with YUN.
  • YUN has a built-in page saved in it from where you can quite easily configure its properties.
  • So, opne your browser and write http://192.168.240.1/ and hit enter, its the current IP adress of Arduino YUN, so when you hit enter, a page similar to the below figure will open up asking for the password.

  • The default password for this page is "arduino" so insert this password and click on Log in as in above figure.
  • After log in, you will be directed to a page similar to one shown in below figure and you can see in the below figure different properties or values of Arduino YUN like current ip address, netmask etc.
  • For Wifi, it is giving connected but for Ethernet, it is showing disconnected because we haven't yet connected with Ethernet.
  • Now click on the Configure button shown in the above figure.
  • After clicking on the configure button, you will be directed to the configuration panel of YUN shown in below figure and you can see there are many fields which are ready for configuring.
  • First one is YUN NAME, which I have gven is TEP, you can give it any name which you can easily remember.
  • Second field is password, the default password as we have seen before is "arduino" so if you want to change that password then add a new password here, which I dont want, so I have left it blank.
  • Next is TIMEZONE, select our time zone from drop down list.
Note:
  • If your project involves time log or date, then its very important to select your time zone so that you get your local date and time.
  • Next are wireless parameters, where we are gonna select the wifi connection with which we want to connect our Arduino YUN.
  • Select the SSID of your network with which you wanna connect, its a drop down list which will have all the currently available networks, so you just need to connect with the one you want and also give its password and hit Configure & Restart button.
  • That's all, when you hit this button, the below screen will appear which will say Configuration Saved and the YUN is restarting.
  • It will take around 10 to 15 minutes to get completely restarted meanwhile, what you need to do is to connect with that wifi connection with which you have connected your Arduino YUN. In my case its SALAM so I connected my computer with SALAM.
  • After restart, now your Arduino YUN will be connected to the wifi connection and you won't see it in the local wireless connections as we have seen in the start.
  • So now your Arduino YUN and computer both are connected with the same network, which in my case is SALAM.
  • So, now open your Arduino 1.5.5 software and click on Tools and then Port and you can see below Aduino YUN is available and named as "TEP at 192.168.1.1" , where TEP is the name of Arduino YUN board which we have given in above steps and the ip address is the current ip address of Arduino YUN.
  • By selecting this 4th option shown in above figure, you can burn any sketch in your Arduino YUN wirelessly without any cable unless your computer and YUN are connected with the same wifi connection.
  • I don't think it was much difficult connecting YUN with the wifi connection, but quite interesting, isn't it?
  • So, give it a try and have fun. I will post more tutorials on YUN soon so stay connected and have fun. :))

Sensorless Speed Estimation of Induction Motor in MATLAB

Buy This Project

Today I am going to show you Sensorless Speed Estimation of Induction Motor in MATLAB. In order to control and estimate the speed of Induction motor, there are many methods proposed by different scientists. The method I have selected in my project is Adaptive method. Using this method, I have controlled the speed of Induction motor using MATLAB software. Matlab software is used for simulation design. The simulation is designed in simulink and the MATLAB version used for designing this project is MATLAB 2010. It is also tested on MATLAB 2012 and 2013. All the details of this project are mentioned below.

If someone wants to buy this project then click on the button shown on right side. Its quite difficult to implement and is designed because of the efforts of our team that's why we haven't made it open source but we have placed a very small purchase amount because mostly it is asekBefore going into the details of Induction motor, let’s first have a look on the mathematical derivations. Few of the well-known methods are:

  1. Adaptive Method.
  2. Least-Squares Method.
  3. Non Linear Method.
So let's get started with Sensorless Speed Estimation of Induction Motor in MATLAB:

Mathematical Derivation - Sensorless Speed Estimation of Induction Motor

In order to apply the adaptive method on the Induction motor, there was a need to first design the induction motor on Simulink. For designing the Induction motor on Simulink, mathematical calculations were required. So, my first task was to derive the complete mathematical equations for all the variables of Induction motor.

The basic mathematical model also known as the a-b model (or two-phase equivalent model) of induction motor is given as:

Where,

  • ? is the rotor angular velocity.
  • ?Ra& ?Rb are the rotor magnetic fluxes.
  • iSa and iSbare the stator currents.
  • s = 1 – M­­­2/ LR LSalso known as leakage parameter.

Adaptive Method Calculation

The approach used in this report is to consider the speed as an unknown constant parameter. The reason for choosing this parameter is that it changes slowly as compared to all the other electrical parameters and as it changes slowly so it can be controlled more effectively. The adaptive method techniques are applied on the speed parameter and thus estimated it. This adaptive method approach on speed parameter was first implemented by Shauder and are further enhanced and researched by Peng and Fukao. Using the last two equations of the system (1), I derived the below equations:

Where,

  • ?maand ?mb are the magnetic fluxes and are thus known quantities.

Now take the second and third equations of system (1) and divide them by M / LR and then differentiate them w.r.t time and the below equations are obtained:

Where,

  • d? / dt = 0 as we have already assumed in this approach that the speed will remain constant.

System (3) gives us the derivative of magnetic fluxes. In order to calculate the error dynamics induced in the system, we need to calculate the estimated values of these magnetic fluxes and then subtract them from the system (3). The estimated values of the magnetic fluxes are as follows:

Now the error dynamics in the system will be calculated by subtracting system (4) from the system (3), which is calculated as:

Now, according to the Lyapunov function,

V (ema, emb) = ½ (e2ma + e2mb)

Using the above equation and the values of ema and emb, we get:

Now after putting the value of ?and then applying Popov’s criteria, we get:

These are the mathematical equations used in the modeling of this system in MATLAB. In the next part, we will check the simulation designed in MATLAB using these set of equations and will study that model in detail.

Modeling in Simulink

The model designed in MATLAB is shown in the figure 1. This model is performing the simulation of motor moving in both the directions i.e. clockwise and anti-clockwise. It contains four main blocks, which are:

  • 3-Phase Input Voltage with variable Frequency.
  • Vabcto stationary frame conversion block.
  • Motor system block.
  • Speed estimation block.

All these four blocks are discussed below in detail:

Figure 1: Model Designed in MATLAB for Induction Motor

3-Phase Input Voltage with variable Frequency

This block, as the name depicts, is used for generating variable frequencies. In the start, the first model, I generated, was for fixed frequency of induction motor and was also showing just one direction of motor. So, I did few modifications in the model and added this block so that the motor could move both in positive and negative directions and can also move at different frequencies.

Figure 2 shows the parameter block for this block and from this block one can set the frequency of this motor quite easily. From this parameter block, one can set:

  • Amplitude of the input signals.
  • Phase difference between the input signals.
  • Frequencies of these input signals.

By default, I have taken two frequencies, for which the motor will rotate during a cycle.

Reverse Direction of motor

In order to change the direction of the motor, I have used the phase change. When the voltage applied to the motor reverses its direction, the direction of the motor also reverses. For this simulation, the motor will rotate in clockwise direction when:

  • Phase of Va = 0
  • Phase of Vb = -2*pi/3
  • Phase of Vc = -4*pi/3

And it will reverse the direction, when:

  • Phase of Va = 0
  • Phase of Vb = -4*pi/3
  • Phase of Vc = -2*pi/3

i.e. Vb and Vc are changing their positions. In order to do so I added a phase change in this block and thus for the first 5 sec the motor will move in one direction and for the last 5 sec it will move in the opposite direction automatically.

Figure 2: Parameter Block

Vabcto Stationary Frame Conversion Block:

This block is separately shown in the figure 2. This block takes Vabc as an input and gives output in the form of V(alpha) and V(beta). This conversion is known as Clarke Transformation. This transformation is used in order to simplify the implementation of three phase systems as in Clarke Transformation, a reference signal is obtained. V (gamma) becomes zero in Clarke Transformation that’s why it becomes very easy to use.

Figure 3: Vabc to Stationary Frame Conversion Block

In Clarke Transformation, the relation between Vabc and V (alpha) and V (beta) is given as:

The above equation is implemented in the sub system named as Vabc to stationary frame in figure 2 and is shown in the below figure 3.

If we closely examine the figure 3, then it is shown that inputs coming are Va, Vb and Vc. After that the above equations are applied on these input signals and the output received is V (alpha) and V (beta). In simple words, figure 3 is implementation of Clarke Transformation.

  • Va, Vb and Vc are simple sine waves with amplitude of 2300 and frequency of 50 rad/s.
  • As it’s a three phase system so all these three signals have a phase difference of 120o.

Figure 4: Implementation of Clarke Transformation

  • V (alpha) and V (beta) obtained after the Clarke Implementation are shown in the Figure 4.

Figure 5: Graphical Representation of V (alpha) & V (beta)

Motor System Block:

Motor system block is the practical implementation of set of equations shown in the system (1). It is the basic mathematical model of Induction motor shown in figure 5. It is taking V (alpha) and V (beta) as an input along with the load applied on Induction motor. In other words, I can say that this block is the actual Induction motor and I need to apply the adaptive method technique on this block in order to estimate and control its speed.

V (alpha) and V (beta) applied here are the same obtained in the Clarke Transformation explained in the previous section. Outputs of this function are the states which we will study in detail in the fourth section and the derivatives of currents Isa and Isb.

Figure 6: Induction Motor System Block

Let’s double click this motor system block and check the functions it’s calculating. The functions of this sub system are shown in the figure 6. As I told earlier, this block is the simulation of system (1), which is also shown below:

Figure 6: Motor Block Functions

As shown in the figure 6, motor block is implementing all the five equations of system (1), which are:

  • First block in Figure 6 is calculating d?Ra/dtwhich is the equation 2 of the system 1.
  • Second block in Figure 6 is calculating d?Rb/dtwhich is the equation 3 of the system 1.
  • Third block in Figure 6 is calculating d? /dtwhich is the equation 1 of the system 1.
  • Fourth block in Figure 6 is calculating usawhich is the equation 4 of the system 1.
  • Fifth block in Figure 6 is calculating usbwhich is the equation 5 of the system 1.

All these functions are shown in the figures 7(a-e).

Figure 7a: Implementation of equation 2 of system 1

Figure 7b: Implementation of equation 3 of system 1

Figure 7c: Implementation of equation 1 of system 1

Figure 7d: Implementation of equation 4 of system 1

Figure 7e: Implementation of equation 5 of system 1

  • Graphical representation of all these systems are shown in the figure 7(f, g, h, i).

Figure 7f: Graphical Representation of equation 2 of system 1

Figure 7g: Graphical Representation of equation 3 of system 1

Figure 7h: Graphical Representation of equation 4 of system 1

Figure 7i: Graphical Representation of equation 5 of system 1

After the implementation of all these equations, a complete model of Induction motor has been obtained. Now there’s a need to apply the technique of adaptive method on it so that the speed could be controlled without the help of sensor, which is done explained in detail in the next section.

In order to change the parameter of this system, I have added a parameter block in it shown in the below figure:

Speed Estimation Block:

Let's have a look at the Speed Estimation Block of Sensorless Speed Estimation of Induction Motor in MATLAB. Speed Estimation is the place where adaptive method technique is applied to estimate the speed of Induction motor. This block is actually implementing the system (3) and system (4) and thus calculating the real speed and the estimated speed of the Induction motor respectively. After the calculation of these speeds, it is further calculating the error dynamics by subtracting the estimated speed from the real speed.

Figure 8: Speed Estimation Block

Speed Estimation block is shown in the figure 8. Inputs coming to the speed estimation are the same obtained in the first and second block i.e. V (alpha), V (beta), Isa, Isb, dIsa/dt and dIsb/dt. The functions implemented by this subsystem are shown in the figure 9.

Figure 9: Functions Implemented by System Estimation Block

System (3) and system (4) are implemented in the figure 9, which are as follows:

  • First green block in the figure 9 is implementing the equation 2 of the system 3.
  • Second blue block in the figure 9 is implementing equation 1 of the system 3.

Thus the outputs of these two blocks will give us the real speed values.

  • Third green block in the figure 9 is implementing the equation 2 of the system 4.
  • Fourth pink block of the figure 9 is implementing the equation 1 of the system 4.

So, the output of these two blocks will give us the value of estimated speed. The internal functions of all these four blocks are shown in figures 10a, 10b, 10c and 10d respectively.

Figure 10a: Implementation of Equation 2 of System 3.

Figure 10b: Implementation of Equation 1 of System 3.

Figure 10c: Implementation of Equation 2 of System 4.

Figure 10d: Implementation of Equation 1 of System 4.

After the calculation of all the four values, the speed estimator block then implemented the system (5), which is:

Implementation of this system 5 is separately shown in the figure 11, which finally gives us the value of estimated speed.

Figure 11: Implementation of System (5)

Graph of both the estimated speed and the actual speed is shown in the figure 12.

Figure 12: Graph of Estimated Speed and Actual Speed

Conclusion:

Let's have a look at the conclusion of Sensorless Speed Estimation of Induction Motor in MATLAB. Figure 12 shows both the actual and estimated speed induction motor. In the start, the motor is moving at the speed of around 25 rpm, after that the speed is increased to 50 rpm, and the motor starts to rotate in the opposite direction that’s why the graph shows the negative value. Now, it’s moving at 50 rpm in the opposite direction and lastly, it is moving at 25 rpm in the opposite direction. Figure 13 shows the graph for estimated errors. It is quite obvious from the error graph that whenever the speed of the motor fluctuates the error goes quite high. In other words, the acceleration produced in the motor causes the error to increase while the error remains zero when the motor is moving at constant speed, regardless of direction.

Figure 13: Estimated Error Dynamics

So, that's all for today. I hope you have enjoyed Sensorless Speed Estimation of Induction Motor in MATLAB. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)

Download Serial Terminal Software in vb2010

Hello everyone, I hope you all are doing great and having fun. In today's tutorial, I am going to share a new software which I have named Serial Terminal. I have designed this Serial terminal in vb2010. You can download this software from below button. I have already posted a complete tutorial on How to use Serial Port in Visual Studio 2010 in which I have explained how to send and receive data via serial port. It was quite a basic software, which just transmit and receive data from a serial port but today I am gonna provide you a complete serial terminal, which will not only transmit and receive data but will also display that data in different formats.

As shown in the below figure, first of all you need to select the COM Port from which you want to receive the data and then select the Baud Rate. Hit Connect and you are now ready to communicate with the selected com port.Download link for this software is given below:

Download Software

Features added in Serial Terminal

Different features are added in the serial terminal to make it more user friendly. First, let's talk about the Transmitting portion. If you guys have noticed, in the previous version of serial terminal. there was no option for Carriage Return and Line Feed but now these options are added.

  • If you simply want to send data without Carriage Return or Line Feed then uncheck both of them.
  • If you check the Carriage return, then it will be sent after the data.
  • If you check Line feed, then it will be sent after the data.
  • If both are checked, then both will be sent after the data.
  • Here's its final look:
  • Now, coming to the receiving side, the data received will be shown in different formats.
  • In the above figure, I have shown a random data.
  • Now in order to check this data in hex format, simple click on hex tab and the data will be presented in Hex format, as shown in below figure:

  • Similarly you can also convert your data in Decimal Format by clicking the Dec tab, as shown in below figure:

  • In the below figure, the data is displayed in the Binary format.

Showing data in different formats helps in designing the project because understanding of coming data is quite necessary. Give this software a try and let me know your suggestions for the improvement. That was all for today, will see you guys in next tutorial. Have fun !!! :)

How to add a Delay in Visual Studio 2010

Hello friends, hope you all are enjoying good health and having good time. Today's tutorial is not too big and is simple about how to add a delay in visual studio 2010. Before starting this tutorial, let me first tell you that I got an excellent feedback about the last tutorial on How To Use Proteus ISIS & ARES & also got few queries and suggestions. One of them was to post a similar tutorial on the Eagle software as well which I will hopefully start in the coming week.

Today's post is a very small trick but yet very effective one. In a recent project of mine, it helped me a lot and yet its quite a small thing but it took me around half an hour to find it online and that's the reason I decided to share it with you guys. I have to design a software in which I was using a database in visual studio 2010 and in that project I have to add some delay in my readings addition in database so I was like :O how to add delay in visual studio 2010. I searched online and after quite a lot of time I finally able to get it, which I am sharing now in this post. Btw if you wanna learn about database then read How to create a database in visual studio 2010. After the creation of any software in visual studio there's a need of creating its executable file so  that we can use the software standalone and just simply install our software on any computer so I think you should also read How to create exe file in Visual Studio 2010. Anyways coming back to adding delay in visual studio 2010, let's first discuss delay in programming language. :)

What is a delay?

The engineers who had worked on Microcontrollers like Arduino or PIC Microcontroller or 8051 Microcontroller, then they know that what is a delay.
  • A delay in programming is a statement which adds a pause in your code.
For example, in some project you want to turn on two lights one after another with a delay of like 5 sec so now what will you do. You will first turn the first light on and then add a delay of 5 sec and then turn the second light on. That delay just let your code wait for 5 sec and then execute the next line. So, now we have an idea what is a delay so lets have a look at how can we add this delay in visual studio 2010.

Add a Delay in Visual Studio 2010

In Microsoft Visual Studio, the command used for adding the delay is:
System.Threading.Thread.Sleep(1000)
This command will generate a delay of 1sec. You can change this value in order to change the time of delay. i.e.
  • 500 for 0.5 sec delay.
  • 2000 for 2 sec delay.
  • 5000 for 5 sec delay.
You need to calculate this value for your required delay and add it here. Note:
  • You should take much care in using this delay because this delay simply makes your software to sleep and thus while the delay is in process, your software won't do any other task.
As I told earlier, its quite a small tutorial, in fact not a tutorial just a quick trick of adding a delay in visual studio 2010. If you are interested in Visual studio projects then must read How to send Emails in Microsoft Visual Studio 2010. Its quite exciting. :)
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