View unanswered posts | View active topics It is currently Fri Apr 18, 2014 4:47 am






Reply to topic  [ 4 posts ] 
hyyyy please help, with ROBOTc 
Author Message
Rookie

Joined: Tue Mar 01, 2011 6:16 pm
Posts: 21
Post hyyyy please help, with ROBOTc
hello, I'm 17 and im starting with a project in the school. In this project i wanna make a lego robot, so i'm using ROBOTC for first time
I know im a nob, but i want to learn as much I can.
the problem is that my english is not too much god, for understand this program ( im a spanish man). I want to ask, how i can do more than one Task. For example: i want the robot to go forward until the touchsensor detects any wall. After this i want the robot to go backwards, and turns 180 degress. And after 2 seconds begin to move the motor A ( power = 100). when the motor A its working ( for 10 seconds) i want the robot goes 2 seconds forwards, and turns at left hand ( for 2 or 3 seconds)

please help me, and sorry for my bad bad english.


Tue Mar 01, 2011 6:25 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: hyyyy please help, with ROBOTc
Ola ebille69,

You don't need multitasking for this. I broke down your requirements into the separate tasks but as you can see, they're all run after one another (nothing at the same time):

  1. i want the robot to go forward until the touchsensor detects any wall.
  2. After this i want the robot to go backwards,
  3. and turns 180 degress.
  4. And after 2 seconds begin to move the motor A ( power = 100).
  5. when the motor A its working ( for 10 seconds)
  6. i want the robot goes 2 seconds forwards,
  7. and turns at left hand ( for 2 or 3 seconds)

What you need to do is look at one of these in the list and write some code to accomplish this. I will help you get started, but I am not going to write your whole program for you. If I did that, you wouldn't learn anything from this :)

Code:
#pragma config(Sensor, S1,     TOUCH,               sensorTouch)
#pragma config(Motor,  motorA,          MOTOR_A,       tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorB,          MOTOR_LEFT,    tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorC,          MOTOR_RIGHT,   tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*
 * 1 i want the robot to go forward until the touchsensor detects any wall.
 * 2 After this i want the robot to go backwards,
 * 3 and turns 180 degress.
 * 4 And after 2 seconds begin to move the motor A ( power = 100).
 * 5 when the motor A its working ( for 10 seconds)
 * 6 i want the robot goes 2 seconds forwards,
 * 7 and turns at left hand ( for 2 or 3 seconds)
 */

// This is the main task from which all the other commands are started
task main ()
{

  /*
   * 1 i want the robot to go forward until the touchsensor detects any wall.
   */

  // Start the motors to move the robot forwards at 50%
  motor[MOTOR_LEFT] = 50;
  motor[MOTOR_RIGHT] = 50;
 
  // keep moving until the touch sensor detects a wall
  // Check the bumper every 10 miliseconds
  while (SensorBoolean[TOUCH] == false)
  {
    wait1Msec(10);
  }
 
  // Stop the motors when the wall has been detected
  motor[MOTOR_LEFT] = 0;
  motor[MOTOR_RIGHT] = 0;

  /*
   * 2 After this i want the robot to go backwards,
   */

  // Start the motors to move the robot backwards at 50%
  motor[MOTOR_LEFT] = -50;
  motor[MOTOR_RIGHT] = -50;

  /*
   * 3 and turns 180 degress.
   */


  /*
   * 4 And after 2 seconds begin to move the motor A ( power = 100).
   */


  /*
   * 5 when the motor A its working ( for 10 seconds)
   */


  /*
   * 6 i want the robot goes 2 seconds forwards,
   */


  /*
   * 7 and turns at left hand ( for 2 or 3 seconds)
   */
}


Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Mar 02, 2011 3:30 am
Profile WWW
Rookie

Joined: Thu Feb 10, 2011 4:09 pm
Posts: 12
Post Re: hyyyy please help, with ROBOTc
Xander is this information you guys talking about is for the Cortex vex net


Wed Mar 02, 2011 10:54 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: hyyyy please help, with ROBOTc
No, this is for the NXT but it shouldn't be hard to make it work on the Cortex.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Mar 03, 2011 3:15 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

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.