View unanswered posts | View active topics It is currently Tue Jun 18, 2013 4:01 am






Reply to topic  [ 3 posts ] 
Exception Violation Report 14 
Author Message
Rookie

Joined: Thu Jul 28, 2011 10:54 pm
Posts: 2
Post Exception Violation Report 14
Hi!
I'm asking my question on this forum because a) I have no idea how to fix it, and b) I haven't been able to find any instance of anyone who has had this specific problem, however, I do realize that several people have had this general error, such as this person: viewtopic.php?f=1&t=3312

This is the exact error I'm getting:

ROBOTC Exception Violation Report
Byte Code Interpreter Exception:

Program Slot: 0, Task ID: main[0]
Error at PC: Sub: readSonar1+0x002A
Task PC: Sub: readSonar1+0x002A
TaskState: 'Exception'
Exception Type: 'Shift value Out of range(14)'


Anyways, to clarify, I have RobotC v2.26, running on a Windows XP system (if that information helps at all.)
I am trying to write a program where I have a simple two-wheeled, individual-wheel-drive robot with one SONAR sensor mounted on a motor at the front. I am running a fairly basic code (see below for an example of v2.01 of the code). However, it does not matter what the rest of the code is, but whenever the program is running, as soon as it tries to execute this line:
Code:
if(sonarRead >> SensorValue[SONAR])
and/or this line:
Code:
while(sonarRead >> SensorValue[SONAR])
I get the error and the program quits/stops. Any help on this error would be greatly appreciated.
(I have tried restarting RobotC and my computer, and that makes no difference.)
Essentially I'm getting an error when I try to compare a known value to the SONAR sensor value. (I haven't checked to see if the light sensor/sound sensor also get this error, although I'm assuming they would.)

Code:
#pragma config(Sensor, S1,     SONAR,               sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
int sonarRead, lowLeft, lowRight, leftSpeed, rightSpeed;

void readSonar1()
{
   nMotorEncoder[motorA] = 0;
   nMotorEncoderTarget[motorA] = -40;
   motor[motorA] = -40;
   sonarRead=300;
   while(nMotorRunState[motorA] != runStateIdle)
   {
      if(sonarRead >> SensorValue[SONAR])
      {
         sonarRead = SensorValue[SONAR];
      }
   }
   lowLeft=sonarRead;
   nMotorEncoder[motorA] = 0;
   nMotorEncoderTarget[motorA] = -40;
   motor[motorA] = -40;
   sonarRead=300;
   while(nMotorRunState[motorA] != runStateIdle)
   {
      if(SensorValue[SONAR] << sonarRead)
      {
         sonarRead = SensorValue[SONAR];
      }
   }
   lowRight=sonarRead;
}

void readSonar2()
{
   nMotorEncoder[motorA] = 0;
   nMotorEncoderTarget[motorA] = 40;
   motor[motorA] = 40;
   sonarRead=300;
   while(nMotorRunState[motorA] != runStateIdle)
   {
      if(SensorValue[SONAR] << sonarRead)
      {
         sonarRead = SensorValue[SONAR];
      }
   }
   lowRight=sonarRead;
   nMotorEncoder[motorA] = 0;
   nMotorEncoderTarget[motorA] = 40;
   motor[motorA] = 40;
   sonarRead=300;
   while(nMotorRunState[motorA] != runStateIdle)
   {
      if(SensorValue[S1] << sonarRead)
      {
         sonarRead = SensorValue[SONAR];
      }
   }
   lowLeft=sonarRead;

}

void getSpeed()
{
   rightSpeed=lowLeft/5;
   leftSpeed=lowRight/5;
}

void drive()
{
   motor[motorB] = leftSpeed;
   motor[motorC] = rightSpeed;
}

task main()
{
   while(true)
   {
      readSonar1();
      getSpeed();
      drive();
      readSonar2();
      getSpeed();
      drive();
   }
}


Thu Jul 28, 2011 11:27 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2904
Location: Rotterdam, The Netherlands
Post Re: Exception Violation Report 14
If you are trying to compare two values, you need to use < and >, not << and >>.

The >> and << operators are for bit-shifting :)

More info about bit-shifting here: http://en.wikipedia.org/wiki/Logical_shift

- Xander

_________________
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)

| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Jul 29, 2011 1:19 am
Profile WWW
Rookie

Joined: Thu Jul 28, 2011 10:54 pm
Posts: 2
Post Re: Exception Violation Report 14
Whoops. DUH
I guess I was thinking since in if an while statements && and || are used, then >> and << are used also.
Hopefully that fixes the problem!
Thanks!


Fri Jul 29, 2011 6:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 4 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:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.