Log in

View Full Version : speed control


punarhero
23-01-2002, 17:14
Hi,
I am so happy that because of this forum, i've got my robot controller running. I still have a question though::cool:

Last year whoever programmed our robot didn't leave the code, so I don't have it. Anyway, last year, our joysticks worked like this:
If u just move the right joystick forward, the robot moved in an arc towards left, and If u just move the left joystick forward, the robot moved in an arc towards right. That means moving left joystick alone moved the left motor faster than the right motor, but the right motor still moved. When we moved both joysticks forward or backword, the robot moved in a straight line forward or backward.

I just want to know what I should do to the default code, so that if I move one joystick forward alone, it moves that side motor faster than the other side motor, and also how can I control the speed of both motor

Sorry for boring u with my long story, but I need this info to work with my motors
Thanx:p

thedillybar
23-01-2002, 17:50
Many teams use the "tank drive" control system for their robot. I believe the default code is pretty much already set up for this. Set PWM1 equal to the y-axis of the left joystick and PWM2 equal to the y-axis of the right joystick. Put PWM1 on the motor driving the left side and PWM2 on the motor driving the right side.

When you want to turn left gradually, push the left joystick farther forward than the right. If you want to spin around with an almost 0 degree turning radius, push the left stick all the way forward and the right stick all the way backward.

The programming isn't very difficult, if you need help with the exact code let me know and I (or someone else) can help you. Driver practice is the key. It takes a while to get used to it.

Kit Gerhart
23-01-2002, 20:15
Unless something has changed this year, The default has the two sticks completely independant of each other. If you move the right stick forward, the right motor(s) run forward and the left motor(s) do nothing, etc.

Jnadke
23-01-2002, 20:51
Originally posted by Kit Gerhart
Unless something has changed this year, The default has the two sticks completely independant of each other. If you move the right stick forward, the right motor(s) run forward and the left motor(s) do nothing, etc.


Other than the fact that the speed controllers have a built in dead zone apparently (says in the team update).

Lloyd Burns
23-01-2002, 22:23
The victors have always (and still do) have a zone (from 117 to 137) where no output to the motors is made. This allows the somewhat imprecise joystick to go to neutral position, where they may or may not put out 127, and still let the motor go off and not draw current.

You are probably confusing the 883 victors which were used in the past and which you got this year, too, with the very new 884, which you didn't get in the kit, but may have seen on the Ifirst website.

The 884's only difference with what has gone before is that the response to 138 is now a near zero output, whereas with the 883, the response is 10% output. For 883 and 884 alike 136 gives zero output. Same for going from 118 to 116.

iscrc2
23-01-2002, 23:24
The innovationfirst web site has a sample 'tank drive' code thats great to start with its at

tank drive (http://www.innovationfirst.com/FIRSTRobotics/pdfs/OneJoystickControl.pdf)

Its a good idea to look around their site at http://www.innovationfirst.com

punarhero
24-01-2002, 00:35
last year on our robot, if we moved left joystick forward alone, the robot moved in an arc towards the right, but u say that each joystick is independent of each other. How is that?

I AM A LITTLE confused:confused:

Jordan A.
24-01-2002, 00:58
Umm its hard to explain I guess.

By only moving your left joystick you only rotate your left motor.

So since the right isnt moving it becomes the pivot.

The more you move the left the quicker it goes around that pivot.

Now if you were to move the right joystick forward you would plac the pivot farther and farther from the robot until you are going straight.

Ever had a fast trax RC car?

MattB703
24-01-2002, 08:12
Let's see

I read your post a couple times and I don't think all of the people who responded understand the question. Or maybe I don't.

I think what you are saying is that when you moved the right joystick to full it made the left motor go full forward but ALSO made the right motor move at a lesser level. Thi should not be that hard to code.

Set the left motor value to the value of the right joystick plus the value of the right joystick multiplied by some gain (maybe 1/2). Since you can't use 1/2 you will probably need to get tricky like multiply by 100 amd divide by 200.

Don't forget to add "MIN 254" to the end of the line that you are defining the motor output variable. This will keep the value from wrapping around to 0.

Alot of you guys out there know a lot more about this stuff than e. Did I miss much?

Matt B.

Joe Johnson
24-01-2002, 15:59
Punarhero,

Are you satisfied or do you need more info?

Joe J.

P.S. I think that your robot was just plain wired wrong last year. The more natural way for robots to drive tank style is for the right joystick to give gas to the right motor and the left to give gas to the left. It seems to me that your robot last year had it wired right to left and left to right. It is a testament to the human brain that your drivers could drive it at all. By the way, all you have to do to fix it is switch the PWM cables around -- no coding needed. JJ

punarhero
24-01-2002, 16:12
But how can I change the rate at which the motor accelerates. For example, I need to move the joystick almost all the way forward to make the motor run at its max. speed. What if I want the motor to get to its max speed only half-way on the joystick.

I tried writing a loop for it like so:

FOR pi_y=127 TO 254
p1_y=P1_y*2

I was hoping to make the motor go accelerate at double rate than before, but when I run it, the motor started running at full speed aytomatically, I couldn't control it from the joystick anymore.

So, what modifications or additions should I make to my program to control the acceleration of the motor

Joe Johnson
24-01-2002, 18:03
You can use the following to scale up or scale down your joysticks

Value = Sqr (Value) << 4

and

Value = Value* Value >> 8

Both transformations give you 0=>0 and 256=>256 but what happens in between is either concave or convex.

Try it out.

You will have to modify code I gave already to put the squaring or squareroot in the right place.

It should not be to hard to noodle out.

Basically it only works on positive values (just like the scaling only works on positive values) so you have to make sure whatever you are scaling is positive before you apply the operation.

Good luck.

Joe J.

P.S. This method of shifting was first introduced to me by Sister Mary Katherine at my highschool. Sister was a wonderful woman but not a wiz when it came to math. Her method of curving an exam was to either take the square root of a raw test score and then multiply it by 10 if the exam was too hard or to take the score, square it and then divide by 100 if it was too easy. She had no idea why it worked and didn't care. I puzzled about it for quite a while. Now I share it with you, generalized for base 16. JJ