Hbridge mosfet dc motors

man im confused! everyone in this MSGboard knows exactly what
everyone else is talking about. im a beginner. ok ive looked online
and looked through books. this is what i dug up... a robot needs a
brain which is a microcontroller. so far, i can get my oopic to run
servos and turn lights on and off. my next step is to run somethign a
little more powerful than just some rc servos while still using the
microcontroller so i can program commands. I found these THREE TERMS
over and over again in threads and webpages that run more powerful
motors (usually electric drill motors) im no specialist with
electronics so correct me if im wrong anywhere. supposedly the
microcontroller sends and receives 5 volt (whatever a volt is) signals
to turn on and off lights and motors. now what actually powers the
motor i would assume is the batteries. now im assuming you cant power
an electric drill motor (DC MOTOR? whats the diff between a dc motor
and an rc car servo?) so you need a MOSFET and an H-BRIDGE to help you
control and power the motor? how does all this connect to the
microcontoller? and what does a mosfet and h-bridge do? please help me
i really really want to learn this...thanks!
~jim
Reply to
jimmy
Loading thread data ...
Hi, Jim. Welcome to the group.
We've all been there, don't feel bad.
This in itself is a great accomplishment. You understand how to get the software to make things happen in the real world. The rest is mostly details.
Right. The power for whatever motor youuse will come from the robot's batteries. The signal from the processor is nothing more than "instructions" and not meant to supply any sizable current.
Okay, most electric drills these days have some sort of electronic control circuit that converts AC from the wall into DC to drive the motor. Or, you can buy electric screwdrivers (a real favorite of mine) and use them directly from DC to operate them. In all cases, you must control direction and speed. To control direction, you need either to use a brute force approach, like a SPDT relay to swap the positive and negative connections to the motor, -OR- the better solution, an all-electronic switching device called an H-bridge. An H-bridge circuit provides paths that let the motor terminals reverse their connections, therefore reversing the direction that the motor will spin. It typically takes a single bit from your processor to tell it to go forward or reverse. You might choose for the default to be low=forward and high=reverse. Now, you have to decide how to control the speed. Pulse width modulation is the cheapest and easiest choice. That is usually abbreviated as PWM. All that means is that you control speed not by changing the voltage, but by switching it on and off very rapidly at full voltage. The advantage to this is that your motor produces full torque, even at low speeds. The disadvantage is that you must either make a device to control the speed, or write a program that lets your robot "brain" control it on the fly. Even that is not very hard to do.
You will select two bits to "talk to" the motor- one bit selects the direction using the H-bridge. The other bit controls the power sent to the motor- fully on or fully of- and therefore controls the speed. That is the PWM I was talking about. Virtually all robot builders use a very low resistance type of power transistor called a MOSFET to do this. It is a sort of ideal switch device that takes a very low current signal and controls the raw power being fed to the motor. The way I handle PWM in simple robots is like this- I write a 1 millisecond timer routine. Every millisecond, the routine generates an interrupt and the processor then "services" the robot. I use a 100 Hertz PWM frequency. Each "time slice" is 10% of the duty cycle. So, I have the processor figure out the motor speed, how many percent it has been on versus how long it should be on, and whether it should be turned on or off in this particular millisecond. So for each PWM cycle, there are ten times that the processor checks the system out, figures out what to do next, and sets the PWM to high or low. You can do it any way you want, but this sort of scheduling lets the processor have nearly a whole millisecond to do everything, then sleep the rest of the time. Most software can get everything done in well under 500 microseconds- but it depends on the type of processor you are using. I prefer the BL1800 card myself, and have not used the OOPIC at all. I hope that this is helpful.
Cheers!
Chip Shults My robotics, space and CGI web page -
formatting link

