⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainokuse.lst

📁 用电键控制步进电机朝各个方向做曲线
💻 LST
📖 第 1 页 / 共 3 页
字号:
 240   1      //RunB(2500,0);
 241   1      DelayX10ms(1000);
C51 COMPILER V7.06   MAINOKUSE                                                             09/01/2006 15:13:01 PAGE 5   

 242   1      
 243   1      //for(test=0;test<200;test++)
 244   1      //{RunA(1,1);Delay(100);}
 245   1      //RunA(200,0);
 246   1      
 247   1      //Delay(5000);
 248   1      
 249   1      
 250   1      //Circle(400,500,250);
 251   1      //DelayX10ms(1000);
 252   1      //Mypath();
 253   1      //Trace();
 254   1      while(1);
 255   1      }
 256          
 257          void Display(unsigned char  *sd)//显示程序
 258          { 
 259   1          disp_buf[0] = sd[0];                        
 260   1          disp_buf[1] = sd[1];                
 261   1          disp_buf[2] = sd[2];   
 262   1          disp_buf[3] = sd[3];
 263   1          disp_buf[4] = sd[4];
 264   1          disp_buf[5] = sd[5];
 265   1          disp_buf[6] = sd[6];        
 266   1          disp_buf[7] = sd[7];
 267   1          ZLG7290_SendBuf(disp_buf,8);
 268   1      }
 269          
 270          void DelayX10ms(int count) //Delay time=count*10ms
 271          {
 272   1              unsigned int l,m,n;
 273   1      
 274   1              for(l=0;l<count;l++)
 275   1                      for(m=0;m<12;m++)
 276   1                              for(n=0;n<120;n++);
 277   1      }
 278          
 279          void Delay(unsigned char no)
 280          { 
 281   1              int  i,j;                                       //延时参数
 282   1              for(; no>0; no--)
 283   1              { 
 284   2                      for(i=0; i<10; i++)
 285   2                      for(j=0; j<100; j++)
 286   2                                  _nop_();
 287   2              }
 288   1      }
 289          
 290          void DelayAD(unsigned char no)
 291          { 
 292   1              int  i,j;                                       //搞整到轨道中心的每步所用延时参数,消除跳跃
 293   1              for(; no>0; no--)
 294   1              {       for(j=0; j<100; j++)
 295   2                                  _nop_();
 296   2              }
 297   1      }
