View unanswered posts | View active topics It is currently Wed Aug 27, 2014 5:02 pm






Reply to topic  [ 5 posts ] 
Tasks on RobotC vs 2.31 
Author Message
Rookie

Joined: Sat Mar 19, 2011 2:32 am
Posts: 12
Post Tasks on RobotC vs 2.31
Tried to write a task for the cortex using vs 2.31. Task did not run. Copied the block of code from the task & pasted it into the autonomous section & it ran so I know the block of code is correct. Tried writing the task in vs 2.3. It didn't work. I had written a task back in November using vs 2.3 but at that time I was using the pic 5. This is the 1st time I'm using the task on the cortex. Please help. Thanks. jokai


Sat Mar 19, 2011 2:58 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: Tasks on RobotC vs 2.31
Hi Jokai,

Please post your code for the entire program to the forum, so I can take a look. Also, please detail what you mean when you say it doesn't work - doesn't run the code, code doesn't compile, ect.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Mon Mar 21, 2011 8:39 am
Profile
Rookie

Joined: Sat Mar 19, 2011 2:32 am
Posts: 12
Post Re: Tasks on RobotC vs 2.31
Jesse, here is a test code we used. The original was changed when the task wouldn't execute.
Code:
#pragma config(Sensor, dgtl1,  tip_switch,          sensorTouch)
#pragma config(Motor,  port2,           right_motor,   tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task stop_tip()
{
  while(1)
  {
    if (SensorValue[tip_switch] == 1)
    {
       motor[right_motor] = -50;
       wait1Msec(1000);
       motor[right_motor] = 0;
     }
  }
}

task main()
{

  StartTask(stop_tip);

   while (true)
   {
     motor[right_motor]  = vexRT[Ch2];

 /*   if (SensorValue[tip_switch] == 1)
    {
       motor[right_motor] = -50;
       wait1Msec(1000);
       motor[right_motor] = 0;
     }
*/
   }
}


When we realized the task wasn't executing in task main we wrote this simple code to test it out. It didn't execute the task when we used the fucntion StartTask. But when we copied the code from the task into the body of task main (the commented out block it ran so we know it isn't our block of code. Tried it in RobotC vs 2.3 & it also doesn't execute. Yet when we were using the pic 5 using vs 2.3 back in November it worked on the pic. Just doesn't work on the cortex. joan


Mon Mar 21, 2011 4:42 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Tasks on RobotC vs 2.31
Controlling the same motor from two tasks is a bad idea. Unless you add additional code in there, you are asking for issues.

If vexRT[Ch2] is 0, what do you suppose the value of the motor will be set to when it gets to that line in the main task? What do you think will happen to the motor when it is told to run at 50% in the other task a millisecond later, only to be told to run at whatever level vexRT[Ch2] is?

You need to rethink your program and try to look at it from the robot's perspective. Right now it's like having two people shouting at you, one in your right ear, one in your left ear and both are giving you different directions on where to go. Who are you going to listen to? :)

- 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]


Mon Mar 21, 2011 5:40 pm
Profile WWW
Rookie

Joined: Sat Mar 19, 2011 2:32 am
Posts: 12
Post Re: Tasks on RobotC vs 2.31
Thanks. We'll try & change the code. joan


Tue Mar 22, 2011 2:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.