WD-Robot-Smart-Car-Chassis-Kits-car-with problem

hi,
i tried to control a 4wd car with an aplication.
i connected to H-bridge l298N 2 motors on the right and 2 motors on the left.

it works with a battery of 9V but everytime the speed of thw wheels changes, i suppose because the battery is getting weaker.

so i connected the arduino throuth power suplly of 12V.
when im using analogWrite for the motors under the value 100(i can insert between 0-255) the motors are doing noise but not moving, from 101 they begin to spin, but to fast, and i wnat the car to go slow.
so i have few question:

  1. if im giving boost as value of 100 for few micro sec it works but is that the correct way? this is for project at university and the demo will be with battery, not power supply so i worried that 100 won"t be enough.

  2. is connecting another H-bridge will help?

3)for controling spped, what is the correct way to convert value between 0-255 of analogWrite into rpm actual speed?

thank you for answer :slight_smile:

Hi. Welcome to the forum.
If by 9V battery you mean a smoke detector battery, then you should know that these are never the right choice for powering motors. They have large voltage drop when larger current demands (like motors) are made.

i connected the arduino throuth power suplly of 12V

I cannot quite picture how you have things wired. Can you provide a wiring diagram?
Pencil, paper and a camera are usually good enough if you include proper detail like pin numbers and such.

3)for controling spped, what is the correct way to convert value between 0-255 of analogWrite into rpm actual speed?

I cannot think of any way with just that. actual speed will always depend on the load on the motors.
If you want accurate speed measurements, you will need some sensor, maybe an optical encoder, that will measure the actual speed of something in the drive chain.

thanks for answering,
i uploaded the circuit just instead of battery it s a 12V power supply connected ecxatly the same way
with the wires.

about the speed, value of 200 its twice the value of 100 but the speed realtion not the smae, i mean its not linear, so the main problem im trying to figure out its how control speed, but slow speed

OPs image so we don’t have to download.
e894d5d547154f1d667c4a267364bd66a24ec45c.jpg

Pretty picture. Not very useful for identifying important details, like pin numbers, but pretty.

You say 12v power supply. I am curious about how much current it can deliver. Not critical for your question but it is a good habit to be in to give full details.

You say pwm value of 200 gives little speed change over pwm value of 100. Is that with the motors free wheeling of under load (driving around)?

You can either map out the pwm values to various movement rates to find the pwm value that gives you what you want (and hope that the conditions do not change later). Or you can add a method to measure your speed and have the program adjust the pwm value on the fly.

You do not say much about what this car is intended to do.
Will there be any steering input? How will you know how much to speed up or slow down on side to steer?
Will you expect it to go straight? How will you know that it is going straight? Hint, simply giving the same pwm value to the motors on each side rarely results in going straight.

the intend to be autonomous.
under the car will be sensors which recognize colors.
i paste white strips on a black board to be the path excatly the width of the car and each time the sensor detect black the algorithm add speed to the side to be on the white again.

the problem is the car going to fast so it problematic at the curves.
at the pwm 40 the speed it ok but i only achived that by boost at first with pwm of 100.

So, you can use that method. 100 to get it rolling then throttle back to 40 to maintain a good speed.

Or you can create a method to measure you speed.
Then you let the car adjust the throttle on the fly.

Both could work.

One common reason for needing a much higher value to start the motor than you need to keep it running is that the power supply is weak and the voltage is dropping when the motor is demanding a higher current…as it always will do when it first starts up.

That’s why we ask for details of exactly how you are powering your motors.

Steve

yes but lets say i want to car go on 300 RPM, what is the coorect PWM?

There is no direct correlation between the PWM value and the motor RPM.
It varies widely on motor load, current capacity of the supply and probably other factors.

If you want accurate RPM, you have to measure it.
Like I said in reply #1, #4 and #6.

Add a sensor to measure the RPM. Use that measured value to adjust the PWM value. repeat.
If you go this route, we will likely introduce you to PID logic, but that might be more than is needed.

If you do not want to measure RPM, then it is up to you to guess. Trial and error.
Set a PWM value and see what RPM it gives, under your best estimation of the actual environment the system will be in.
Not getting enough RPM? Repeat the test with a higher PWM value.
You get the idea?
You already did some of this to get the PWM value of 40.
If that is good enough, then go with it.
If it is not good enough, then add a sensor and read the RPM.

Hi slipstick I wanna start a new discussion it says how to build a 4wd drive remote control car