Pure Sine Wave Inverter Design With Code

Hello guys, in the last post I have explained the Basics of Inverters along with its types and also the inverters topology in other words working of inverters, then we discussed the Major Components of Inverters. Now in this post I am gonna explain the pure sine wave inverter and how to create it. I have used AVR microcontroller int his project. The reason I am using random microcontrollers is that so you guys get a taste of each one. Before starting on sine wave inverter read this article again and again as I have also mentioned the problem i got while making it. You should also read the Modified Sine Wave Design with Code.

I have divided this tutorial into four parts which are shown below. This is a step by step guide to design and build an inverter and I hope at the end of this tutorial you guys will be able to design your own inverter. I tried my best to keep it simple but still if you guys got stuck at any point ask in comments and I will remove your query. This project is designed by our team and they put real effort in getting this done so that's why we have placed a small fee on its complete description. You can buy the detailed description of this project along with the complete code and circuit diagram, by clicking on the below button:

Buy This Project Note:

Pure Sine-Wave Inverter

  • Pure Sine wave inverter consist of a microcontroller unit which generates a switching signal of 15 KHz, an H-bridge circuit to convert the signal into AC, a low pass LC filter circuit to block the high frequency components and the transformer unit to step-up the voltages.
  • Block diagram of sine wave circuit is given below:
FIGURE 1 : Block diagram of pure sine wave inverter

AVR Micro-Controller Unit

  • Microcontroller unit is a multi-purpose control unit which can handle multiple tasks simultaneously.
  • We have used it just to generate a switching signal of 15 KHz.
  • I am using AVR micro-controller unit for this pure sine wave inverter.
