B4R Question Choosing the correct Power Supply?

ilan

Expert
Licensed User
Longtime User
hi

i am working on a project that includes 3 stepper motors with an L298n driver for each motor.

i am connecting all motors to a external power supply 12v - 3A.
what i get is that if i move 1 stepper motor it works fine if i try to move another one arduino is shutting down and again on.
and again if i move another stepper motor it works fine as long as i try to move the second motor it shuts down and again on (light gets dim and again normal) so my first thinking was
there is not enough current flowing so i wanted to order a 12v - 5A power supply but i have another power supply where i can set the voltage

this one:


it is a 3-24v with 3A power supply.

so i tried to set a lower voltage and to my surprise if i set between 6-7 volt i can move all 3 stepper motors if i set lower then 6 or higher then 7 again it shuts down if i try to move more then 1 stepper motor.

why is it like that? is it the arudino that shuts down the motors because the high amperage?
i know that the motors can run with 12 volts and the l298 also so i don't think it is the voltage that makes the problem i think the 3A is to high. am i right?
should i try a 12v with 2A?

this is the stepper motor i use:


and this is the l298n driver:


thanx
 
Last edited:

RJB

Active Member
Licensed User
Longtime User
Are you powering the arduino and the motors from the same psu?
If so, and you are happy that you know what you are doing, then try powering them from separate PSUs. That way you shouldn't get feedback via the psu (i.e. the motors could be pulling too much power and dropping the voltage on the psu which then causes a black/ brown out in the arduino).
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
the l298n has a 5v output so i connect it to the VIN pin to power the arduino from the same power supply. i also thought that that could be the problem so i tried to connect the arduino to my PC via usb and use the power supply only for the motors but i got the same result. 1 stepper motor works when trying to turn another motor it shuts down and starts again when using 12V on the motors and 5v form the pc usb to power the arduino.

i need to mention that the power supply - pole is connected to all motors ground pin and also to arduino ground pin and the + pole is connected to all 12v pin on the l298n drivers.

so they are connected in parallel connection.
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
The motor listing says its 'rated current' is 1.7A. I'm not sure what they mean by that but two motors presumably take up to 3.4 amps.
Have you tried looking at what happens to the 12v line when you start the second motor? An oscilloscope would be best for that, possibly an analogue meter would show something, a digital meter might show something but would probably miss any dip. The PSU is presumably protected by current limiting.
What does the arduino do. i.e does the log show it restarting?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i tried to use a digital multimeter (i dont own an oscilloscope, and the multi meter is a cheap one) to measure the current (amps) and it is always changing. going up down up down also the voltage. the weird part is that less voltage works but more then 7v i can only move 1 motor as soon as i try to move another one it shutsdown.

where can i see the logs? in b4r i always get an error when uploading the project something with no valid path but the project is uploaded to the arduino but i dont see any logs on b4r.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would connect the L298N Vs pin and the Arduino Vin pin to the 12V power supply.
And connect the Vss pin of the L298N to the 5V pin of the Arduino.
This means that:
- the power supply for both is given by the 12V source.
- the logical 5V power supply for the L298N is given by the Arduino.
This is how I connected a similar circuit, L293N.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I would connect the L298N Vs pin and the Arduino Vin pin to the 12V power supply.
And connect the Vss pin of the L298N to the 5V pin of the Arduino.
This means that:
- the power supply for both is given by the 12V source.
- the logical 5V power supply for the L298N is given by the Arduino.
This is how I connected a similar circuit, L293N.
thank you klaus for your feedback but i am not sure i understood you correctly.

so you would connect the 12v DC power supply to all L298n 12v pin and also to the VIN pin of the arduino and connect the 5v output of the l298n to the 5v pin of the arduino?

i thougth that the l298n 5v is only an output and does not need to be connected. am i wrong?
i followed this tutorial:



so this is how i connected the power:

1655880620994.png


so all grounds are connected to the DC - PS and ONE l298n ground pin is also connected to the arduino. then i connect all 12V pins from the l298n driver to the DC-PS and from ONE l298n driver i give power to the VIN pin for the arduino.

is this wrong?

why does everything works with 6-7v but not with more then 7 v?

(ps all jumpers are in place on the l298n drivers)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Could you show us the datasheet of the drivers?
I looked at this L298N datasheet, and there the Vss Logic Voltage Supply is an input and not an output.
I do not know what the 5V connection of the drivers is.
Is it an output of a voltage regulator in the driver or the 5V logic power supply for the drivers circuits?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I had a look at the data sheets.
What you can try is:
- connect all GND pins together as you did.
- connect the 12V of the L298Ns and the Vin pin of the Arduino to the DC-PS.
- connect all 5V pins together L298Ns and Arduino.
If the problem remains, this means that your power supply does not supply enough current as suggested by RJB.

