4x4 software differential

Posted by James.

Coach on team #21, ComBBAT, from Brevard Community College and Boeing.

Posted on 11/4/2000 1:27 PM MST

I am trying to come up with a single joystick operated 4x4 base that the front wheels are steerable. I have tried tank style single joysitck and doesn’t work well. So I need software ‘differential.’ Both motors going in the same direction, but at different speeds while turning proportional to the radius of the turn. The tighter the turn, the slower(to a point) the inside motor spins. Any thoughts?
James Rallo

Posted by nick reynolds.

Engineer on team #237, sie h2o bots, from watertown high ct.

Posted on 11/4/2000 10:14 PM MST

In Reply to: 4x4 software differential posted by James on 11/4/2000 1:27 PM MST:

James. You dont say how many motors you are using but assuming your using three ’ 2 for driving and 1 for steering ’ then it should be fairly easy.
One motor drives the right side, one the left side. The left wheels are connected by a chain or a thin ‘V’ belt so they run at the same speed. The right the same.
If you turn left then the right motors drive faster than the inside ones as the joy stick is moved in that direction, and vice versa. the third motor is reserved to help steer by rotation of the four wheels in unison.
One of the buttons on the joy stick could be used to operate the third motor for over steering or side ways driving?
The tricky part is to have the wheels turn while they are being steered at the same time but it can be done simply.
Soft ware should not be to much of the equation.
nick 237.

: I am trying to come up with a single joystick operated 4x4 base that the front wheels are steerable. I have tried tank style single joysitck and doesn’t work well. So I need software ‘differential.’ Both motors going in the same direction, but at different speeds while turning proportional to the radius of the turn. The tighter the turn, the slower(to a point) the inside motor spins. Any thoughts?
: James Rallo

Posted by James.

Coach on team #21, ComBBAT, from Brevard Community College and Boeing.

Posted on 11/5/2000 4:04 PM MST

In Reply to: Re: 4x4 software differential posted by nick reynolds on 11/4/2000 10:14 PM MST:

Correct, three motors, two drills (right and left) and one other motor for steering. The third motor is also connected to the same axis of the joy, X axis, the speed and direction of the drills is connected to the y axis. Forward and back is easy, but not turning left or right at fourth travel of the joy.
: James. You dont say how many motors you are using but assuming your using three ’ 2 for driving and 1 for steering ’ then it should be fairly easy.
: One motor drives the right side, one the left side. The left wheels are connected by a chain or a thin ‘V’ belt so they run at the same speed. The right the same.
: If you turn left then the right motors drive faster than the inside ones as the joy stick is moved in that direction, and vice versa. the third motor is reserved to help steer by rotation of the four wheels in unison.
: One of the buttons on the joy stick could be used to operate the third motor for over steering or side ways driving?
: The tricky part is to have the wheels turn while they are being steered at the same time but it can be done simply.
: Soft ware should not be to much of the equation.
: nick 237.

:
: : I am trying to come up with a single joystick operated 4x4 base that the front wheels are steerable. I have tried tank style single joysitck and doesn’t work well. So I need software ‘differential.’ Both motors going in the same direction, but at different speeds while turning proportional to the radius of the turn. The tighter the turn, the slower(to a point) the inside motor spins. Any thoughts?
: : James Rallo

Posted by Joe Johnson.   [PICTURE: SAME | NEW | HELP]

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

Posted on 11/5/2000 7:26 PM MST

In Reply to: Re: 4x4 software differential posted by James on 11/5/2000 4:04 PM MST:

I think you need to really think out your whole system.

I would recommend that you have the steering angle set to the X axis of the joystick via a feedback loop.
Then you need to coordinate the throttle settings for your left and right wheel.

In my opinion, it is often best to have a ‘base throttle’ and a ‘throttle off-set’

Base throttle could be set via the Y axis.

Throttle off-set is an add to one side and a subtract from the other.

For my money, estimates work just fine rather than going with the perfect mathmatical corrections.

