ROBOTC.net forums
http://www.robotc.net/forums/

What is the code for Robot Acceleration?
http://www.robotc.net/forums/viewtopic.php?f=66&t=6078
Page 1 of 1

Author:  coachkrauss [ Fri Jun 28, 2013 10:10 am ]
Post subject:  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);
}
}

Author:  NeXT-Generation [ Fri Jun 28, 2013 10:15 am ]
Post subject:  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.

Author:  coachkrauss [ Fri Jun 28, 2013 10:18 am ]
Post subject:  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?

Author:  coachkrauss [ Fri Jun 28, 2013 10:28 am ]
Post subject:  Re: What is the code for Robot Acceleration? My second atte

task main()
{

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

}

Author:  NeXT-Generation [ Fri Jun 28, 2013 11:11 am ]
Post subject:  Re: What is the code for Robot Acceleration?

That looks right to me. Did it work?

Author:  Ernest3.14 [ Fri Jun 28, 2013 3:59 pm ]
Post subject:  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 :)

Author:  coachkrauss [ Sat Jun 29, 2013 12:08 am ]
Post subject:  Re: What is the code for Robot Acceleration?

I thought motor values represent power?

Author:  coachkrauss [ Sat Jun 29, 2013 12:18 am ]
Post subject:  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.

Author:  Ernest3.14 [ Sat Jun 29, 2013 12:32 am ]
Post subject:  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.

Author:  rcahoon [ Sat Jun 29, 2013 5:37 pm ]
Post subject:  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

Author:  Ernest3.14 [ Sat Jun 29, 2013 10:30 pm ]
Post subject:  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

Author:  NeXT-Generation [ Sat Jun 29, 2013 10:34 pm ]
Post subject:  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.

Author:  rcahoon [ Sat Jun 29, 2013 10:36 pm ]
Post subject:  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.

Author:  coachkrauss [ Mon Jul 01, 2013 12:07 pm ]
Post subject:  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);
}

}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/