Application experiment of analog-to-digital conversion DAC0832

Publisher:eta17Latest update time:2012-11-03 Source: 21IC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

[ Experimental task ]
Use two buttons to control the output of DAC0832 through the microcontroller, so that the OUT terminal can output two waveforms, sawtooth wave and triangle wave, with an amplitude of 0-5V and a frequency of 1KHZ. After the power is turned on; press INT1 to output a triangle wave, and press INT0 to output a sawtooth wave.

[ Experimental principle ]
ADC0804 is an 8-bit full MOS medium-speed D/A converter, using R-2RT resistor decoding network, the conversion result is a pair of differential current output, the conversion time is about 1us. Use a single power supply +5V-+15V. The reference voltage is -10V-+10V. Here we directly choose +5V as the reference voltage. DAC0832 has three working modes: direct mode, single buffer mode, double buffer mode; here we choose the direct mode, connect all XFER WR 1WR2 CS pins to digital ground. Pin 8 is connected to the reference voltage, and the reference voltage we connect here is +5V. Then after the first stage op amp, the output voltage will be -5V-0V, and after the second stage op amp inverts and amplifies 1 times, it can output 0V-5V. When we control the regular changes of the output data of P1 port, we can generate waveforms such as triangle wave, sawtooth wave, ladder wave, etc.

[ C language source program ]
#include
unsigned char keycnt=0;
unsigned char tcnt=0; //Key value judgment
bit sjz=0; //Flag used when generating triangle wave
void delayl() //Delay subroutine
{ unsigned char i,j;
for(i=20;i>0;i--)
for(j=248;j>0;j--); }
void KEY() //Key scanning program
{
if(P3_2==0)
{
delayl(); //Delay skips the jitter when pressing
if(P3_2==0)
{
keycnt=0; //Timer generates sawtooth wave flag
TR0=0; //Temporarily stop waveform output
TH0=0x256-40; //Assign TH0 TL0 to
TL0 TL0=0x256-40;
TR0=1; //Start timing and generate sawtooth wave
while(P3_2==0); //If the key is pressed all the time, wait for the key to be released to open
delayl(); //Delay to skip the jitter after releasing
} }
if(P3_3==0)
{
delayl(); //Delay to skip the jitter when pressing
if(P3_3==0)
{
keycnt=1; //Timer generates triangle wave flag
TR0=0; //Temporarily stop waveform output
TH0=0x256-40; //Assign TH0 TL0 value
TL0=0x256-40;
TR0=1; //Start timing to generate triangle wave
}
while(P3_2==0); //If the key is pressed all the time, wait for the key to be released to open
delayl(); //Delay to skip the jitter after releasing
}
} //Please pay attention to the format specification when writing the program, this is to save paper
void t0(void) interrupt 1 using 0 //Timer interrupt service function
{
if(keycnt==0) //Generate sawtooth wave
{
P0=tcnt;
tcnt=+0x0a; //Step 0.2V/one interruptif
(tcnt==0xfb)
{tcnt=0;}
}
if(keycnt==1) //Generate triangle wave
{ if(sjz==0)
{P0=tcnt;
tcnt=+0x0a;//Step 0.2V/one interruptif
(tcnt==0xfa)
{sjz=1;}
}
if(sjz==1)
{
P0=tcnt;
tcnt=-0x0a;
if(tcnt==0)
{sjz=0;}
}
}
}
void main(void)
{
TMOD=0x02; //Timer works in mode 2
ET0=1;
EA=1;
while(1)
{ KEY(); }
}

[Hardware Circuit Diagram]


Reference address:Application experiment of analog-to-digital conversion DAC0832

Previous article:I2C read and write operation experiment based on single chip microcomputer
Next article:Application experiment of analog-to-digital conversion DAC0832

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号