Interfacing Flame Sensor with Arduino

Hello everyone! I hope you all will be fine and having fun. Today I am going to tell you that how can you make a simple program for Interfacing Flame Sensor with Arduino. Flame sensor is used in offices, home and at different places to detect the fire. First of all I would like to tell you about the working principle of the flame sensor. Flame sensor is a device designed for the detection of the fire and to respond it. They are usually designed for the detection of most frequently used industrial fuel e.g. diesel, gasoline, karosene, ethylene, hydrogen etc. They are designed in way to distinguish between the radiations from the sunlight and the actual flames. There different types of flame sensors e.g. Ultraviolet (UV) detectors, Infrared (IR) flame detectors, UV/IR detectors, IR/IR flame detectors, closed circuit video cameras. The purpose of these all flame detectors/sensors is almost similar i.e. to detect the fire and responding quickly to it. The flame sensors have a wide range of applications in our daily life e.g. fume cupboards, felt manufacture, nuclear industry, pharmaceutical industries, printing, spray booths, generator, storage tanks, industrial heating and drying systems etc.
Where To Buy?
No.ComponentsDistributorLink To Buy
1Flame SensorsAmazonBuy Now
2Arduino UnoAmazonBuy Now

Interfacing Flame Sensor with Arduino

In this section of the tutorial Interfacing Flame Sensor with Arduino, I will explain you the step by step procedure to make a simple algorithm or program in Arduino software for the interfacing of flame sensor with Arduino. The algorithm is pretty simple. I will set a threshold limit, when the temperature exceeds that limit, an LED will be turned on to show the there is something wrong. You can also attach a buzzer with the Arduino. When the fire will be detected buzzer will be turned on automatically. First if all I would like to share the complete source code for Interfacing Flame Sensor with Arduino with all of you guys.
  • You can download the complete source code here by clicking on the button below.
  • Just download the .rar file, extract it and enjoy the complete simulation.

Components Required

Here, I am going to show you the list of all the components used in this project.
  • Arduino UNO
  • Flame Sensor
  • LED
  • Soldering Iron
  • Soldering Gum
  • Power Supply (12V)
  • Jumper Wires
  • Varrow Board
Brief Description of the Components
  • Arduino UNO acts as the back bone of the project. It manipulates the whole source code uploaded to the board, prints the desired data on the serial monitor and also prints the executed commands on the LCD. Arduino UNO is shown in the figure below.
  • Power Supply of 12V is used to turn the entire system ON. Because, we can not test and verify our system until we have not switched it ON. Power supply used for this project is shown in the figure below.
  • Jumper Wires are used to make the connections of the all the components in order to make the complete circuit with proper working. Jumper wires are shown in the figure below.
  • Flame Sensor is used for the detection of the temperature and for showing the immediate response when the temperature is above the threshold. Flame sensor is shown in the figure below.
Circuit Diagram
  • Circuit diagram for the tutorial Interfacing Flame Sensor with Arduino is shown in the figure below.
  • You can run this project properly, by making the circuit first, identical to the circuit diagram shown in the figure above.
  • The analog pin A5 of the Arduino UNO will help us in reading the data from the sensor.
  • The other two pins of the sensor are connected to the supply of 5V and ground respectively as you can see from the above figure.

Block Diagram

  • The block diagram for the project Interfacing Flame Sensor with Arduino is shown in the figure below.
  • Power supply is provided in order to run the project properly.
  • Arduino is the backbone of the whole system and controls all of the devices used.
  • When the temperature crosses the adjusted threshold the LED will be turned ON to indicator that the fire is detected.
  • In normal condition LED will remain Off.

Source Code Descritption

  • Source code for Interfacing Flame Sensor with Arduino is given below.
  • Just copy the entire code and paste it in your Arduino software and upload it to the Arduino board.
#include<SoftwareSerial.h>//library for software serial object

int sensorPin = A0; // flame sensor is attached to A0 pin of Arduino

int sensorValue = 0; // Initial value of the sensor is 0

int led = 9; // an LED is attached to the pin no 9 of Arduino

void setup() //method used to run the code for the one time
{

pinMode(led, OUTPUT);//changint the mode of LED as an output

Serial.begin(9600);//rate at which arduino communicates with laptop

}

void loop()//method used to run the code repeatedly

{

Serial.println("Welcome to TechPonder Flame Sensor Tutorial");//prints on the serial monitor

sensorValue = analogRead(sensorPin);//reads the analog data from the sensor

Serial.println(sensorValue);//prints the sensor data on serial monitor

if (sensorValue < 100)//threshold for the LED indication

{

Serial.println("Fire Detected");//prints on the serial monitor

Serial.println("LED on");//prints on the serial monitor

digitalWrite(led,HIGH);//turning on the LED

delay(1000);//delay of 1 second

}

digitalWrite(led,LOW);//turning of the LED

delay(sensorValue);

}
  • First of all I have declared library of software serial.
  • Then I have defined the pins of Arduino UNO at which the flame sensor and LED are connected.
  • Then I have changed the mode of LED to output.
  • Then I have started reading the analog data from the flame sensor.
  • I have adjusted a threshold, when the temperature exceeds that value LED will be turned on.
  • When the temperature is below the threshold LED will remain off e.g in normal conditions.
So, that is all from the tutorial Interfacing Flame Sensor with Arduino. I hope you enjoyed this tutorial. If you face any sort of problem you can ask me in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino by making different projects on it and will share all of them with you as well in my later tutorials. Till then, Take care :)

DC Motor Control using myRIO

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I would like to provide a complete discussion on DC Motor Control using myRIO. I will first provide you a bit information about DC motor then we will move forward towards DC motor control using myRIO. DC motor is an electronic instrument which is used to convert electrical energy into mechanical energy. It plays a vital role in industrial applications. It has also great importance for the engineers to to study about its working principle. DC motor has basically two input terminals. At one terminal we have to provide voltage supply and the other terminal will be attached to the ground (0V). And if we change the polarity, the direction of the motor will also be changed correspondingly. DC generator can be easily made from the DC motor just by using it in inverse. Generator converts mechanical energy into electrical energy. So, both are inverse of each other. I have also posted a lot of articles on DC motor direction control as well as its speed control. I will share their links later in this tutorial too. You should go through those articles as well. They will be informative for you. DC motor has wide range of applications in real life. Its applications include robotics, home automation, automated door locking systems, home security systems, vehicles, computers, refrigerators, air conditioners and a lot more. The further detail about the DC motor and DC motor control using myRIO will be given later in this tutorial.

DC Motor Control using myRIO

DC Motor is a device frequently used to convert electrical energy to mechanical energy. Electrical power supply is provided to the DC motor and it generates mechanical energy. DC motor has two input terminals for power supply. We can easily change the direction of rotation of DC motor just bu changing the polarity of the applied voltage across its terminals. It has a lot of applications including robotics, vehicles, lifters etc. DC motor energy conversion is shown in the figure given below.
Note
I have also made different simulation for DC motor speed and direction control, as given below. You must go through these articles fo the better understanding of this tutorial.s

1. DC Motor Working Principle

The working principle of DC motor is pretty simple as given below.
  • When a current carrying coil is placed in side the magnetic field, torque is produced as a result.
  • Due to this torque, it becomes capable of rotating, usually known as the motor action.
  • If we change the direction of the current in the wire, direction of rotation of DC motor will also be changes correspondingly.
  • A mechanical force is produced due to the interaction of magnetic field and electric field.

2. DC Motor Direction Estimation

  • The direction of DC motor can be determined by left hand rule introduced by Fleming, a famous scientist.
  • If middle finger, index finger and thumb of your left hand are extended in such a way, that all of these are perpendicular to each other.
  • If the middle finger is in the direction of current and index finger represents the magnetic field.
  • Then thumb of your left hand will show the direction of rotation of the DC motor.
  • This left hand rule is shown visually in the figure given below.

3. Source code description

  • Go to the block diagram window and press Ctrl+Space bar.
  • You will see a new window named as Quick Drop has been appeared on your screen.
  • Type PWM in that window as shown in the figure given below.
  • Pick the blue colored highlighted box and place it over block diagram window, a new window will be appeared on your screen
  • The newly appeared window is shown in the figure given below.
  • Just press OK, and your block diagram window will look like the figure shown below.
  • Now to input terminal of duty cycle and right click on it.
  • Go to Create->Control as shown in the figure below.
  • After doing so your block diagram window will look like the figure shown below.
  • Now right click on block diagram window.
  • Go to Functions->Programming->Structures->For Loop.
  • Select while loop and place it over block diagram window.

3. DC Motor Control using myRIO VI

  • A complete NI LabVIEW VI for DC motor control using myRIO is shown in the figure given below.
  • You can download the complete NI LabVIEW VI here by clicking on the button below.
This is all from the tutorial DC Motor Control using myRIO. I have provided a lot detail about the working of DC motor and its control through myRIO. I have also provided the complete NI LabVIEW VI for DC motor control using myRIO. I hope you enjoyed the tutorial. If you feel any problem, you can ask us in comments. We will try our level best to solve your issues. I will also share further tutorials on NI myRIO. So, till my next tutorial taker care and bye :)

Interfacing Temperature & Humidity Sensor with Arduino

Hello everyone! I hope you all will be absolutely fine and having fun. In the tutorial Interfacing Temperature & Humidity Sensor with Arduino I will tell you that how can you interface temperature and humidity sensor named as DHT11 with Arduino and how can you observe the temperature and humidity level using this sensor. This sensor has usually three pins but some of its types has four pins but only the three pins are of importance for us e.g. VCC, GND and the third pin for reading the data from the sensor. In the tutorial Interfacing Temperature & Humidity Sensor with Arduino, I will make a simple Arduino program which will estimate the level of temperature and humidity continuously and will display the value of both temperature and humidity on the serial monitor. You will see that the sensor will give different readings for the different environments.
Where To Buy?
No.ComponentsDistributorLink To Buy
1LCD 16x2AmazonBuy Now
2DHT11AmazonBuy Now
3Arduino UnoAmazonBuy Now

Temperature & Humidity Sensor with Arduino

I will tell you the step by step procedure that how can you interface DHT11 sensor with Arduino and how to make a simple program in Arduino software to read the data continuously from the sensor and how to display the obtained data on the serial monitor. You can also display this data on Liquid Crystal Display (LCD) as I have discussed in detail in my previous tutorial DC Motor Direction Control using Arduino, DC Motor Speed Control using Arduino, Stepper Motor Direction Control in Arduino and Stepper Motor Speed Control using Arduino.
  • You can download the complete source code here by clicking on the button below.
  • Download .rar file, extract this file and enjoy the complete simulation code.

Block Diagram

  • First of all, I would like to explain you the algorithm with the help of a block diagram.
  • It will help in better understanding of an algorithm.
  • The block diagram for interfacing of temperature and humidity sensor with Arduino is given in the figure below.
  • Power supply in necessary to turn the whole system ON.
  • DHT11 is connected with the Arduino UNO.
  • Arduino UNO reads the data from the DHT11 sensor and displays the obtained data on the serial monitor.
  • That data will also be displayed on the LCD.

Circuit Diagram

  • The complete wiring diagram for this project is shown in the figure below.
  • You can run this project properly, by making the circuit first, identical to the circuit diagram shown in the figure above.
  • The analog pin A3 of the Arduino UNO will help us in reading the data from the sensor.
  • The other two pins of the sensor are connected to the supply of 5V and ground respectively as you can see from the above figure.

Flow Chart

  • The flow chart will help you to understand the flow of the program while executing.
  • The flow chart for this project is shown in the figure below.
  • The data from the sensor can be estimated on the serial monitor only after opening the serial port
  • Then data will be displayed on the LCD and at end serial port must be closed in order to avoid the exchange of unwanted commands.

Source Code Description

  • The source code for this project is given below.
  • You have to just copy and paste the code given below in your Arduino software after properly interfacing DHT11 with the Arduino.
  • After uploading the code onto your Arduino board you will be able to observe the humidity and temperature and humidity level on serial monitor.
#include<dht.h>// DHT11 humidity sensor library
#include<LiquidCrystal.h> //LCD library
dht DHT; //Creating sensor object
#define DHT11_PIN A3 // Sensor is connected to Arduino pin 3
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);// LCD connected with Arduino on these pins
void setup()
{
  Serial.begin(9600); //setting baud rate
  Serial.println("   =====================================================");
  Serial.println("   ||   Welcome to Temperarue and Humidity Detector   ||");
  Serial.println("   =====================================================");
  Serial.println("");
  lcd.begin(20, 4); // initialinzing the LCD order
  lcd.setCursor(4,1); //Setting the cursor on LCD
  lcd.print("Welcome to");//printing on LCD
  lcd.setCursor(2,2);
  lcd.print("Humidity detector");
  delay(2000);//adding delay of 2 secons or 2000 msec
  }
void loop()//method used to run the code repeatedly
{
  int chk = DHT.read11(DHT11_PIN); //Reading data from sensor
  Serial.print(" Humidity = ");//prints on the serial monitor
  Serial.print(DHT.humidity);// prints obtained humidity on serial port
  Serial.print(" g/m^3");

  lcd.clear();//clears all the data on LCD
  delay(1000);//adding delay of 1 second
  lcd.display(); //starting the display of LCD after clearing
  lcd.setCursor(0,0);
  lcd.print("Humidity=");
  lcd.print(DHT.humidity);
  lcd.print(" g/m^3");
  
  Serial.print("    \tTemperature = ");//prints on the serial monitor
  Serial.print(DHT.temperature, 1);//prints obtained temperature on serial port
  Serial.println(" degrees");

  lcd.setCursor(0,1);
  lcd.print("Temperature=");//prints on LCD
  lcd.print(DHT.temperature, 1);//prints the obtained temperature on LCD
  lcd.print(" deg");

  lcd.setCursor(1,2);
  lcd.print("www.TheEngineering");
  lcd.setCursor(4,3);
  lcd.print("Projects.com");

  delay(2000);//adding the delay of 2 seconds
  }  
  • I am going to explain you that how this code is working!
  • First of all I have added the library in the libraries folder at the destination where the Arduino software is installed.
  • I have defined DHT11’s library in the source code then.
  • Then I have defined the library for LCD.
  • I have defined the pin at which DHT11 is attached with the Arduino board.
  • Then I have defined the Arduino pins at which the LCD in interface.
  • Then by opening the serial port I have started to print the level of temperature and humidity on the serial monitor as well as on the 20×4 LCD.
  • At the end, I have added the delay of 2 seconds so that the speed of the data to be printed on the serial monitor can be reduced to some extent in order to observe properly.
  • This was the brief description of the source code.
That is all from the tutorial Interfacing Temperature & Humidity Sensor with Arduino. I hope you enjoyed this tutorial. If you are facing any problem regarding any of my tutorials, you can ask me freely in the comments without even feeling any kind of hesitation, I will try my level best to solve you issues in a better way, if possible. I will explore Arduino by making further projects and will share them with you as well. So, till then, Take Care :)

Brushless DC Motor

