View unanswered posts | View active topics It is currently Wed Sep 19, 2018 6:55 am






Reply to topic  [ 5 posts ] 
motorPWMLevel on 4.26 for NXT 
Author Message
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
Post motorPWMLevel on 4.26 for NXT
RobotC 3.x had a nice function to get the real output PWM on the motors
Code:
motorPWMLevel

This function does not excist in 4.26 for the NXT.
there is a new function
Code:
motorpowersigned[]

but this returns the setspeed and not the actual motorPWM.
I have used this to test the load on the motors.
Is there an other way to do this?


Sat Sep 27, 2014 5:00 pm
Profile
Rookie

Joined: Wed Sep 10, 2014 9:53 am
Posts: 20
Post Re: motorPWMLevel on 4.26 for NXT
It appears that the code to enable that command for the NXT was given the wrong conditional compile parameters. This will be fixed in the next release of ROBOTC.

Until the next version is released, you can add the following code to your program directly. Alternatively, if you have a lot of files that use the command, you can add the code to the end of the RobotCIntrinsics.c file in the Includes folder in the ROBOTC install folder.

Code:
#if defined(NXT)
intrinsic const short property(motorPWMLevel,               propertyMotorPWM,                   kNumbOfTotalMotors, tMotor);
#endif


Wed Oct 01, 2014 11:57 am
Profile
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
Post Re: motorPWMLevel on 4.26 for NXT
Thanks for the reply. I tryed both options and get both times the same errors:
Code:
**Error**:Undefined variable 'propertyMotorPWM'. 'short' assumed.
**Severe*:Constant Expression Expected
**Severe*:Property type expression is not compile time value.
**Error**:Unexpected ',' during parsing
**Error**:Expected->';'. Found ','
**Error**:Executable statements not valid in 'main' declaration block
**Error**:Missing 'Identifier' before ')'
**Error**:Unexpected ')' during parsing


Probably something else should be added somewhere?


Wed Oct 01, 2014 12:08 pm
Profile
Rookie

Joined: Wed Sep 10, 2014 9:53 am
Posts: 20
Post Re: motorPWMLevel on 4.26 for NXT
The problem is that "propertyMotorPWM" is not defined. There are several solutions but I think the best option is to just edit the property definition code that you added.

old:
Code:
#if defined(NXT)
intrinsic const short property(motorPWMLevel,               propertyMotorPWM,                   kNumbOfTotalMotors, tMotor);
#endif


new:
Code:
#if defined(NXT)
intrinsic const short property(motorPWMLevel,               29,                                 kNumbOfTotalMotors, tMotor);
#endif


Wed Oct 01, 2014 1:04 pm
Profile
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
Post Re: motorPWMLevel on 4.26 for NXT
Thanks. This is a little better. I made the folowing code:

Code:
#if defined(NXT)
intrinsic const short property(motorPWMLevel,               29,                                 kNumbOfTotalMotors, tMotor);
#endif

task main()
{

   int i=motorPWMLevel[motorA];
   delay(10000);
}


It compiles just fine. However running it generates an exception:

Code:
Exception Error in User Program:
   
   Exception Type: 'Get Property index out of range(8)'
   
   Program Slot: 0, Task ID: main[0]
   Error at PC: Task: main+0x0009
   Task PC: Task: main+0x0000,
   TaskState: 'Exception'


Any ideas?


Wed Oct 01, 2014 1:55 pm
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:  
cron



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