View unanswered posts | View active topics It is currently Tue Sep 16, 2014 12:54 am






Reply to topic  [ 14 posts ] 
What is the code for Robot Acceleration? 
Author Message
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post What is the code for Robot Acceleration?
This is what I have tried unsuccessfully;

task main()
{
int powerlevel;
powerlevel=0;
while(powerlevel<127)
{
forward(powerlevel);
wait(0.5);
forward(powerlevel+10);
}
}


Fri Jun 28, 2013 10:10 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: What is the code for Robot Acceleration?
That code will run it forwards at powerlevel for 0.5 seconds, then at powerlevel + 10 for the instant before it goes back to the start of the loop. You never increase the value of powerlevel, therefore it'll be an endless cycle of power, and an instant of power + 10.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Jun 28, 2013 10:15 am
Profile WWW
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post Re: What is the code for Robot Acceleration?
so what do you recommend? Can you give me an example of a simple code that will work?


Fri Jun 28, 2013 10:18 am
Profile
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post Re: What is the code for Robot Acceleration? My second atte
task main()
{

for(int powerlevel=20;powerlevel<127;powerlevel++)
{
forward(powerlevel);
wait(.5);
}

}


Fri Jun 28, 2013 10:28 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: What is the code for Robot Acceleration?
That looks right to me. Did it work?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Jun 28, 2013 11:11 am
Profile WWW
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: What is the code for Robot Acceleration?
Although to be picky, when you set a motor speed, you are setting acceleration. You just reach your terminal velocity extremely quickly :)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Fri Jun 28, 2013 3:59 pm
Profile
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post Re: What is the code for Robot Acceleration?
I thought motor values represent power?


Sat Jun 29, 2013 12:08 am
Profile
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post Re: What is the code for Robot Acceleration?
Can somebody show how write a similar program using this function.

Y=10t

Y = motor power
t=time

Use a loop that would allow Y to increase as time does. This would continue until max motor output is achieved.


Sat Jun 29, 2013 12:18 am
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: What is the code for Robot Acceleration?
The more power applied to the motor, the more it accelerates. You can't directly control speed--or PID would be quite useless :)

A code to continually increment the power might look something like the following:
Code:
const int g_powerIncrement=1;
const int g_loopDelay=10; //msec
int power=0;

while (true)
{
    motor[motorA]=power;
    // Do stuff.
    power+=g_powerIncrement;
    Wait(g_loopDelay);
}


Of course, you should adjust the `const` parameters.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Sat Jun 29, 2013 12:32 am
Profile
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: What is the code for Robot Acceleration?
Ernest3.14 wrote:
Although to be picky, when you set a motor speed, you are setting acceleration. You just reach your terminal velocity extremely quickly


coachkrauss wrote:
I thought motor values represent power?


To be picky, motor values represent average voltage applied to the motor*, which is basically proportional to motor speed for a fixed load on the motor and if the motor speed doesn't change too quickly.

The amount of power consumed by the motors depends on both this voltage and the amount of current that is being drawn, which is basically proportional to the load on the motor. Load on the motor is the amount of resistance** to the motor turning, whether from friction, the robot's inertia resisting acceleration, because the motor is lifting something, etc.

You can have the motor output command set to 100%, but if there's nothing hooked to the motor, it will be drawing very little power.

Also interesting is the amount of electric power consumed is not the same as the amount of mechanical power generated. If you have the motor set at "full power," but hold the wheels so they can't move, the motor will indeed draw its max amount of electrical power, but the amount of mechanical power will be 0. The ratio between the amount of mechanical power and the amount of electrical power is called the motor's efficiency.

More on brushed DC motor physics here and here for anyone who's curious.

--Ryan


*ignoring non-idealities of batteries which cause the system voltage to sag the more current that is drawn from them.

**torque applied against

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Sat Jun 29, 2013 5:37 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: What is the code for Robot Acceleration?
rcahoon wrote:
If you have the motor set at "full power," but hold the wheels so they can't move, the motor will indeed draw its max amount of electrical power...


Don't try this at home kids, we've burnt out way too many motors with that kind of stress testing :D

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Sat Jun 29, 2013 10:30 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: What is the code for Robot Acceleration?
Ernest3.14 wrote:
rcahoon wrote:
If you have the motor set at "full power," but hold the wheels so they can't move, the motor will indeed draw its max amount of electrical power...


Don't try this at home kids, we've burnt out way too many motors with that kind of stress testing :D


Yeah... also, no need to overvolt your XL motor to see if it'll snap an axle. Been there, done that. Bye-bye motor.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sat Jun 29, 2013 10:34 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: What is the code for Robot Acceleration?
Ernest3.14 wrote:
Don't try this at home kids, we've burnt out way too many motors with that kind of stress testing :D


Truth.

Conservation of energy still holds, so all the energy that you've put into the motor that can't get turned into mechanical energy get turned into heat instead. Burnt motors soon result.

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Sat Jun 29, 2013 10:36 pm
Profile
Rookie

Joined: Thu Sep 29, 2011 6:51 am
Posts: 6
Post why not do this the easy way people?
task main()
{

int PowerLevels;
PowerLevels=0;
while(PowerLevels<127)
{
forward(PowerLevels);
wait(.5);
PowerLevels=PowerLevels+10;
}
{
stopMotor(rightMotor);
stopMotor(leftMotor);
}

}


Mon Jul 01, 2013 12:07 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 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.