直立闭环+CCD.docVIP

  • 3
  • 0
  • 约1.63万字
  • 约 21页
  • 2017-12-22 发布于河南
  • 举报
直立闭环CCD

直立闭环+CCD #include includes.h unsigned char TimerFlag20ms = 0; unsigned char Pixel[128]; unsigned char Pixel_average; int Pixel_DISTANCE0[128]; int Pixel_DISTANCE1[128]; int threshold; int mid_sign; int left_drop=0, left_drop_sign; int right_drop=0,right_drop_sign; int start=0; float DISTANCE_BLACKLINE; //直立的参数也要修改 /************************** 零点 ****************************/ #define acceler_zero 1434.0 ///加速度计零点 /**************************直立参数**************************/ #define K_angle 15.0 //8.5 ///35.0 #define K_angle_dot 0.40 //0.32///0.40 /**************************速度参数**************************/ #define speed_set 3.0 ///39.400 #define K_speed 10.0 #define K_speed_dot 0.03 /**************************转向参数**************************/ #define K_Direction_P 0.25 #define K_Direction_D 0.232 #define K_Direction_I 0.000001 int TimerCnt20ms = 0; int part=0; int Speedsmooth_count=0; int Speedcontrol_count=0; int Directionsmooth_count=0; int Directioncontrol_count=0; /************************** 死区参数 ************************/ #define deadzone 2 //-------------- 初始化函数 ----------------// //----- 时钟初始化程序 --------// void PLL_Init(void) //PLLCLK=2*OSCCLK*(SYNR+1)/(REFDV+1) { //BUS CLOCK=64M 总线是64M的; CLKSEL=0X00; //disengage PLL to system PLLCTL_PLLON=1; //turn on PLL SYNR =0xc0 | 0x07; REFDV=0x80 | 0x01; POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=128MHz; _asm(nop); //BUS CLOCK=64M _asm(nop); while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it; CLKSEL_PLLSEL =1; //engage PLL to system; } //-----PIT 初始化程序 --------// void PIT_Init(void)//定时中断初始化函数 0.001s=1ms定时中断设置 { PITCFLMT_PITE=0; //禁止PIT PITCE_PCE0=1; //定时器通道0 使能 PITMTLD0=64-1; //8 位定时器初值设定。 PITLD0=1000-1; //16 位定时器初值设定 PITINTE_PINTE0=1;//定时器中断通道0 中断使能 PITCE_PCE1=1; //允许时钟通道1 PITMUX_PMUX1=1;

文档评论(0)

1亿VIP精品文档

相关文档