Hello friends, i hope you all are fine and enjoying. Today i am going to share a new tutorial which is Brush-less DC motor. The basics of DC motor have been explained in one of my previous tutorial which was named as Difference Between DC and AC motors in that tutorial i explained in detail the basics of a DC motor, its construction and working.

Now in today's tutorial i am going to share a tutorial on one of the type of DC motor which is Brush-less DC motor. Brush-less DC motor is commonly known as Electronic Commutated motor. It is in fact a synchronous motor. From the word DC, one thing becomes clear that the supply voltage will be DC but as i mentioned in the previous line that it is a synchronous motor then, it will need AC supply to run. So what actually happens is that from source DC voltages appears and after the inverter circuit, we get AC voltages and these AC voltages are actually given to the motor to operate. The rotor of a Brush-less DC motor is actually a permanent magnet rotor. While some winding is done on stator. Brush-less DC motors are also commonly known as stepper motor but there is a very little difference in between both these motors and their operation. Like stepper motor are generally used at that placed where they have to stop again and again and the continuous operation of the motor is not required. There is also another big difference between Brush-less DC motor and stepper motor that the rotor of stepper is placed to work in proper angular direction. Now lets get started with the working and applications of Brush-less DC motor

Brush-less DC motor

Brush-less DC has 2 parts. One is called rotor and the other is called Stator. Here the rotor is a permanent magnet and it rotates inside the fixed armature. This assembly gives us a very big advantage which is, that it reduces the heating losses. Rotor is placed inside the stator and this allows the motor to produce more torque. It is our choice to make a brushless DC motor of different poles. For example we can made a motor having 2,3 or poles and all are DC brushless motors. Brush-less DC motor can be made in 2 different design. In first design, the rotor is placed inside the fixed stator. This configuration is also known as 'inrunner' because the rotor is running inside the stator.

While in the second configuration, we have a fixed stator inside and the permanent magnet rotor rotates around it.  This type of configuration is called 'outrunner'. We can also place the stator windings in 2 different configurations. If we place the stator winding in delta configuration and we are dealing with a 3 pole motor then, all the windings will be connected in series and the power supply from the source is applied to all the windings. The resulting configuration looks like a triangle shape. While on the other hand if we wish to place the stator winding in Wye (Y) then we will common the one terminal of each winding. And to the remaining 3 terminals, we will connect the power supply to all those three points.(Since we are working with 3 phase motor and we will have three wires and all of them will be phase wires).

Both these winding configurations have their own advantages and they are listed below as:

  • If you have made the stator winding configuration in Delta, then this motor will have a low starting torque. Which means at slow speeds it will generate a very low torque and at higher speeds its torque will also increase with speed.
  • The Star type stator motor possess high starting torque. At starting or at very low speed it generates much high torque but as the motor picks up speed, it torque doesn't builts up as compared to Delta type motor.
  • Efficiency also have a greater impact on the operation and reliability of motor operation. If we compare the efficiecies of both these motors then, we will see that motor having Star shaped winding is more efficient as compared to delta shape winding.
  • Reason is that the star shape winding motor have high starting torque and it is able to drag heavy loads even at low speeds.

Control circuit of Brush-less DC motor

As i explained earlier that the supply voltages may be DC but this motor requires AC voltages to operate actually. So, we have a control circuit which allows the motor this kind of operation of the motor on such voltages. Since the control circuit has to rotate the rotor so the control circuit needs to know the position of the rotor in rest position. To cope with this thing, we implement HALL EFFECT Sensor in control circuit. If you are using a 4 pole motor then the controller will energize the 2 coils with NORTH polarity and the other 2 coils with South polarity. When the stator coils will be energized then one set of coils will tends to push the rotor away from it and the other set of coils will tend to attract the rotor to itself, in this way the rotor will start to rotate and a torque will be established in it and afterwards it would be able to pick load.

Practical Applications

Brush-less DC motor possess a large no of industrial applications. Although, these types of motors are little costly and also complex to operate because of the control circuit but still we can't ignore the importance of this type of motor. Some of its industrial based applications are listed below as:
  • Biggest and most common use is that these motors are used in laptops and computers for cooling purpose.
  • An old use of low power and very low speed DC brushless motor was that they were used in gramophones records.
  • High rating and bigger size DC brushless motors are used in transport vehicles and also in Hybrid cars.
  • These motors may be of small size but have permanent magnet rotor and are able to develop high starting torque.
  • In refrigeration and cooling systems, Brushless DC motor is used in all appliances for the condenser cooling purposes. Both large and small air-conditioning systems uses Brushless DC motor.
  • When high voltages AC is generated and transmitted, so need a control mechanism for its safe operation and control. Brushless DC motors are also used at those places for proper cooling of micro processors.
  • Brushless DC are able to develop high starting torque and gives good speed response. That's why they are widely used in water pumps, fans and variable speed industrial applications.
  • These motors are preferred to work in industries because they possess high power density, can give good speed and torque characteristics and also high efficiency.
  • Brushless DC motors have good thermal conditions so they are able to operate at variable speed without excessive heating.
  • Brushless DC motor have the biggest demand in defense applications. Now a days they are commonly used in helicopter's rotors, because of their favorable power to wight ratio.
