ROBOTC.net forums
http://www.robotc.net/forums/

Tasks on RobotC vs 2.31
http://www.robotc.net/forums/viewtopic.php?f=53&t=3131
Page 1 of 1

Author:  jokai [ Sat Mar 19, 2011 2:58 am ]
Post subject:  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

Author:  jbflot [ Mon Mar 21, 2011 8:39 am ]
Post subject:  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.

Author:  jokai [ Mon Mar 21, 2011 4:42 pm ]
Post subject:  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

Author:  mightor [ Mon Mar 21, 2011 5:40 pm ]
Post subject:  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

Author:  jokai [ Tue Mar 22, 2011 2:57 pm ]
Post subject:  Re: Tasks on RobotC vs 2.31

Thanks. We'll try & change the code. joan

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/