Esempio n. 1
0
task beep(){
  while(true){
     if(joy1Btn(8) == 1){
       PlaySound(soundBeepBeep);
       wait1Msec(500);
    }
    endTimeSlice(); //makes way for other tasks to run; ends its allotted "time slice"
  }
}
Esempio n. 2
0
task KeepArmInPosition()
{
  while(true)
  {
    currentError = armPosition - SensorValue[ArmPoten];
    derivative = currentError - lastError;
    lastError = currentError;
    integral = 0.9 * integral + currentError;

    motorPower = kP * currentError + kD * derivative + kI * integral;
    motorPower = abs(motorPower) > motorThres ? motorPower : 0;

    if (armPosition >= maxArm && motorPower < 15)
      motorPower = 15;

    LiftArm(motorPower);
    endTimeSlice();
  }
}