Alright friends, that's all from today's tutorial. If you have any questions then, feel free to ask. Till next tutorial Take Care !!! :)

Brushed DC Motor

Hello friends, i hope you people are fine and enjoying. Proceeding to my previous tutorial, in which i explained Brushless DC motor in detail. Now in this tutorial i am going to explain in detail the second type of DC motor which is Brushed DC motor. In this tutorial, we will see what is in fact a Brushed DC motor, how it works and what are the advantages and practical application of this type of motor on some other type of motors.

Brushed DC motors are also known as commutated DC motors. Reason is that these motors contain commutator and carbon brushes for rotor excitation. I will explain all these terminologies in detail, later in tutorial. These are the most important type of motors designed to run directly on DC power supply. These were the very first type of motors, which were designed to operate on DC voltages at industrial levels and as we also know that DC power system had been used in some countries like USA for power transmission and distribution. DC series motors are still in use for industrial applications. Reason is that these motors gives us the ease to vary the speed of motor by simply changing the supply voltages or magnetic field strength. We can also change the speed and torque characteristics of the motor by changing the power supply connections. Brushed DC motors contain carbon brushes, which wear out with time and continuous operation of motor, so where maintenance operation is required, Brushless DC motor is preferred. Now first of all, lets see the operating principle of Brushed DC motor:

Operating principle of Brushed DC Motor

Brushed DC motor rotates on the principle of Fleming's Left Hand Rule. When a current is make to pass through a coil placed in a permanent magnetic field, then a torque acts on the coil which makes it to rotate. The direction of rotation of the coil is given by the Fleming's Left Hand Rule. The process can be elaborated by the image which is shown below as:

The above figure a showing the basic operating principle of Brushed DC motor. I have chosen the example of permanent magnet Brushed DC motor to make it easy to understandable. From the above shown image, you can see that:

  • A DC supply has been connected to rotor circuit through carbon brushes and commutator.
  • Commutator is made of brass while carbon brushes are made of soft silicon material.
  • The reason why carbon brushes are made of silicon is to reduce the friction between carbon brushes and commutator.
  • If you use carbon brushes made of brass or copper then, conduction between carbon brushes and commutator will increase but a massive sparking will produce, which can damage our system.
  • When the rotor poles are at 90 degrees to the stator poles then zero torque is produced in rotor.
  • On the other hand, when rotor poles are at 0 degrees to the stator poles, then maximum torque is produced in rotor circuit.
  • So we can conclude that half of the supply cycles would be wasted in this way, that's why we have connected commutator in this system. It automatically change the direction of direction after every half cycle.
  • The resultant gives us maximum torque continuously during our operation.

TYPES of Brushed DC Motor

Based on the types of connections between Rotor and Stator windings, DC Brushed motors have been divided into 5 major types. All these types are given below as:

Series Type DC Motor

  • In these type of motors, the rotor winding is in series with rotor winding.
  • These type of motors have High Starting Torque.
  • The beauty of these type of motors is that, their speed varies automatically with the applied load. If load increases or suddenly vanishes then, this motor has the ability to maintain it's speed.
  • These motors are used at those places where the motor has to supply heavy load. For example in Electric trains DC series motors are used.

Shunt Type DC Motor

  • In these type of motors, rotor winding is in parallel with stator winding.
  • These motors have low starting torque as compared to Dc series motor.
  • These motors have constant speed and their speed doesn't varies with load.

Compound Type DC Motor

  • You can judge the properties of this motor by its name. In this type of DC motor, both series and compound windings are embedded together.
  • This type of motor have much dominating features than any other type of DC motor.
  • These motors have high starting torque, which is in fact a property of DC series motor.
  • While on the other hand, this motor is capable to run on constant speed and it speed doesn't vary as much with load, which is in fact a property of DC shunt motor.

Permanent Magnet Type DC Motor

  • It can be seen from the name of these type of motors that they contain a permanent magnet stator instead of a wound electromagnet stator.
  • No need of external energizing field current.
  • More efficient design.
  • This design is only possible for small size but much efficient motors.

Separately Excited Type DC Motor

  • In these type of motors, some heavy excitation system is required for the excitation of rotor circuit.
  • High field is drawn by these type of motors.
  • This motor has the ability to draw much heavy loads even at a very low speed.
  • The reason these motors are able to bear much heavy loads is that they draw much field current and much armature voltages.

Features and Practical Applications

Brushed DC motors possess a large no of features and practical applications. Some of them are listed below as:
  1. These motors have a very simple design and it is very cost effective to built them on large scale.
  2. Their operation is very simple and it doesn't requires any control mechanism.
  3. DC motors are used in both domestic and industrial applications, because of their simpler design and advanced features.
  4. They are commonly used in car power windows and seats.
  5. Car's wind wiper motor is also a DC motor. And it has variable speed and high starting torque.
  6. DC motors are enclosed in a solid frame and they don't have any environmental impact on their operation. They are capable to work under any severe condition.
Alright friends, this ends my today's tutorial here. If you have questions regarding my today's tutorial, feel free to ask. Till next tutorial Take Care!!! :)

