D[0.3]D[4.7]t[0.7]171819202122324C1C2C3C4C5C6C7C8C1C2C3C4C5C6C7C8C8C1C2C3C4C7C6C5B2B13B2B3B4B5B6B7B8B8B6 B43B217524321 1781920A1A2A3A4A5A6A7A8T7T0T1T2T3T4T6T7T5T0T1T2T3T4T6T5D3D3D2D2D1D4D5D6D7 D7D4 D5 D6D1D0D0E1E2E3E4A1A2A3A4Z1Z0Z0Z1Z1Z0 Z2E6E7E8E5171819E1E324E56E78XTAL218XTAL119ALE30EA31PSEN29RST9P0./AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD63P0.7/AD732P2.7/A1528P2.0/A821P2.1/A92P2./A1023P2.3/A124P2.4/A1225P2.5/A1326P2.6/A1427P1.01P1.2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD1P3.2/INT012P3./INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115U180C31C130PC230PD034D13D232D331D430D529D628D727RD5WR36A09A18REST35CS6PA04PA13PA22PA31PA440PA539PA638PA737PB018PB119PB220PB321PB42PB523PB624PB725PC014PC115PC216PC317PC413PC512PC61PC710U2825AD03 Q02D14 15D27 Q26D38 39D413 Q412D514 515D617 Q616D718 719OE1LE1U374LS37A23BC21D0E118290112233445566778899101013124315146517U474154A23BC21D0E118290112233445566778899101013124315146517U574154 A23BC21D0E118290112233445566778899101013124315146517U674154A23BC21D0E118290112233445566778899101013124315146517U77415412 3 456910 8A02 B018A13 B117A24 B216A35 B315A46 B414A57 B513A68 B612A79 B71CE19AB/A1U974LS24512365489=7 +CON0ABCD1 2 43+8.8IN15IN27ENA6 OUT12OUT23ENB1 OUT313OUT414IN310IN412SENSA1SENSB15 GND8VS4VC9L298+36VU1NADD71463D5124D31029D1807E6RW5S4VS1D2VE3LCD1LM016L+5V/**********************************************//*********兰州交通大学电子电工实验中心 *********//*******************2009-8-2********************//*********************************************/#include“reg51.h“#include“intrins.h“#include“math.h“#include“absacc.h“#define PORTA XBYTE[0x8500]#define PORTB XBYTE[0x8502]#define PORTC XBYTE[0x8504]#define PORTC0 XBYTE[0x8506]#define nop _nop_()#define Right_RUN 1#define Left_RUN 0unsigned long RunSpeed=76;unsigned char RUNState=1;sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit P17=P1^7;bit flag=0;unsigned char xx[]=“speed(n/min):“;unsigned char SD[]=“76“;char state[2][14]={“direction:cw“,“direction:ccw“};unsigned char FLG,INMA=0;unsigned char t,s=0x01;unsigned int a;main(){void OPJIAN();unsigned char JIAN();unsigned char JIANZHI();void speed();void SHOW_LCD();void show_state();void write1();void writ2(unsigned char i);void delay();void time();void busy();unsigned char i;i=0x90;PORTC0=i;i=0x01;TMOD=i;t=0x10;a=0x0f;TH0=0x10;TL0=0x0f;FLG=INMA; SHOW_LCD();show_state();EA=1;ET0=1;TR0=1;while(1){i=JIAN();if(i!=0){time();time();}i=JIAN();if(i!=0){INMA=JIANZHI();OPJIAN();time();}if(FLG!=INMA||flag==1){ FLG=INMA;SHOW_LCD();show_state();flag=0;}}}void SHOW_LCD()/*lcd 设置程序*/{P1=0x38;write1();delay();P1=0x38;write1();delay(); P1=0x38;write1();delay();P1=0x01;write1();delay();P1=0x0f;write1();delay();P1=0x06;write1();delay();P1=0x0c;write1();}void show_state()/*状态显示程序*/{unsigned char i=0;P1=0x80;write1();while(xx[i]!='\0'){writ2(xx[i]);i++;delay();}i=0;while(SD[i]!='\0'){writ2(SD[i]);delay();i++;}P1=0xc0;write1();i=0;if(RUNState==Right_RUN)while(state[0][i]!='\0'){writ2(state[0][i]);i++;}elseif(RUNState==Left_RUN)while(state[1][i]!='\0'){writ2(state[1][i]);i++;}}void write1()/*lcd 写控制字*/{RS=0;RW=0;E=0;busy();E=1;}void writ2( unsigned char i)/*lcd 写数据*/{ P1=i;RS=1;RW=0;E=0;busy();E=1;}void delay()/*延时程序*/{unsigned char i;for(i=0;i1;if(s==0x0f)s=0xf7;}TH0=t;TL0=a;TR0=1;}
展开阅读全文