View unanswered posts | View active topics It is currently Wed Sep 19, 2018 2:56 pm






Reply to topic  [ 3 posts ] 
I2c on EV3 with robotC 4.26 
Author Message
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
Post I2c on EV3 with robotC 4.26
Hello,

I am trying to get a mindsensors NXTServo-V2 working with the EV3.
I created a smaller code whitch regenerates the problem. I know it will never work this way, but it compiles and generates an error on the EV3 but not on NXT
Code:
task main()
{
   ubyte volt;
   readI2CReply(S1, &volt, 1);
}

This is the RobotC debugger Exception
Code:
Exception Error in User Program:
   
   Exception Type: 'Real Address Range Exception(59)'
   
   Program Slot: 0, Task ID: main[0]
   Error at PC: Task: main+0x0017
   TaskState: 'Exception'

I know it has something to do with pointers but i cannot figure out what. Any ideas?
To test this code it is not necessary to connect a NXTServo.

some longer piece of code which displays battery voltage of the NXTServo:
Code:
ubyte MS_Servo_SendMsg[5];
char MS_servo_replyMsg[2];
tSensors MS_Servo_port;

const int MS_Servo_ID       = 0xb0;
const int MS_Servo_VbattReg = 0x41;

void servoSetPort(tSensors port)
{
  MS_Servo_port=port;
#ifdef NXT
  SensorType[MS_Servo_port] = sensorI2CCustomFastSkipStates;
#endif

#ifdef ev3
     SensorType[MS_Servo_port] = sensorI2CCustom9V;   //   sensorEV3_GenericI2C
#endif
}

int  servoGetBattV()
{
  // Build the I2C message
  MS_Servo_SendMsg[0] = 2;
  MS_Servo_SendMsg[1] = MS_Servo_ID ;
  MS_Servo_SendMsg[2] = MS_Servo_VbattReg;

//  waitForI2Cbus();
  sendI2CMsg(MS_Servo_port, &MS_Servo_SendMsg[0], 1);
//  waitForI2Cbus();
  delay(10);
 readI2CReply(MS_Servo_port, &MS_servo_replyMsg[0], 1); //Error is generated at this line
//  return 0;
    return(37*(0x00FF & MS_servo_replyMsg[0]));  // 37 is calculated from supply from NXT =4700 mv /128
}

task main()
{
   int batVoltage=0;
   servoSetPort(S1);
   delay(10);
   batVoltage=servoGetBattV();
   displayBigTextLine(3, "%d V",batVoltage);
   delay(100000);
}

/* EV3 error when running code
Exception Error in User Program:
   
   Exception Type: 'Real Address Range Exception(59)'
   
   Program Slot: 0, Task ID: main[0]
   Error at PC: servoGetBattV+0x003B
   TaskState: 'Exception' 
*/


Wed Oct 22, 2014 7:35 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: I2c on EV3 with robotC 4.26
Have you tried making the variable volt a single item array? As in ubyte volt[1];

Try that and see if it makes a difference.

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


Thu Oct 23, 2014 8:31 am
Profile WWW
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
Post Re: I2c on EV3 with robotC 4.26
You mean like this?
Code:
task main()
{
   ubyte volt[1];
   readI2CReply(S1, &volt[0], 1);
}


i get the exact same message.
I tryed figuring out how you are handling this in the driversuite, but its a bit too complicated for me.
But thanks anyway. Any other ideas?


Thu Oct 23, 2014 9:13 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.