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

📄 process.bak

📁 Welding Robot controller C Embedded Program on micro-controller.
💻 BAK
字号:


//------- run robot in continuous mode --------------------------------------//
void runCont () {
  output_high(WELDING);
  while (run) {
    //controlRobotSpeed(inSpeed);
    controlWeaver();
    controlRobotSpeed(InSpeed);
    delay_ms(8);

    //controlWeaver(00);
   // delay_ms(70);//SAMPLING_TIME
    // set_adc_channel(0);
    // delay_us(10);
      //inWeaveSpeed = read_adc();
     // printf("Speed=  %ld\r",inWeaveSpeed);
     // set_adc_channel(1);
     // delay_us(10);
     // p = read_adc();
    //  printf("bientro=  %ld\r",P);
  }
  output_low(WELDING);
  controlRobotSpeed(0);
  resetWeaver();
}

//------- run robot in intermitted mode -------------------------------------//
void runInt () {
  float   weldTime    = 0;
  float   noWeldTime  = 0;
  float   ctrlTime    = 0;
  int     speed       = 0;
  int1    isWelding   = 1;

  speed       = inSpeed;
  weldTime    = (float) inSeg / (float) inSpeed;
  noWeldTime  = (float) inGap / (float) MAX_SPEED;


  while (run) {
    // switch from welding to none-welding and vice versa
    if (isWelding && (ctrlTime > weldTime)) {
      isWelding    = 0;
      speed        = MAX_SPEED;
      ctrlTime     = 0;

    }else if ((!isWelding) && (ctrlTime > noWeldTime)) {
      isWelding    = 1;
      speed        = inSpeed;
      ctrlTime     = 0;
    }

    controlRobotSpeed(speed);
    controlWeaver();
    output_bit(WELDING, isWelding);              // on - off welding machine

    //printf("ctr= %f\r",ctrlTime);
    ctrlTime  +=(float)SAMPLING_TIME/1000;

    //delay_ms(SAMPLING_TIME);
  }
  output_low(WELDING);
  controlRobotSpeed(0);
  resetWeaver();
}


//------- run robot in spot-welding mode ------------------------------------//
void runSpot () {
  int16   nSpot       = 0;
  float   weldTime    = 0;
  float   noWeldTime  = 0;
  float   switchTime  = 0;
  float   ctrlTime    = 0;
  int1    isWelding   = 1;
  int     speed       = 0;

  weldTime    = (float) SPOT_TIME;
  noWeldTime  = (float) inGap / (float) MAX_SPEED;

  while (run) {
    // switch from welding to none-welding and vice versa
    if (isWelding && (ctrlTime > weldTime)) {
      isWelding    = 0;
      speed        = MAX_SPEED;
      ctrlTime     = 0;
    }else if ((!isWelding) && (ctrlTime > noWeldTime)) {
      isWelding    = 1;
      speed        = 0;
      ctrlTime     = 0;
    }

    controlRobotSpeed(speed);
    controlWeaver();
    output_bit(WELDING, isWelding);                // on - off welding machine
    ctrlTime += (float) SAMPLING_TIME / 1000;
    //ctrlTime += (float) SAMPLING_TIME / 1000;
    printf("ctr= %f\r",ctrlTime);
    //delay_ms(SAMPLING_TIME);
  }
  output_low(WELDING);
  controlRobotSpeed(0);
  resetWeaver();
}

//------- run robot in trapezoid mode ---------------------------------------//
void runTrapezoid() {
  int16 temp = 0;
  int16 wdelay;
  if (!useWeaver) return;
  wdelay = inGap * 100 / SAMPLING_TIME;

  output_high(WELDING);
  while (run) {
    controlRobotSpeed(inSpeed);
    if (atBorder) {
      controlWeaver();
    	if (++temp > wdelay) {
    		atBorder = 0;
        temp = 0;
    	}
    }else {
      controlWeaver();
    }
    delay_ms(SAMPLING_TIME);
  }
  output_low(WELDING);
  controlRobotSpeed(0);
  resetWeaver();
}

//------- run robot in square mode ------------------------------------------//
void runSquare() {
  int16 temp = 0;
  int16 wdelay;
  if (!useWeaver) return;
  wdelay = inGap * 100 / SAMPLING_TIME;

  output_high(WELDING);
  while (run) {
    if (atBorder) {
      controlWeaver();
      controlRobotSpeed(inSpeed);
    	if (++temp > wdelay) {
    		atBorder = 0;
        temp = 0;
    	}
    }else {
      controlWeaver();
      controlRobotSpeed(0);
    }
    delay_ms(SAMPLING_TIME);
  }
  output_low(WELDING);
  controlRobotSpeed(0);
  resetWeaver();
}

⌨️ 快捷键说明

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