|
原理簡單,附有源程序,同時(shí)能夠直接仿真看結(jié)果?梢詼y試三角波,正弦波等,同時(shí)測量1-100khz。
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載):
捕獲.PNG (29.55 KB, 下載次數(shù): 71)
下載附件
2017-6-22 12:20 上傳
捕獲1.PNG (18.4 KB, 下載次數(shù): 66)
下載附件
2017-6-22 12:21 上傳
0.png (46.06 KB, 下載次數(shù): 72)
下載附件
2017-6-22 18:44 上傳
單片機(jī)源程序如下:
- /********************************************************************
- 匯誠科技
- 網(wǎng)址:http://www.ourhc.cn
- 產(chǎn)品有售淘寶店:http://shop36330473.taobao.com
- *********************************************************************/
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar duan[10]={0xc0,0Xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //所需的段的位碼
- //uchar wei[4]={0XEf,0XDf,0XBf,0X7f}; //位的控制端 (開發(fā)板)
- uchar wei[4]={0X80,0X40,0X20,0X10}; //位的控制端 (仿真)
- uint z,x,c,v, date; //定義數(shù)據(jù)類型
- uint dispcount=0;
- uint lck=0;
- uint disp=0;
- /******************************************************************
- 延時(shí)函數(shù)
- ******************************************************************/
- void delay(uchar t)
- {
- uchar i,j;
- for(i=0;i<t;i++)
- {
- for(j=13;j>0;j--);
- { ;
- }
- }
- }
- /**********************************************************************
- 數(shù)碼管動(dòng)態(tài)掃描
- *********************************************************************/
- void xianshi()
- {
- /*****************數(shù)據(jù)轉(zhuǎn)換*****************************/
- z=date/1000; //求千位
- x=date%1000/100; //求百位
- c=date%100/10; //求十位
- v=date%10; //求個(gè)位
- P2=wei[0];
- P0=duan[z];
- delay(50);
- P2=wei[1];
- P0=duan[x];
- delay(50);
- P2=wei[2];
- P0=duan[c];
- delay(50);
- P2=wei[3];
- P0=duan[v];
- delay(50);
-
- }
- /*************************************************************************
- 定時(shí)器初值1ms
- **************************************************************************/
- void initTimer(void)
- {
- TMOD=0x0;
- TH0=0xe3;
- TL0=0xc;
- }
- /*************************************************************************
- 定時(shí)器函數(shù)
- **************************************************************************/
- void timer0(void) interrupt 1
- {
- TH0=0xe3;
- TL0=0xc;
- lck++;
- if(lck==1000)
- {
- disp=dispcount;
- lck=0;
- dispcount=0;
- }
- }
- /*************************************************************************
- 中斷函數(shù)
- **************************************************************************/
- void int0(void) interrupt 0
- {
- dispcount++; //每一次中斷,計(jì)數(shù)加一
- }
- /*************************************************************************
- 主函數(shù)
- **************************************************************************/
- void main(void)
- {
- IT0=1; //INT0下降沿中斷
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
trycry.rar
(70.62 KB, 下載次數(shù): 49)
2017-6-22 12:21 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|