View unanswered posts | View active topics It is currently Mon Sep 21, 2020 4:20 pm






Reply to topic  [ 2 posts ] 
Events in RobotC 2.01 
Author Message
Rookie

Joined: Mon Feb 15, 2010 11:56 am
Posts: 2
Post Events in RobotC 2.01
I'm programming a robot using events in RobotC 2.01. My program was originally written in version 1.46 where it worked fine. However, when I updated to 2.01, it ceased working.
The main problem is that the catch block is not executed when the event is triggered, the code simply returns to the beginning of the monitor block.
Here's some code displaying the problem.
Code:
int i;

task display(){
  while(true){
    nxtDisplayBigTextLine(2,"I=%d",i);
    nxtDisplayBigTextLine(0,"US=%d",SensorValue[S1]);
    wait10Msec(1);
  }
}

task main(){
  SetEvent((const byte)1,S1,eventTypeEnterLow);
  eventLower[1]=10;
  SensorType[S1]=sensorSONAR;
  StartTask(display);
  while(true){
    monitor(EVENT_MASK(1)){
      while(true){
        for(i=0;i<5;i++){
          wait10Msec(100);
        }
        for(;i<15;i+=2){
         wait10Msec(100);
        }
      }
    }
    catch(EVENT_MASK(1)){
      i=10;
      PlayImmediateTone(440,250);
      wait10Msec(100);
    }
  }
}

When the US sensor sees less than 10 cm, the number 10 should be displayed, and a beep played, but the value of i simply resets to 0 instead.


Mon Feb 15, 2010 12:06 pm
Profile
Rookie

Joined: Mon Feb 15, 2010 11:56 am
Posts: 2
Post Re: Events in RobotC 2.01
bump

anyone have a solution to this? (besides using an older version of RobotC)


Mon Feb 22, 2010 4:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.