Ejemplo n.º 1
0
void model1()
{
    /* clear all pixels */
    glClearColor (0.0, 0.0, 0.0, 0.0);//default background for white
    glClear (GL_COLOR_BUFFER_BIT);
    
    /* print coordinate */
    grid();
    coordinate();
    function_1();
    function_2();
    function_3();
    function_4();
    /* buffer */
    glFlush();
}
Ejemplo n.º 2
0
void main( void )
{
  WDT_init();
  UCS_init();
  TimerA1_init();
  TimerB0_init();
  UART_init(UCA1,115200);
  RotaryEncoder_init();
  
  keyboard_init();
//  GUI_init();
  
  Motor_init();
  
  {  
    RP.myOutput = 0;
    RP.myInput = &E1_absPulseCnt;
    RP.mySetpoint = 0;
    RP.inAuto = 1;
    PID_setOutputLimits(&RP, (signed long)-100, (signed long)100);//(加速度)    
//    PID_setOutputLimits(&RP, (signed long)-600, (signed long)600);    
    RP.SampleTime = 5;
    PID_setControllerDirection(&RP, 1);
    PID_setTunings(&RP, 184, 7000, 34);                              //400,0,0 //184,6000,35
    if (TimeBase>RP.SampleTime)
      RP.lastTime = TimeBase-RP.SampleTime;
    else
      RP.lastTime = 0;    
  }
  
  _EINT();
  
//  while(UCA1_GET_CHAR(&command));
  _DINT();
  E1_pulseCnt=2000;
  E2_pulseCnt=0;
  E1_pulseInLastMs=2000;
  _EINT();
  
  startTime = TimeBase;
  
//  Motor_config(362);
  
//  Clear_Screen();
//  TFT_Menu_StartMenu();  
  
  while(function_3());
  
  /*
  
  while(1)
  {
    
//主要任务
    switch(function)
    {
      
    case 1:
      break;
      
    case 2:
      break;
      
    case 3:


      break;
      
    case 4:

      
      break;
    case 5:
      break;
    case 6:
      if (E1_absPulseCnt==0)
      {
        function6Flag=1;
        function6_E2_pulseCnt=E2_pulseCnt;
        function6_speed=400;
      }
      if (function6Flag)
      {
//          if((!PID_compute(&RP))&&(abs(E2_pulseCnt-function6_E2_pulseCnt)<2000))
          {
            speed+=RP.myOutput;
            speed-=E2_interval;
            if (speed>0)
              speedSign = 1;
            else if (speed<0)
              speedSign = -1;
            else
              speedSign = 0;
            if (abs(speed)>900)
              speed=speedSign*900;
            if (speedSign>0)
              Motor_config(speedSign*400+speed/3+5);
            else
              Motor_config(speedSign*400+speed/3+5);
//          }
  
        if ((abs(E1_absPulseCnt)<500)&&(abs(E1_absPulseCnt)>2))
        {
          RP.inAuto=1;
    //      PID_setMode(&RP,AUTOMATIC);
          if(!PID_compute(&RP))
          {
            speed+=RP.myOutput;
            speed-=E2_interval*3;
            if (speed>0)
              speedSign = 1;
            else if (speed<0)
              speedSign = -1;
            else
              speedSign = 0;
            if (abs(speed)>900)
              speed=speedSign*900;
            if (speedSign>0)
            {
                Motor_config(speedSign*400+speed/3+5);
            }
            else
            {
                Motor_config(speedSign*400+speed/3+5);
            }
          }
          if(abs(E2_pulseCnt-function6_E2_pulseCnt)>2000)
          {
            function6Flag=0;
            Motor_config(0);
          }          
        }
      }
      else
      {
        Motor_config(0);
        if ((abs(E1_absPulseCnt)>1990)&&(function6Flag))
        {
          function6Flag=0;
        }
      }
      break;
    default:
      break;
    }
    

    
  }*/
}