Reply to
Sir Charles W. Shults III
wow sir charles...thanks so much that was incredible. so an H-bridge electronically switches the circuits for you!! wow!! and a mosfet helps you switch the bit on and off at a certain rate to regulate the speed of the motor while retaining torque. thats just mind blowing. i have some more questions though...naturally it seems =). I went onto how stuff works.com and looked up what a volt amp and ohm is. i feel very good about that. And i also looked up on how some of the little components of a green circuit board does. i know in a normal household in america the current running through is considered an alternating current(AC) and most products that you buy that use motors is DC. what is DC? there arent any websites that tell you what this is. why would a motor need to change an ac current to a dc current. why do electric screwdrivers "automatically" have a dc current converter? and why doesnt a drill? and also...probably the most important thing...i dont think my four AA batteries be able to run a DC screwdriver/drill motor for very long. how can i power my motors to a wall jack, and still be able to control it from my microprocessor? my batteries connect to my circuit board. wouldnt a motor that takes so much power to run burn out my circuit board? do i need some kind of bypass? again thankyou so much.. you cleared so much up for me!!! ~jim
> > Hi, Jim. Welcome to the group. > > > man im confused! everyone in this MSGboard knows exactly what > > everyone else is talking about. im a beginner. > > We've all been there, don't feel bad. > > > ok ive looked online > > and looked through books. this is what i dug up... a robot needs a > > brain which is a microcontroller. so far, i can get my oopic to run > > servos and turn lights on and off. > > This in itself is a great accomplishment. You understand how to get the > software to make things happen in the real world. The rest is mostly details. > > > my next step is to run somethign a > > little more powerful than just some rc servos while still using the > > microcontroller so i can program commands. I found these THREE TERMS > > over and over again in threads and webpages that run more powerful > > motors (usually electric drill motors) im no specialist with > > electronics so correct me if im wrong anywhere. supposedly the > > microcontroller sends and receives 5 volt (whatever a volt is) signals > > to turn on and off lights and motors. now what actually powers the > > motor i would assume is the batteries. > > Right. The power for whatever motor youuse will come from the robot's > batteries. The signal from the processor is nothing more than "instructions" > and not meant to supply any sizable current. > > > now im assuming you cant power > > an electric drill motor (DC MOTOR? whats the diff between a dc motor > > and an rc car servo?) so you need a MOSFET and an H-BRIDGE to help you > > control and power the motor? > > Okay, most electric drills these days have some sort of electronic control > circuit that converts AC from the wall into DC to drive the motor. Or, you can > buy electric screwdrivers (a real favorite of mine) and use them directly from > DC to operate them. > In all cases, you must control direction and speed. To control direction, > you need either to use a brute force approach, like a SPDT relay to swap the > positive and negative connections to the motor, -OR- the better solution, an > all-electronic switching device called an H-bridge. > An H-bridge circuit provides paths that let the motor terminals reverse > their connections, therefore reversing the direction that the motor will spin. > It typically takes a single bit from your processor to tell it to go forward or > reverse. You might choose for the default to be low=forward and high=reverse. > Now, you have to decide how to control the speed. Pulse width modulation is > the cheapest and easiest choice. That is usually abbreviated as PWM. All that > means is that you control speed not by changing the voltage, but by switching it > on and off very rapidly at full voltage. > The advantage to this is that your motor produces full torque, even at low > speeds. The disadvantage is that you must either make a device to control the > speed, or write a program that lets your robot "brain" control it on the fly. > Even that is not very hard to do. > > > how does all this connect to the > > microcontoller? and what does a mosfet and h-bridge do? please help me > > i really really want to learn this...thanks! > > ~jim > > You will select two bits to "talk to" the motor- one bit selects the > direction using the H-bridge. The other bit controls the power sent to the > motor- fully on or fully of- and therefore controls the speed. That is the PWM > I was talking about. Virtually all robot builders use a very low resistance > type of power transistor called a MOSFET to do this. It is a sort of ideal > switch device that takes a very low current signal and controls the raw power > being fed to the motor. > The way I handle PWM in simple robots is like this- I write a 1 millisecond > timer routine. Every millisecond, the routine generates an interrupt and the > processor then "services" the robot. I use a 100 Hertz PWM frequency. Each > "time slice" is 10% of the duty cycle. So, I have the processor figure out the > motor speed, how many percent it has been on versus how long it should be on, > and whether it should be turned on or off in this particular millisecond. So > for each PWM cycle, there are ten times that the processor checks the system > out, figures out what to do next, and sets the PWM to high or low. > You can do it any way you want, but this sort of scheduling lets the > processor have nearly a whole millisecond to do everything, then sleep the rest > of the time. Most software can get everything done in well under 500 > microseconds- but it depends on the type of processor you are using. I prefer > the BL1800 card myself, and have not used the OOPIC at all. > I hope that this is helpful. > > Cheers! > > Chip Shults > My robotics, space and CGI web page -
formatting link
Reply to
jimmy
Greetings,
jimmy wrote:
The secret is to use two seperate power supplies. I'm using a Mark-III and am about as far along as you. See
formatting link
for a description.
As for the controlling the motors, I'm using the H-Bridge described at:
formatting link
with great success. One side of the hbridge using 5v from the PIC, while the other side uses whatever voltage you need from a seperate battery pack. The big advantage from what I understand is this setup minimizes power surges caused by the motors starting & stopping.
Best o' luck
Reply to
Kyle York
wow sir charlse thanks so much i have but one more question to this answer
is the ac to dc adapter called a transformer? like the ones all around my house that look like black plastic boxes as a plug? if not then what exaclty are transformers? thansk So much!! ~jim
> > wow sir charles...thanks so much that was incredible. > > You're welcome! Glad to help out. > > > i have some more questions though...naturally it seems =). I went > > onto how stuff works.com and looked up what a volt amp and ohm is. i > > feel very good about that. And i also looked up on how some of the > > little components of a green circuit board does. > > Knowing some of these things will help a great deal in your understanding. > And experience is the best teacher- every so often, look at what your meter is > reading and what components you have, and do a rough calculation to show you how > they fit together. Knowing any two of the three- voltage, current, and > resistance- will allow you to figure the third unknown. And knowing those, you > can figure out power consumption and dissipation as well. > > > i know in a normal household in america the current running through > > is considered an alternating current(AC) and most products that you > > buy that use motors is DC. what is DC? > > AC means alternating current. It means that the polarity is reversing every > so often. In the US, this complete cycle of change from plus to minus and back > again- happens 60 times per second. That is what 60 hertz AC means. > DC, however, does not change- it means direct current and it remains of the > same polarity (and typically, voltage) at all times. This is what batteries > produce- DC. > > > why would a motor need to change an ac current > > to a dc current. > > There are motors designed to run on DC, and motors designed to run on AC. > It all depends on the application. There are also special motors that take > pulses of current in a set of coils to move, and they are called stepper motors. > > > why do electric screwdrivers "automatically" have a > > dc current converter? > > Virtually all electric screwdrivers are battery powered. This means that DC > is what is available, so the motor will be a DC motor. And, you need DC to > charge the batteries. > > > and why doesnt a drill? > > The original electric drills ran off wall current- AC. They used AC motors. > As new features were needed, the move to convert to DC was made. This meant > simple speed controls, simple reversing, and eventually the ability to drive > them from batteries. > > > and also...probably the > > most important thing...i dont think my four AA batteries be able to > > run a DC screwdriver/drill motor for very long. > > AA batteries do not store a great deal of power. You would have better luck > with D cells or a wall adapter. > > > how can i power my motors to a wall jack, and still be able to control > > it from my microprocessor? > > You need an AC to DC adapter or a power supply. Whatever you use, you > should make certain that it is a regulated supply. The AC ripple on cheap > adapters will either cause erratic operation or complete destruction of > microprocessor based equipment. That is why you need a voltage regulator. > > > my batteries connect to my circuit board. > > wouldnt a motor that takes so much power to run burn out my circuit > > board? > > Most designs isolate the power for the processor from the power for motors. > There are lots of good reasons to do this, and most center around the fact that > motors are inductive devices, using magnetic fields. They can store and > discharge energy in the magnetic field that those motors create. This leads to > high voltage spikes and noise, and it can easily destroy delicate semiconductor > circuitry. > Motors can live in peace with micros, but it takes a targeted effort at > noise reduction to do it. Capacitors across the motor terminals help a lot, > MOVs help even more, and ferrite beads on the power lines finish the task. > Also, you will want to put "snubber" diodes across your drivers- H-bridge, > MOSFET, or whatever- to get rid of the last bits of noise and prevent damage. > > > do i need some kind of bypass? again thankyou so much.. you > > cleared so much up for me!!! > > ~jim > > Yes. It is best to use two separate battery packs, one for the motors and > one for the logic. Then when the motors are activated, they will feed very > little (or no) noise into the logic. > > Cheers! > > Chip Shults > My robotics, space and CGI web page -
formatting link
Reply to
jimmy
A transformer is an AC to AC adapter - to get DC you need a rectifier too. "black plastic boxes as a plug" (aka "wall warts") often (not always) have a simple rectifier, but still leave a little residual AC superimposed on the DC - that is ripple. You need to be careful your adapter has a built-in rectifier before you connect to a regulator... The rating panel will normally give the input voltage as 220 (or 110 in the US) volts AC, and the output voltage as, say 9 volts DC, plus the current rating, but if the low voltage side says AC, you need an external rectifier..
HTH
PeterS Remove my PANTS to reply.
Reply to
Spam Magnet
thanks so much
so where can i get a rectifier that will completely get rid of the ripple? can you send me a link?
THanks so much for you information~ ~jim
Reply to
jimmy
I just got 6 x 70W DC to torque converters off eBay. Maxon rare earth magnet motors. Only 36mm diameter but if you have the amps these wonderful things can deliver half a foot pound at stall - although how you get that much torque down a 4mm, non-flatted shaft eludes me right now.
I don't usually tidy up even when we have visitors, but it just didn't seem right putting these motors in my motor draw without freshening it out and making a special space so I could gloat over them properly :o)
best regards
Robin G Hewitt
Reply to
Robin G Hewitt

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.