0

I am using a L298n driver to make a basic RC car. I realise that PWM is used to control the speed of the motors and that the car would turn when the wheels on one side of the car have a rpm different from the other side. I am taking user input from the x-axis of a joystick.

However, I am not sure how to arrive at an exact relationship between rpm and the angle by which the car turns.

My approach so far :

  1. If the car is turning left, the wheels on the left side are turning in a smaller arc and hence the inner wheels have a lower rpm. The sharper the turn the slower the inner wheels turn.

  2. PWM is used to control the speed of the motors.

  3. Each angle of turning corresponds to circles of different radii. Hence a sharper turn would correspond to a circle with a very small radius.

  4. So I need to map the x-axis values of the analog stick to angles by which I want the car to turn. Once I know the relation between rpm and the angle by which the car turns, I can map the joystick values to PWM values.

This question has already been asked here and the consensus seems to be that some sort of feedback mechanism is required for an exact calibration.

I have two questions :

  1. Where do I learn more about this feedback mechanism?
  2. Purely from a physics perspective, considering an ideal environment, how do I derive a relation between rpm and the steering angle?
1
  • 1
    Regarding #1, the turn angle won't be just a factor of the inner wheel RPM. Nor will it be a simple ratio of the 2 wheels RPM. The wheel speed (RPM * wheel circumference) is a better measure. The side-to-side distance between the wheels is also important. You want the ratio of inner to outer wheel speeds to match the ratio of desired inner to outer wheel turn circumference. That would give you a smooth turning circle with no wheel slippage. If the ratio of wheel speeds does not match a ratio inner-to-outer wheel turn circumferences, one or both sets of wheels will slip. Commented Oct 30, 2020 at 13:52

1 Answer 1

2

Where do I learn more about this feedback mechanism?

It depends on the kind of feedback. You can have absolute or relative feedback. Relative would be, for example, to use an encoder on each wheel to find out how much it has turned. Absolute would be using a compass to know exactly what direction the vehicle is facing at any time.

Purely from a physics perspective, considering an ideal environment, how do I derive a relation between rpm and the steering angle?

If you know how much each wheel has turned then it is really just simple trigonometry. You have two arcs that are the same proportion around the circumference of two circles. The circles must have the same centre point. Well, I say "simple" - that's a relative term. And of course it depends if you are moving like a car (i.e., turning while moving forwards) or like a tank (turning on the spot) as to whether such calculations are particularly meaningful.

But then of course that's only if you actually know the RPM. Which requires feedback.

There is no easy relationship between PWM and the angle turned. This is because PWM does not define the RPM:

  • PWM defines the current
  • The current defines the torque
  • The torque defines the acceleration (and ultimately maximum speed) under different loads and conditions.

Those loads and conditions change depending on lots of factors. With no way to change the angles of the wheels they will need to slip on the surface as you turn. That adds friction and varies depending on both the speed at which you turn, the angle you turn through, and the surface you are driving on at the time. A high friction surface will both increase the power transfer and at the same time require more power to turn. A sharper turn angle will slip more and require more power to overcome the friction.

It's a very complex relationship with far too many variables. Which is why cars have steering mechanism to change the angle of the wheels, and some vehicles have rear-wheel steering as well to change the angle of the rear wheels to reduce slip and friction (such as the Porsche 911 and many large heavy vehicles), and why London cabs use "Ackermann" steering which gives each wheel a different angle while turning to increase the angle the vehicle can turn through so it can turn in the road easier.

So all in all if you want to know what direction you are pointing at any time, although it's harder to interface with and use, and may be a little more expensive, a compass or other absolute rotation sensor is the way to go.

If you want to turn to a specific angle, (or turn through a specific angle, which is just a relative change between two specific angles) then it's a case of "move a bit" then "see what angle I'm at" then "move a bit more" and "see what angle I'm at".

You could either use a simplistic approach where you always move in discrete steps, or use a PID to calculate what would be a good amount to turn to get you closer and closer to the desired angle depending on how far you turned last time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.