Arduino Vending Machine || Controlling Four Stepper Motors using Shift Registers

Hello, I am about halfway through making my arduino powered vending machine and i am starting to worry about frying my board as I intend to use four stepper motors (could be switched for DC motors), four ultrasonic sensors, four pushbuttons and an LCD. I plan to connect the LCD using a shift register due to lack of pins and want to connect the motors using shift registers as well.

I am using 28-BYJ48 as my steppers and an Arduno Uno.

I am assuming using the 5V on the arduino board will not cut it and will have to use some sort of external source.

I am considering using a 9V wall adaptor from amazon to power the board as opposed to the 5V on the arduino but I am not sure if that is enough either.

Another option I am considering is to take a 9V battery and connect it to the four motors independently using a battery snap so that i can power the motors using the battery and the rest using the 5V from the arduino.

The motors will only be running one at a time. I was wondering if using DC motors as opposed to steppers will work better in this situation as accuracy is irrelevant and we simply want the motors to turn off and on in one direction.

Hello, I am about halfway through making my arduino powered vending machine and i am starting to worry about frying my board as I intend to use four stepper motors (could be switched for DC motors), four ultrasonic sensors, four pushbuttons and an LCD. I plan to connect the LCD using a shift register due to lack of pins and want to connect the motors using shift registers as well.

I am using 28-BYJ48 as my steppers and an Arduno Uno.

I am assuming using the 5V on the arduino board will not cut it and will have to use some sort of external source.

I am considering using a 9V wall adaptor from amazon to power the board as opposed to the 5V on the arduino but I am not sure if that is enough either.

Another option I am considering is to take a 9V battery and connect it to the four motors independently using a battery snap so that i can power the motors using the battery and the rest using the 5V from the arduino.

The motors will only be running one at a time. I was wondering if using DC motors as opposed to steppers will work better in this situation as accuracy is irrelevant and we simply want the motors to turn off and on in one direction.

drashid:
Hello, I am about halfway through making my arduino powered vending machine

I think you should change mental gears and rather picture it as

my arduino controlled vending machine

The following pic, taken from here, shows how the power to the controller is separate from the power to the motor. (Details would vary according to the exact stepper motor and stepper motor driver board, but the concept won’t change.)

PS, I have no idea how to drive steppers with shift registers, but I’m sure the same idea as shown above is true: the motor power is separate from the control power, and think of it as Arduino controlled, not Arduino powered.

And if you switch to DC motors, it’s exactly the same idea. You would have something like this instead, also from Messrs Pololu, and once again details would depend on exact motor and board:

And in fact for one direction it’s even easier, just a transistor to switch the power, but it’s still separate power. Something like the below: (pic selected from the huge number that came up in a search of the Forum.)

SMALL DC MOTOR DRIVER.jpg

drashid:
Hello, I am about halfway through making my arduino powered vending machine and i am starting to worry about frying my board

Side note: the engineer in me is wondering about how you got halfway without having made some pretty fundamental decisions some time back? :wink:

Oh, okay I think I get what you mean by arduino controlled rather than powered. I am just a little confused on how to wire the external power supply to the four stepper motors. I attached an example diagram I was looking at

Would you just wire it as it is in the diagram except the 5V and GND on the arduino that go to the motor control board would be replaced with positive and negative terminals of a battery with a resistor?

Thank you for the replies so far, and yeah i didnt really realize this could be a problem as I was planning until I poked around on the internet and found that you can actually fry the board by drawing too much current from it. This is actually my first arduino project haha.

drashid:
I attached an example diagram I was looking at

Would you just wire it as it is in the diagram except the 5V and GND on the arduino that go to the motor control board would be replaced with positive and negative terminals of a battery with a resistor?

You would leave the GND from Arduino to that board, but lose the 5V wire. Then the external supply pos and neg both go to the board. That way the grounds are joined together: if you don't do that, then the signal wires from the Arduino to the board have no 0V to measure against and have no meaning.

But DC motors would be easier, if as you say position isn't an issue, and especially simple if only one direction is required.

Oh okay, so if I were to use DC motor instead it would look something like this: (attached file), except the 5V would be coming from the 9V battery rather then the arduino board right?

Indeed it would.

Although of course it would only be a 9V battery if it was a 9V motor, and even then hopefully not a PP3 since they don't last long.

