📄 renwu.lst
字号:
C51 COMPILER V8.02 RENWU 05/19/2008 23:56:23 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE RENWU
OBJECT MODULE PLACED IN Renwu.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE src\Renwu.c BROWSE DEBUG OBJECTEXTEND PRINT(.\Renwu.lst) OBJECT(Renwu.obj)
line level source
1 #include "reg5410.h"
2 #include "head.h"
3
4 unsigned int Maxjiao=502;
5 unsigned int Minjiao=483;
6
7 unsigned int j_time=750;
8 unsigned int f_time=1500;
9
10
11 extern void DispShuzi(unsigned char x,unsigned char y,unsigned int n); //8*16数字显示
12 extern void DispShuzi0(unsigned char x,unsigned char y,unsigned int n); //8*16数字显示
13 extern void DispShuzi1(unsigned char x,unsigned char y,unsigned int n); //8*16数字显示
14 extern void DispShuzi2(unsigned char x,unsigned char y,unsigned int n); //8*16数字显示
15 extern void send_data(unsigned char command_data) ;
16
17 void yuyin(unsigned char n,unsigned char *str);
18 void yuyin1(unsigned char n,unsigned char *str,unsigned int x,unsigned char n1,unsigned char *st);
19
20
21 extern unsigned char five_ms;
22 extern unsigned char Sound_time;
23 extern unsigned int Run_time;
24 extern unsigned int delay;
25 extern unsigned char work;
26
27 bit Dir=0;
28 bit Start=0;
29
30 void Find_Way(void)
31 {
32 1 if(Start==1)
33 1 {
34 2 if(Dir==Froth)
35 2 {
36 3 if(Led_left==Black)
37 3 { LZMove=1;RZMove=0; }
38 3 else if(Led_right==Black)
39 3 { LZMove=0;RZMove=1; }
40 3 else if(Led_qian==Black)
41 3 { LZMove=0;RZMove=0; }
42 3 }
43 2 else if(Dir==Back)
44 2 {
45 3 if(Led_leftH==Black)
46 3 { LFMove =1;RFMove=0;}
47 3 else if(Led_rightH==Black)
48 3 { LFMove =0;RFMove=1;}
49 3 else if(Led_qianH==Black)
50 3 { LFMove =0;RFMove=0;}
51 3 }
52 2 }
53 1 else
54 1 { LZMove=1; RZMove=1; LFMove =1; RFMove=1;}
55 1 }
C51 COMPILER V8.02 RENWU 05/19/2008 23:56:23 PAGE 2
56
57
58
59 void GetADCaiJi(unsigned int *ADData)
60 {
61 1 unsigned int i, j, Sum;
62 1 ADC_CONTR=0x80|0x05;
63 1 for(i=0; i<100; i++);
64 1 Sum = 0;
65 1 for(i=0; i<64; i++)
66 1 {
67 2 ADC_CONTR|=0x08;
68 2 while((ADC_CONTR&0x10)==0x00); //等待变成flag=1
69 2 Sum = Sum + (ADC_DATA*4+ADC_LOW2);
70 2 for(j=0; j<100;j++);
71 2 }
72 1 *ADData = Sum / 64;
73 1 }
74
75
76
77 void Do_Renwu0(void)
78 {
79 1 unsigned int tmp=0,lasttmp=0,tim;
80 1 unsigned char Pingheng=0;
81 1 unsigned char dei=10;//运动时间
82 1 unsigned int delayi=200,j=0,ji=0;
83 1 unsigned char PH=0;
84 1
85 1 yuyin(18,"基本部奋|测试|开始");
86 1
87 1 for(j=0;j<520;j++)
88 1 for(ji=0;ji<5000;ji++);
89 1
90 1 yuyin(9,"向C点行驶");
91 1 Sound_time=50;
92 1
93 1 Run_time=0;
94 1 Dir=Froth; Start=1;
95 1 LZMove=0;RZMove=0;
96 1 while(Run_time<j_time)
97 1 { Find_Way(); }
98 1 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
99 1 tim=Run_time/20;
100 1 DispShuzi(0,4,tim);
101 1
102 1 Sound_time=20;
103 1 yuyin1(12,"到达C点|用时",tim,10,"寻找平衡点");
104 1
105 1 Pingheng=0;
106 1 Run_time=0;
107 1 while(1)
108 1 {
109 2 Start=0;
110 2 delay=50;
111 2 while(delay); //100ms
112 2 GetADCaiJi(&tmp);
113 2 if(tmp<lasttmp+7||tmp>lasttmp-7)
114 2 {
115 3 if(tmp>(Maxjiao+7))
116 3 { Dir = Froth ; Start = 1 ;
117 4 delay=3;
C51 COMPILER V8.02 RENWU 05/19/2008 23:56:23 PAGE 3
118 4 LZMove=0;RZMove=0;
119 4 while(delay)
120 4 Find_Way();
121 4 Start=0;
122 4 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
123 4 Pingheng=0;
124 4 }
125 3 else if(tmp<(Maxjiao-7))
126 3 {
127 4 Dir = Back; Start = 1;
128 4 delay=3;
129 4 LFMove=0;RFMove=0;
130 4 while(delay)
131 4 Find_Way();
132 4 Start=0;
133 4 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
134 4 Pingheng=0;
135 4 }
136 3 else
137 3 { Pingheng++;
138 4 if(Pingheng>=20)
139 4 {Start=0; LZMove=1;RZMove=1;LFMove =1;RFMove=1; tim=Run_time/20;DispShuzi(1,4,tim);delay=200;/*while(d
-elay){Sound_time=2;}*/ break;}
140 4 }
141 3 }
142 2 lasttmp=tmp;
143 2 }
144 1
145 1 yuyin1(15,"到达平衡点|用时",tim,0,"");
146 1 delay=1000;
147 1 while(delay)
148 1 {
149 2 if(delay%200==190)
150 2 Sound_time=10;
151 2 }
152 1 yuyin(11,"向|B点|行驶");
153 1 // delay=200;
154 1 // while(delay);
155 1 Run_time=0;
156 1 Dir=Froth; Start=1;
157 1 LZMove=0;RZMove=0;
158 1 while(Led_left==White||Led_right==White||Led_qian==White)
159 1 Find_Way();
160 1 Start=0; { LZMove=1; RZMove=1; LFMove =1; RFMove=1;}
161 1 tim=Run_time/20;
162 1 DispShuzi(2,4,tim);
163 1 yuyin1(13,"到达|B点|用时",tim,0," ");
164 1 // delay=200;while(delay){Sound_time=2;}
165 1
166 1 delay =1000;
167 1
168 1 while(delay)
169 1 {
170 2 if(delay%200==190)
171 2 Sound_time=10;
172 2 }
173 1 yuyin(10,"向|A点行驶");
174 1 // delay=200;
175 1 // while(delay);
176 1 Run_time=0;
177 1 Dir = Back;Start = 1;
178 1 LFMove=0;RFMove=0;
C51 COMPILER V8.02 RENWU 05/19/2008 23:56:23 PAGE 4
179 1 while(Led_leftH==White||Led_rightH==White||Led_qianH==White)
180 1 Find_Way();
181 1
182 1 Start = 0;
183 1 Sound_time=50;
184 1 tim=Run_time/20;
185 1 DispShuzi(3,4,tim);
186 1 yuyin1(12,"到达A点|用时",tim,18,"|基本部奋|测试完毕");
187 1 work=Renwu0;
188 1 Run_time=0;
189 1 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
190 1 }
191
192 void Do_Renwu1(void)
193 {
194 1 unsigned char flagph=0,Pingheng=0,i=0,PH=0;
195 1 unsigned int tmp=0,lasttmp=0,jiaodu=0,tim=0;
196 1 unsigned char si=0,phi=0; //phi为平衡次数
197 1 unsigned char dei=20;//运动时间
198 1 unsigned int delayi=20,j=0,ji=0;
199 1 yuyin(18,"发挥部奋|测试|开始");
200 1 /* delay=650;
201 1 while(delay!=0);*/
202 1 for(j=0;j<520;j++)
203 1 for(ji=0;ji<5000;ji++);
204 1 Run_time = 0;
205 1 Dir = Froth ; Start = 1;
206 1 delayi=200;
207 1 dei=20;
208 1 Sound_time=50;
209 1 LZMove=0;RZMove=0;
210 1
211 1 yuyin(12,"向|跷板|行驶");
212 1 while(Run_time<f_time)
213 1 { /*if(Led_leftH==Black&&Led_rightH==Black&&Led_qianH==Black)
214 2 {;}
215 2 else*/
216 2 Find_Way();
217 2 }
218 1
219 1 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
220 1
221 1 while(1)
222 1 {
223 2 Start=0;
224 2 LZMove=1; RZMove=1; LFMove =1; RFMove=1;
225 2 if(tmp>Maxjiao)
226 2 {
227 3 jiaodu=1.25*(tmp-Maxjiao);
228 3 DispShuzi1(1,1,jiaodu);
229 3 }
230 2 else if(tmp<=Maxjiao)
231 2 {
232 3 jiaodu=1.25*(Maxjiao-tmp);
233 3 DispShuzi2(1,1,jiaodu);
234 3 }
235 2 if(PH==0)
236 2 {
237 3 delay=50;
238 3 while(delay); //100ms
239 3 GetADCaiJi(&tmp);
240 3 if(tmp>(Maxjiao-20))
C51 COMPILER V8.02 RENWU 05/19/2008 23:56:23 PAGE 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -