3.幅度可调,峰峰值在0——5V之间变化。
当然还是存在不足的地方,比如不能实现频率的按一个小的步进调整。并且当频率太小时矩形波会有些失真。
信号发生器可以生成更多的波形,只需要再加些波形表即可。
在这里得感谢学校为我们提供个这样一个实践的机会,当然还得感谢实验室指导老师们的细心指导。
参考文献:
[1] 郭天翔.新概念51单片机C语言教程 入门、提高、开发、拓展全.北京.电子工业出版
社 2009.1
[2] 童诗白.模拟电路技术基础[M].北京:高等教育出版社,2000.171~202.
附录
1:总电路图
11
12
附录2:源程序
#include
#define uchar unsigned char #define uint unsigned int
sbit csda=P2^2; sbit wr=P2^1; sbit s1=P3^2; sbit s2=P3^3;
uchar k=0,p=0,delay=0; uchar bxxz=0;pinglv=0; uchar a=1,b=0,c=0,d=0,e=0;
uchar code sin[64]={
135,145,158,167,176,188,199,209,218,226,234,240,245,249,252,254,254,253,251,247,243,237,230,222,213,204,193,182,170,158,
146,133,121,108,96,84,72,61,50,41,32,24,17,11,7,3,1,0,0,2,5,9,14,20,28,36,45,55,66,78,90,102,114,128 };
uchar code juxing[64]={
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
uchar code juchi[64]={
0,4,8,12,16,20,24,28,32,36,40,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,130,134,138,142,
146,150,154,158,162,166,170,174,178,182,186,190,194,198,202,206,210,215,219,223,227,231,235,239,243,247,251,255 };
uchar code tixing[64]={
0,13,26,39,52,65,78,91,104,117,130,143,156,169,182,195,208,221,234,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
247,247,247,247,247,247,247,242,229,216,203,190,177,164,151,138,125,112,99,86,73,60,47,34,21,8 };
uchar code sanjiao[64]={
0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,
248,240,232,224,216,208,200,192,184,176,168,160,152,144,136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,0 };
void delay1()
13
{ int a,b;
for(a=1;a>0;a--) for(b=122;b>0;b--);
} void int0() interrupt 0
{ EX0=0; delay1(); if(s1==0){
bxxz++; if(bxxz==5) bxxz=0; switch(bxxz) {
case 0 :
{a=1,b=0,c=0,d=0,e=0;} break; case 1 : {a=0,b=1,c=0,d=0,e=0;}
break;
case 2 : {a=1,b=0,c=1,d=0,e=0;} break; case 3 : {a=0,b=0,c=0,d=1,e=0;}
break;
case 4 : {a=0,b=0,c=0,d=0,e=1;}
break;
} delay1(); while(!s1);
} while(!s1); EX0=1;
}
void int1() interrupt 2 { EX1=0; delay1(); if(s2==0){
p++;
if(p==8)
14
p=0;
switch(p) { case 1 : pinglv=3; break; case 2 :
pinglv=6; break; case 3 :
pinglv=9;
break; case 4 : pinglv=12; break; case 5 : pinglv=15; break; case 6 : pinglv=18;
break;
case 7 : pinglv=21; break;
default : pinglv=0;
break;
}
delay1();
while(!s2);
} while(!s2);
EX1=1;
}
void main() { csda=0; wr=0; EA=1; IT0=1; EX0=1; IT1=1; EX1=1;
while(1)
15