I have a car which is pretty heavy, and has various parts including an Arduino Mega R3 2560, a LCD(20x4), a heavy duty AR Parrot Drone 11.1V battery, 4 motors, an L298N, and so on. It is for a science project, and it needs to travel trough a maze. As you might guess, it needs to perform several turns and must move forward a lot. The problem with this is that there is a delay of about 5 seconds every 2 feet and after every turn. But every time it stops, it travels a bit extra. Does anyone know a math formula to take into account momentum? Please answer promptly, and ask questions if needed.

As a science project, you already know the formula for momentum, so you need to be able to convert the velocity component into heat and then dissipate the heat. I guess your statement about the car stopping and then moving actually means when you command it to stop, it continues to move a bit.

Did you include any braking ability in your design? Probably not. Can you add it? Are you using stepper motors? Probably not, or else they are way too small to hold the vehicle stationary. Does you motor controller include a braking ability?

You might explain why a formula will stop the car when you want it to.

Paul

I don't have a braking system.

Wrong989: I don't have a braking system.

Then the other option is stopping the motors some time before the car is supposed to stop completely. IS that possible? That still does not answer the question of why you want a formula.

Paul

No stepper motor either.

Yes, that is possible. But I need the formula to figure out how much sooner to switch off the motors, and I can figure that out by learning how much the momentum is pushing the car forward.

Wrong989: Yes, that is possible. But I need the formula to figure out how much sooner to switch off the motors, and I can figure that out by learning how much the momentum is pushing the car forward.

To be perfectly frank, there is no "formula". What you need to do is track the distance traveled after turning the motors off and vary the speed a tiny bit each test run.

Then you can derive a formula to fit the data or if you graph the results, you can determine a formula for the curve of the graph, if there is a curve. This is the best part of your "science" display!

Paul

You don't need brakes for electric motor. You can use the motor to brake if the controller has this feature. Also if you are able to reverse the motor you can use it for braking - provided you are able to measure the speed and stop the reverse power when your car stops.

Hi,

The problem with this is that there is a delay of about 5 seconds every 2 feet and after every turn

Do you have any delay(), functions in your code.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Your choice of motor driver is not good, they are not very efficient.

google L298N arduino braking

There are articles that show you how to apply brakes dynamically.

Tom.. :)

The kinetic energy of a moving body in joules is KE = 0.5 x mv^{2} where m is the mass of the body in kg and v is its velocity in m/s.

The important thing to note is that if you double the speed the energy does not double it increases much faster e.g.

e.g. 1kg travelling a 1m/s has 0.5J of KE, but the same object traveling at 2m/s 2J of KE and at 4m/s it has 8J of KE.

To stop your car you need to somehow lose or convert the kinetic energy into another form.

Run your vehicle car at different speeds and plot how much it overshoots by, the overshoot will be related to to the square of the velocity. Once you know how much the vehicle overshoots by at different speeds you can then work out how early you need to begin stopping so that you actually halt at the desired location.

I am confused by you saying “The problem with this is that there is a delay of about 5 seconds every 2 feet …”, you need to be clearer about what is happening. Are you saying if you drive in a straight line the car stops every 2 feet?

You should post your code putting it within the </> tags.

Not sure if it will help, but the formula for momentum is Mass x Velocity, so you would need to take the mass of your car and add a sensor to track your displacement (and then divide this by time)...

As stated by someone else, you should be able to use the motor itself for a brake by some combination of logic to your motor driver.

Also you are better using something in the maze for feedback to your car rather than basing everything off of theoretical formulas and assumed delays. I dont know what your maze consists of, but if it is just lines then you might be able to partially utilize a line following robot. If it has walls you could use an IR/ultrasonic sensor. You could also count the number of times the wheel has turned and extrapolate that.

Ashtech: Not sure if it will help, but the formula for momentum is Mass x Velocity, so you would need to take the mass of your car and add a sensor to track your displacement (and then divide this by time)...

You are correct that the momentum= mass x velocity

However it is the kinetic energy that is important in this problem. If you think about a real car the breaking distance does not increase in a linear fashion with speed, double your speed and you more than double your stopping distance. To stop the car you need to convert its kinetic energy into some other form such as heat in brakes or potential energy by letting it coast up a hill or even spin a gyro.

The difference between momentum and kinetic energy is quite a hard one to get your head around. If there is a 1000kg car going at 10m/s it would have the same momentum as a 500kg car going at 20m/s however, counter intuitively, the larger car only has 100kJ of KE but the smaller car has 400kJ of KE. So if you are going to be in an accident and its a choice between hitting vehicles with the same momentum always chose getting hit by vehicle with the biggest mass.

Forget momentum!! You need a closed loop control algorithm with quadrature encoders. You can precisely and accurately figure out how far you’ve traveled using encoders (one for each motor).

Power_Broker: Forget momentum!! You need a closed loop control algorithm with quadrature encoders. You can precisely and accurately figure out how far you’ve traveled using encoders (one for each motor).

The OP wants to travel through a maze. The car could travel dead slow and navigate using encoders but presumably the OP wants it to travel as fast as possible. In that situation he cannot forget about momentum and kinetic energy.

The car may sense a turn ahead, to make the turn the car needs to start slowing before it gets there. Encoders on their own don't help the car avoid breaking too soon or too late. The car needs to know its velocity, which it could get from encoders, but then it needs to be able to calculate its stopping distance which is relate to mass.

I didn’t say he only needed encoders, but that they should be part of a closed loop control system. With a form of feedback, OP could design a system that does a form of “active throttling” where the setpoint is the car speed, feedback is encoders, and output is the motor control signal. As long as the system is stable, you can tune it to get the transient response you need. BTW, the control loop can be, but doesn’t need to be, a PID loop. This way you can accurately set your speed and account for any disturbances instead of blindly trusting a (possibly) rather inaccurate momentum model and using an open loop control system.

Considering that the OP said in his Original Post " Please answer promptly, and ask questions if needed." we have heard virtually nothing from him (or her).

He has not even taken the trouble to explain what she means by "The problem with this is that there is a delay of about 5 seconds every 2 feet and after every turn. But every time it stops, it travels a bit extra" which does not make much sense as a description of a problem. Is he describing two separate problems or just one?

To solve a computer programming problem effectively the first requirement is a very precise description of the problem.

...R

Robin2: Considering that the OP said in his Original Post " Please answer promptly, and ask questions if needed." we have heard virtually nothing from him (or her).

He/she may be relying the mythical email notification system.... :)

I am shutting down this topic, because I'm not getting help. Don't comment any more.

Wrong989: I am shutting down this topic,

That is not under your control.

because I'm not getting help

I think a more accurate description would be that you are not prepared to work with the generally very good advice you have received.

...R