|
虚拟示波器proteus仿真原理图
虚拟示波器程序:
- /*Mini51B数字示波器*/
- /*原作者:田开坤*/
- //移植:古道热肠
- #include <reg52.h>
- #include "osc.h"
- #include "lcd12864.h"
- #include "irm.h"
- #include "timer2.h"
- #include "dots.h"
- void main()
- {
- char i=0,j=0,k=0;
- unsigned char dah,dal,dam;
- int tmp,tmp1;
- pointxA=10;
- pointxB=110;
- pointyA=14;
- pointyB=44;
- lcd12864_init();
- extern2_init();
- timer2_init();
- lcd12864_put_xywhb(0,7,128,8,bg);
- disp_vdiv();
- disp_ypoint();
-
- while(1)
- {
- key_scan();
- if((da_finish)||(run_flag)) {
- dah=0;dal=255;
- for(i=0;i<DATA_SIZE/2;i++) {
- if(da_buffer[i] > dah) dah = da_buffer[i]; //找出最大值
- if(da_buffer[i] < dal) dal = da_buffer[i]; //找出最小值
- }
- dam=(dah-dal)/2+dal; //计算出中间值
- i=0;
- while(da_buffer[i] <= dam) if(++i > (DATA_SIZE/2)) break;
- while(da_buffer[i] > dam) if(++i > (DATA_SIZE/2)) break;
- while(da_buffer[i] <= dam) if(++i > (DATA_SIZE/2)) break;
- while(da_buffer[i] > dam) if(++i > (DATA_SIZE/2)) break;
- for(j=0;j<WIDTH;j++)
- {
- if(acdc_flag==0)
- {
- tmp = da_buffer[i+j+movx]-dam;
- tmp1 = da_buffer[i+j+movx+1]-dam;
- tmp = tmp/(vdiv[val_vdiv])+HEIGHT/2 + movy; //过滤直流成分
- tmp1 = tmp1/(vdiv[val_vdiv])+HEIGHT/2 + movy; //过滤直流成分
- }
- else
- {
- tmp = da_buffer[i+j+movx]/(vdiv[val_vdiv]) + movy;
- tmp1 = da_buffer[i+j+movx+1]/(vdiv[val_vdiv]) + movy;
- }
- if(tmp > HEIGHT-1) tmp = HEIGHT-1;
- if(tmp1 > HEIGHT-1) tmp1 = HEIGHT-1;
- if(tmp < 0) tmp =0;
- if(tmp1 < 0) tmp1 =0;
- k=tmp-tmp1;
- disp(j,tmp,k);
- }
- da_finish=0;
- }
- }
- }
复制代码
虚拟示波器的所有资料下载:
示波器程序.zip
(102 KB, 下载次数: 119)
|
|