Thursday, February 24, 2011

Managing MOSFETs

So as a continuation from the last post, I'm going to explain the usage (and then the proper usage) of Metal Oxide Semiconductor Field Effect Transistors, or MOSFETs.

For those of you not familiar with transistors, it is essentially a gate controlled by electricity.  It has three pins, the collector, the base, and the emitter.  As the names would imply, current goes into the collector and out of the emitter.  However, it is normally closed, allowing no electricity to run through it.  You open it up and therefore allow current to flow by pushing current into the base.  The common analogy is a water faucet.  The cool thing here is, you can control larger currents with smaller ones.  So if you 1/100th of an amp into the base, you could control 1A with it.  Cool right?

Now MOSFETs are a special type of transistor.  They are controlled with an electric field rather than a current.  So rather than having to constantly supply a current to the base, also called the Gate on the MOSFET, you apply a voltage to it which charges an internal capacitor in the FET and the resulting electric field allows much larger currents to flow through the MOSFET.  Because you only need to supply enough current to charge the internal capacitor instead of a constant one, MOSFETs can be more power efficient in the long run.  They also have the capability to control much larger currents than normal transistors.

I'll be honest, I didn't know much about MOSFETs when I went into this project, but, being the persistent little bugger that I am, I decided to forge ahead anyway.  (I bet you can see where this story is going already)  Anyways, I used a lot to figure out what exactly I was doing.  It's very helpful and tells you a lot of detailed stuff that most other h-bridge explanations won't go into.  Since I'm not nearly as eloquent as the H Bridge website, and since I'm generally busy, I won't go into a detailed explanation of the H Bridge here.  Suffice to say it's a way to control the direction of a motor.  It generally consists of 4 switches, in my case MOSFETs, and by turning on two at a time you can control which way the motor travels.  He's a picture from the H Bridge Secrets website.

If Q1 and Q4 are on, the motor goes one way, and if Q3 and Q2 are on, the motor goes the other way.  I'll from here on out refer to them as upper left and right, and lower left and right.

Now as for the types of MOSFETs I could use, there are P Channel and N Channel MOSFETs.  The differences are that P FET is closed and allows no current through (from the Source pin to the Drain pin) when the Gate pin is held low, and an N FET allows no current through (from Drain to Source this time) when the Gate pin is high.  Due to the fact that N FETs are easier to produce, have a lower resistance, more on that later, and are plain cheaper, I'll be using four of those.

Probably the most important thing to keep in mind when designing an H Bridge is the current draw of the motors you are using.  For the first revision of my bridge, I used the Fisher Price Motor spec spreadsheet found at the following link.

I then decided to use the 12V graph on the second page of that spreadsheet.  So if you look at the general information listings you can see that the stall current of the motor is 148A approximated to 150A.  This means that when the motor is forced to stop turning, like when jeep hits a wall, that's the amount of current that the motors draw.  I wanted to build an H Bridge capable of handling this current and so I searched for the necessary parts.  Looking through them all, I settled on buying 10 IRL7833's so that I would have enough for two H Bridges and then two spares in case something went wrong.  Little did I know things would end very poorly.

I won't go into much detail about how I designed and built the H Bridge, because I didn't put much thought into it and it did not end well.  It was basically scrapped together using an old perforated PCB board, some old romex wire, and a ton of solder.  Here are some pictures.

If you look closely you can see how that the wire is pretty burnt and two of the MOSFETs burst.  There was a lot of smoke and my basement smelled for a while.

Having read several pages on H Bridges, I assumed that the old wire was the problem and went to Radioshack and bought two spools of 12AWG wire.  Only when I couldn't fit the wire into the holes of the PCB board did I decide to post onto a forum and ask for help.

The forum is actually a very nice place, and having recently joined, I decided to post my questions there.  Since I have no shame and already feel really stupid for having made so many mistakes, I'll post the direct link to my thread right here.  I'm Gumbercules, btw.

Essentially I made a boatload of errors, and the very helpful people on the forums had no lack of advice to give me.  To name a few things I did wrong, I:

  1. Didn't turn on the upper MOSFET's all the way
  2. Misread the motor curves on the spreadsheet
  3. Didn't read all of the way through the thread from which I received the spreadsheet
  4. Probably did an awful job of soldering things
  5. Used improperly rated MOSFET's
I'll try and address each of these issues in the next few posts.

Wednesday, February 16, 2011

Procuring Parts and Batteries

