Author |
Message |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 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 |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 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 |
|
 |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 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 |
|
 |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 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 |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 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 |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 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 |
|
 |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 Re: What is the code for Robot Acceleration?
I thought motor values represent power?
|
Sat Jun 29, 2013 12:08 am |
|
 |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 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 |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 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: 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 |
|
 |
rcahoon
Site Admin
Joined: Tue Oct 09, 2012 10:34 am Posts: 192
|
 Re: What is the code for Robot Acceleration?
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 |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: What is the code for Robot Acceleration?
Don't try this at home kids, we've burnt out way too many motors with that kind of stress testing 
_________________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 |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: What is the code for Robot Acceleration?
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 |
|
 |
rcahoon
Site Admin
Joined: Tue Oct 09, 2012 10:34 am Posts: 192
|
 Re: What is the code for Robot Acceleration?
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 |
|
 |
coachkrauss
Rookie
Joined: Thu Sep 29, 2011 6:51 am Posts: 6
|
 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 |
|
|