Explanation for PWM in AVR
  • AVR is acting as the brain of Pure Sine Wave Inverter.
  • Below is the program for atmega16 microcontroller with a clock frequency of 8 MHz (Fcpu = 8MHz). We have worked on a compiler named AVR GCC.
  • Initially we included AVR libraries,then we initialized sine table in which the values of a complete sine wave are stored (we generated a sin table in range 0-359 degrees whereas, zero of sine wave is set at decimal 128(0x80 in Hex).
  • Then in the next chunk of the code, we used timer0 (8-bit) which starts from 0 and peaks to 255 (it gives a saw tooth output).
  • The constant float step = (2*180)/256 = 1.40625 For i=0; s = sin (0*1.40625) = 0 For i = 255 s = sin (255*1.40625) = 358.5937 = 359deg approx.
  • This is how the sine wave is generated from 0-359deg.
  • When timer reaches 255 then interrupt over flow is generated (Refer the sine wave code, at the end).
  • The next part of the code shows that we have used the clock select bits as pre-scalar.
  • TIMSK| = (1<<TOIE0) means we are enabling timer overflow interrupt enable 0.
  • The last part of the code is the most important part of pure sine wave generator.
  • OCR0 is output compare register for timer 0 and it continuously compares timer0 values i.e. 0, 1, 2.......255, and for each value of timer the value from sine wave table is computed then sample++increases the pointer of sine wave table to the next i.e. the value at the second index of sine table and that is computed for the output until samples equals to 255.
  • Then we used the command sample = 0 the cycle is repeated again and again.
  • Here's the programming code for Pure Sine Wave Inverter:
    #include <stdlib.h>

    #include <avr/io.h>

    #include <util/delay.h>

    #include <avr/interrupt.h>

    #include <avr/sleep.h>

    #include <math.h>

    #include <stdio.h>

    0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,

    0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,

    0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,

    0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,

    0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,

    0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,

    0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,

    0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,

    0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,

    0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,

    0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,

    0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,

    0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,

    0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,

    0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,

    0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,

    0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,

    0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,

    0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,

    0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,

    0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,

    0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,

    0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,

    0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,

    0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,

    0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,

    0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,

    0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,

    0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,

    0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,

    0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,

    0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D

    void InitSinTable()

    {

    Page | 42

    //sin period is 2*Pi

    const float step = (2*M_PI)/(float)256;

    float s;

    float zero = 128.0;

    //in radians

    for(int i=0;i<256;i++)

    {

    s = sin( i * step );

    //calculate OCR value (in range 0-255, timer0 is 8 bit)

    wave[i] = (uint8_t) round(zero + (s*127.0));

    }

    }

    void InitPWM()

    {

    /*

    TCCR0 - Timer Counter Control Register (TIMER0)

    -----------------------------------------------

    BITS DESCRIPTION

    NO: NAME DESCRIPTION

    --------------------------

    BIT 7 : FOC0 Force Output Compare

    BIT 6: WGM00 Wave form generartion mode [SET to 1]

    BIT 5: COM01 Compare Output Mode [SET to 1]

    BIT 4: COM00 Compare Output Mode [SET to 0]

    BIT 3: WGM01 Wave form generation mode [SET to 1]

    BIT 2: CS02 Clock Select [SET to 0]

    BIT 1: CS01 Clock Select [SET to 0]

    BIT 0: CS00 Clock Select [SET to 1]

    Timer Clock = CPU Clock (No Pre-scaling)

    Mode = Fast PWM

    PWM Output = Non Inverted

    */

    TCCR0|=(1<<WGM00)|(1<<WGM01)|(1<<COM01)|(1<<CS00);

    TIMSK|=(1<<TOIE0);

    //Set OC0 PIN as output. It is PB3 on ATmega16 ATmega32

    DDRB|=(1<<PB3);

    }

    ISR(TIMER0_OVF_vect)

    {

    OCR0 = wave[sample];

    sample++;

    if( sample >= 255 )

    sample = 0;

    }
 

H-Bridge Circuit

  • H-Bridge Circuit is acting as the main core of Pure sine Wave Inverter.
  • H-bridge circuit is basically enables a voltage to be applied across a load in either direction.
  • In inverters, it is used to amplify the input square wave coming from the micro-controller.
  • We are giving modulated square wave at the input of the H-bridge because if we give sine wave to the MOSFET or any other switching device like the BJT or IGBT, very high switching losses occur. This is because when we give sinusoidal waveform to any of these devices, they start operating in the linear region, and power loss occurs in devices operating in linear region.
  • When we give a square waveform to them, they operate on either saturation or cut-off regions thus having minimum power loss.
  • We used IRF5305 and IRFP150 MOSFETs. These are high power MOSFETs with maximum current rating of 31 Amp and 42 Amp respectively.
  • IFR5305 is a Pchannel MOSFET whereas IRFP150 is an N-channel MOSFET.
  • The circuit configuration of H-bridge is given below:
FIGURE 2 : H-Bridge Circuit
Working
  • Working of an H-bridge for pure sine wave inverter can be divided into two modes.
  • In Mode1, the input signal at the gate of M1 is high and at the gate of M4 it is low.This causes conduction from M1-M4 and we achieve a +12V signal at the output.
  • In Mode2, the input signal at the gate of M3 is high and at the gate of M2 it is low.This causes conduction from M3-M2 and we achieve a -12V signal at the output.
  • And thus we obtain a 24Vpeak-peak signal at the output.
  • The working of H-Bridge in both conduction modes can be easily understood by the following figure:
FIGURE 3 : H-Bridge Conduction Modes (A) FIGURE 3 : H-Bridge Conduction Modes (B)  
  • Due to the conduction of half part of the bridge at +ve half cycle and the other half part of the bridge at –ve half cycle, we obtain a square waveform of 24 Vpeak-peak at the output.
  • In figure below is the Proteus simulation showing the waveform output of bridge circuit during each conduction cycle.
FIGURE 4 : Wave-forms of H-bridge conduction cycle
Observations
  • In the H-bridge circuit we have observed that input signal"s frequency does not change at the output that means the frequency remains un-altered.
  • Only the power of the signal increase in terms of current.
Problems
  • Initially we used all the MOSFETs of same type (i-e. n-channel MOSFETs). This caused the shorting of the MOSFETs during the conduction mode. This phenomenon is known as shooting over of the MOSFET.
  • Despite the duration of this shooting over was quite small, it caused loading on the MOSFETs.
  • The MOSFETs started heating up due to this, and eventually they burned out.
  • Another problem occurred while using the MOSFETs of same channel was that the upper MOSFETs (M1 and M3) did not turn on properly.
  • After studying, we learned that they required 18V to turn on thus; we needed a MOSFET driver that was IR2110.
  • We worked on it but it did not working properly too, because according to the formula for bootstrap capacitor given in datasheet, the driver must have given 18V output but it was not working so we had to search for an alternate.
  • Then after extended study we came to know that replacing the upper two n channel MOSFETs with p channel MOSFET is the solution. We applied this technique and it worked.
  • Using this technique also solved the problem of MOSFET shooting over by inducing a dead time/delay in the MOSFET switching.

LC Filter

  • We have determined inductance of the inductor using LC resonant band stop filter as LC meters were not available in the lab.
FIGURE 5 : LC filter
Working
  • Understanding the working of H-Bridge is very essential, if you want to work on Pure sine Wave Inverter.
  • The method to determine L or C is simple. Suppose we are required to determine the inductance, then by above circuit,
  • V1 signal from function generator is set to 1Vrms using multi-meter.
  • At resonance frequency the LC combination will have very low impedance so it will short out the signal and will drop across resistor R1 and prevents the signal to reach the load.
  • Using this principle we have varied signal frequency from function generator and we are detecting output voltage at load using multi-meter.
  • At resonance frequency multi-meter will show ideally zero volts.
  • So by using formula we have :
Problems
  • First we designed an RC circuit but we observed that the Resistance R in the circuit acts as a load and dissipates power.
  • After studying, we decided to use an LC filter.
  • The main problem with the LC filter was the designing of the inductor as the inductor of desired value was not available in the market, thus we had to make it by hand.
  • LC meter was not available also thus we had to repeatedly calculate the inductance value mathematically.

Working of Pure Sine Wave Inverter

  • Let's have a look at the working of Pure Sine Wave Inverter.
  • A 50Hz sin wave is generated with the help of a lookup table within the AVR microcontroller and is modulated over a switching frequency signal of 15KHz.
  • As this signal has very weak current, so it is amplified by a BC 547 transistor.
  • The amplified signal is given at the gates of M1 and M2 MOSFETs.
  • The output of the microcontroller is given to another BC 547 which is working as an inverting amplifier.
  • By this, the signal from the microcontroller gets inverted as well as amplified.
  • This signal is given at the gates of M3 and M4 MOSFETs.
  • Now what happens is that, when the input signal at the gate of M1 of the H-bridge is high and at the gate of M4 of the H-bridge is low, conduction from M1-M4 occurs and we achieve a +12V signal.
  • When the input signal at the gate of M3 goes high and at the gate of M2 goes low, conduction from M3-M2 occurs and we achieve a -12V signal.
  • Thus at the output we receive a waveform of 12Vpeak or 24Vpeak-peak.
  • The output of the H-bridge is then fed into a low pass LC filter which filters the high frequency components of 15 KHz and gives the 50 Hz sine output.
  • This output is then fed into a transformer which steps up this 12 Volts AC waveform into 220Volts AC.
So, that's all for today. I hope you guys have enjoyed this Pure Sine Wave Inverter Project. You should also look at Proteus simulation of Pure sine wave and Introduction to Multilevel Inverters, because simulations help a lot in designing hardware projects. So, take care and have fun !!! :)

Major Components of Inverters

No. Proteus Tutorials
Give Your Suggestions !!!
1. Basics of Inverters With Topology
2. Major Components of Inverter
3. Pure Sine Wave Inverter Design With Code
4. Modified Sine Wave Design With Code

Hello guys, in the last post I have explained the basics of inverters along with its types and also the inverters topology in other words working of inverters. Now in this post I am gonna explain the major components required for making an inverter. This post is not giving you any technical knowledge about inverter but to workout with inverters its necessary to go through its basic components.

I have divided this tutorial into four parts which are shown below. This is a step by step guide to design and build an inverter and I hope at the end of this tutorial you guys will be able to design your own inverter. I tried my best to keep it simple but still if you guys got stuck at any point ask in comments and I will remove your query.

Major components of an inverter

  • An inverter design and components vary with requirements but following components are most commonly used in designing an inverter.

Microcontroller

  • Microcontroller is the main and integral part of an inverter. The main working of microcontroller is to control the switching of signals according to the requirements.
  • A single microcontroller can perform multiple functions (e.g.) generating PWM for switching, controlling the protection systems etc.
  • There are various types and families of microcontrollers available in the market, for example :
  •   Depending on the design specifications, any microcontroller can be used.

Bipolar junction transistors (BJTs)

  • BJT or a bipolar junction transistor is a three layered device which is capable of controlling the current flow.
  • In a BJT, a small current at the input of the device can control larger currents at the output. Thus, BJTs can amplify currents.
  • They can be used as a relay driver, as a switch, as a constant current source, as an amplifier (etc.).
  • Circuit symbol of a BJT is given in figure below :
FIGURE 1 : BJT symbols
Types of BJTs
  • There are two types of transistors, NPN and PNP transistors
1. NPN Transistor :
  • NPN is one of the two types of bipolar transistors, in which the letters "N" and "P" refer to the majority charge carriers inside the different regions of the transistor.
  • In other terms, an NPN transistor is "on" when its base is pulled high relative to the emitter.
  • The arrow in the NPN transistor symbol is on the emitter leg and points in the direction of the conventional current flow when the device is in forward active mode.
FIGURE 2 : PNP Transistors 2. PNP transistor
  • PNP transistors have two layers of P-doped material and in between these two layers, there's a small layer of N-doped material.
  • A small current leaving the base in common-emitter mode is amplified in the collector output. In other terms, a PNP transistor is "on" when its base is pulled low relative to the emitter.
  • The arrow in the PNP transistor symbol is on the emitter leg and points in the direction of the conventional current flow when the device is in forward active mode.
  • Below figure shows both NPN and PNP transistors.
FIGURE 3 : PNP Transistors

H-Bridge

  • H –bridge is a topology in which four switching devices BJTs, MOSFETs or IGBTs are integrated together in a single circuit.
  • The name H-Bridge is given to it because of the typical arrangement of this circuit.
  • Mainly used switching devices in the H-bridge circuits are BJTs, MOSFETs or IGBTs.
Working
  • In an H-bridge, corresponding to the figure below when the switches S1 and S4 are closed, the switches S2 and S3 are open.
  • Thus a positive voltage issupplied across the motor or any other load attached to it instead of motor (e-g) transformer.
  • When S1 and S4 switches are opened, and S2 and S3 switches are closed, the voltage is reversed, supplying negative voltages to the load.
  • A problem with this is that the switches S1 and S2 should never be closed at the same time, as this causes a short circuit on the input voltage source.
  • The same thing applies on the switches S3 and S4. This condition is generally known as the shoot-through condition.
  • Following figure describes the above phenomena.
  FIGURE 4 : H-Bridge Working

MOSFETs

  • The Metal-Oxide-Semiconductor-Field-Effect-Transistor (MOSFET) is a voltage controlled device and requires a very small input current.
  • It is mainly used for switching of electronic signals as its switching speed is very high.
  • It is the most commonly used FET in low-power high-frequency circuits.
  • The MOSFET is composed of a channel of n-type or p-type semiconductor material, and is accordingly called an N-MOSFET or a P-MOSFET.
  • Circuit symbols of MOSFET are shown in the figure below :
FIGURE 5 : MOSFET Types and symbols
Types of MOSFETs
There are two main types of MOSFETs.
  • The Depletion-type MOSFET (DMOSFET)
  • Enhancement-type MOSFET (E-MOSFET)

Filters

  • At times it is desirable to have circuits capable of selectively filtering one frequency or range of frequencies out of a mix of different frequencies in a circuit.
  • A circuit designed to perform this frequency selection is called a filter circuit.
Low-Pass Filters
 
  • A low-pass filter is a circuit offering easy passage to low-frequency signals and difficult passage to high-frequency signals.
  • There are two basic kinds of circuits capable of accomplishing this objective, and many variations of each one.
LC Filters
  • An LC filter is a low-pass filter which consists of an inductor attached in parallel with the capacitor and the load.L and C connected together act asan electrical resonator.
LC Filter over RC Filter
  • RC filters have R thus they dissipate power. They have attenuation even in the pass band.
  • To achieve a narrow transition band, RC circuits have to be of higher orders.
  • Only certain types of filters can be implemented by an RC filter.
  • Whereas, LC filter does not dissipate power.
  • Better characteristics can be achieved by the LC filter than RC with a lower order.
  • Thus it is desirable to choose an LC over an RC in the case of an inverter.
Transformer
  • A transformer is used to step up or step down the electrical voltages.
FIGURE 6 : Ideal Transformer
Working of Transformer
  • A changing electric flux in the primary of the transformer creates a changing magnetic field which induces a changing voltage in the secondary.
  • By adding load, one can transfer energy from one part to another.
  • The secondary voltage Vs of an ideal transformer is scaled from the primary voltage Vpby a factor equal to the ratio of the number of turns of wire in their respective windings.
  • By appropriate selection of the numbers of turns, a transformer thus allows an alternating voltage to be stepped up by making Ns more than Np or stepped down,by making it less.
  • If the secondary coil is attached to a load that allows current to flow, electrical power is transmitted from the primary circuit to the secondary circuit.
  • Ideally,
    • Pin = Pout
    • IpVp= IsVs
  • Where:
    • Pin = Input Power.
    • Pout = Output Power.
    • Ip = Primary Current.
    • Vp = Primary Voltage.
    • Is = Primary Current.
    • Ip = Primary Voltage

Basics of Inverters With Topology

No. Proteus Tutorials
Give Your Suggestions !!!
1. Basics of Inverter With Topology
2. Major Components of Inverters
3. Pure Sine Wave Inverter Design With Code
4. Modified Sine Wave Design With Code

Hello friends, hope you all are fine and enjoying good health. I have recently posted a project of my friend named as Design & Development of Hybrid Renewable Energy System, which is a pure electrical project.After that project, I thought of sharing some common electrical modules.

So first of all, I am gonna explain all about inverters. I have divided this tutorial into four parts which are shown in the table. This is a step by step guide to design and build an inverter and I hope at the end of this tutorial you guys will be able to design your own inverter. I tried my best to keep it simple but still if you guys got stuck at any point ask in comments and I will solve your query.

What is an Inverter

  • An Inverter is an important electrical instrument used to convert DC voltage into AC voltage, its quite easy to explain what is an inverter but its too way difficult to design an inverter.
  • In projects, mostly inverter is used to convert the 12V DC voltage into 220V AC voltage, obviously first it is converted to 12V AC and then stepped up to 220 volts (mainly) for the consumers.

Types of Inverters

There are various types of an inverters such as :
  • Pure Sine-wave inverters.
  • Modified sine wave inverters.
  • Square wave inverters.
  • Multi-level inverters.
  • Resonant inverters (etc.).
The main three of which are discussed below in detail.
Modified sine-wave inverters
  • The output of a modified square wave, quasi square, or modified sine wave inverter is similar to a square wave output except that the output goes to zero volts for a time before switching positive or negative.
  • It is quite simple to design and is compatible with almost every electrical equipment except for sensitive or specialized equipment,e.g. laser printers, audio equipments etc.
  • Most AC motors can run on this power source but with reduction in efficiency of approximately 20%.
Sine-wave inverters
  • A pure sine wave inverter is the best form of inverter as it produces perfect sine wave and the energy dissipation in it is minimal.
  • Pure sine wave inverter is compatible with all electrical devices.
  • Its designing is complicated as compared to all other inverters.
Square wave inverters
  • The square wave output has a high harmonic content, not suitable for certain AC loads such as motors or transformers.
  • Square wave units were the pioneers of inverter development.

Inverter topologies.

  • There are many different power circuit topologies and control strategies used in inverter designs.
  • Different design topologies address various issues that may be more or less important depending on the way that the inverter is intended to be used.
First Method
  • Inverters normally use H-bridge configuration.
  • However, the voltage level at which, the H-bridge is operated can be varied.
  • The normal inverters convert the DC into AC at 12 Volts.
  • After this inversion, this 12Volt AC is stepped up into 220 Volts AC by the means of a transformer.
  • The advantage of such an approach is that the bridge construction is easy, as it is not exposed to high voltages.
  • The disadvantages accompanying such an approach are :
    • The transformer steps up the harmonic content.
    • The size and weight of the transformer increases considerably, as the capacity of inverter is increased.
Second Method
  • To overcome such problems, we can use a topology of converting DC into AC at the output voltage of the inverter.
  • At first, boosting the battery voltages by the means of a DC-DC converter and then giving these voltages toa specially designed Hbridge.
  • This arrangement can overcome the previously mentioned disadvantages.
  • The main disadvantage of such an approach is that the bridge circuit becomes too complex.
So, that was the basics of Inverters, you should also have a look at Introduction to Multilevel Inverters. If you have any problem then as in comments.

Relay Interfacing With Microcontroller using ULN2003A

Hello friends, I hope you all are doing great. In today's tutorial, I am going to explain the Relay Interfacing with Microcontroller using ULN2003A. In the previous lecture, we have discussed the detailed Introduction to Relay along with its working. Now we are going to practically interface the relay with a microcontroller to design an automatic switch. Relay is a key component in almost every electronic circuit. It can be used as a switch and can also be used as a voltage regulator.

The microcontroller I am going to use here is PIC18F4552 but you can use any other Microcontroller. You just need to change the syntax of coding but the logic will remain the same. Here, I am using ULN2003A to control the relay and from this relay, we can control anything.

So, let's get started:

Where To Buy?
No.ComponentsDistributorLink To Buy
1LEDsAmazonBuy Now
2RelayAmazonBuy Now
3ResistorAmazonBuy Now
4ULN2003AmazonBuy Now

Relay Interfacing With Microcontroller

  • I am using a 12V relay, meaning we need to provide a 12V at its input coil, in order to get it energized.
  • In simple words, when we send the +12V signal from our PIC microcontroller, it will actuate the relay coil and the relay output gets connected and when we make the input LOW, the coil de-energized.

Now, the question is ???

  • But the real question is PIC gives 5V at its high signal but the relay operates at 12V so how to convert this 5V signal into 12V?

What's the Solution ???

  • The solution to this problem is ULN2003A.
  • ULN2003A is used in between the PIC and the relay, so when the PIC sends the HIGH signal i.e. 5V, ULN converts it to 12V, sends it to the relay and the relay gets actuated.

Circuit Diagram of Relay with ULN2003A

  • Here's the circuit diagram for this complete project:

  • Resistance R1 is used as a pull-up resistance.
  • LED is used for the indication, when the relay is actuated LED goes ON otherwise OFF.
  • The programming portion is not much, just send high and low signals from PIC to ON and OFF the relay.

That's all for today guys. If you guys have any problem in any part of this tutorial ask in the comments, and I will reply to your queries. Till next tutorial ALLAH HAFIZ .... :))

Introduction to Relay

Hello everyone! I hope you will be fine and having fun. Today, I am going to give a detailed Introduction to Relay. In this tutorial, we will learn the basics of relays, the working principle of relays, the types of relays and their applications in detail.

A relay is a simple automatic switch that opens and closes the circuit(either electronically or mechanically) based on its input signal. A relay is an electromechanical switch that uses electromagnetism from a small current or voltage to switch higher current or voltage for different appliances. When a relay is in a Normally Open (NO) state, no current passes through it and when the relay is energized, the current starts to flow and we can say the relay is in a Normally Closed state. You should also have a look at Relay Interfacing with Microcontroller using ULN2003.

A Relay is used to control high-power devices with small current devices i.e. microcontrollers. When a small voltage is applied(normally from microcontrollers) to the input coil of a relay, it gets energized and the relay output changes its position from NO to NC. Relays are also used for protection purposes i.e. overload, reverse, under current, over current etc.

Now let's have a detailed overview of What is Relay???

What is a Relay?

Relay is an automatic switch, which opens and closes the circuit electronically. It uses electromagnetism from small voltage to provide higher voltages. It has two basic contacts i.e. NO (Normally Open) and NC (Normally Closed). When input voltage is applied across its coil, NC changes to NO and NO changes to NC. When input voltage is supplied, we say that the relay is energized. It has several features e.g. it can be used for switching smaller voltage to higher. But it can not be used in power-consuming devices. It has a wide range of applications. It can be used in home appliances, electronic circuits where there is a need of protection, robotics for controlling its motors for the proper motion and many more. A basic relay is given in the figure shown below.

1. Relay Pins
  • Relay has total five (5) pins with different individual functions.
  • Three pins are at one side of the structure.
  • The other two pins are on the opposite side of the structure.
  • All of these pins are provided in the table given in the figure shown below.
  • I have also made a relay pin configuration diagram.
  • Pin configuration diagram is shown in the figure given below.
2. Relay Pins Description
  • Each pin has different functions to perform.
  • So, we must know about each of the function before using it, for the better use of it.
  • All these pin descriptions are listed in the table shown in the figure below.
3. Relay Internal Structure
  • Internal structure of any electronic device leads to the better understanding about its working principle.
  • I have made a completely labeled internal structure of relay along with its pin configurations.
  • Relay internal structure is shown in the figure given below.
4. Relay Pinout
  • If you want to know about the pin configuration of any electronic device you must have a look at its pinout diagram.
  • Pinout diagram helps us to understand the pin configurations in a better way.
  • I have made a pinout diagram which contains relay animation, internal structure and the real image.
  • Relay pinout diagram is given in the figure shown below.

5. Relay Working Principle
  • Relay works on a pretty simple principle.
  • Initially when the power is not supplied and relay is in normally open condition, its contact will be opened.
  • When relay is in normally closed condition, its contact will be closed.
  • When power is supplied to its coil, it gets energized and its normally open condition is changed to normally closed and normally closed condition is changed to normally open.
  • If we want to control the device via relay through a software then we have to attach this device to its normally open terminal.
  • When the relay gets energized, that device will be turned on for the appropriate operation.
  • Working principle of array can be understand from the visuals given in the figure shown below.
  • Initially, when the power is not supplied and you can see the relay has normally closed contact as shown in the figure give below.
  • As I have told earlier, when we supply power the normally closed contact will changed its state to normally open contact and vice versa.
  • The explanation of the above step is given in the figure shown below.
  • From the above figure, you can see contact has been changed to normally open contact.
6. Relay Functions
  • Relay has the three basic functions to perform.
  • All of these three functions are provided in the table given in the figure shown below.
  • Air conditioning control (to limit & control a very high power load) are the examples of on/off control of the relay.
  • Limit control includes motor speed control (to disconnect it if it is moving with slow or faster than the desired speed).
  • Test equipment is an example of logic operation, which connects the device with no. of test points.
7. Types of Relays
  • This section will focus on the major types of relays commonly used these days.
  • There are several different types of relays.
  • The basics types are listed in the table given in the figure shown below.
  • Electromagnetic Relay is made up of magnetic, electrical and mechanical components. It has operating coil and mechanical contacts. When AC or DC supply is provided its mechanical contacts get either open of close. An electromagnetic relay is given in the figure shown below.
  • Solid State Relay consists of solid state components. It is used to perform switching operation without any movement in its parts. Its power gain is higher than the electromagnetic relays because it requires low power as in input and provides high power at the output. Solid state is given in the figure shown below.
  • Hybrid Relay is made up of electronic components and electromagnetic relays. Its input part consists of electronic circuitry which performs rectifications tasks. Its output part consist of electromagnetic relay. Hybrid relay is given in the figure shown below.
  • Thermal Relay works on a very simple principle based on heat effect i.e. the rise in ambient temperature changes one position of the contact to another. Mostly it is used for the motor protection purposes. It consists of temperature sensors and control elements. Thermal relay is given n the figure shown below.
  • Reed Relay has two magnetic strips. These strips are known as reed. These are sealed with a glass tube. The reed acts as blade as well as an armature. When magnetic field is applied to the coil. It wraps around the tube and reed start to move to perform the switching operation. Reed relays are given in the figure shown below.
8. Relay Applications
  • Relay has a wide range of application in real life.
  • Some of the major applications are listed in the table given in the figure shown below.
  • Relay can also be used in relay boards for controlling either DC or stepper motor.
  • One relay can control a single device, since two relay module has two relays so it can control two device simultaneously.
  • Two relay board is given in the figure shown below.
  • TV remote is another example of relay applications.
  • TV remote is given in the figure shown below.
  • Relay can also be used in mobile robots to control their motion properly.
  • Visuals for the above step is given in the figure shown below.
9. Relay Simulation in Proteus
  • I have made relay simulation in Proteus ISIS in order get a better idea about it.
  • As the relay is energized, LED will be turned ON.
  • A simple relay simulation in Proteus is given in the figure shown below.
  • I have also made another relay simulation in Proteus ISIS as shown in the figure below.
  • When the relay gets energized, LED will be turned ON, as shown below.
In the tutorial, Introduction to Relay, I have discussed the basics of relay. This is a fully detailed article the basically focuses on the the basics of relay including its pins configurations, its functions, types, working principle and many other things. I hope you have enjoyed the tutorial and I am sure you will appreciate my efforts. If you have any sort of problem you can freely ask us in comments anytime. Our team is always there to help you and to entertain you. I will also try my level best to answer your questions. I will share further interesting topics in my upcoming tutorials. Till my next tutorial, take care and bye :) strong>

