If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Motor controller functions

This video outlines in simple terms why a motor controller is needed and what it does. Created by Karl Wendt.

Want to join the conversation?

Video transcript

All right, so this is our motor, and this is our battery. And we know that if we switch the connections on the battery, we can change the direction of the motor. But all we can do right now is put the motor in some sort of a housing and have it run around. And then we have to manually change everything. So what we want to do based on our goals or objectives for this project was we want to be able to control the motor and have it turn on and off and go backwards and forwards when we want it to. So what we've done is we've selected a microcontroller. This particular one is called an Arduino Uno. And you can get these online. I got this particular one for about $20. There are variations that you can get that are as cheap as $10 or $12, all the way up to $70 or $80, depending on what you want it to do and how much work you're willing to do to put the board together. So this one comes preassembled. It's ready to go. It's got the connector for your computer so it's easy to use. And that's why I selected this particular one. So Arduino is an open source microcontroller. And it comes with a compiler. So you can download the compiler and write your code, upload it to the Arduino, and cause your robot to move and do different things. So the Arduino can take information from sensors and use that information to tell parts of the robot what to do. So we know we've got a motor that moves. And we know we have a power source. And we have brains to make it move, but there's an issue. We can't hook the motor directly to the Arduino because the Arduino wants to run on a lot less current than what the motor wants to run on. So the motor's going to burn the Arduino out. We have to have a way to switch the high current of the motor, control it, in other words, a way to turn the high current on and off and a way to control the direction of that high current, the polarity of it, without directly affecting the Arduino. So we need another device to do that, and that device is called a motor controller. So I've already built this motor controller up. And I'm going to show you how to make it. It's a Solarbotics motor controller. And I'll talk a little bit about what it does. So it basically controls the speed and direction of our motor. And so it switches that the higher power of the batteries and allows more current to flow, and it takes signal information from the Arduino, which is a low-voltage, low-current signal. And so the low voltage, low current comes into the motor controller and says, hey, turn the motor on in this direction. And then the motor controller let's power from the battery flow through the motor controller to the motor without damaging the Arduino. And so it lets us run the motor on a higher amount of power than we could if we tried to run it through the Arduino itself. So the way it does that is signals come from the Arduino, and they go into these little ports here. And those ports are-- the signals are interpreted by this logic chip here, which is an L298 chip. And that allows us to control the power going from the battery to the motor. Now, there's also a chip here. This is a fiv5-volt power supply, regulated power supply chip. And this allows us to take 5 volts out of the motor controller to power the Arduino. So we can take that 5 volts out from this terminal block right here and connect it to the Arduino. So this also allows us to run multiple different voltages. So the motor is going to be pulling 12 volts from the batteries, but the Arduino will be pulling only 5 volts from this supply here. So then we also have these diodes on board. And the diodes, they're flyback diodes, and they prevent voltage from coming back from the motor and damaging other parts of the circuit. And when you stop a motor fast or when your reverse its direction, you can get a pulse of electricity that comes back down the line and can affect other parts of the board. So because diodes act as valves and only allow the electricity to flow in one direction, it protects your board. So then we also have some resistors here. You can see these resistors. These two resistors are designed to protect the LEDs here. And these LEDs are Light-Emitting Diodes, and they indicate the direction or the polarity of the current. And that will indicate the direction that the motor is turning. So that's what they're there for. And these resistors protect them from getting too much power and burning out. And then we have a little tiny capacitor here that's a high-frequency filtering capacitor. And then we have an electrolytic capacitor, and that probably helps to smooth out some of the variations in current. We have two more resistors back here, and they are protect various aspects of our chip back here, I believe. So we have our terminal blocks. And these terminal blocks, that's where the power goes. So the motor will be connected to the terminal block. This motor will be connected to the terminal block like that. And the power from the battery will come in to the terminal blocks here. And I'll show you how to connect all this and wire it up. And in the next video, we're going to build this little guy and show you how it works.