View unanswered posts | View active topics It is currently Fri Oct 24, 2014 12:34 pm






Reply to topic  [ 6 posts ] 
Constants declared in #pragmas not working in 1.93... 
Author Message
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Constants declared in #pragmas not working in 1.93...
The following code does not compile:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     MOTOR_LEFT,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     MOTOR_RIGHT,   tmotorNormal, openLoop)
#pragma config(Servo,  servo1,          SERVO_ARM,            tServoNormal)
#pragma config(Servo,  servo2,          SERVO_CLAW,           tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#define CLAW_OPEN          200
#define ARM_HOME           120

void InitializeRobot()
{
    // make sure claw is in open position, arm is retracted
    servo(SERVO_CLAW) = CLAW_OPEN;
    servo(SERVO_ARM) = ARM_HOME;
}

task main()
{
    InitializeRobot();

}



It procuces the following errors on the two statements in InitializeRobot():

Code:

**Error**:Undefined variable 'SERVO_CLAW'. 'short' assumed.
**Error**:Undefined variable 'SERVO_ARM'. 'short' assumed.


_________________
Jeff McBride
Benson Robotics Club


Tue Sep 22, 2009 3:03 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: Constants declared in #pragmas not working in 1.93...
Jeff,
Is that code from a 1.46 program you opened up in 1.93? If so, I had a similar problem.
I don't have access to RobotC at the moment, but as I recall, I completely re-entered the servos in the Motor/Servo setup screens and it replaced the #pragma entries for the servos with an updated syntax which then compiled fine. I can't remember what was different about the syntax, but if you are having the same issue, maybe you can post the changes?
Thanks,
l0jec


Tue Sep 22, 2009 8:14 am
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: Constants declared in #pragmas not working in 1.93...
Running through the Motor and Sensor Setup Wizard again and reentering all of the data did not fix the problem It still doesn't compile.

_________________
Jeff McBride
Benson Robotics Club


Tue Sep 22, 2009 10:37 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: Constants declared in #pragmas not working in 1.93...
If you deleted the existing #pragma info and then re-entered it from scratch, then I'm not sure why you're still seeing an issue. I'm pretty sure I have code in 1.93 with motor/servo #pragma statements with aliases defined as constants which compile for me...
I'll double check this evening if you still have the issue unresolved.


Tue Sep 22, 2009 10:57 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: Constants declared in #pragmas not working in 1.93...
Jeff,
I get the same error with your code, but the workaround of re-entering the servos in the Motor/Servo setup does resolve the issue for me. Specifically, I renamed each servo, clicked Apply, then renamed them back, and clicked Apply again. Here I suspect the IDE will not update the #pragma statements unless it detects a change.

The #pragma statements for the servos changed from this:
Code:
#pragma config(Servo,  servo1,          SERVO_ARM,            tServoNormal)
#pragma config(Servo,  servo2,          SERVO_CLAW,           tServoNormal)

To this:
Code:
#pragma config(Servo,  srvo_S1_C2_1,    SERVO_ARM,            tServoNormal)
#pragma config(Servo,  srvo_S1_C2_2,    SERVO_CLAW,           tServoNormal)

Note the different addressing scheme; I suspect this specific change is to allow multiple servo controllers in the new version of RobotC?

Perhaps we need to put together a migration tip sheet for users porting code from 1.46 to 1.93 as this is not entirely intuitive?

Regards,
l0jec


Tue Sep 22, 2009 6:28 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Constants declared in #pragmas not working in 1.93...
A few of the sensors have new names, too. An example of this is the I2C sensor at normal speed. It was called "sensorI2CCustomStd" in 1.46 but in 1.9x it's "sensorLowSpeed". The "sensorI2CCustomStd" name still works but is substituted when you run the wizard. This does render your code unusable for people using 1.46, so I tend to edit those pragmas by hand :)

Regards,
Xande

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


Wed Sep 23, 2009 3:26 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.