How to use Serial Port in VB 2010

Update: Few bugs were reported by some readers, which I have corrected and updated the code. Now, its fully tested and 100% working.

Hello friends, hope you all are enjoying the start of winter season. By the way, I really hate winter season and I just want to hibernate in this season . :) Well coming to our today's lecture, my today tutorial, serial port in VB 2010, is actually based on a request made by one of the member on my Facebook Page and as it is a really good topic so i thought to share it.

Today we will make a software on Microsoft Visual Basic 2010 in which we will send data through the serial port in VB 2010. In this software we will send the data and also receive it. Simply follow all the given steps carefully and you can easily interface the Serial Port in VB 2010, its a fully working project with code so don't do any mistake. Moreover check these two complete tutorials on Microsoft Visual Studio 2010 as well, these are quite fascinating.

First of all download the Microsoft Visual Basic 2010. The installer can be freely downloaded from Microsoft. After installing the software follow these simple steps. So ,let's get started with How to use Serial Port in VB 2010:

How to use Serial Port in VB 2010 ???

Step 1 : Creating a New Project
  • Open your installed Microsoft Visual Studio 2010 software. The first interface will be something like that :
  •  Now click on the New Project and select Windows Form Applications.
  • In the project name box, add name of your project as I have added Serial Port Interface.
  • Click OK and a new window will be opened as shown in below image which contains a blank Form1.
  • In this Form1 we are gonna add our controls buttons etc.
