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

ev3 program doesn't run directly from brick
http://www.robotc.net/forums/viewtopic.php?f=63&t=8910
Page 1 of 1

Author:  dadum [ Sat May 31, 2014 12:29 pm ]
Post subject:  ev3 program doesn't run directly from brick

Hi, I'm kinda new in programming with robotic, I have an ev3 robot (using robotc 4.10 beta and the last ev3 robotc firmware) and when I launch a program directly from robotc it works well, but when I try to start it directly from the brick, it doesn't start, giving e.g:

Code:
Exception Error in User Program:
   
   Exception Type: 'Bad integrity of internal task queues(42)'
   
   Program Slot: 0, Task ID: main[0]
   Error at PC: +0xD760
   Task PC: Task: main+0x0000,
   TaskState: 'Exception'


(Sometimes the "Exeption Type" like as the "Task ID" are different from this).

The code i tried to use is very simple:
Code:
task move() {
   while (true) {
      motor(motorB)=80;
      motor(motorC)=80;
      wait1Msec(50);
   }
}

task prox() {
   while (true) {
      if (SensorValue(irs)<10) {
         stopTask(move);
         motor(motorB)=-50;
         motor(motorC)=-50;
         wait1Msec(1000);
         startTask(move);
      }
      wait1Msec(50);
   }
}

task main()
{
   setSensorMode(irs, 0);
   
   startTask(prox);
   startTask(move);
   
   while (true) {
      wait1Msec(100);   
   }
}

The robot should just move until the IR sensor has a value < 10, than move backward for 1 sec start all again. It works well if started from robotc but not directly by selecting the program from the brick, like said before. Any tip to solve this?
Another thing I can't manage to do is using the "hogCPU" and "releaseCPU" statement instead of stop and start the "move" task again, the code just stops to work if I try to use these two statements (at the same position of where the "stopTask" and "startTask" are)... I don't know if it's not supported by ev3 or if I'm just making some mistake... Thank you guys for support.

Author:  mightor [ Sat May 31, 2014 2:52 pm ]
Post subject:  Re: ev3 program doesn't run directly from brick

It seems to run just fine for me, but the way you are controlling the motors is very unorthodox, to say the least.

What exactly are you trying to achieve and why do you think you need tasks to do it?

This code does the same thing:
Code:
#pragma config(Sensor, S1,     irs,            sensorEV3_IRSensor)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  motor[motorB]=80;
  motor[motorC]=80;
 
  while (true) {
    if (SensorValue(irs)<10)
    {
      motor[motorB]=-50;
      motor[motorC]=-50;
      wait1Msec(1000);
      motor[motorB]=80;
      motor[motorC]=80;
    }
    wait1Msec(50);
  }
}

= Xander

Author:  dadum [ Sat May 31, 2014 6:34 pm ]
Post subject:  Re: ev3 program doesn't run directly from brick

Thank you for the answer, it's just a test program because i'll need to write a program with several tasks and i'm trying with something easier to begin... I know for such a simple program it isn't the best way to do it but i'm trying to fix it so that i can start it without having the brick connected to the computer. I think it could be some beta or firmware bug but if it isn't it would be nice to find a way to fix it ^^

Author:  mightor [ Sun Jun 01, 2014 1:08 am ]
Post subject:  Re: ev3 program doesn't run directly from brick

Multiple tasks are seldom the right way to go. Most programming problems are doable using just a single task. I would advise you to read the sticky post on multitasking here: [LINK], it's well worth the time.

= Xander

Author:  dadum [ Sun Jun 01, 2014 11:50 am ]
Post subject:  Re: ev3 program doesn't run directly from brick

Ok, I just tried with your code and it works well even if started from the brick, so I guess it was a problem in my code. I'm going to do how u suggested and structure my program in another way. Thank you for the support again!

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