#include "reg52.h" #include "math.h" #include "intrins.h" /********************************************************/ typedef unsigned char uint8; /* 定义可移植的无符号8位整数关键字 */ typedef signed char int8; /* 定义可移植的有符号8位整数关键字 */ typedef unsigned int uint16; /* 定义可移植的无符号16位整数关键字 */ typedef signed int int16; /* 定义可移植的有符号16位整数关键字 */ typedef unsigned long uint32; /* 定义可移植的无符号32位整数关键字 */ typedef signed long int32; /* 定义可移植的有符号32位整数关键字 /***********************************************************/ /**********************************************************/ /************ vfd ************************************/ //unsigned char code disp_0[]={0x15,0x10,0x51,0x51,0x54,0x45,0x45,0x11,0x55,0x55 }; //unsigned char code disp_1[]={0x15,0x04,0x11,0x14,0x04,0x14,0x15,0x04,0x15,0x14 }; //unsigned char code disp_2[]={0x2a,0x20,0xa2,0xa2,0xa8,0x8a,0x8a,0x22,0xaa,0xaa}; //unsigned char code disp_3[]={0x2a,0x08,0x22,0x28,0x08,0x28,0x2a,0x08,0x2a,0x28 }; /***************************************************************************************/ unsigned char code disp_0[]={0x15,0x04,0x51,0x45,0x44,0x45,0x55,0x04,0x55,0x45,0x54,0x55,0x11,0x55,0x51,0x50,0x15,0x54 }; unsigned char code disp_1[]={0x15,0x01,0x11,0x11,0x05,0x14,0x14,0x11,0x15,0x15,0x15,0x04,0x14,0x01,0x14,0x14,0x05,0x04 }; unsigned char code disp_2[]={0x2a,0x08,0xa2,0x8a,0x88,0x8a,0xaa,0x08,0xaa,0x8a,0xa8,0xaa,0x22,0xaa,0xa2,0xa0,0x2a,0xa8}; unsigned char code disp_3[]={0x2a,0x02,0x22,0x22,0x0a,0x28,0x28,0x22,0x2a,0x2a,0x2a,0x08,0x28,0x02,0x28,0x28,0x0a,0x08}; /**********************************************************************************/ /**********************************************************************************/ /**********************************************************************************/ unsigned char code disp_4[]={0x2a,0x20,0xa2,0xa2,0xa8,0x8a,0x8a,0x22,0xaa,0xaa,0xaa,0x88,0x0a,0xa0,0x8a,0x8a,0x88,0x28}; unsigned char code disp_5[]={0x2a,0x08,0x22,0x28,0x08,0x28,0x2a,0x08,0x2a,0x28,0x0a,0x2a,0x22,0x2a,0x22,0x02,0x0a,0x2a}; unsigned char code disp_6[]={0x15,0x10,0x51,0x51,0x54,0x45,0x45,0x11,0x55,0x55,0x55,0x44,0x05,0x50,0x45,0x45,0x44,0x14}; unsigned char code disp_7[]={0x15,0x04,0x11,0x14,0x04,0x14,0x15,0x04,0x15,0x14,0x05,0x15,0x11,0x15,0x11,0x01,0x05,0x15}; unsigned char code disp1[]={0x01,0x57,0x18,0x50,0x46,0x60,0x20,0x55,0x00,0x40,0x04,0x22,0x29,0x12,0x28,0x2c}; uint8 bdata set1; uint8 vfd_disp[16]; uint8 disp_a[8]; uint8 disph[3]; uint8 bdata vfd_data; uint8 disp_count,disp_count1; uint8 buffer_uv,buffer_liang,buffer_size,buffer_chong; uint8 b,c; sbit vfd_data0=vfd_data^0; void data_write(void); void write_task(void); void convert(void); void convert1(void); void xiaoyan(void); void xiaoyan1(void); void rtc_xiaoyan(void); /********************************************************/ void WDT(void); /**********************************************************/ void delay(void); void check_uv(void); void check_mg(void); void check_size(void); void func(void); void minus(void); void ji_count(void); void ji_batch(void); void jishu(void); void anjin(void); void jincao(void); void xianshi(void); void jishu(void); void chushi(void); void weicao(void); void shiwei(void); void zhijin(void); void send_jishu(void); void cuv(void); void jczt(void); void key_add(void); void key_mg(void); void key_uv(void); void key_size(void); void key_preset(void); void key_preset_add(void); void key_preset_dec(void); void frist(void); /*****************1302******************************************/
/**********************************************************/ sbit sw_mg=P3^6; sbit sw_uv=P0^7; sbit sw_size=P0^6; sbit sw_add=P1^4; sbit sw_preset=P3^5; sbit sw_fuwei=P3^5; sbit sw_preset_add=P0^1; sbit sw_add1=P0^1; sbit sw_preset_dec=P0^2; sbit sw_dec=P0^2; /********************************************************/ sbit a_sda=P2^2; sbit a_scl=P2^3; sbit chong_a=P2^4; sbit chong_b=P2^6; sbit cheshi =P2^2; sbit beep=P1^6; sbit T2_PORTE=P1^2; sbit motor_b=P1^3; sbit motor_s=P1^5; sbit input_c=P2^0; sbit output_c=P2^1; sbit count_ca=P3^0; sbit count_cb=P3^1; sbit da_chi=P3^2; sbit VIO=P2^5; sbit right_mg=P3^7; sbit disp_clk = P1^0; sbit disp_cs = P1^2; sbit disp_out = P1^1; sbit disp_clk1 = P0^4; sbit disp_cs1 = P0^3; sbit disp_out1 = P0^5; /************************************************************/
/**********************************************************/
/**********************************************************/ uint8 bdata set; uint8 batch1[3]; uint8 bdata count; sbit count0=count^0;/*计数管有遮盖 */ sbit count1=count^1;/*机器在异常下停止*/ sbit count2=count^2;/*指示机器识伪已结束,防止报警钞票压住队管又退回*/ sbit count3=count^3;/*第一张钞票标志*/ sbit count4=count^4;/*幅面用?/ sbit count5=count^5;/*磁头脉冲识别用*/ sbit count6=count^6;/*报警后钞票压住计数管吗*/ sbit count7=count^7;//测试 uint8 bdata jl; sbit jl0=jl^0;//E00 sbit jl1=jl^1;//EF1 sbit jl2=jl^2;//EA2 sbit jl3=jl^3;//EA0 sbit jl4=jl^4;//EE0 sbit jl5=jl^5; sbit jl6=jl^6; sbit jl7=jl^7;//半张 uint8 bdata function; sbit function0=function^0; //分版 sbit function1=function^1; //幅面 sbit function2=function^2; //预置 sbit function3=function^3; //累加 sbit function4=function^4; //手动 sbit function5=function^5; //MG(磁性或智能) sbit function6=function^6; //美元(紫光) sbit function7=function^7; //复位键按下时 /***************************************************/ uint8 bdata tiao; sbit tiao0=tiao^0; sbit tiao1=tiao^1; sbit tiao2=tiao^2; sbit tiao3=tiao^3; sbit tiao4=tiao^4; sbit tiao5=tiao^5; sbit tiao6=tiao^6; sbit tiao7=tiao^7; uint8 bdata biao; sbit biao0=biao^0; /****************************************************/ uint8 uv_zhi,mg_zhi,liang_zhi1,fu_zhi,jishu_zhi,chong_a_data,chong_b_data,chong_zhi,chong_zhi1,shou_zhi,shoudong; uint8 yanshi,yanshi1,yanshi2,yanshi5; uint8 fu_can; uint16 fu_can1; uint8 huan0,huan1,huan2; uint8 dachi,huan3; uint8 idata k,che_mapan; uint8 uv; uint8 ma_pan; uint8 fu_huan; uint8 banhuan,vfd_huan,vfd_huan1; uint8 motor_zuan,beep_du; uint8 weima,i,n; uint8 set_led,set_led1,mapanl,beep_huan,motor_huan,motor_s_yanshi; unsigned char bdata ok; sbit data7=ok^7; /***************************************************/ /***************************************************/ /*************************************************************/ void start(void); void stop(void); void receive(void); void send(void); void read2401a(void); void write2401a(void); void ack(void); void noack(void); void delayms(void); /***************************************************/ /***************************************************/ //at2401a寄存// uint8 bdata huan_2401; uint8 bdata huan1_2401; sbit huan_2401_7=huan_2401^7; sbit huan1_2401_7=huan1_2401^7; uint8 bdata a_ack; sbit ack0=a_ack^0; uint8 m; /***************************************************/
/***************************************************/ void chushi(void){ P2=0xff; TMOD=0x02; TCON=0x00; TH0=0; TL0=0; TH1=0; TL1=0;
T2CON=0; TL2=0x00; TH2=0Xff; RCAP2L=0x00; RCAP2H=0Xff; //c6
IE=0x2F; IP=1; TR0=1; disp_a[0]=0; disp_a[1]=0; disp_a[2]=0; disp_a[3]=0; disp_a[4]=0; disp_a[5]=0; disp_a[6]=0; beep=0; beep_huan=0x02; motor_huan=0x02; motor_b=1; motor_s=0;
EA=1; TR2=1; } void main(void) { _nop_(); _nop_(); _nop_(); _nop_(); chushi(); while(1){ _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); }
} //************************************************************** /************************************************************************/ /***********************************************************************/ /************************************************************************/ /*********************** VFD *********************************/ /************************************************************************/ void xianshi (void) { // TF2=0; /******************************************************/ // if(motor_s==1){ // if(biao0==1){ // motor_s_yanshi++; // if(motor_s_yanshi==0x0f){ // motor_s_yanshi=0; // motor_s=0; // biao0=0; // } // } // } // WDT();//看门狗 convert(); convert1(); xiaoyan(); xiaoyan1(); // rtc_xiaoyan(); disp_cs=0; vfd_data=0X38; data_write(); disp_cs=1; _nop_(); disp_cs=0; vfd_data=0X70; data_write(); disp_cs=1; _nop_(); disp_cs=0; vfd_data= 0xc0; data_write(); _nop_(); c=9; b=0; while(c>0){ vfd_data= vfd_disp; data_write(); b=b+1; vfd_data=vfd_disp; b=b+1; data_write(); vfd_data=0; data_write(); c=c-1; } disp_cs=1; _nop_(); disp_cs=0; vfd_data=0XBF; data_write(); disp_cs=1; /******************外显**************************************/ disp_cs1=0; disp_clk1=0; ok=weima; ok=~ok; for (n=0;n<8;n++){ disp_out1=data7; disp_clk1=1; _nop_(); _nop_(); disp_clk1=0; ok<<=1; } ok=disph; ok=~ok; for (n=0;n<8;n++){ disp_out1=data7; disp_clk1=1; _nop_(); _nop_(); disp_clk1=0; ok <<=1; } disp_cs1=1; _nop_(); _nop_(); disp_cs1=0; weima>>=1; i=i+1; if(i==3){ i=0; weima=0x40; } /******************外显**************************************/ } void data_write (void) { disp_out=1; for (k=0;k<8;k++){ disp_clk=0; disp_out=vfd_data0; disp_clk=1; vfd_data >>=1; } } void convert(void){ /**************************************************/ //16511G1=vfdG8,16511G3=VFDG6 /***************************************************/ vfd_disp[0]=0; vfd_disp[1]=0; vfd_disp[2]=0; vfd_disp[3]=0; vfd_disp[4]=set_led; vfd_disp[5]=0x00; vfd_huan=disp_6[disp_a[0]]; vfd_huan1=disp_4[disp_a[1]]; vfd_disp[6]=vfd_huan|vfd_huan1; vfd_huan=disp_7[disp_a[0]]; vfd_huan1=disp_5[disp_a[1]]; vfd_disp[7]=vfd_huan|vfd_huan1; vfd_huan=disp_6[disp_a[2]]; vfd_huan1=disp_4[disp_a[3]]; vfd_disp[8]=vfd_huan|vfd_huan1; vfd_huan=disp_7[disp_a[2]]; vfd_huan1=disp_5[disp_a[3]]; vfd_disp[9]=vfd_huan|vfd_huan1; vfd_disp[10]=(motor_huan<<4)|set_led1|0x10; vfd_disp[11]=beep_huan|(motor_huan>>4); vfd_huan=disp_2[disp_a[6]]; vfd_disp[12]=vfd_huan; vfd_huan=disp_3[disp_a[6]]; vfd_disp[13]=vfd_huan; vfd_huan=disp_2[disp_a[4]]; vfd_huan1=disp_0[disp_a[5]]; vfd_disp[14]=vfd_huan|vfd_huan1; vfd_huan=disp_3[disp_a[4]]; vfd_huan1=disp_1[disp_a[5]]; vfd_disp[15]=vfd_huan|vfd_huan1; } void convert1(void){ disph[0]=disp1[disp_a[3]]; disph[1]=disp1[disp_a[2]]; disph[2]=disp1[disp_a[1]]; } void xiaoyan(void){ if(disp_a[0]==0){ vfd_disp[6]=vfd_disp[6]&0xaa; vfd_disp[7]=vfd_disp[7]&0x2a; if (disp_a[1]==0){ vfd_disp[6]=vfd_disp[6]&0x55; vfd_disp[7]=vfd_disp[7]&0x15; if (disp_a[2]==0){ vfd_disp[8]=vfd_disp[8]&0xaa; vfd_disp[9]=vfd_disp[9]&0x2a; } } } if (disp_a[4]==0){ vfd_disp[14]=vfd_disp[14]&0x55; vfd_disp[15]=vfd_disp[15]&0x15; if (disp_a[5]==0){ vfd_disp[14]=vfd_disp[14]&0xaa; vfd_disp[15]=vfd_disp[15]&0x2a; } }
} void xiaoyan1(void){ if (disp_a[1]==0){ disph[2]=0xff; if (disp_a[2]==0){ disph[1]=0xff; } } } //void rtc_xiaoyan(void){ // disp_count1++; // if(disp_count1==16){ // disp_count1=0; // /****************************/ // //进钞轮转动 // if(motor_b==1){ // motor_zuan>>=1; // if(motor_zuan==0x02){ // motor_zuan=0x20; // } // motor_huan=motor_zuan; // } // else{ // motor_huan=0x3f; // } // /****************************/ //报警闪烁 /******************************/ // if(count1==1){ // beep_du>>=1; // if(beep_du==0x02){ // beep_du=0x40; // } // beep_huan=beep_du; // } // else{ // beep_huan=0x3c; // } /******************************/ // } //} /********************************************************************/
void TIME2(void) interrupt 5 { TF2=0; beep=0; motor_b=0; motor_s=1; disp_a[0]=disp_a[0]+1; disp_a[1]=disp_a[1]+1; disp_a[2]=disp_a[2]+1; disp_a[3]=disp_a[3]+1; disp_a[4]=disp_a[4]+1; disp_a[5]=disp_a[5]+1; disp_a[6]=disp_a[6]+1; xianshi();
}
void ji_count(void){ batch1[3]=batch1[3]+1; if(batch1[3]>9){ batch1[3]=0; batch1[2]=batch1[2]+1; if(batch1[2]>9){ batch1[2]=0; batch1[1]=batch1[1]+1; if(batch1[1]>9){ batch1[1]=0; batch1[0]=batch1[0]+1; if(batch1[0]>9){ batch1[0]=0; } } } } disp_a[3]=disp_a[3]+1; if (disp_a[3]>9){ disp_a[3]=0; disp_a[2]=disp_a[2]+1; if (disp_a[2]>9){ disp_a[2]=0; disp_a[1]=disp_a[1]+1; if (disp_a[1]>9){ disp_a[1]=0; disp_a[0]=disp_a[0]+1; if(disp_a[0]>9){ disp_a[0]=0; } } } } }
|