Step 2 : Changing Name of Form
  • Now click on the form1 and the properties panel will be open on the right side. Now, in the properties tab shown on the right side change its name to frmMain (for easier identification specially when adding more forms).
  • Also change the text of the form to something you like as Serial Terminal. This will be shown on the title bar of your application.
Step 3 : Adding Controls To The Project
  • Lets start to add some controls in our software like buttons,combo box and labels etc.
  • So from the Common Controls tab add two buttons, two combo boxes and two labels into your Form1 and  align them as shown below :
  • For Button 1, change the text to Connect and change the name to btnConnect.
  • For Button 2, change the text to Disconnect and change the name to btnDisconnect.
  • For Combo Box 1, change the name to cmbPort.
  • For Combo Box 2, change the name to cmbBaud.
  • For Label 1, change the text to Comm Port.
  • For Label 2, change the text to Baud Rate.
Note :
  • Keep the names and texts of same character as i wrote them.
  • They are case sensitive so be careful. I will recommend to just copy paste them.
  • If you make even a one letter mistake the code will not run.
  • btn and cmb are just to remind that they are button and combo box respectively. Its better to do neat programming.
Step 4 : Adding Serial Port & Boxes
  •  Now from Container tab, add two Group Boxes in the forum.
  • Change the name of Group Box 1 to Transmit Data.
  • Change the name of Group Box 2 to Received Data.
  • Now add a Text Box and a Button in the Transmit Data Group Box.
  • Change the name of the Button to Send and text to btnSend.
  • Change the name of the Text Box to txtTransmit.
  • Now add a Rich Text Box in the Received Data Box and change its text to rtbReceived.
  • Arrange all these components as shown in the below image :
  •  Lastly and i think its the most important part of this tutorial, add a Serial Port Block into your forum. It will appear at the bottom. Don't change any of its parameters just leave it as it is.
Step 5 : Coding Section
  • Now we come to the coding part of our project. If you double click on your forum, it will open a new window something like that :
  • This is the place where we add our code and in other words add functionality to our project, this window is called Code Editor.
  • If you double click on any button or box, its respective code will created in this region automatically.
  • Now what you need to do is copy the below code and paste it in your code editor window.
  • Just remove all the previous code in your Code Editor Window.
  • Here's the code for Serial Port in VB 2010:
    'Code Starts here ....
    'Import Systems which we are gonna use in our code
    Imports System
    Imports System.ComponentModel
    Imports System.Threading
    Imports System.IO.Ports

    'frmMain is the name of our form ....
    'Here starts our main form code .....
    Public Class frmMain
    Dim myPort As Array
    Delegate Sub SetTextCallback(ByVal [text] As String)

    'Page Load Code Starts Here....
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    myPort = IO.Ports.SerialPort.GetPortNames()
    cmbBaud.Items.Add(9600)
    cmbBaud.Items.Add(19200)
    cmbBaud.Items.Add(38400)
    cmbBaud.Items.Add(57600)
    cmbBaud.Items.Add(115200)
    For i = 0 To UBound(myPort)
    cmbPort.Items.Add(myPort(i))
    Next
    cmbPort.Text = cmbPort.Items.Item(0)
    cmbBaud.Text = cmbBaud.Items.Item(0)
    btnDisconnect.Enabled = False
    End Sub
    'Page Load Code Ends Here ....

    'Connect Button Code Starts Here ....
    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
    SerialPort1.PortName = cmbPort.Text
    SerialPort1.BaudRate = cmbBaud.Text
    SerialPort1.Parity = IO.Ports.Parity.None
    SerialPort1.StopBits = IO.Ports.StopBits.One
    SerialPort1.DataBits = 8
    SerialPort1.Open()
    btnConnect.Enabled = False
    btnDisconnect.Enabled = True
    End Sub
    'Connect Button Code Ends Here ....

    'Disconnect Button Code Starts Here ....
    Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
    SerialPort1.Close()
    btnConnect.Enabled = True
    btnDisconnect.Enabled = False
    End Sub
    'Disconnect Button Code Ends Here ....

    'Send Button Code Starts Here ....
    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
    SerialPort1.Write(txtTransmit.Text)
    End Sub
    'Send Button Code Ends Here ....

    'Serial Port Receiving Code Starts Here ....
    Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    ReceivedText(SerialPort1.ReadExisting())
    End Sub
    'Serial Port Receiving Code Ends Here ....

    'Serial Port Receiving Code(Invoke) Starts Here ....
    Private Sub ReceivedText(ByVal [text] As String)
    If Me.rtbReceived.InvokeRequired Then
    Dim x As New SetTextCallback(AddressOf ReceivedText)
    Me.Invoke(x, New Object() {(text)})
    Else
    Me.rtbReceived.Text &= [text]
    End If
    End Sub
    'Serial Port Receiving Code(Invoke) Ends Here ....

    'Com Port Change Warning Code Starts Here ....
    Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPort.SelectedIndexChanged
    If SerialPort1.IsOpen = False Then
    SerialPort1.PortName = cmbPort.Text
    Else
    MsgBox("Valid only if port is Closed", vbCritical)
    End If
    End Sub
    'Com Port Change Warning Code Ends Here ....

    'Baud Rate Change Warning Code Starts Here ....
    Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBaud.SelectedIndexChanged
    If SerialPort1.IsOpen = False Then
    SerialPort1.BaudRate = cmbBaud.Text
    Else
    MsgBox("Valid only if port is Closed", vbCritical)
    End If
    End Sub
    'Baud Rate Change Warning Code Ends Here ....

    End Class
    'Whole Code Ends Here ....
 
  • After adding the code your Code Editor Window will look something like this one :
Step 6 : Compile Your Project
  • After adding all the code, now you are ready to compile your code and run your application.
  • To compile go to Debug -> Build SerialPortInterface and if everything's going right then your project will pop up.
  •  To test your application, just add some LCD to your serial port or simply short your Rx Tx pins and whatever you send you will receive it.
  • Here's the image of my final application. I have converted it to .exe file, in my coming tutorials i will tell you how to convert a project to .exe file.
Note :
  • The project exe file and the complete code has already been emailed to all our subscribed members.
  • If someone didn't get it or want to get these files then first Subscribe to Our Newsletter and then post your email here and I will email it to them.
So that was all on How to use Serial Port in VB 2010. I hope you guys have enjoyed it and are gonna design it on your own. Take care !!! :)

LED Blinking Project using PIC16F877a

Hello friends , I hope you all are fine and enjoying good health. In today's tutorial, I am going to design an LED Blinking Project using PIC16F877a. In the previous chapters, we have seen all the basics of PIC Microcontroller and now we are ready to design our first project on PIC Microcontroller.

Its a very simple project so the programming level is very basic. We will just add some LEDs on all pins of PortB of PIC16F877a and then we will program it in such a way that these LEDs will blink in different pattern, we can also change the speed of blinking by adding a delay.

I will explain the whole code but if you got any problem may ask in comments.I will recommend you guys to do this project, I know a beginner can't make this project work in first attempt but when you do it, you will make mistakes and will learn a lot. So let's start the LED Blinking Project using PIC16F877a:

LED Blinking Project on PIC Microcontroller

  • You can download the Proteus Simulation and Programming code for LED Blinking Project using PIC16F877a, by clicking the below button:

[dt_default_button link="https://www.theengineeringprojects.com/PICProjects/Led Blinking Project with PIC Microcontroller.rar" button_alignment="default" animation="fadeIn" size="medium" default_btn_bg_color="" bg_hover_color="" text_color="" text_hover_color="" icon="fa fa-chevron-circle-right" icon_align="left"]Download Proteus Simulation & Code[/dt_default_button]

  • Now let's design this project so that you can understand how its done.
  • First of all, design a simulation of LED Blinking Project using PIC16F877a in Proteus as shown in below figure:
Components Used:
These components are used while designing this simulation:
  • PIC16F877a.
  • LED. ( We need 8 LEDs )
  • Resistors. ( We need 2 resistors of 10k ohm )
  • Capacitors. ( We need 2 capacitors of 1nF )
  • Crystal Oscillator. ( 16MHz )
Working Principle:
  • The circuit on the left side of PIC is its basic circuit, we need this circuit in order to power up the PIC and to give it a frequency on which it operates. Like in this diagram, I have used crystal oscillator of 16MHz, which is its frequency of operating. You can operate it at different frequencies e.g. 4MHz ,10MHz , 16MHz, 20MHz etc.
  • But keep this thing in mind that if you change the oscillator then you must change the capacitors as well e.g. for 16MHz the capacitors will be of 33pF.
  • Vdd for PIC is 5V , if you have a 5V battery then its cool but mostly adapters are of 12V. So if you have 12V adapter then use 7805 which converts the 12V into 5V.
  • Now come to the circuit on the right side of the PIC, these are simple LEDs which I have connected with PortB of PIC Microcontroller.
  • On the other side of these LEDs is a resistor just for current control and then a GND (ground).
  • Now when we make any of these pins high then respective LED will turn ON and when we make that pin low, LED will turn OFF.
NOTE :
  • Pin High means its at 5V and LOW means its at 0V.
  • Now let's come to the programming part.Open your MikroC Pro For PIC Compiler and create a new project in it.
  • Make sure that you select PIC16F877a in Device Name and keep the frequency to 16MHz.
  • Watch the video, if you got into any trouble, its attached at the end of this article.
  • Now place the below code in your MikroC Pro for PIC Compiler:
// ************ LED Blinking Project using PIC16F877a
void main() {
trisb= 0x00;

while(1)
{
        portb = 0x00;
        delay_ms(2000);
        portb = 0xFF;
        delay_ms(2000);
}
}
  • Now let me explain the code, it's a very simple code just five to six lines.
  • void main ()  This is the main function of program, the compiler always come straight to this part and leaves the rest it will execute only what is written under its braces.
  • trisb = 0x00; This code will tell the compiler to use the pins as output. If we were using a sensor on any pin then we have to make it 1.
  • while(1) This one runs continuously means pic will execute the code with its braces forever and it never stops.
  • and in the next two lines we make the pin high and then low which is connected to the LED so now the LED will turn ON and then OFF continuously.
  • You can also increase the delay between these lines if you want to increase the duration of ON / OFF.
  • Now Build your project to get the hex file.
  • Upload this hex file in your Proteus Simulation and then run your simulation.
  • If everything goes fine then you will get something as shown in below figure:
  • Looking Pretty, isn't it ? :D
  • Here's the video which will give you better idea of its working:

I have tried my best to explain it in full detail but if still you got any problem or anything left then ask in comments and I will explain it to you. So, that was all about LED Blinking Project using PIC16F877a.

Stay Blessed .... ALLAH HAFIZ :))

XBee Arduino Interfacing

Hello friends , I hope you all are fine and having fun with your lives. Today, I am going to share a new project which is XBee Arduino Interfacing. In my previous tutorials in the XBee series, we have had first Introduction to XBee Module and after that we have also discussed How to Interface XBee Module with Computer. Now we are all well aware of XBee Module and can easily do the XBee Arduino Interfacing. We have seen in the previous tutorial that XBee Module works on Serial protocol so we have to use the Serial Pins of Arduino UNO board.

If you want to use any other microcontroller then you can its not a big issue, just see the way how the programming goes and convert it to the language of your microcontroller i.e. PIC Microcontrollers or 8051 Microcontrollers. If you guys have any question, you may contact me or can ask in the comments. so, let's get started with XBee Arduino Interfacing:

Other XBee Projects:

XBee Arduino Interfacing

  • First of all you need to do is XBee Arduino Interfacing.
  • So, in order to do that you have to connect the Pin # 2 and Pin # 3 of Xbee with the Tx and Rx of Arduino and Pin # 1 to 3.3V of Arduino and Pin # 10 to ground of Arduino as shown in the below figure:
Note :
  • Don't solder the XBee pins directly into the Arduino as it may damage the XBee.
  • You can buy the XBee Shield for Arduino.
  • After that attach your XBees with the two Arduino Boards and use the below code:
int b1 = 2;
int b2 = A3;int mode1 = A4;
int mode2 = A5;void setup()
{
Serial.begin(9600);
delay(100);
pinMode(b1,OUTPUT);digitalWrite(b1, LOW);

pinMode(b2,INPUT_PULLUP);
pinMode(mode1,INPUT_PULLUP);
pinMode(mode2,INPUT_PULLUP);

}

void loop()
{
if (Serial.available() > 0)
{
delay(500);
Serial.print("+++"); delay(1000);
Serial.print("rnATDL1"); delay(100);
Serial.print("rnATCN"); delay(100);
Serial.print("A");
}

}
  • Now add this code in one of your Arduino Board and a simple serial receiving code on the second arduino.
  • Now whenever you press the button you will get A on the second arduino board.
  • You can change it with anything you like and on the second side you can do anything by adding a condition.

That's all for today. I hope you have enjoyed this tutorial XBee Arduino Interfacing. I will share more projects on XBee Arduino Interfacing soon. If you are getting any problem you can ask in comments. Thanks. ALLAH HAFIZ :))

Interfacing of XBee with Computer

Hello friends, I hope you all are fine and having fun with your lives. In today's tutorial, I am going to show you the Interfacing of XBee with Computer. In the previous part of this tutorial, I have given the Introduction to XBee Module. Hope you guys have read it and if not then go visit it so that you may have some idea about XBee module.

Now come to the second part about how to interface xbee with computer because its important as if you cant interface the xbee with computer then you cant interface it with any microcontroller and later I will tell you its interfacing with microcontroller. You should also check this XBee Library for Proteus which will help you to simulate XBee module in Proteus.