It would look like the circuit I posted earlier, which shows a mosfet which could be a bjt of course, provided either the mosfet or bjt are chosen to suit the voltage and current of the motor.

I don't think the diagram in Reply#1 is useful in the context of a 28BYJ stepper motor. Those little motors usually use a ULN2003 as the driver and require 4 I/O connections to the Arduino which directly control the ON/OFF of current in the stepper coils. (With an A4988 and similar the stepper driver is responsible for controlling the individual coils - which reduces the computational load on an Arduino.)

That said, I presume the OP's question about shift registers was for the purpose of having enough I/O ports (i.e. 16) to control four 28BYJ stepper motors.

Provided the motors do not need to work at the same time with high step rates shift registers should be a very suitable solution.

I am using a 28BYJ motor in one of my own projects and it brought home to me one big advantage of a stepper motor over a DC motor which is that you can make a stepper motor move at low speed without losing torque. That makes it very useful where you want to operate at a specific speed even though the load may vary.

...R

These steppers in fact run quite well off the 5V supplied by an Arduino, using an ULN2003 Darlington array as controller. Note that I did this using a single stepper, USB power supply, and it's definitely not the recommended way for a permanent project. Four of them will be too much for a regular USB supply. Use a separate 5V supply for these steppers.

Using a 9V power supply to power the Arduino and then from the Arduino the stepper will result in an overheating regulator. Using a 9V block battery will not work at all (it can't supply the current).

If you use shift registers, use those with built-in power drivers, and high current output. Regular shift registers can produce no more than 10-20 mA, in which case you still need drivers to connect to the stepper coils.

Robin2:
I don't think the diagram in Reply#1 is useful in the context of a 28BYJ stepper motor.

You're right, and I should have said that I didn't mean that was necessarily the right solution for OP's motor, my bad. I was just trying to show the principle of separating the control (which comes from Arduino) from the motor power supply, which doesn't.

(edit) Although looking back, I did say that...

Willpatel_Kendmirez:
The following pic, taken from here, shows how the power to the controller is separate from the power to the motor. (Details would vary according to the exact stepper motor and stepper motor driver board, but the concept won't change.)

A shift register will severly limit the maximum speed of the stepper motors. But maybe that is not a problem for this application.

A 9V smoke alarm battery will be flattened in just a few minutes. Definitely go for the 9V adapter.

Okay, I think I understand now.

Would it be okay if I used like two 9v batteries in series lol. The thing is I only need it to run like a few times. Also would you guys think it is fine if I use two 9V batteries in series to power 4 of the above mentioned stepper motors?

2x 9V in series is 18V. You can't run a 5V motor from 18V, not that you can run it from 9V either, for that matter.

Oh, does the voltage of the battery need to match the voltage of the motor? Would it work if you put a resistor in series with the motor and power supply, to make like a voltage divider.

Oh okay, thanks for the reply, I am confused on how to connect the external power suppy and what to use as the external supply for the motors.

I was thinking that I would just use the 9V batteries you can get from the store. I attached an image of what i'm talking about.

If the voltage isnt enough I thought i'd just connect two in series or so and then connect all four motors to the batteries. Would this work?

A resistor in series is not a voltage divider, and in any case you can't use voltage dividers for supplying current.

If you must use 9V, you would need some kind of voltage regulator to get down to 5V, so why don't you just get a 5V supply of some kind in the first place.

4x AA rechargeables @1.2V would give you 4.8V for example.

(But check the specs of the motor; perhaps there's some quoted tolerance on the voltage they can handle.)

That all said, I don't think you said what it is that the motors (be they steppers or normal DC) are actually going to be doing. You said you might be able to use DC motors, which is certainly simpler, but of course it all depends on the application. Who knows; in the absence of info, maybe servos would work too?

With an appropriate motor controller 9V is adequate to run a 5V motor. But we don't know what controller you have.

And definitely not those rectangular smoke alarm batteries.

MorganS:
With an appropriate motor controller 9V is adequate to run a 5V motor.

But controllers typically (correct me if I'm wrong) let the supply voltage through to the motor do they not, so 9V would get to the 5V motor, which is likely to be too much. (Although as I said, OP should check the motor datasheet to see if the nominal 5V can go as high as 9V.)

He seems hell-bent on using 9V.

edit: A bit confusing to have another thread on this.