Friday, November 4, 2016

Bluetooth HC-05 Interfacing With Microcontroller

HC-05 is a Bluetooth module that is mostly use in Embedded Electronics for the purpose of transfer serial data wirelessly to a Android, Laptop and also Microcontroller to Microcontroller. So we can say Bluetooth is a wireless replacement of Serial Communication. HC-05 Module (fig. 1) have 6-pin. 




Front View of HC-05

Back View of HC-05
fig. 1


Pin Description:
        1. State  - State pin is high if device is connected to another device  
        2. RxD  - Receiver Pin of Bluetooth (max 3.3V)
        3. TxD  - Transmitter pin of Bluetooth
        4. GND - Ground Supply
        5. Vcc   - +5V Supply
        6. EN    - This pin is use to change mode(AT Command, Communication                       mode)
Note.  Basically HC-05 work at 3.3 V  but there is no problem to use this module at 5V. But the Tx &            Rx pin are at 3.3V level. so DON'T CONNECT Tx Rx pin Directly to Microcontroller Drive at 5V. So use a voltage divider to convert 5V in to 3.3V level. (fig.2)

Fig.2 Voltage Divider Circuit use to convert Voltage level
   
here we can also use resistance of same value. 


Communication Mode:-  Communication using HC-05 is very easy. connect HC-05 with MCU as shown in fig.3. Bluetooth is turn on then check bluetooth device in your Laptop/ Android. then pair this bluetooth with Laptop/ Android. if u use android download "Blue Term " android application from google play. open this bluetooth in application. than send "Hello World" from Microcontroller serial. and u receive in your in application. 




fig.3 connection

 
                                                         

Wednesday, September 28, 2016

Speed Control of DC motor using Microcontroller and motor driver L293

Using Microcontroller we can easily control or interface a DC motor with direction control. but if we wants to control the speed of a DC motor. in DC we are use PWM technique to control average power delivered to load. so also here we use PWM technique to control speed o a DC motor. in motor driver L293 first & ninth pin are enable pin.
L293D pin diagram

       the first pin EN1 is use to enable IN1 & IN2 pin to get input and same as EN2 is use to enable IN3 & IN4 pin. if we simple drive a DC motor we connect these both pin to +5V applied at 16th pin
of L293.but to control speed of DC motor we are connect these both pin to PWM pins of Microcontroller.then we can simple control the speed of DC motor by control the Duty cycle.

Saturday, September 10, 2016

IR Module

IR Module is a module which is use to detect obstacle.An IR module uses a comprator. which is use to compare the output of photodiode with output of preset. when output of photo diode is greater than the voltage applied at non-inverting pin of comparator, the output of comparator is goes to high. but if output of photo diode is not exceed the output of preset then the output of comparator is zero volt.




Circuit of IR Module
The output of photo diode is changes with change in intensity of incoming ir Light coming from IR LED. ir light is reached at photo diode after reflection by object placed in front of ir module.
so we can change range of ir module by change in voltage applied at non-inverting pin.

Saturday, September 3, 2016

Speed Control of Stepper Motor using PIC microcontroller

To control the speed of unipolar stepper motor we use a Microcontroller to control the activation and also control activation time. ULN2003 is used as current amplifier. Preset use to control speed of motor


Circuit to speed control of stepper motor


connection of stepper motor
connection of stepper motor to control circuit



1 - coil 1
2 - coil 2
3 - coil 3
4 - coil 4
&
5 - CMN

CODE:-

unsigned short i,k;                            // Globle variable initialisation

void delay(unsigned short j)                                   // Delay function
{
 for(i=0;i<=j;i++)                        // For loop to generate multiple delay
 {
  delay_ms(1);                                                      // delay 1ms
 }
}

void main()                                                     // Main function
{
 ANSEL = 0x00;                                      // Analog selection register
 TRISA = 0x07;                                // Input/output selection register
 TRISC = 0x00;                                // Input/output selection register
 PORTC = 0x00;                                  // Default PORTC all output zero

 a = 0;                                                        // bit a is clear

 ADC_Init();                                                   // initialise ADC

 while(1)                                                            // Inf loop
 {
  k = 20 - ADC_Read(0)/60;   // Formula to generat delay by read ADC at analog 0

  PORTC=0x01;                       //
  delay(k);                         //
  PORTC=0x04;                       //
  Delay(k);                         // 
  PORTC=0x02;                       //
  Delay(k);                         //
  PORTC=0x08;                       //
  Delay(k);                         //
 }
}

Tuesday, August 30, 2016

Analog to Digital convertor parameters

In Microcontroller we need to interface a sensor which gives analog output. So we need to use ADC of Microcontroller. before use ADC we have to learn some basic parameter of ADC. some parameter are given below.

1. ADC is 10 bit, 8 bit or other:- or n bit ADC here n decided the total number of quantization level.

                                 total no. of quantization level  = 2n level
Now if an ADC of 10 bit than n=10 than
                                      total no. of quantization level = 210
                                                                                   = 1023
2. -Vref and +Vref voltage:- -ve and +ve reference voltage define the range of analog signal or analog voltage applied at analog pin of MCU.
If we take 0 volt as -Vref and 5 volt as +Vref
                                                             than the range is (5 - 0 = 5)volts

the range of this signal of range 5V

                       if 10 bit ADC then          no. of slice of 5V is 1023
                       if  8 bit ADC then           no. of  slice of  5V is 511
                       and same this with other

