小猪毕业设计图.docx

上传人:b****7 文档编号:10268025 上传时间:2023-02-09 格式:DOCX 页数:22 大小:5.42MB
下载 相关 举报
小猪毕业设计图.docx_第1页
第1页 / 共22页
小猪毕业设计图.docx_第2页
第2页 / 共22页
小猪毕业设计图.docx_第3页
第3页 / 共22页
小猪毕业设计图.docx_第4页
第4页 / 共22页
小猪毕业设计图.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

小猪毕业设计图.docx

《小猪毕业设计图.docx》由会员分享,可在线阅读,更多相关《小猪毕业设计图.docx(22页珍藏版)》请在冰豆网上搜索。

小猪毕业设计图.docx

小猪毕业设计图

仿真图

仿真运行状态图

辅助电源模块

12864显示模块

按键选择模块

DAC0832数模转换模块

输出滤波及信号转换模块

主控芯片模块

整体电路原理图

整体电路PCB板

实物图

正在运行

输出图形

程序部分

#include

#include//定义绝对地址访问

#include

#include

#include

#defineucharunsignedchar

#defineuintunsignedint

/////LCD控制口定义////////////////////////

/////////////////////////////////////////

sbitRS=P2^3;

sbitWRD=P2^1;

sbitE=P2^2;

sbitPSB=P2^4;

sbitRES=P2^5;

/****************************************/

//按键定义//

//****************************************//

sbitflag_add=P3^0;//显示当前显示波形的下一个波形

sbitflag_sub=P3^1;//显示当前显示波形的上一个波形

sbitfm_add=P3^3;//频率增大按钮

sbitfm_sub=P3^4;//频率减小按钮

uintnum=0;

ucharflag=0;

uchartime_control=1;

uintfbt=0;

uintjct=0;

uintsjt=0;

ucharf=0;

uintsanjiao=6;

uchars[]={"SSSS"};

uinti=0;

//////////////////////////////////////12864变化频率显示函数段//////////

/////////////////////////////////////////////////////////////////////////

/**********************************************************************

***********************************************************************/

ucharaa[]={'','','','','','0','0','0','0','H','z','','','*','*'};

uchartable1[]="波形:

正弦波频率:

";

uchartable2[]="波形:

方波频率:

";

uchartable3[]="波形:

锯齿波频率:

";

uchartable4[]="波形:

三角波频率:

";

ucharmiao1,miao,miao2,count,miao3;

///////显示延时

voiddelay(uchart)

{

inti,j=t*125;;

for(i=0;i

}

voidwrite_com(ucharcom)

{

WRD=0;

RS=0;

delay(10);

P0=com;

delay(100);

E=1;

delay(100);

E=0;

delay(100);

}

voidwrite_date(uchardate)

{

WRD=0;

RS=1;

delay(100);

P0=date;

E=1;

delay(100);

E=0;

delay(100);

}

voidinit()

{

RES=0;

delay(100);

RES=1;

delay(100);

write_com(0x30);

delay(120);

write_com(0x30);

delay(100);

write_com(0x0c);

delay(150);

write_com(0x01);

delay(90);

write_com(0x06);

delay(90);

}

voiddesplay()

{

ucharj;

write_com(0x80);

for(j=0;j<16;j++)

{

if(flag==1)

write_date(table1[j]);

if(flag==2)

write_date(table2[j]);

if(flag==3)

write_date(table3[j]);

if(flag==4)

write_date(table4[j]);

//delay

(1);

}

}

voidwrite_sfm(ucharmiao)

{

inti;

aa[6]=(miao%100)/10+0x30;

aa[7]=(miao%10)/1+0x30;

aa[5]=(miao%1000)/100+0x30;

aa[4]=miao/1000+0x30;

write_com(0x88);

for(i=0;i<13;i++)

{

write_date(aa[i]);

//delay(10);

}

}

/****************************************显示段结束**************

*****************************************************************

*****************************************************************/

/***********sin表***************************************/

ucharcodesin1[]={

0x80,0x83,0x86,0x89,0x8c,0x8f,0x92,0x95,0x98,0x9c,0x9f,0xa2,

0xa5,0xa8,0xab,0xae,0xb0,0xb3,0xb6,0xb9,0xbc,0xbf,0xc1,0xc4,

0xc7,0xc9,0xcc,0xce,0xd1,0xd3,0xd5,0xd8,0xda,0xdc,0xde,0xe0,

0xe2,0xe4,0xe6,0xe8,0xea,0xec,0xed,0xef,0xf0,0xf2,0xf3,0xf4,

0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfc,0xfd,0xfe,0xfe,0xff,

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,

0xfd,0xfc,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf3,0xf2,

0xf0,0xef,0xed,0xec,0xea,0xe8,0xe6,0xe4,0xe3,0xe1,0xde,0xdc,

0xda,0xd8,0xd6,0xd3,0xd1,0xce,0xcc,0xc9,0xc7,0xc4,0xc1,0xbf,

0xbc,0xb9,0xb6,0xb4,0xb1,0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,

0x99,0x96,0x92,0x8f,0x8c,0x89,0x86,0x83,0x80,0x7d,0x79,0x76,

0x73,0x70,0x6d,0x6a,0x67,0x64,0x61,0x5e,0x5b,0x58,0x55,0x52,

0x4f,0x4c,0x49,0x46,0x43,0x41,0x3e,0x3b,0x39,0x36,0x33,0x31,

0x2e,0x2c,0x2a,0x27,0x25,0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,

0x15,0x14,0x12,0x10,0x0f,0x0d,0x0c,0x0b,0x09,0x08,0x07,0x06,

0x05,0x04,0x03,0x03,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x03,0x03,0x04,

0x05,0x06,0x07,0x08,0x09,0x0a,0x0c,0x0d,0x0e,0x10,0x12,0x13,

0x15,0x17,0x18,0x1a,0x1c,0x1e,0x20,0x23,0x25,0x27,0x29,0x2c,

0x2e,0x30,0x33,0x35,0x38,0x3b,0x3d,0x40,0x43,0x46,0x48,0x4b,

0x4e,0x51,0x54,0x57,0x5a,0x5d,0x60,0x63,0x66,0x69,0x6c,0x6f,

0x73,0x76,0x79,0x7c

};//5ms

/*****************************************

*scnaner()按键扫描处理*

*波形的选择波形显示德实牡鹘?

*

*****************************************/

voidscnaner()interrupt0{

if(flag_add==0)

{

flag+=1;

if(flag>=5)flag=1;

}

elseif(flag_sub==0)

{

flag-=1;

if(flag<=0)flag=4;

}

elseif(fm_add==0)

{

time_control+=1;

if(time_control>=20)time_control=20;

}

elseif(fm_sub==0)

{

time_control-=1;

if(time_control<=1)time_control=1;

}

miao=time_control*7;

miao1=time_control*12;

miao2=time_control*13;

miao3=time_control*6;

if(flag==1)

write_sfm(miao);

if(flag==2)

write_sfm(miao1);

if(flag==3)

write_sfm(miao2);

if(flag==4)

write_sfm(miao3);

desplay();

}

///////延时函数

voidpdelay(intn)

{

while(n--);

}

voidmain(void)

{

//initinal();//调用LCD字库初始化程序

IT0=1;

IE=0x83;

init();

while

(1)

{

switch(flag)

{

//sin

case1:

switch(time_control)

{

case1:

P1=sin1[num];break;//72

case2:

P1=sin1[num];break;//144

case3:

P1=sin1[num];break;//215

case4:

P1=sin1[num];break;//289

case5:

P1=sin1[num];break;//356

case6:

P1=sin1[num];break;//430

case7:

P1=sin1[num];break;//500

case8:

P1=sin1[num];break;//578

case9:

P1=sin1[num];break;//637

case10:

P1=sin1[num];break;//712

case11:

P1=sin1[num];break;//771

case12:

P1=sin1[num];break;//841

case13:

P1=sin1[num];break;//925

case14:

P1=sin1[num];break;//972

case15:

P1=sin1[num];break;//1003

case16:

P1=sin1[num];break;//1150

case17:

P1=sin1[num];break;//1230

case18:

P1=sin1[num];break;//1320

case19:

P1=sin1[num];break;//1470

case20:

P1=sin1[num];break;//1500

}

num+=time_control;

//if(num==flagnum[time_control])

if(num>=256)

{

num=0;

}

break;

case2:

//方波

switch(time_control)

{

case1:

fbt=450;break;//120

case2:

fbt=226;break;//240

case3:

fbt=146;break;//360

case4:

fbt=110;break;//480

case5:

fbt=86;break;//600

case6:

fbt=72;break;//720

case7:

fbt=60;break;//840

case8:

fbt=52;break;//960

case9:

fbt=46;break;//1080

case10:

fbt=40;break;//1200

case11:

fbt=36;break;//1320

case12:

fbt=32;break;//1440

case13:

fbt=28;break;//1560

case14:

fbt=26;break;//1680

case15:

fbt=24;break;//1800

case16:

fbt=22;break;//1920

case17:

fbt=20;break;//2040

case18:

fbt=18;break;//2160

case19:

fbt=16;break;//2280

case20:

fbt=14;break;//2400

}

if(f==0){f=1;P1=0x01;pdelay(fbt);}

else{f=0;P1=0xff;pdelay(fbt);}

break;

case3:

//锯齿

if(jct<5)

{

switch(time_control)

{

case1:

jct=256;break;//136

case2:

jct=256;break;//270

case3:

jct=256;break;//406

case4:

jct=256;break;//540

case5:

jct=256;break;//660

case6:

jct=256;break;//800

case7:

jct=256;break;//940

case8:

jct=256;break;//1050

case9:

jct=256;break;//1200

case10:

jct=256;break;//1350

case11:

jct=256;break;//1580

case12:

jct=256;break;//1750

case13:

jct=256;break;//1830

case14:

jct=256;break;//1930

case15:

jct=256;break;//2060

case16:

jct=256;break;//2170

case17:

jct=256;break;//2320

case18:

jct=256;break;//2560

case19:

jct=256;break;//2700

case20:

jct=256;break;//2700

}

}

jct-=time_control;

P1=jct;

break;

//三角

case4:

switch(time_control)

{

case1:

sjt=140;break;//72

case2:

sjt=140;break;//144

case3:

sjt=140;break;//215

case4:

sjt=140;break;//289

case5:

sjt=140;break;//356

case6:

sjt=140;break;//430

case7:

sjt=140;break;//500

case8:

sjt=140;break;//570

case9:

sjt=140;break;//637

case10:

sjt=140;break;//712

case11:

sjt=140;break;//771

case12:

sjt=140;break;//841

case13:

sjt=140;break;//925

case14:

sjt=140;break;//970

case15:

sjt=140;break;//1005

case16:

sjt=140;break;//1150

case17:

sjt=140;break;//1230

case18:

sjt=140;break;//1320

case19:

sjt=140;break;//1470

case20:

sjt=140;break;//1500

}

if(f==0)

{

if(sanjiao>=sjt)f=1;

sanjiao+=time_control;

P1=sanjiao;

}

else

{

sanjiao-=time_control;

P1=sanjiao;

if(sanjiao<=6)

{

sanjiao=0x06;

f=0;

}

}

break;

}

}

}

////////////////////////END///////////////////////////////

/************************************************************

*************************************************************/

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1