智能车制作

标题: 贴出你的主程序,大家相互学习吧,我开个头! [打印本页]

作者: zzy2099    时间: 2010-8-28 10:15
标题: 贴出你的主程序,大家相互学习吧,我开个头!
摄像头组:

#include "smartcar.h"
void main(void)
{
                 
  ready_go();
  setspeed();
  setfun() ;
  for(;;)
  {  
   
      //angle_test();
      if(flag_bmp);
      {  
          bin_pic();
          search_image();
          calc_parameter();  
          calc_center();
          check_start();
          get_angle();
          flag_bmp=0;
      }
      get_speed();
  }                     
}
作者: zzy2099    时间: 2010-8-28 10:16
光电:
#include "shake_head.h"
void main(void)
{
  init();
  for(;;)
  {     
     light_led();
     if(check_start&&key1)   start();                           
     getposition();
     head();  
     direction();
     speedpid();
  }
}
作者: zzy2099    时间: 2010-8-28 10:18
电磁:

#include "Cpu.h"
#include "Events.h"


//================================================================================================

void main(void)
{

  unsigned long aa=800000;
  while(aa--);
  get_set_speed();
  PE_low_level_init();
  LCD_Initial();

  DDRB_DDRB3=1;       //设置B3口作为输出  测试周期
  return_ok=AD_Start();
   for(;;)
        {   
        get_line_data();
        calcu_position();
        calcu_angle_speed();
        control_angle_speed();
        PORTB_PB3=  ~PORTB_PB3;
        }
        
}
作者: chiusir    时间: 2010-8-28 22:35
不错,很简洁,模块化设计,顺序执行,逻辑清晰,功夫就在函数里,呵呵
作者: 段鹏飞    时间: 2010-10-5 10:49
void main(void)
{

  Set_BusCLK();
  Init_PWM();  
  PORT_Init();
  PIT_Init();
        EnableInterrupts;
       
  while(Scf_State){  //检测完成标志位
    //舵机控制
    Scf_State=0;
  }
  while(Speed_State){ //速度获取完成标志位
    //电机控制
    Speed_State=0;
  }

  for(;;) {
    _FEED_COP(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
这样的设计合理吗??
作者: 段鹏飞    时间: 2010-10-5 12:35
光电的 用的是中断采样
作者: 段鹏飞    时间: 2010-10-5 12:36
虚心求教
作者: 紫藤    时间: 2010-10-7 22:36
学习---
作者: zzy2099    时间: 2010-10-10 16:16
回复 5# 段鹏飞


    个人觉得用中断方式更好一些,更能精确控制好 采样周期和控制周期。
作者: 段鹏飞    时间: 2010-10-10 18:00
回复 9# zzy2099


    哦  中断 来检测采样 同样的用中断来给舵机PWM值 ,这样能避免给舵机的PWM值 不一定就在一个周期内或者超过一个周期
作者: 13xchun    时间: 2010-10-17 15:50
感谢无私分享
作者: xushu    时间: 2010-10-19 23:40
向师兄们学习!
作者: husthjp    时间: 2010-10-26 21:55
大公无私啊
作者: meizhen2008    时间: 2010-11-27 16:58
学习
作者: ccronaldo    时间: 2011-2-27 14:28
路过,准备自己写,学习下
作者: 傲视水影    时间: 2011-3-3 18:38
虚心请教
作者: ture_2010    时间: 2011-3-4 16:57
学习
作者: skywolf    时间: 2011-9-3 18:46
学习了
作者: 封剑    时间: 2011-9-11 09:37
学习了
作者: tju_speed    时间: 2011-9-11 10:20
光电:


void main(void)
{
  DisableInterrupts;
  Init();
  YeJing_LED=1;
  LCD_Print(0,0,"1aserLine");
  LCD_Print(0,1,"2:TestLaserRec");
  LCD_Print(0,2,"3:TestYaoTou");                 
  LCD_Print(0,3,"4:TestHongWai");
  LCD_Print(0,4,"5:TestRun");
  LCD_Print(0,5,"6:Run");
  switch(Select_Function())
  {
     case 1:
             for(;;)
             {
               U_Laser_A=1;
               D_Laser_A=1;
               DLY_ms(5);
               U_Laser_A=0;
               U_Laser_B=1;
               D_Laser_A=0;
               D_Laser_B=1;
               DLY_ms(5);
               U_Laser_B=0;
               U_Laser_C=1;
               D_Laser_B=0;
               D_Laser_C=1;
               DLY_ms(5);
               U_Laser_C=0;
               D_Laser_C=0;
               DLY_ms(5);
             }
             break;
     case 2:  
             for(;;)
             {
               DLY_ms(500);
               TestLaserRec();
             }
             break;
     case 3:
             TestYaoTou();
             break;
     case 4:
             Test();
             break;
     case 5:
             DLY_ms(500);
             Set_CanShu();
             speed_tab_init();
             DLY_ms(2000);     //2S自启动
             PACNT=0;
             U_Laser_C=1;
             EnableInterrupts;
             QiPao();
             for(;;)
             {
               Engine_Protect();
               QiPao_Process();
               Laser_Process();
             }
     case 6:
             DLY_ms(500);
             Switch_Dang();
             speed_tab_init();
             DLY_ms(2000);     //2S自启动
             PACNT=0;
             U_Laser_C=1;
             EnableInterrupts;
             QiPao();
             for(;;)
             {
               Engine_Protect();
               QiPao_Process();
               Laser_Process();
             }
  }
  // please make sure that you never leave main
  
}
作者: tju_speed    时间: 2011-9-11 10:22
什么情况?冒出来个表情。。。 冒号后面一个L
作者: 马路    时间: 2011-9-17 13:38
给力!谢谢,参考下。。。




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2