View unanswered posts | View active topics It is currently Sat May 25, 2013 10:11 am






Reply to topic  [ 8 posts ] 
RobotC Motor Control 
Author Message
Novice

Joined: Thu Jan 28, 2010 6:13 pm
Posts: 51
Post RobotC Motor Control
Hi,

As some of you already know I'm a newbie of RobotC. I was looking at motor Control. I see that there is a function "nMotor" that sets the motor power (i.e. PWM control duty cycle) so you can apply a percentage of full battery voltage. This only for "open loop" motor setting, isn't it? If I've understood the functionality, when i choose "cloosed loop" functionality using the internal PID control and setting the max regulated speed the value of "nMotor" is no more the percentage of battery level applied but the percentage of max velocity i have set up, am I wrong?

Thanks,
Marco.


Sat Jan 30, 2010 5:29 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: RobotC Motor Control
Hiya Marco,

That is pretty much correct, yes. The PID regulator has an idea of what constitutes 100% speed, so therefore also how quickly the motors should rotate at 40 or 60%. When you set the power to 50% and the motor becomes more loaded, the speed will drop. The PID regulator will then increase the power to the motor to try and maintain this 50% speed.

Please note that if you set the motor to 100% and apply a load, it won't be able to maintain the speed, there's no more than 100% power :) If that were the case, we would've solved the world's power problem; just use an NXT and ROBOTC! There is also an issue that the official firmware from Lego has an unrealistic idea of how many rpm constitutes 100%, that means you can't really ever maintain that speed very reliably. ROBOTC maintains the same standard for backwards compatibility. If you want a constant speed at a variety of loads, I would try to stay around 80-85% max.

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]


Sat Jan 30, 2010 9:59 am
Profile WWW
Novice

Joined: Thu Jan 28, 2010 6:13 pm
Posts: 51
Post Re: RobotC Motor Control
Hi Xander.

Your answer is complete as usual. :)
I understand the problem of speed keeping at different load conditions infact i've put the nMotor[] al 75 in my esperiment so i'm sure that the regulated speed is what i'm asking to the NXT motor no matter the load is.

One more and last question about Motors. What time interval for the PID control do you suggest me to put? 10ms is too much?

Everyday i understand more and more about RobotC and i've to say that it's fantastic because it's just like Ansi C: simple, efficient and very schematic. :)

Regards,
Marco.

P.S. Xander excuse me for the many question i'm aking to you but as a mathematican i am very precise and i need to understand things deeply. :)


Sat Jan 30, 2010 4:52 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 2864
Location: Rotterdam, The Netherlands
Post Re: RobotC Motor Control
marco.francini wrote:
One more and last question about Motors. What time interval for the PID control do you suggest me to put? 10ms is too much?

There should be no reason for you to really mess with this parameter. Leave it as is.

Quote:
P.S. Xander excuse me for the many question i'm aking to you but as a mathematican i am very precise and i need to understand things deeply. :)

Don't worry about it. It is better to ask than to wonder and speculate :)

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]


Sat Jan 30, 2010 5:46 pm
Profile WWW
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: RobotC Motor Control
Hi,

RobotC has an array called motorPWMlevel. It tells you how much power is going to each of the motors. To be precise, it tells what percentage of the time power is going to the motors. This info is very usefull if you want to understand regulated speed or when you want to set the maximum level of the regulated speed.

On my blog there is a post about regulated speed. It doesn't explain the working of it but it has a nice graph of regulated speed in action. It is found at nxttime.wordpress.com

_________________
My most recent blog: A grain of sugar


Sun Jan 31, 2010 9:39 am
Profile WWW
Novice

Joined: Thu Jan 28, 2010 6:13 pm
Posts: 51
Post Re: RobotC Motor Control
Hi Aswin.

Ah! I didn't see that array on RobotC Hel! I understand the meaning of that array but it seems very similar to motor[] in "open loop" configuration, isn't it? But where can i find a full documentation of RobotC arrays/functions because that one it's not present in the official help.

Thanks,
Marco.


Sun Jan 31, 2010 9:55 am
Profile
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: RobotC Motor Control
There is no documentation for this function. I just found it in the the IDE one day and experimented a bit with it. The name gave me a clue on its meaning, I suspected PWM stands for Pulse Width Modulation.

I think you are right that in open loop the value of this variable will be the same as the motor variable but I never tested this. also I don't know if it is readonly.

_________________
My most recent blog: A grain of sugar


Sun Jan 31, 2010 10:39 am
Profile WWW
Novice

Joined: Thu Jan 28, 2010 6:13 pm
Posts: 51
Post Re: RobotC Motor Control
I've seen that function in the IDE too. You're right, PWM is Pulse Width Modulation.

To be honest i expected a better documentation for a program like RobotC because it's not for free... :(


Sun Jan 31, 2010 2:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  



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