View unanswered posts | View active topics It is currently Sat Aug 30, 2014 6:31 pm






Reply to topic  [ 1 post ] 
Concurrent tasks 
Author Message
Rookie

Joined: Wed Feb 22, 2012 4:23 am
Posts: 10
Post Concurrent tasks
How do we insert code to move servos 1 and 12 to a different position at the same time as the rest of this code runs?

Code:
#pragma config(Hubs,  S1, HTServo,  HTServo,  HTMotor,  HTMotor)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C3_1,     motorD,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     motorF,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C4_2,     motorG,        tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_1,    servo7,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    servo8,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_3,    servo9,               tServoStandard)
#pragma config(Servo,  srvo_S1_C2_4,    servo10,              tServoStandard)
#pragma config(Servo,  srvo_S1_C2_5,    servo11,              tServoStandard)
#pragma config(Servo,  srvo_S1_C2_6,    servo12,              tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"  //Include file to "handle" the Bluetooth messages.

void initializeRobot()
{
  //from the front of the robot
  servo[servo1] = 138; //right bowling ball servo up pos
  servo[servo12] = 96; //left bowling ball servo up pos

  servo[servo7] = 0; //from the front, the left hand servo is a 0 when the arm is extended. It is at 229 when it is at its lowest.
  servo[servo8] = 0; //from the front, the right hand servo is a 26 when the arm is extended. It is at 255 when it is at its lowest.

  servo[servo9] = 225; //small servo joint
  servo[servo2] = 0;

  servo[servo11] = 225;
  return;
}

task main()
{
  nNoMessageCounterLimit = 200;
  initializeRobot();

  waitForStart(); // Wait for the beginning of autonomous phase.

 //Going forwards

  motor[motorD] = 40;
  motor[motorE] = -40;
  wait1Msec(2000);

  motor[motorD] = 0;
  motor[motorE] = 0;
  wait1Msec(500);

  //Going back

  motor[motorD] = -40;
  motor[motorE] = 40;
  wait1Msec(250);

  motor[motorD] = 0;
  motor[motorE] = 0;
  wait1Msec(500);

  //Turning

  motor[motorD] = 50;
  motor[motorE] = 50;
  wait1Msec(800);

  motor[motorD] = 0;
  motor[motorE] = 0;
  wait1Msec(500);

  //Going forward after turning

  motor[motorD] = -40;
  motor[motorE] = 40;
  wait1Msec(5000);

  motor[motorD] = 0;
  motor[motorE] = 0;
  wait1Msec(500);


  while (true)
  {}

}

Thanks,
Ming


Sat Feb 25, 2012 4:34 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.