I have a osepp motor shield version 1 (as shown here http://osepp.com/products/shield-arduino-compatible/motor-servo-shield/) but am really new to arduino and electronic tinkering entirely. I tried posting this question a few moths back and got no good answers that a total newbie could understand/utilize. I got frustrated and put the arduino stuff away for a while and am now ready to give it another shot. Could someone PLEASE explain it to me like I’m 5 years old and don’t know what anything is whatsoever? I want to control 4 dc motors and be able to use them bidirectionally. I have absolutely no idea how to use ANY shield as this is my first and only, I get that it plugs into the arduino uno but I don’t get it beyond that. If you have the motor shield I do (or if you look at the pictures) you’ll see the two green blocks with spots to attach wires, each block has 5 posts to plug wires into, and one side says M1 and M2 and the other M3 and M4. I’m guessing/assuming that M is for motor and it’s for motor 1-4 and I would understand it if there were 4 posts, M1+ M1- M2+ and M2- but I don’t know how h-bridges work or what to plug into those 5 slots. I also don’t understand what they go to on the arduino. Could someone PLEASE explain to me how to plug in the 4 DC motors and also give me/make a demonstration sketch with a lot of notes describing what each thing in the sketch does. I’m mainly confused on once the motors are plugged in, where do they go on the arduino? If I wanted to program DC motor 1 clockwise ,how would I do that? What in the sketch do I type, as in which arduino pin does it go to? Please help me and realize that I’m absolutely new to arduino/electronics and have only done some LED stuff so far.
Ok, lets take this stepwise.
There are two things you can control on a dc motor.
- Speed/Power, this is controlled by controlling the amount of electrical energy fed into the motor
- Direction, this is controlled by controlling the polarity
Speed/Power control can be achieved in two different ways.
- You can control the motor voltage continuously with a voltage regulator. This is called serial regulation and is very inefficient because the series resistance of the regulator will convert electric energy into heat. This is what resistors do
- The other way is switching the motor on and off very rapidly. Rapidly enough so that you get no noticeable acceleration or retardation during a switching cycle. If you have the switch on 25% of the time ond off 75% of the time you will be running the motor at 25% power. A switch has (almost) no inherent power loss so this way is much more effective. Its called PWM, pulse with modulation. Why it is called that should be clear from the explanations. The longer the on pulse relative to the whole on/off cycle the higher the power will be.
When it comes to directional control it just switches all the way. You can use either a DPDT switch or 4 SPST switches as indicated in the figure. When using 4 switches you simultaneously operate the two diagonally opposed switches to chose one direction or the other. Please observe that operating both switches in the same leg will lead to a short circuit. this must be avoided at all times.
If this is understandable and helpful give me some feedback and we take it to the next step
awesome response so far, I really appreciate the schematic you attached.
Ok, lets take the circuit with the 4 switches and exchange the switches for transistors (MOSFET or BJT, doesn’t matter) This is called a H-bridge. It is a very useful circuit because with its configuration of switches it can control both speed and direction of motors (and a lot of other things as well…) This can be done in the following matter:
- You select two diagonally opposite switches/transistors. That will control which polarity the motor is going to get and hence the direction of rotation.
- Of these two transistors/switches keep one constant on and control the other with a PWM signal in order to control the speed
Thats really all there is. On the L293 (the chip on the shield) you have 2 of these H-bridges. Each half/leg of the bridge has an input signal which select the upper or the lower transistor. In addition each bridge has an enable signal which can be used to turn all four transistors off independent of input selection.
If you want to control a dc motor with a L293 you connect the motor between out1 and out 2. You apply a low signal on in1 and a high signal to in2for one direction or a high signal to in1 and a low signal on in2 for the other direction. Finally you apply the PWM signal to enable1. Then you have half of the chip left to control another motor. (the pin number on the graphic are not correct or so it seems, but the principles apply)