View unanswered posts | View active topics It is currently Sun Sep 21, 2014 4:04 am






Reply to topic  [ 5 posts ] 
ev3 program doesn't run directly from brick 
Author Message
Rookie

Joined: Sat May 31, 2014 12:01 pm
Posts: 3
Post 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.


Sat May 31, 2014 12:29 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 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

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


Sat May 31, 2014 2:52 pm
Profile WWW
Rookie

Joined: Sat May 31, 2014 12:01 pm
Posts: 3
Post 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 ^^


Sat May 31, 2014 6:34 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 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

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


Sun Jun 01, 2014 1:08 am
Profile WWW
Rookie

Joined: Sat May 31, 2014 12:01 pm
Posts: 3
Post 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!


Sun Jun 01, 2014 11:50 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.