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);
  }
 }
}

Saturday, December 26, 2015

PIC MICROCONTROLLER based traffic light control

Hi friends today we make a traffic light control based on PIC 12F675.to make this project we need electronic components given blow.

ELECTRONIC COMPONENTS

1. PIC 12F675 microcontroller 
2. power supply 5V
3.3 Resistance (100 - 1K ohm)
4.3 LEDs (Red,Yallow and Green)
PIC 12F675 based traffic light control circuit diagram

microc code for project

" void main()
{
TRISIO = 0x00;          // pins select as o/p

 while(1)               // infinit loop
 {
 GPIO.F0 = 1;           // active RED LED
 delay_ms(5000);        //for 5sec.
 GPIO.F1 = 1;           // active YELLOW LED
 delay_ms(2000);        //for 2sec.
 GPIO.F2 = 1;           // active GREEN LED
 delay_ms(5000);        //for 5sec.
 }
} "

by using this code the red led active for 5sec. and yellow led for 2sec and green led for 5sec.

Saturday, December 12, 2015

7805 Regulator Based power supply

HI Friends,Now We make a power supply for PIC microcontrollers using 7805 regulator.for making power supply we need some components given blow.




                    1.General purpose PCB.
                    2.Transformer (center tap) 12-0-12.
                    3.2 Diode 1N4007.
                    4.Regulator 7805.
                    5.Capacitor (220uF ,0 . 01 uF )
CIRCUIT DIAGRAM OF POWER SUPPLY

working:- 
The Transformer and rectifier circuit give output 12V DC and than the regulator 7805 ( i/p 7-24V, o/p is 5V) give output 5V. now we can use this circuit as power supply for micontroller.