I try to match things at the end points, specifically, going straight ahead and turning as sharply as you will in competition (45 deg?).

Anyway, contrary to Nick’s opinion that the software should not be too much of the equations, I believe that the software in this case can be VERY tricky to get right. The corrections change signs based on the angle of steering & direction of base throttle. You can easily drive yourself nuts making sure you have it all worked out.

I wish you luck.

Joe J.

Posted by Mike Gray.

Engineer on team #67, H.O.T., from Huron Valley Schools and GM MIlford Proving Ground.

Posted on 11/6/2000 6:38 AM MST

In Reply to: Use Feedback on the steering… posted by Joe Johnson on 11/5/2000 7:26 PM MST:

: I think that Joe is right about reevaluating the system. I’m not real clear on the approach you are taking, but it sounds as though you have CV or universal joints on all four steering knuckles. All four wheels turn the same amount for a given x axis value.

For turning without scuffing, a line projected through each of the axles must meet all the other lines at the
instantaneous center of rotation. In a car, this is accomplished by using a relay rod that is shorter than the distance between the ‘kingpins’ (cars don’t actually have kingpins, but they once did, and it makes for a good analogy). The steering components form a four-bar linkage, with the axle as ground link and the relay rod as the coupler. Getting the dimensions right can be very difficult, but getting close will improve the steering a bunch.

Articulated loaders don’t have the wheel scuffing problem because they pivot in the middle. Power transmission becomes a ploblem on center-pivot machines. Systems like this can be very unstable at high speeds too.

You might try two steering motors, one per side. Compute the proper angle for one side with respect to the other using the ‘law of cosines’. OR use one motor and connect fore and aft four-bar steering linkages with a transverse relay rod. Effective steering angle will be limited to about 45-50 degrees
because the linkage will ‘lock up’ at some point which depends on the coupler and rocker lengths.

Joe already warned about using positive integers for complex calculations. Its difficult and often confusing, but it is possible to evaluate angular relationships realtime. It may slow the system down quite a bit though…I don’t know how much.

Don’t let these comments dissuade you from doing something that would be really cool. Just be warned
that it takes much more than it appears on the surface to make it work effectively.

Best wishes!

Posted by Bill Beatty.

Other on team #71, Team Hammond, from Team Hammond.

Posted on 11/8/2000 8:53 AM MST

In Reply to: System approach posted by Mike Gray on 11/6/2000 6:38 AM MST:

I believe the Bomb Squad successfully did exactly what you are trying to do. In fact, not only did they steer the steering wheel, they also powered it. Greg-Mike. How about some info?

Bill B

Posted by James.

Coach on team #21, ComBBAT, from Brevard Community College and Boeing.

Posted on 11/8/2000 12:45 PM MST

In Reply to: 4x4 software differential posted by James on 11/4/2000 1:27 PM MST:

: I am trying to come up with a single joystick operated 4x4 base that the front wheels are steerable. I have tried tank style single joysitck and doesn’t work well. So I need software ‘differential.’ Both motors going in the same direction, but at different speeds while turning proportional to the radius of the turn. The tighter the turn, the slower(to a point) the inside motor spins. Any thoughts?
: James Rallo

I have figured out a simple little program that does what I needed. Thanks to all. Here it is:
note: untested in the real world, only tested on computer
Pwm1 is the right motor
Pwm2 is the left motor
Pwm3 is the steering motor(if using a speed controler)
relay1 is the steering motor (if using a spike)

'---------4x4 differential----------------------------------------------------
If p1_y=127 then notmoving:

adjustrightspeed
If p1_x>138 then adjustright: goto dontadjustright	
	
	adjustright
	pwm1=(p1_y-(p1_x/19)) min 0 max 254 :goto adjustleftspeed 'adjust the speed of the left wheel

	dontadjustright
	pwm1=p1_y

adjustleftspeed
If p1_xp1_x then subtract:

If sensor1

Posted by Joe Johnson.   [PICTURE: SAME | NEW | HELP]

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

Posted on 11/8/2000 1:57 PM MST

In Reply to: Re: 4x4 software differential posted by James on 11/8/2000 12:45 PM MST:

If your steering is not a spring return to center mechanism, I don’t think your method will work.

Basically your drive motors need to have their throttle adjusted up or down based on steering POSITION, not based on the amount of throttle the steering motor sees (PWM3).

If you have a spring return to center steering, then there is a rough correlation between your steering angle and the voltage on the steering motor (assuming your steering fork geometry is more or less just a simple pivot with no ‘caster’ effect).

I really think that in order to get your system to work right you should put the steering angle into a feedback loop. Have the X pot on the joystick provide the ‘desired’ steering angle. Have the ‘actual’ angle be measured via a pot onboard your robot. Compute the ‘error’ (be careful about 16 bit unsigned math – which you seemed to at least know a bit about from you earlier posting). Multiply the ‘error’ by a gain (actually you will probably want to multiply it by a gain constant and divide it by another gain constant so that you can get fractional gains * 3 / 2 => 1.5). Then add or subtract this scaled error from 127 to get your output to the steering motor.

This is ‘proportional feedback’ meaning that the amount of throttle applied to the motor is proportional to the amount of error. In general, higher gains are desirable, but if you make the gain too high, the system will go unstable.

Once you have a steering mechanism whose steering angle tracks the position of the joystick’s X pot, you can use some sort of left/right differential throttle mechanism.

For my money, I suppose that you could do much worse than just adding (SteeringAngle-127)*C1/C2 to one wheel’s throttle and subtracting the same amount from the other.
You will have to deal with some overflow/underflow issues. Below is one way to make sure your result does not underflow or overflow:

PWM1 = $8000 + BaseThrottle - ((SteeringAngle-$7F)*C1/C2) MIN $8000 - $8000
PWM2 = BaseThrottle + ((SteeringAngle-$7F)*C1/C2) MAX $FF

Note: the above assumes that Steering Angle is greater than or equal to 127. This insures that (SteeringAngle-$7F) is a positive number. Also, $7F = 127 and $FF = 255.
IMHO, using hexadecimal often makes your PBASIC life more livable, others disagree. To some extent this is just a matter of style.

For what it’s worth.

Good luck.

Joe J.

Posted by James.

Coach on team #21, ComBBAT, from Brevard Community College and Boeing.

Posted on 11/8/2000 8:10 PM MST

In Reply to: Re: 4x4 software differential posted by James on 11/8/2000 12:45 PM MST:

1/2 the code is missing. Here is the whole code

If p1_y=127 then notmoving:

adjustrightspeed
If p1_x>138 then adjustright: goto dontadjustright

adjustright
pwm1=(p1_y-(p1_x/19)) min 0 max 254 :goto adjustleftspeed 'adjust the speed of the left wheel

	dontadjustright
	pwm1=p1_y

adjustleftspeed
If p1_x

Posted by Joe Johnson.   [PICTURE: SAME | NEW | HELP]

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

Posted on 11/8/2000 8:48 PM MST

In Reply to: Re: 4x4 software differential,oops posted by James on 11/8/2000 8:10 PM MST:

Note there is a problem posting PBASIC code on the Forums: The ‘less than’ and ‘greater than’ signs get stripped out of the message by the Perl code – ment to keep HTML out of the text of messages I suppose.

Anyway, if you are going to use these symbols you have to put in some other text so that the code is readable on the forum.

Joe J.

Posted by Joe Johnson.   [PICTURE: SAME | NEW | HELP]

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

Posted on 11/8/2000 8:55 PM MST

In Reply to: Re: 4x4 software differential,oops posted by James on 11/8/2000 8:10 PM MST:

One more thing I just noticed about your PBASIC code.

The line of code below will always leave Variable unchanged (even if Variable=’-1’)

Variable = Variable MIN 0

This is because in 16 bit unsigned math, (A MIN 0) is ALWAY equal to A. There is nothing less than 0 in unsigned math.