Calculating trigonometric Functions in MATLAB

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about Calculating Values of Trigonometric Functions in MATLAB. Trigonometric function have a great importance in latest mathematics. There are six types of trigonometric functions out of which first three are used more frequently in comparison to the other three. Trigonometric functions are important in the study of triangles. Trigonometric functions show the relationship between the angles of the triangle and the lengths of its sides. The positive and negative signs with the trigonometric functions indicate the portion of the quadrants. Well known theorem of mathematics i.e. Pythagoras Theorem is used in case of the right angle triangle and is totally based on the first three trigonometric functions.

Calculating trigonometric Functions in MATLAB

Here in the tutorial Calculating Values of trigonometric Functions in MATLAB, I will explain you that how can you calculate the values of trigonometric functions in MATLAB. First of all I would like to explain a bit about the trigonometric functions. They are important in the studies of triangles and depend upon some particular angle, as I have told earlier. There six types of trigonometric functions and they are given below.
  • sine
  • cosine
  • tangent
  • cosecant
  • secant
  • cotangent
Suppose there is a particular angle ? then all of these functions can be written in MATLAB as shown below.
  • sin?
  • cos?
  • tan?
  • cosec?
  • sec?
  • cot?

 Calculating Values

  • Here I am going to calculate the values of the trigonometric functions in editor of the MATLAB.
  • First of all open the MATLAB software and open the editor then.
  • You need to define a time duration in which the function is defined.
  • Set the frequency of sinusoidal signal and write the function to calculate the value.
  • All of the above steps are shown in the figure below.
  • In the above figure you can see that I have define the duration from 0 to
  • I have adjusted the frequency of the signal as 5Hz.
  • And then I have written the desired function to calculate its value.
  • Since, I want to observe its value on the command window so I have removed the semicolon at the end of this statement as shown in the figure above.
  • The result displayed on the command window is shown in the figure below.
  • Similarly you can also calculate the values of all of the other trigonometric functions.
  • Here I am going to calculate the values of cosine and tangent functions for the same time duration and same frequency as well.
  • The code for calculating the values of the cosine and tangent functions is shown in the figure below.
  • You can see that there is no semicolon at the end of the last three statements because I want to observe the results of these three statements on the command window, if I put a semicolon, there will appear nothing on the command window then.
  • The results shown in the command window are shown in the figure below.
  • By scrolling up you can also observe the result of the sine function.
So, that is all from the tutorial Calculating Values of trigonometric Functions in MATLAB. I hope you enjoyed this tutorial. If you face any sort of problem you can ask me in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. In my next tutorial I will explain you that how to Plot Simple Signal in MATLAB. I will explore MATLAB further in my later tutorials and will share all of them with all of you as well. So, till then, Take Care :)

Generating Simple Signal in MATLAB

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about Generating Simple Signal in MATLAB. Signals are of great importance in our daily life. The signals are basically the graphical display of the analog values. We can estimate the severity level by the shape of the signals. The signals have a very wide range of applications in our daily lives. If we observe the shape of the AC voltages of 220V that is supplied in our homes, it is a sinusoidal signal. So, its an application of the signals. Signals also play a vital role in the medical field. While performing ECG and EEG tests in hospitals, doctors visualize the signals displayed on the screen and they can estimate the severity of the disease with the help of these signals. Depending upon the severity they suggest different medicines to the patients. Oscilloscope is a device to monitor the shape of the different signals usually present in engineering institutions. We can observe the shape of the voice, heat and a lot of other signals on it.

Generating Simple Signal in MATLAB

Here in the tutorial Generating Simple Signal in MATLAB, I will explain you the step by step procedure that how can you generate simple sinusoidal signal in MATLAB and how to visualize it.
  • First of all open your MATLAB software and open the editor.
  • Define a time duration at which the sinusoidal signal is completely defined.
  • Set the frequency of the sinusoidal signal.
  • Define the sinusoidal signal as the function of time and frequency.
  • Then at the end plot that sinusoidal signal across the time duration using the command
  • All of the above steps are shown in the figure below.
  • You can download the MATLAB simulation here by clicking on the button below.
  • Download .rar file, extract it and enjoy the complete simulation.
  • You can see that I have defined the time duration from 0 to
  • And adjusted the frequency of the signal as
  • Now press the Run button as encircled in the figure above.
  • A new figure having a sinusoidal signal will be appeared on the screen.
  • The sinusoidal signal is shown in the figure below.
  • Now, I am going to reduce the frequency of the signal to observe that what will happen to the shape of the signal.
  • I am going to reduce the frequency from 10 to 5Hz and want to observe the new shape of the signal.
  • The new code with the updated frequency is shown in the figure below.
  • The new signal generated is shown in the figure below.
  • If we compare the both of the signals we can conclude that there is an inverse relation between the frequency and the width of the signal.
  • Smaller the frequency greater will be the width of the signal and vice versa.
  • So, that was the brief description of the signal generation in MATLAB.
So, that is all from the tutorial Generating Simple Signal in MATLAB. I hope you enjoyed this tutorial. If you face any sort of problem you can ask me in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. In my next tutorial I will explain you that how to Change the Properties of the Figure in MATLAB. I will explore MATLAB further in my later tutorials and will share all of them with all of you as well. So, till then, Take Care :)