We will cover arduino with more detail as its the most usable microcontroller these days with XBee. In this tutorial, I will remain to the basics of XBee i.e. we will just simple send data from one xbee to another but in coming tutorials we will have a look on quite difficult projects i.e. plotting of nodes using Rssi value. I have also posted a tutorial on Interfacing of XBee Module with Arduino. If you guys have any question, you may contact me or can ask in the comments. So, let's get started with Interfacing of XBee with Computer:

Interfacing of XBee with Computer

  • XBee works on the TX / RX logic so if we want to interface xbee with computer, we need to use a serial module.
  • There are two type of module, one is usb module available at sparkfun and its costly for the students of Pakistan.
  • So we have created our own module, its based on serial port and works is a similar way as this sparkfun module.
  • This serial module consists of MAX232 and here's its circuit diagram.
  • You just need to do is, the pins going to the uC are now go to the pin # 2 and pin # 3 of XBee.
  • Moreover, +3.3 V to the pin # 1 of XBee and Ground to the pin # 10 of XBee.
  • One more thing , dont forget to common the grounds of XBee and this circuit.

Software to Download

  • There is a software named X-Ctu, is used for Interfacing of XBee with Computer.
  • So first of all, download X-Ctu and install it in your computer.
  • Attach your module's serial port with the computer after placing the XBee in it.
  • Open the software, the first interface of this software is shown in the image below :
  • The White Box in which there is written USB Serial Port (COM 9) indicates the serial ports attached to your computer.
  • In my case it is COM 9 and in your case it will be mostly COM 1.
  • Now Click on the Test / Query button and if everything's going fine then the following window will pop up.
  •  This prompt box tell us a few things about XBee.
  • In case if something's missing and not working properly then you will get something like that :

Configuring the XBee

  • There are a lot of AT commands used for the configuring XBee. I will tell you where to enter these commands but first lets have a view at these commands.
  • Here I am explaining those which we are going to use for the simplest communication.
  • + + +  : This command will initiate the command mode and now our xbee is ready for taking orders and in this mode it wont transmit data.
  • ATMY2 : ATMY is used to set the address of xbee we are using and 2 is the address we have set for our module.
  • ATDL5 : ATDL is used to set the address of the destination module and 5 is the address. In other words now our module 2 only send data to that module which has address 5 .
  • ATWR : This command is used to write these configurations into XBee . If you don't use these commands then once you removed your xbee your values will be erased.
  • ATCN : To terminate the command mode and after that you are ready to send data.
NOTE :
  • ATDL of tranmitter = ATMY of reciever
  • Suppose I have two modules so in order them to communicate I will set the first module as ATMY = 2 and ATDL = 5 and the second module as ATMY = 5 and ATDL = 2. Now both the modules can send data to each other.But if I change the second module's ATDL = 3 then my second module can't send the data to first but still my first module can send data to the second. ( a bit complicated :) )
  • Only this +++ command doesn't require ENTER but in all other press the ENTER tab after entering command.

Where to Enter These Commands

  • Now the most common question is where to enter these commands.
  • Let's come back to X-Ctu,Now click the Terminal tab on top of the software as shown below :
  •  Now Enter the Commands one by one as shown in the image below :
  • In the above figure, I have set my first xbee as ATMY = 1111 and ATDL = 2222.
  • Now remove the first XBee and attach the second XBee , restart the software and do the same steps as for first but now the settings will be as follows :
  • In the above figure, I have set my first xbee as ATMY = 2222 and ATDL = 1111.
  • Check the difference in addressing of both XBees.
  • Your both XBees are configured.

Communication Between XBees

  •  Now attach first XBee to one computer using the module and the second to other computer using another module.
  • Open the software and click the terminal tab.
  • Now whatever you enter in the terminal tab of first xbee , it will be receiving on the terminal tab of second and vice versa.
  • So, that's all about Interfacing of XBee with Computer.

That's all for today and I am a bit tired too while writing this tutorial on Interfacing of XBee with Computer, so I will continue it tomorrow regarding the microcontroller part. One more thing play with the software and do let me know what you find in the comments. Thanks. ALLAH HAFIZ :))

Introduction to XBee Module

In this tutorial, we are gonna hanve an Introduction to XBee Module. XBee is an RF module and these days its using in lots of student projects and I am getting a lot of queries reagarding this module. So first we will cover the introduction of XBee in this post. Soon I will tell you about Interfacing of XBee Module with Computer and also after this discussion we will also discuss Interfacing of XBee Module with Arduino. You can also Interface it with other Microcontrollers like PIC Microcontroller or 8051 Microcontroller.

We will cover arduino with more detail as its quite famous and easily accessible microcontroller these days. In this tutorial I am gonna add just simple interfacing of XBee module with arduino but soon I will post few quite difficult project on XBee like mesh networking. If you guys have any question, you may contact me or can ask in the comments. So, let's get Started with Introduction to XBee Module:

What is XBee ?

  • XBee is a very complicated module used for RF communication. It is used for wireless communication.
  • It is used these days in many projects as it is very easy to use and its advantages are more than any other RF module.
  • You can use XBee for point to point communication also.
  • There are two commonly used versions of XBee, one is XBee series 01 and other is XBee pro.
  • The only difference between the two is in their range.XBee pro has more range to operate than the simple XBee.
  • Its hardly available in Pakistan so if you want to buy XBee Series 01 in Pakistan then use our Contact Form. You will get it within 2 days.
  • Download the datasheet of XBee and must read it as reading datasheet is always beneficial.

How to operate XBee ?

  • To operate XBee, you will need two XBees, one will act as a transmitter and the other will act as a receiver.
  • Now suppose you want to send something from one side to another, now you have to connect one xbee at the transmitter side and the other at the reciever side.
  • Let's take an example of home automation project in which you are using a remote to switch on your light or fan etc.
  • So in that case there must be one XBee in your remote and the second one in your board where the light circuit is placed.
  • So when you press the button of remote, the XBee in remote will send an instruction to the XBee in the board.
  • As soon as the XBee in the board recieve the instruction from XBee in the remote it will on the light.
  • Obviously there will be microcontrollers attached with both the xbees and you need hell of a programming to do this operation but I was just explaining the procedure.
So, that's all about Introduction to XBee Module, I hope you have enjoyed this Introduction to XBee Module and are gonna use it in your projects. Thanks for reading and have fun !!! :)
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