My apologies for the lack of posts recently.  I've spent these past few weeks essentially working to earn more money for this project, moving back to my dorm room at school, homework for classes, and searching the vastness of the interwebs for parts that I need.

Basically, the rundown of what I needed is as follows:

  • Batteries:  High capacity sealed lead acid batteries to power the motors of the robot
  • Power MOSFETs to control the motors of the robot
  • Tools to make sure I don't kill myself or start a fire
So with respect with batteries,  one would think this would be easy to accomplish.  You just go out to radioshack, buy some AA's, or even splurge on a lantern battery, and hook it up right?  Not even close!  Batteries are incredibly complex demons and can be very costly.  The jeep I received came with the stock two Fisher Price batteries.  However, since these were dead and wouldn't take a charge, I had to go out and search for more.

Now the things to keep in mind when purchasing batteries are price, weight, ease of use, and capacity.  The lightest and most energy dense batteries are generally Lithion Ion batteries, like the ones used in cell phones or computers.  However, the problem is in order to get the required amount of these batteries, you would have to buy hundreds of dollars worth.  So, instead I decided to go with the classic Lead Acid batteries.  These are generally a little cheaper, as they are used all around in things such as cars, wheelchairs, or other high power applications.  They are also the same type of batteries that come with standard Power Wheels vehicles.  For more detailed comparison of types of batteries, Wikipedia is a great resource.  A general overview can be found here
and from there you can go to each battery technology wiki page to see a more in depth description.

**NOTE:  Do NOT use car batteries to power your project.  They are generally normal lead acid batteries, not sealed, and if not maintained carefully, charging them can produce hydrogen and oxygen gas, which are extremely explosive.  Seeing your robot explode and having sulfuric acid fly everywhere is not fun.  Car batteries are also made to deliver high amperage loads over a short period of time, using it for a steady stream of current can damage the batteries internal plates and greatly decrease the life of the battery.

So now that I've decided to use Lead Acid batteries, it's time to look up their suggested use and handling.

There are two types that can be used in this application, Wet Cell batteries and AGM/Dry Cell batteries.  Wet Cells require a decent amount of maintenance and are not sealed, meaning there is still the danger of hydrogen explosions.  They can also require the occasional refilling of the battery with water.  Both of these are reasons why I opted for the Sealed AGM style battery.  Because it is sealed, it requires less maintenance, and the way it is produced causes it to be more efficient than the Wet Cells, with the trade off being that it costs a little more.

For optimum number of battery cycles, meaning the number of times it can be charged and discharged, this battery should never be drained below 50% capacity.  Another general rule to remember for all Lead Acid Batteries is that they should never be left sitting alone for long periods of time.  Over time, the battery discharges itself, and if left alone for too long, they will lose the ability to take a charge.  It's a good rule of thumb to charge them to full capacity once every month or so.  You can check the overall charge of a battery by checking the voltage.  While the specs for a battery may say 6V, it usually means that it is more like 6.3V when fully charged and 5.8V when fully discharged.

Something I almost forgot to mention was how to determine battery capacity!  Battery capacity is measured in ampere hours, or Ah.  I'll explain with an example.  Say you have a 5Ah battery, and want to see how long you can provide 5A to a load.  Just take the capacity and divide by the number of amperes you're supplying, so 5Ah/5A means 1 hour of battery life, and 5Ah for a 1A load means 5 hours of battery life.

Because I'm not an expert on these things by any means, I went on the Internet and found most of my information from this site.
They go far more in depth than I do, and even have a handy table that lists voltages compared to the charge level of the battery.

As for finding and purchasing the batteries, I searched eBay for Sealed Lead Acid, or SLA batteries and managed to find some good prices.  I ended up buying 4 UB670 6V 7Ah SLA AGM batteries for a total of $42.  Not too bad of a price for a decent amount of capacity.  If I run the robot at 6V, this means I can put all four batteries in parallel and have a total of 28Ah capacity.

And after some waiting...

I've taped them together into two 6V modules.  This is because at first I wasn't sure if I was running the Jeep on 6V, 12V, or both, but for reasons I will explain in the MOSFET post....  I went with 6V

I cut the connectors off of the old batteries and soldered them onto the new batteries using some old Romex wire

Here's the solder joint between the wire and the battery itself.  The wire didn't fit well so I had to widen the hole a little bit to fit it, which explains the metal shavings.

And so here are the battery modules.  Since I'm not sure how much the motors are actually going to draw, I can't calculate how long they're going to last, but I feel as if I'm probably going to need to buy some more at some point.  So please!  Tell your friends about this site!  Every person who visits helps to fund our project!