Effect of Noise on Signal in MATLAB

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about Affect of Noise on Signal in MATLAB. Noise is basically an unwanted signal that effects the normal signal. Noise the natural signal which can be removed but can be reduced to some extent. We can see a lot of examples of the signals effected by noise in our daily lives e.g. the distorted voice signal while calling, creates hearing problems, distorted TV signal makes the video invisible and the distorted AC signal can burn most of the home as well as other appliances. In signal processing term, noise is also known as the unwanted signal which carries no useful information. To recover the original signal from the noise effected one, is the basic and necessary goal of the signal processing. All of the filters including low pass, high pass, band pass, band reject (notch) are also designed for this purpose. Noise can never be removed completely but we can make its magnitude lower to some extent.

Effect of Noise on Shape of Signal

Here, in the tutorial Effect of Noise on Shape of Signal, I will elaborate that how noise an effect the shape and the information carried by the normal signal. Since noise is a random and unwanted signal having no useful information, so it has no fix shape, instead it could of any shape. Some of the shapes of the noise signals are shown below.
  • Noise across the time with random amplitude is shown in the figure below.
  • The noise signal displayed on the oscilloscope is shown in the figure below.
  • You can download the MATLAB simulation here by clicking on the button below.
  • Download .rar file, extract it and enjoy the complete simulation.

Block Diagram
  • I have made a simple block diagram to explain the flow of the program.
  • The block diagram is shown in the figure below.
  • Noise is added in the signal and hence generated the noise effected signal.
Code Description
  • Just copy and paste the source code given below in your editor.
t=0:0.01:1;%time duration
x=sin(2*pi*5.*t);%orignal signal
noise = rand(1,101);%noise signal
corrupted_signal=x+noise;%noise effected signal
subplot(311);%division of figures
plot(t,x);%plotting
title('Orignal Signal');%title
subplot(312)%division of figures
plot(t,noise);%plotting
title('Noise Signal');%title of the corresponding signal
subplot(313)%division of figures
plot(t,corrupted_signal);%plotting
title('Corrupted signal');%title of the corresponding signal
  • First of all I have defined the time duration at which the signal is defined.
  • Then I have generated the original sinusoidal signal.
  • After that, I have generated a random noise.
  • Then the noise effected signal has been generated.
  • I have plotted all of the signals on the same figure but in different sections in order to visualize all of them.
  • As you run the program, a new figure having graphs will be appeared on the screen.
  • The figure containing graphs of all the signals is shown in the figure below.
  • That was the brief description of the source code for visualizing the Effect of Noise on Shape of Signal.
So, that is all from the tutorial Effect of Noise on Shape of Signal. I hope you enjoyed this tutorial. If you find any sort of problem, you can ask in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. In my next tutorial I will elaborate that how to create a simple Graphical User Interface (GUI) in MATLAB and how to use it. I will further explore MATLAB in my later tutorials by making further projects on it and will share them with all of you as well. So, till then, Take Care :)

Convolution in MATLAB

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how to convolve the signals using an amazing software tool, MATLAB. MATLAB is an efficient tool for signal processing. MATLAB basically works on matrices. First of all I would like to tell you a bit about the convolution. In engineering terms, convolution describes the output of the Linear Time Invariant (LTI) systems.

Convolution is basically an integral which tells us about the overlapping of one function as it is shifted over another function. Convolution and cross correlation are similar. It has a wide range of applications e.g. computer vision, probability, statistics, engineering, differential equations, signal processing etc.

Convolution in MATLAB

Here in the tutorial, Convolution in MATLAB, I will tell you that how to convolve the two signals in MATLAB using built-in command, conv. Before going into the details of this tutorial, I would like to explain you about the convolution and its mathematical form.

  • You can download the MATLAB code or convolution of two signals here by clicking on the button below.
  • Download .rar file, extract it and enjoy the simulation.

In simple engineering terms, convolution is used to describe the out of the Linear Time Invariant (LTI) systems (the systems which shows different response at different times). Convolution is similar to cross correlation. Input output behavior of the system can be estimated with the help of the impulse response of that system. And the output of the system can be obtained by convolving the input applied to the system and impulse response of that system.

  • Suppose x(t) is the input applied to the system and h(t) is the impulse response of the system.
  • Its output y(t) can be obtained using the mathematical expression given below.

y(t) = x(t)*h(t)

  • In above expression * sign expresses the convolution between the input and the impulse response of the system.
Block Diagram
  •  I have made a very simple block diagram representation of convolution.
  • The input x(t) is applied to the system.
  • The system has convolved the input x(t) and the impulse response of the system h(t) to obtain its output y(t).
  • The block diagram is shown in the figure below.
Signal Representation
  • The convolution can also be represented in the form of signals.
  • The figure shown below displays the convolution between input and impulse response of the system in order to obtain its output.
Source Code Description
  • Just copy and paste the source code give below in your MATLAB editor to observe the convolution results.