It worked with lower voltages probably because the current consumption decreases and then the power supply can provide it.
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
I had a look at the data sheets.
What you can try is:
- connect all GND pins together as you did.
- connect the 12V of the L298Ns and the Vin pin of the Arduino to the DC-PS.
- connect all 5V pins together L298Ns and Arduino.
If the problem remains, this means that your power supply does not supply enough current as suggested by RJB.

It worked with lower voltages probably because the current consumption decreases and then the power supply can provide it.
thank you very much klaus i will try it out. 🙏 🙏 🙏

(PS.: if i will not be online in the next few weeks, you can assume that i have probably burned my house down 😁)
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
btw this is what they write on ali express about the 5v pin on the l298n

1655889548304.png


what i understand is that it acts like an output but i may be wrong so i will try what you have suggested @klaus
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
what i understand is that it acts like an output
Yes, it is, but anyway I would supply the Arduino with 12V on pin Vin.
The driver circuit has a 5V regulator.
I also read, that if supply the L298N board with more than 12V you should supply 5V on the 5V connector.
From my understanding, all the 5V pins L298N and Arduino can be used as inputs and as outputs, but 5V.
 
Upvote 0

Sifu

Active Member
For a supply, you should take at least 2x the current of the motors because you use 2 motors.
Next to that, motors are made of coils, so when you start driving it there will be a current peak. So for example the current of the motor is 2A at 12V, it could be at start that the peak is at 2.3A or whatever. So when using a supply that only gives 4A it is already to less. If you use a single supply for both motor and Arduino this could potentially influence the working of the Arduino in case of voltage drop.
And as seen in an other comment use 1 supply for the motors and a separate one for you Arduino.
Also use a stabilised power supply, so that it regulates its output. Meaning that if more power is needed, the voltage is regulated to 12V.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
For a supply, you should take at least 2x the current of the motors because you use 2 motors.
Next to that, motors are made of coils, so when you start driving it there will be a current peak. So for example the current of the motor is 2A at 12V, it could be at start that the peak is at 2.3A or whatever. So when using a supply that only gives 4A it is already to less. If you use a single supply for both motor and Arduino this could potentially influence the working of the Arduino in case of voltage drop.
And as seen in an other comment use 1 supply for the motors and a separate one for you Arduino.
Also use a stabilised power supply, so that it regulates its output. Meaning that if more power is needed, the voltage is regulated to 12V.
acctually i am using 3 motors and you are right about the peak on the motor start. as soon as i start 1 motor everything is fine starting the other motor shutsdown everything and it really looks like power is missing but the weird thing is that giving less voltage like between 6-7 with the same power supply (as seen in post #1) works fine as soon as i go less then 6v and over 7v only 1 motor works.

klaus said this about that behavior:

It worked with lower voltages probably because the current consumption decreases and then the power supply can provide it.

so i will follow his suggestion and see if i can run the motors with 12 volts too. i can set the power supply up to 24volts but the problem is that if i power the arduino with that power supply using the VIN pin i dont want to user more then 12v to avoid destroying the arduino board.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I am afraid that setting the voltage to 24V will be worse.
The power supply cannot provide enough current, and that case the voltage will drop down.
You will need a more powerful supply 12V but maybe with 6A.
But it works fine with 6-7volt and 3 amps so why not with 12 volts?
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Just to clarify:
below 6 volts the motors probably can't draw enough current to work
above 7 volts they will draw more current, building up to the 1.7 amps specified (AT 12V?). two motors will then overload your psu.
As you can't monitor the supply well enough to show the problem then it looks like you need to do as Klaus suggests and just try a psu with higher current capability.
 
Upvote 0

Sifu

Active Member
Yes correct. P=UxI So the consumed power is Voltage times Current. If the Voltage is increased while the motor uses the same current, the needed Power will increase.
To protect your board, use a separate supply for it. I've done this before with a Raspberry and a stepper motor and used Py to steer the motordriver. But it should work similar, except a steppermotor is constantly powered when rotating and stopping(holding position).
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
Just realised I missed something in #5 above:
where can i see the logs? in b4r i always get an error when uploading the project something with no valid path but the project is uploaded to the arduino but i dont see any logs on b4r.
You should be able to see and use the logs in the same way that you do usually, so there's something strange going on there. Presumably you see the text (
Loading configuration...
Initialising packages...
Preparing boards...
Verifying...) etc. as it compiles/ links....?
Possibly the baud rate is wrong??
Also from #5 you said:
...measure the current (amps) and it is always changing. going up down up down also the voltage
If the voltage is changing then it is also an indication that too much current is being drawn. You are using a regulated supply so the voltage shouldn't change much.
 
Upvote 0
Top