?? mainline.lst
字號:
C51 COMPILER V7.50 MAINLINE 09/10/2005 16:30:06 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MAINLINE
OBJECT MODULE PLACED IN .\mainline.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ..\control\mainline.c BROWSE DEBUG OBJECTEXTEND PRINT(.\mainline.lst) OBJEC
-T(.\mainline.obj)
line level source
1 #include "reg52.h"
2 #include "intrins.h"
3 #include "math.h"
4 #include <absacc.h>
5 #include "VIIC_C51.h"
6 #include "ZLG7290.h"
7
8 sbit KEY_INT=P3^2;
9 sbit PA1=P2^0;
10 sbit PB1=P2^1;
11 sbit PC1=P2^2;
12 sbit PA2=P2^4;
13 sbit PB2=P2^5;
14 sbit PC2=P2^6;
15 //端口定義
16
17 #define stepleng 0.2 //c=單步距離
18 #define a0 1160
19 #define b0 1492 //物體在原點的兩懸線長度
20
21 bit dir;
22 char sta1,sta2;
23 //unsigned int linex,liney;
24 unsigned char key;
25 unsigned char send[8]={00,00,00,00,00,00,00,00};//定義發(fā)送緩沖區(qū) 0~3--y 4~6--x 7--sign
26 unsigned int x,y,a,b;
27 int za,zb;
28 int numa,numb;
29 unsigned char disp_buf[8]={0,0,0,0,0,0,0,0};//定義全局變量
30
31 unsigned char display(unsigned char *sd)//顯示程序
32 {
33 1 disp_buf[0] = sd[0];
34 1 disp_buf[1] = sd[1];
35 1 disp_buf[2] = sd[2];
36 1 disp_buf[3] = sd[3];
37 1 disp_buf[4] = sd[4];
38 1 disp_buf[5] = sd[5];
39 1 disp_buf[6] = sd[6];
40 1 disp_buf[7] = sd[7];
41 1
42 1 ZLG7290_SendBuf(disp_buf,8);
43 1 return 0;
44 1 }
45
46 unsigned char delay(unsigned char no)
47 {
48 1 unsigned char i,j; //延時參數(shù)
49 1
50 1 for(; no>0; no--)
51 1 {
52 2 for(i=0; i<10; i++)
53 2 for(j=0; j<100; j++);
54 2 }
C51 COMPILER V7.50 MAINLINE 09/10/2005 16:30:06 PAGE 2
55 1 return 0;
56 1 }
57
58 void runner1(unsigned int num,bit dir)//輸入轉動的步數(shù)、方向,完成電機1轉動(相對3相電機)
59 {
60 1 unsigned int i;
61 1 if(dir)
62 1 {
63 2 for(i=0;i<=num;i++)
64 2 {
65 3 sta1++;
66 3 sta1=sta1%6;
67 3 delay(2);
68 3 if (sta1==0)PC1=1;
69 3 if (sta1==1)PB1=0;
70 3 if (sta1==2)PA1=1;
71 3 if (sta1==3)PC1=0;
72 3 if (sta1==4)PB1=1;
73 3 if (sta1==5)PA1=0;
74 3 }
75 2 }
76 1 else
77 1 {
78 2 for(i=0;i<=num;i++)
79 2 {
80 3 sta1--;
81 3 if (sta1<0)sta1=5;
82 3 delay(2);
83 3 if (sta1==0)PB1=1;
84 3 if (sta1==1)PA1=0;
85 3 if (sta1==2)PC1=1;
86 3 if (sta1==3)PB1=0;
87 3 if (sta1==4)PA1=1;
88 3 if (sta1==5)PC1=0;
89 3 }
90 2 }
91 1 }
92
93 void runner2(unsigned int num,bit dir)//輸入轉動的步數(shù)、方向,完成電機1轉動(相對3相電機)
94 {
95 1 unsigned int i;
96 1 if(~dir)
97 1 {
98 2 for(i=0;i<=num;i++)
99 2 {
100 3 sta1++;
101 3 sta1=sta1%6;
102 3 delay(2);
103 3 if (sta1==0)PC2=1;
104 3 if (sta1==1)PB2=0;
105 3 if (sta1==2)PA2=1;
106 3 if (sta1==3)PC2=0;
107 3 if (sta1==4)PB2=1;
108 3 if (sta1==5)PA2=0;
109 3 }
110 2 }
111 1 else
112 1 {
113 2 for(i=0;i<=num;i++)
114 2 {
115 3 sta1--;
116 3 if (sta1<0)sta1=5;
C51 COMPILER V7.50 MAINLINE 09/10/2005 16:30:06 PAGE 3
117 3 delay(2);
118 3 if (sta1==0)PB2=1;
119 3 if (sta1==1)PA2=0;
120 3 if (sta1==2)PC2=1;
121 3 if (sta1==3)PB2=0;
122 3 if (sta1==4)PA2=1;
123 3 if (sta1==5)PC2=0;
124 3 }
125 2 }
126 1 }
127
128
129 unsigned int point_A (unsigned int x,unsigned int y)//變量轉換xy-a
130 {
131 1 unsigned int lineA;
132 1 unsigned int tmp;
133 1 tmp=(1150-y)*(1150-y)+(x+150)*(x+150);
134 1 tmp=sqrt(tmp);
135 1 lineA=tmp;
136 1 return lineA;
137 1 }
138
139 unsigned int point_B (unsigned int x,unsigned int y) //變量轉換xy-b
140 {
141 1 unsigned int lineB;
142 1 unsigned int tmp;
143 1 tmp=(1150-y)*(1150-y)+(950-x)*(950-x);
144 1 tmp=sqrt(tmp);
145 1 lineB=tmp;
146 1 return lineB;
147 1 }
148 /*
149 unsigned int loc_X (int lineA,int lineB)//變量轉換ab-x
150 {
151 unsigned int loc;
152 loc = (lineA*lineA-lineB*lineB)/2200+400;
153 return loc;
154 }
155
156
157 void circle (unsigned int x,unsigned int y)//畫圓程序
158 {
159 unsigned char i;
160 unsigned int x1,y1;
161 float tmp1,tmp2;
162 unsigned int linex,liney;
163 unsigned int linex1,liney1;
164 x1=x-250;
165 y1=y;
166 linex=point_A(x1,y1);
167 liney=point_B(x1,y1);
168 for (i=0;i<360;i++)
169 {
170 //取絕對坐標
171 tmp1=sin(3.1415926*(1-i/180));
172 tmp2=cos(3.1415926*(1-i/180));
173
174 x1=x1+x1+25*tmp2;
175 y1=y1+25*tmp1;
176 linex1=point_A(x1,y1);
177 liney1=point_B(x1,y1);
178 za=linex-linex1;
C51 COMPILER V7.50 MAINLINE 09/10/2005 16:30:06 PAGE 4
179 zb=liney-liney1;
180 if (za>=0)runner1(za,1);
181 else runner1(-za,0);
182 if (zb>=0)runner1(zb,1);
183 else runner1(-zb,0);
184 }
185 }
186
187 void mypath (void)//將物體直線運動 5mm*200
188 {unsigned int x=0,y=0,i,ta,tb;//ta,tb a,b前一個狀態(tài)長
189 ta=a0;tb=b0;
190 for(i=0;i<=200;i++)
191 {
192 a=point_A(x,y);
193 b=point_B(x,y);
194 za=ta-a;//za,zb a,b的增量
195 zb=tb-b;
196 numa=za/stepleng;
197 numb=zb/stepleng;
198 runner1(numa,1);// 1/0表示掛線伸縮的方向
199 runner2(numb,1);
200 x=x+5;
201 y=y+5;
202 ta=a;
203 tb=b;
204 }
205
206 }
207
208 */
209
210 void main()
211 {
212 1
213 1 PA1=0;
214 1 PB1=1;
215 1 PC1=1;
216 1 sta1=0;//電機1初始化
217 1 PA2=0;
218 1 PB2=1;
219 1 PC2=1;
220 1 sta2=0;//電機2初始化
221 1
222 1
223 1
224 1 display(send);
225 1
226 1 runner1(1500,1);
227 1 for(;;);
228 1
229 1
230 1 }
231
232
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 586 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 35 ----
C51 COMPILER V7.50 MAINLINE 09/10/2005 16:30:06 PAGE 5
IDATA SIZE = ---- ----
BIT SIZE = 1 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -