Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Experiment -3

Name of the Experiment: Producing simple waveforms


using a microcontroller (effectively making a simple
function generator)

Submitted By:
Nikhil Kumar Agrawal(2015MT60562)
Ajay Yadav(2015MT60551)
Aim
Creating a simple function generator using UART and PWM to
show different waveforms on LCD matrix keeping a constant time
scale.
Apparatus
• Arduino Board
• GLCD
• Bread Board
• Connecting wires
• Push button
• Op-amp 741
• Potentiometer

Challenges faced:
• We faced challenge in installing the GLCD library as this was
the first time we got to use Arduino board
• We got the error stk500_getsync() several times which occurs
when we upload the code while Arduino is connected to
GLCD.
• Wiring the GLCD with Arduino board was a difficult task.
Block Diagram:

Flow chart:
Circuit Diagrams:

Square wave generated on a screen. Look for appendix A1 for it’s code.

Above picture is of Sine waveform generated by using the code A3


Triangular wave generated on a screen. Look for appendix A2 for it’s code.

Observation and Conclusion:


Using the GLCD library we can easily access the inbuilt codes for LCD
manpulation. Functional generator is most widely used hardware in labs
and we can also make it using an Arduino.

Appendix:
A1. Code for Square Wave
#include <openGLCD.h>
#include <math.h>
int i=0;
int j=1;
int amp =15;
void setup()
{
// Initialize the GLCD
GLCD.Init();
}
void loop()
{
if(i>=127){
i=0;
j=1;
}
GLCD.SetDot(i,32+amp*j,BLACK);
i = i+1;
if(i%amp == 0){
j=-j;
for(int k =32-amp;k<=32+amp;k++){
GLCD.SetDot(i,k,BLACK);
}
}
}

A2. Code for Triangular Wave


#include <openGLCD.h>
#include <math.h>
int i=0, x=0,y=0;
int j=1;
int amp =15;
void setup()
{
// Initialize the GLCD
GLCD.Init();

void loop()
{
if(x>=127){
x=0;
j=1;
}
y = abs((x++ % 30)-15);
GLCD.SetDot(x,22+y,BLACK);
}

A3. Code for Sine Wave


#include <openGLCD.h>
#include <math.h>
int i=0;
void setup()
{
// Initialize the GLCD
GLCD.Init();

void loop()
{
if(i>=127){
i=0;
}
GLCD.SetDot(i,32+10*sin(60*i/3.14),BLACK);
i = i+1;
}

You might also like