Sunday, July 31, 2016

Zero Crossing Detector Circuit Using a Transistor

Zero Crossing Detector Circuit use for check or detect zero cross of AC Power. This circuit is useful
where we need to make a AC Power Controller or Dimmer to control the speed of an AC Moter or Control the Intensity of an electric Bulb etc. with the help of TRIAC (Ex. BT136) than circuit is very useful. Here the circuit of Zero Crossing Detector


Zero Crossing Detector Circuit
Working - In this circuit first we use an resistance of 220K ohm for reduce the voltage level
than rectify this voltage u can use 1N4007 for bridge. We get a rectified pulsating DC out(shown in
fig. 2).
Filter it for supply +ve supply for transistor for pull up the collector of transistor with 10K ohm
than apply this pulsating DC to the base of transistor with 10K ohm. if the voltage at base is less
than base emitter voltage the transistor is in cutoff mode than output is come from 10K ohm pull
up is grater than 5v. so we use an 5v zener diode only for purpose of security of MCU.
but if voltage is greater than base emitter voltage of the transistor the transistor is in saturation mode
and the voltage at collector is zero.


OUTPUT - Output of this circuit is shown in fig.3. U can see that the output is high only
                            when the rectified out is near or less than Veb volts.

Wednesday, February 3, 2016

PUSH BUTTON INTERFACING WITH MICROCONTROLLER

Hi Friend's Today we interface a push button with PIC microcontroller 16F886 .




Circuit Diagram of Push Button with Microcontroller

In this circuit we connect a PUSH BUTTON at PORTA.F0 and we connect a LED at RORTB.F0 for indication. in this circuit we connect a 10K Ohm Resistance with PUSH BUTTON for PULL DOWN the Floating input of Microcontroller. 

CODE of mikroC for PIC

PROGRAM 1:-

void main()
{
 ANSEL = 0x00;                                          // all input are Digital
 TRISA.F0 = 1;                                     //make PORTA 0th bit as input
 TRISB.F0 = 0;                                    //make PORTB 0th bit as output

 while(1)                                                        // infinit loop
 {
  if(PORTA.F0 == 1)                                          //chack Push button
  {
   PORTB.F0 = 1;                                        //if pressed than on LED
   Delay_ms(10);                         //delay of 10 ms to stabilize the output
  }
  else
  {
   PORTB.F0 = 0;                               //if not pressed than off the LED
   Delay_ms(10);                         //delay of 10 ms to stablise the output
  }
 }
}

OUTPUT
In this code if we press the PUSH BUTTON than the LED connect at portb.f0 is on but if we realise
the PUSH BUTTON than the led is off.

PROGRAM 2:-

bit LED_STATUS;                            // define bit variable LED_STATUS

sbit LED at RB0_bit;                                      // LED at PORTB.F0

void main()

 ANSEL = 0x00;                             // confingure ansel as digital i/p
 ANSELH = 0x00;                           // confingure anselh as digital i/p
 TRISA = 0x01;                                // SELECT PORTA.F0 bit as input
 TRISB = 0x00;                               // select PORTB.F0 bit as output

 LED_STATUS = 1;                                          // initially LED ON

 while(1)                                                         // inf loop
 {
  if(PORTA.F0 == 1)                                // check input high or not
  {
   LED_STATUS = ~LED_STATUS;                         // invert LED_STATUS bit
   Delay_ms(200);                           // delay of 200ms to stablise i/p
  }
  LED = LED_STATUS;                               // LED output is LED_STATUS
 }
}

output:- Output of this program is initially LED on than we need press Button only one time than LED continues ON or OFF. We press Button again and again to ON or OFF LED. 


Note:- We need to use Pull Down or Pull up Resistance All time. 

Tuesday, January 19, 2016

Running LED for Lighting using Microcontroller 16F886

Hi Friends, Now we make a Project to blink LED in alternate sequence. In this project the LED blink one by one at PORTB of Microcontroller 16F886. to make this project make circuit given blow.





use all resistance (100-1K) ohm.

PROGRAM CODE in C

unsigned short a,b,x,y,k;                                 //variable initilation
void main()
{
 TRISB=0x00;                                              //make portb as output
 PORTB=0X00;                                                  //clear all output

 while(1)                                                             //inf loop
 {
  for(a=1,b=8;a<=8,b>=1;a=a*2,b=b/2)              //for loop of two variable a,b
  {
   x = a;                                                         //store a in x
   y = b;                                                         //store b in y
   k = x << 4;                                  //mask 4 bit of x and store in k
   k = k | y;                 //applying logic "or" in k,y and store result in k
   PORTB = k;                                           // k as output at port b
   delay_ms(300);                                              //delay of 300 ms
  }
 }
}

OUTPUT of this PROJECT





        ......

An another code for an different lighting

unsigned int i,j;

void main()
{
 TRISB = 0;

 while(1)
 {
  for(i=1;i<=256;i=i*2)
  {
   j = i-1;
   PORTB = j;
   Delay_ms(10);
  }
  for(i=1;i<=256;i=i*2)
  {
   j = 256-i;
   PORTB = j;
   Delay_ms(10);
  }
  for(i=256;i>0;i=i/2)
  {
   j = 256-i;
   PORTB = j;
   Delay_ms(10);
  }
  for(i=256;i>0;i=i/2)
  {
   j = i-1;
   PORTB = j;
   Delay_ms(10);
  }
 }
}