clc %clears the command window
clear all %clears the workspace
t1 = 0:1:1;%time duration for the first signal
t2 = 0:2:10;%time duration for the second signal
f1 = 3;%frequency of the first signal
f2 = 5;%frequency of the first signal
x = sin(2*pi*f1.*t1);%first signal
y = cos(2*pi*f2.*t2);%second signal
convolution = conv(x,y) %convolution of both the signals x & y
  • You can see first of all I have cleared the command window and the workspace.
  • Then I have declared time duration for both the signals.
  • After that I have defined the frequency for the both signals.
  • Then I have defined the two different sinusoidal signals.
  • At the end I have convolved both of them and removed the semicolon at the end of the statement in order to observe the results on command window in MATLAB.
  • So, that was the brief description of the code, you can download it from the above button.
  • The result shown on the command window are shown in the figure below.
  • That was the brief discussion about how to convolve two signals in MATLAB using builtin commands conv.

So, that is all from the tutorial Convolution in MATLAB. I hope you enjoyed this tutorial. If you find any sort of problem, you can ask in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. In my next tutorial I will elaborate that how to declare the variables in MATLAB and how to manipulate them without assigning them with the values. I will further explore MATLAB in my later tutorials. So, till then, Take Care :)

Interfacing Arduino with HC-05

Hello friends, i hope you all are fine and enjoying. Today i am going to share a new tutorial which is Interfacing Arduino with HC05 Bluetooth module. First of all lets have a little introduction about HC-05 Bluetooth module. HC-05 is a bluetooth module, which was designed for wireless data communication. This little module is capable of both sending and receiving data but it performs only one thing at a time, which means at a particular time it can only send or receive data but can't do the both tasks.

In order to send or to receive data, you have to make one module as a master and the other module as a slave. If both the modules are acting as master then, data will not transmit and if both the modules are acting as a slave then, again data will not transmit or receive. The hardware of Bluetooth module contains a large no of features. For example it is much sensitive and it is sensitive up to -80dBm and it catches a Bluetooth signal even from far away. If you wish to transmit data through it then, it also have much power to transmit data to a wider range. You can image its transmitting power from the digits that it has transmitting power of +4dBm. This module operates on a low voltages, that's why the power rating of this module is very low. The hardware of the module comes with a integrated antenna and also its hardware contains edged pins. These edged pins gives us the ease that it becomes very easy to plug in or plug out the wires. and also if you are going to use it within a circuit then, it becomes very easy to connect the cable with module. Above was a little introduction about Bluetooth module and its features. now lets move to the basic theme of our project, which is to do interfacing between arduino and HC-05.

Note:

  • If you have HC-06 or any other module in HC series then you don't need to get worried as they all work quite same. So you can also follow this tutorial for other HC series bluetooth modules.

Pin Configuration of HC-05

HC-05 Bluetooth module has total 6 pins. A simple HC-05  Bluetooth module is shown in the image given below and you can also see its pin configuration from this image. The pin configuration and the purpose of each pin is listed below as:

  1. They pin#1 is abbreviated a KEY pin. The function of this key is to show paired devices. In HC-05 module this pin is used to perform the module in AT mode.
  2. Pin#2 of HC-05  module is named as VCC pin. This module requires 3.3 volts to operate. If you will connect it directly with 5 volts then, this module will burn out.
  3. Pin#3 of this module is named as GND. At this pin the common ground of the circuit is provided.
  4. pin#4 is named as TXD. This pin is used when you have to transmit data to some external device. Asynchronous data transfer is performed by this module.
  5. pin#5 is named as RXD. This pin is used when the module have to receive wireless data from some external source. Asynchronous data is received through this module.
  6. The last pin of the module which is in fact pin#6 of the module and it is named as STATUS pin. The basic function of this pin is to check the status of the Bluetooth module. If the module is connected to some other device then, output of the system becomes HIGH and if the connection of Bluetooth drops then, this module generates a output pulse.

Interfacing with Arduino

So, now let's start with interfacing Arduino with HC05 bluetooth module. Its quite easy to interface as it works on Serial protocol. As mentioned above it has two pins named as TX and RX through which we can send or receive the data. Moreover, it works exactly the same as any mobile's bluetooth, you can connect your mobile with any device and can share data between these devices, similarly you can share the data with this device as well.
  • First of all, connect your HC05 bluetooth module with Arduino as shown in the below figure.
  • In the above figure, the connections are quite easy , we have provided power to the bluetooth module from Arduino and also connected TX pin of bluetooth module with RX pin of Arduino and RX pin of bluetooth module with TX of Arduino.
  • Now we are done with the connections so next part is to upload the code into Arduino.

Code for interfacing HC-05 with Arduino

Now upload the below code into your Arduino and you are ready to get the first data from your Bluetooth module.

Applications of HC-05 Module

  • The biggest application is that it is used to transmit or receive data wirelessly.
  • You can play your favorite sound tracks through bluetooth in your car using this module.
  • The modern Android phones contains a wireless GPS option. IN fact this module is being used in that phones and it works to seek the bluetooth location.
  • This module makes you able to chat with some android phone using Bluetooth.
Alright friends, that all for today. If you have any question, fell free to ask. Till next tutorial Take Care!!! :)
Syed Zain Nasir

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

Share
Published by
Syed Zain Nasir