0% found this document useful (0 votes)
67 views3 pages

Setup Development Environment:: DAC AIM

Uploaded by

Jaishree M ECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views3 pages

Setup Development Environment:: DAC AIM

Uploaded by

Jaishree M ECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DAC

AIM
To generate the continuous sinusoidal waveform, square waveform and Triangular waveform
using the DAC (Digital-to-Analog Converter) of the LPC2148 microcontroller and visualize the output
using Proteus software.
Apparatus Required
Keil µversion4
Proteus software
Procedure

 Setup Development Environment:

 Create a new project in Keil for the LPC2148 microcontroller.

 Create and Configure Project:

 Add the LPC213x.h header file and include the math library.
 Set the target device to LPC2148 in your project settings.

 Write the Code:

 Use the provided code snippet.

 Simulate in Proteus:

 Open Proteus and create a new project.


 Add the LPC2148 microcontroller from the component library.
 Add a DAC component and connect it to the appropriate pin of the LPC2148 (usually pin
Pin 9 – P0.25).
 Connect an oscilloscope to the output of the DAC to visualize the waveform.

 Compile and Upload:

 Compile the code in Keil to generate the hex file.


 Import the hex file into Proteus by setting the appropriate property for the LPC2148 in
the simulation.

 Run the Simulation:

 Start the simulation in Proteus.


 Observe the output waveform on the oscilloscope.
Program
Sine waveform generation
#include<lpc213x.h>
#include"math.h"
unsigned int t;
void Delay(unsigned long b){
while (--b!=0);
}

int main(){
int value=0x3ff;
PINSEL1 = 0X00080000;

while(1){
value = 512+400*sin(t*0.01745);
DACR = value<<6;
if(++t==360)t=0;
}
}

Output

Square waveform Generation


#include<lpc213x.h>
#include"math.h"
unsigned int t;
void Delay(unsigned long b){
while (--b!=0);
}

int main(){
int value = 0x3ff;
PINSEL1 = 0X00080000;

while(1){
if (t < 180) {
value = 512 + 400;
} else {
value = 512 - 400;
}
DACR = value << 6;
if (++t == 360) t = 0;
}
}

Output

Triangular waveform generation


#include <lpc213x.h>
#include "math.h"
unsigned int t;
void Delay(unsigned long b) {
while (--b != 0);
}
int main() {
int value;
PINSEL1 = 0X00080000;
while (1) {
if (t < 180) {
value = (t * 400) / 180;
} else {
value = 400 - ((t - 180) * 400) / 180;
}

value += 512;
DACR = value << 6;
if (++t == 360) t = 0;
}
}
Output

Result
Thus the continuous sinusoidal waveform, square waveform and Triangular waveform using the
DAC (Digital-to-Analog Converter) of the LPC2148 microcontroller was simulated and visualized the
output using Proteus software.

You might also like