One way of getting around this is to do the following:

Variable = $8000 + Variable MIN $8000 - $8000

Now if Variable=’-1’ before the statement it will equal 0 after.

This is a very important lesson to learn when working with PBASIC.

Joe J.

Posted by Joe Johnson.   [PICTURE: SAME | NEW | HELP]

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

Posted on 11/9/2000 6:37 AM MST

In Reply to: ‘Min 0’ does NOTHING!!! posted by Joe Johnson on 11/8/2000 8:55 PM MST:

Just another note about PBASIC.

‘(A) MIN 1’ is almost as bad as ‘(A) MIN 0’

While ‘(A) MIN 0’ does nothing, ‘(A) MIN 1’ does ALMOST nothing.

The problem is the same. Any time you believe that the result could go negative, you have to do something to make the MIN operator produce the expected outcome.

Good luck.

Joe J.

Posted by Peter VanWylen.

Student on team #107, Team ROBOTICS, from Holland Christian High School and Metal Flow Corp…

Posted on 11/10/2000 8:42 PM MST

In Reply to: 4x4 software differential posted by James on 11/4/2000 1:27 PM MST:

Okay, we did something like this last year. I don’t have the code handy, but this is what we did. First, we found that 4 wheel drive is excessive, expecially when you are trying to steer two of them. We made the steering wheels powered, and the other two fixed, but unpowered. You will probably want to put the steerable wheels in the rear of the robot – this makes sense if you have ever seen a hi-lo / forklift operate. When lining up to pick something up, you want the power steering, and the drive power to be in the back.

The program was relatively simple:
leftmotor = p1_y
rightmotor = p1_y

then you need a simple feedback loop between potentiometer and motor to get the wheels to turn in response to the p1_x, and then return to center when you let go of the joystick. Also, you could try breaking the steering and speed control into two seperate joysticks – this worked nicely, and made it easier to drive.

This really did work well, and I would recommend this drive mainly because it is very easy to drive fast, and straight, and to line up for picking things up. Then you just need to make a manual override that when you push the trigger button, it would go into regular two joystick drive, one left, one right, as is usually typical.

Hope you find this helpful and non-cryptic.

Posted by James.

Coach on team #21, ComBBAT, from Brevard Community College and Boeing.

Posted on 11/13/2000 6:01 PM MST

In Reply to: 2 powered, steerable wheels posted by Peter VanWylen on 11/10/2000 8:42 PM MST:

: Okay, we did something like this last year. I don’t have the code handy, but this is what we did. First, we found that 4 wheel drive is excessive, expecially when you are trying to steer two of them. We made the steering wheels powered, and the other two fixed, but unpowered. You will probably want to put the steerable wheels in the rear of the robot – this makes sense if you have ever seen a hi-lo / forklift operate. When lining up to pick something up, you want the power steering, and the drive power to be in the back.

: The program was relatively simple:
: leftmotor = p1_y
: rightmotor = p1_y

: then you need a simple feedback loop between potentiometer and motor to get the wheels to turn in response to the p1_x, and then return to center when you let go of the joystick. Also, you could try breaking the steering and speed control into two seperate joysticks – this worked nicely, and made it easier to drive.

: This really did work well, and I would recommend this drive mainly because it is very easy to drive fast, and straight, and to line up for picking things up. Then you just need to make a manual override that when you push the trigger button, it would go into regular two joystick drive, one left, one right, as is usually typical.

: Hope you find this helpful and non-cryptic.

We done 2 wheel drive for many years. I agree it is simple. We have drove it tank style for all the years that we have been doing it. 2 wheel drive tank style is good for flat open spaces, but when you add a ramp or puck, that’s the trouble. The CG changes when you start climbing. Thus taking some weight off a set of wheels. Putting the drives wheels all the way in the back sounds good, but with interaction with other parts of the robot, it isn’t always possable. We have tried 4x4 in the past and we weren’t very happy with the results. With the front wheels driven, all you would really be adding is 4 sprockets and 4 universial joints. Why not?