Tuesday 12 June 2012

SQUARE WAVE GENERATOR EMBEDDED C


                                        SQUARE WAVE GENERATOR                      

  
     One requirement in a wide range of applications is a spontaneous source of some continuous signal, having a regular and definable wave shape. One of the most important of these is a square wave.
     The circuit to the right uses a comparator with both positive and negative feedback to control its output voltage. Because the negative feedback path uses a capacitor while the positive feedback path does not, however, there is a time delay before the comparator is triggered to change state. As a result, the circuit oscillates, or keeps changing state back and forth at a predictable rate.


CIRCUIT SCHEMATIC & OUTPUT:


 LOGIC ANALYSER OUTPUT:

 SOURCE CODE:

#include<regx51.h>
sfr out1=0x90;
sfr out2=0xa0;
sfr out3=0xb0;
unsigned int i;

void main()
{
out1=out2=out3=0x00;
while(1)
  {
    out1=out2=out3=0xaa;
    for(i=0;i<25000;i++);
    out1=out2-out3=0x55;
    for(i=0;i<25000;i++);
  }
}














0 comments:

Post a Comment

Search Here...