*** WARNING C280 IN LINE 292 OF MAINOKUSE.C: 'i': unreferenced local variable
 298          
 299          
 300          //*/
 301          /*
 302          unsigned int Trace (void) //将物体直线运动 5mm*200
C51 COMPILER V7.06   MAINOKUSE                                                             09/01/2006 15:13:01 PAGE 6   

 303          {
 304                  int i;
 305                  unsigned ad;
 306                  ll++;
 307                  ll%=38;
 308                  if(ll==37)searthstep+=5;
 309                  if(searthstep>20||Traceflag>0) 
 310                  {
 311                          Traceflag++;
 312                          return 0;
 313                  }
 314                  ad=0;
 315                  for(i=0;i<20;i++)ad+=(float)(ad549());
 316                  ad/=20;
 317                  send[0]=ad%10;
 318                  send[1]=ad/10%10;
 319                  send[2]=ad/100%10;
 320                  send[3]=0;
 321                  send[4]=13;
 322                  send[5]=10;
 323                  send[6]=0;
 324                  Display(send);
 325                  DelayX10ms(1);
 326                  Ticks++;
 327                  if(Ticks==10)Ticks=5;
 328                  if(ad<gate) 
 329                  {
 330                          //*
 331                          if( (sqrt( (xlast-xolast)*(xlast-xolast)-((ylast-yolast)*(ylast-yolast)))<10)&&(Ticks>1))
 332                          {
 333                                  sita+=35;
 334                                  Lineto(xo+searthstep*sin(sita/360*2*Pi),yo+searthstep*cos(sita/360*2*Pi));
 335                                  Trace();        
 336                                  if(Traceflag>0)return 0;
 337                          }
 338                          else
 339                          //
 340                          {
 341                                  
 342                                  //测试
 343                                  //sita=45;
 344                          
 345                                  
 346                                  Lineto(xo+searthstep*sin(45/360*2*Pi),yo+searthstep*cos(45/360*2*Pi));
 347                                  xolast=xo;
 348                                  yolast=yo;
 349                                  xo=xlast;
 350                                  yo=ylast;
 351                                  searthstep=5;
 352                                  Trace();
 353                                  if(Traceflag>0)return 0;
 354                           }
 355                  }
 356                  else
 357                  {
 358                          sita+=35;
 359                          Lineto(xo+searthstep*sin(atan((yo-ybegin)/(xo-xbegin))/360*2*Pi),yo+searthstep*cos((yo-ybegin)/(xo-xbegi
             -n)/360*2*Pi));
 360                          Trace();
 361                          if(Traceflag>0)return 0;
 362                  }
 363                  return 0;
C51 COMPILER V7.06   MAINOKUSE                                                             09/01/2006 15:13:01 PAGE 7   

 364          }
 365          //*/
 366          /*
 367          unsigned int Trace (void) //将物体直线运动 5mm*200
 368          {
 369                  int i;
 370                  //while(;;)
 371                  {
 372                          while(ad1()<gate) RunA(1,pull);
 373                          for(i=0;i<80;i++)
 374                          {
 375                                  RunB(1,pull);
 376                                  if(ad549()<gate)break;
 377                          }
 378                          if(i==80)for(i=0;i<160;i++)
 379                          {
 380                                  RunB(1,push);
 381                                  if(ad549()<gate)break;  
 382                          }
 383                          if(i==160)
 384                          {
 385                                  RunB(80,pull);  
 386                                  RunA(65,pull);          
 387                                  yo++;
 388                          }
 389                          for(i=0;i<80;i++)
 390                          {
 391                                  RunA(1,pull);
 392                                  if(ad549()<gate)break;
 393                          }
 394                          if(i==80)for(i=0;i<160;i++)
 395                          {
 396                                  RunA(1,push);
 397                                  if(ad549()<gate)break;  
 398                          }
 399                          if(i==160)
 400                          {
 401                                  RunA(80,pull);  
 402                                  //RunB(45,push);                
 403                                  //yo++;
 404                          }
 405                          Trace();
 406                          xo++;
 407                          if(xo>20||yo>=3)return ;
 408                  }
 409          }
 410          //*/
 411          
 412          
 413          
 414          /*
 415          void Go_ru(bit dir) //右上
 416          {
 417          /*      int i,i1;
 418                  i=ad549();
 419                  send[0]=i%10;
 420                  send[1]=i/10%10;
 421                  send[2]=i/100%10;
 422                  send[3]=i/1000%10;
 423                  send[4]=13;
 424                  send[5]=10;
 425                  send[6]=0;
C51 COMPILER V7.06   MAINOKUSE                                                             09/01/2006 15:13:01 PAGE 8   

 426                  Display(send);
 427                  if(flag_trace<97)return ;
 428          
 429                  if(dir==0)
 430                  {
 431                          RunA(10,push);
 432                          if(ad549()<gate)//正常
 433                          {
 434                                  Go_ru(1);
 435                                  flag_trace=99;
 436                          }
 437                          else //没找到
 438                          {
 439                                  RunB(20,push); //zhaohuilailiao
 440                                  if(ad549()<gate)//正常
 441                                  {
 442                                          Go_rd(1);
 443                                          flag_trace=99;  
 444                                  }
 445                                  else //没找到
 446                                  {
 447                                          RunB(20,pull); //tuihuiqu       
 448                                          Go_rd(0);
 449                                          flag_trace--;
 450                                  }
 451                          }
 452              }
 453                  else
 454                  {
 455                          RunB(10,pull);
 456                          if(ad549()<gate)//正常
 457                          {
 458                                  Go_ru(0);
 459                                  flag_trace=99;
 460                          }
 461                          else //没找到
 462                          {
 463                                  RunB(20,pull); //zhaohuilailiao
 464                                  if(ad549()<gate)//正常
 465                                  {
 466                                          Go_ru(0);
 467                                          flag_trace=99;  
 468                                  }
 469                                  else //没找到
 470                                  {
 471                                          RunB(20,pull); //tuihuiqu       
 472                                          Go_rd(0);
 473                                          flag_trace--;
 474                                  }
 475                          }
 476              }
 477          }
 478                  
 479          
 480          /*
 481                  int i,i1;
 482                  i=ad549();
 483                  send[0]=i%10;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -