Variable Frequency Generator using lpc1768

Published Oct 02, 2018
 3 hours to build
 Beginner

Variable frequency generator generates different waves like sine, square, triangular, sawtooth waves of different frequencies.

display image

Components Used

Potentiometer 10Kohms
Potentiometers 10Kohms 10% 12.5mm Cermet Element
1
Tactile Switches
Tactile Switches 12 x 12 mm 12 mm 100 gf Short Crimped Black Through Hole SPST
4
Breadboard
Breadboard
1
ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
DSO (digital storage oscilloscope)
Benchtop Oscilloscopes 350 MHz 4Ch. with US Power Cord
1
Description

Introduction

   Variable frequency generator generates different waves like sine, square, triangular, saw-tooth. Also we can change the frequency of these waves by variable resistor. Four switches are provided for selecting wave. 

Circuit Diagram

 

Project Working

  • Four switches are given to select the wave
  • When button is pressed particular wave pattern is select given to that switch.
  • Variable pot is provided to change frequency
  • Inbuilt ADC is used to read the values of variable pot. To know more about ADC 
  • Inbuilt DAC is used to generate different wave-forms.To know more about DAC

       Sine wave:

  • When a1=1 sine wave is selected. We get value of potentiometer in range of 0 to 1, so convert it from 0 to 100 multiply it by 100.
  • Put this value of 'A' in sine function to get different frequencies.
while(a1==1)    //For generating sine wave 
  { 
   A=Ain*100; 
   for (n=0;n<A;n++) 
   { 
      Aout= 0.5 + 0.5*sin(n*2*pi/A);   //note the 0.5 V of offset since DAC outputs voltage between 0 and 3.3V 
   } 
        
   }

 

       Square wave:

  • When a2 is '1' square wave is selected. To get different delay Ain is divided by 10 so we get delay in range of 0 to 0.1 Sec.
while(a2==1)        //for generating square wave 
 { 
  Aout=0X00; 
  wait(Ain/10); 
   
  Aout=0XFF; 
  wait(Ain/10); 
   
 }

 

       

Triangular wave:

  • We get value of potentiometer in range of 0 to 1, so convert it from 0 to 100 multiply Ain by 100 and get A.
  • Divide i by A so that we get Aout in range of 0 to 1.
while(a3==1)            //for generating trianguler wave 
 { 
  A=Ain*100.00; 
  for (i = 0.00; i < A; i++) 
       { 
           Aout = (float)i /A; 
           wait(0.0001); 
       } 
   for (i = A-1.00; i > 0.00; i--) 
       { 
           Aout = (float)i / A; 
           wait(0.0001); 
       } 
 }

 

       Saw-tooth wave:

  • Divide i by (Ain*100) to get Aout in range of 0 to 1.
while(a4==1)            //for generating saw-tooth wave 
 { 
   
  for (i = 0.00; i < (Ain*100); i++) 
 { 
           Aout = (float)i / (Ain*100); 
 } 
 }

 

Video

Codes
Comments
Ad