Thursday, June 23, 2011

At last! Productivity!

Well I most certainly did not get anything done that week! However, the semester is over, I survived finals, I have a job at home, and I finally have a bit of time to work on the robot. Actually, I managed to get the drive motors working when I got out of school 3 weeks ago. I copped out on using the MOSFETs, though. I figured I'd try a quick and dirty solution to get it working first, and then work out a much nicer and more efficient motor controller later. The following schematic is the one I used, and the one that was suggested to me on the All About Circuits forums.


As you may or may not be able to tell, the above circuit uses relays, rather than MOSFETs. A relay works using the principle that current generates a magnetic field around a wire. A wire can be coiled in order to increase the strength of this created magnetic field. A relay has a coil of wire inside that creates a magnetic field when activated, and this magnetic field attracts a magnetic switch towards it, closing a circuit. The schematic symbol for relays pretty accurately depicts this concept. The relays I used are called Single Pole Double Throw (SPDT) meaning that there is only one switch, but it can close two different circuits. These relays have a normally open (NO) side and a normally close (NC) side that describes which way is a closed switch and which is an open if there is no current activating the relay.

The circuit above has the NC part of the switch bringing both motor leads to ground. This way, when the motor is running, and suddenly told to stop, the current generated by the magnetic field of the motor not wanting to collapse can be sent to ground, allowing the magnetic field to collapse in a much more gentle fashion. Then, when the left relay is activated, the left side of the motor is set to the positive voltage, and the motor runs one way, and if the right one is activated, with the left side being inactivated, the motor runs the other way. And due to the nature of SPDT relays, it is impossible to activate the high and low of one side of the H bridge and create a short circuit.



All in all, the relay h bridge is a quick and dirty solution to the motor controller problem. However, this design does have the following cons:

  • Relays take more energy - The activation coil requires current to turn the relay on so it requires a small amount of current to keep the motors going. This small amount adds up over time and drains the batteries quicker.
  • Relays don't allow for PWM and speed adjustment - Relays are either on or off and so don't have the capacity for scaling and speed control like MOSFETs do.
  • Relays are bulky - As you see in the picture above, relays are fairly sizable beasts and take up a lot of room. MOSFETs, on the other hand, are much more compact and can fit in smaller spaces.
  • Relays are less durable - They are only rated for a certain number of on and off cycles. The contacts inside break down over time due to the sparks that inevitably occur when current is abruptly allowed or stopped.
So basically while relays are nice and convenient, they're not an efficient or elegant way to make a motor controller. Sometime in the future when I actually have time I'll have to work on remaking the motor controller. In the mean time, however, this will certainly work well enough to make the robot move. I'd include some videos of it in action, but the robot isn't actually capable of movement at the moment for reasons I'll disclose in the next blog post. Once it's up and running, however, I'll be sure to throw a video in here!

Tuesday, March 8, 2011

Getting Up to Date

So the last few of these blog posts have been recap of what has happened, as far as the project is concerned, in the past couple of weeks.  This post will be my attempt at getting all caught up so I can start to enforce a development schedule.

The current status of the project is as follows.  My roommate and I wired up the robot using electrical tape so that it can be directly connected to the four batteries wired in parallel.  The motors are also tied directly together and share current from the 6V super battery.  We then wired it through an old analog multimeter so that we could gauge the current drawn by the motors.  This way, we don't have to listen to questionable data sheets and motor curves.  Here are the results of our weight testing for both motors.


The peak current is the current required to get the motor started, and the steady current is how much it takes to move steadily along.

The current direction with the robot is as follows:

  1. We will be using all four batteries in parallel to provide 6V to both motors.  This puts less strain on the motors, extending their life, although it will mean less speed.
  2. The motors will be wired together in parallel as well, which means both motors will always turn in the same direction.  While differential steering would be easier to maneuver, using the already provided steering will will make the robot's movements more realistic and applicable to actual cars if the project ever expands that far.  The elegance in this lies in the fact that if appropriate hardware and mechanics are provided, the same software could work identically on many different machines.


Things required to do to finish compiling data are:

  1. Get a force measurement of some sort of how much force is required to turn the steering wheel.  This will probably be similar to the graph above with a weight vs. force graph.  With this data, it is then possible to buy a adequately rated servo to turn the wheel and drive the robot.
  2. The stall current of the two motors.  I tried testing this when my roommate and I were doing load testing, but the current spiked past 20A which was the maximum current of the multimeter.  This data would be good to know when taking into consideration protecting the motor controller from overcurrent.  Stall current will cause damage to the motors so when it is detected, the motor controller can be shut off.
Things that will require doing to make the robot functional:
  1. Research and decide on an effective method of getting the robot to steer.  The only two options so far appear to be using a motor to slowly steer the robot, or buy servo to do the steering.  The motor would be cheaper, but it would require switches and types of control to monitor how far the wheel is turned.  A servo would have this functionality built in, but would be much more expensive.
  2. Finally design and build the motor controller.  Because I still have 8 MOSFETs of proper rating left over, all that is required is for me to design a schematic and finally solder together the controller on a PCB board.
So that's what's left that needs doing and where the rUD2 project is currently.  Hopefully I can get something done this week and finally get the ball rolling.

Friday, March 4, 2011

5-6 Wrong FET Specs and Poor heat dissipation.

So basically the previous four instances of me screwing up have snowballed up into one massive snafu ending in one, charred H Bridge.  At the risk of sounding redundant, reading the datasheets is EXTREMELY important.  For example, when I looked up the MOSFETs I was going to use, I read that they were rated for 150A, which was the peak current for 12V on the supposedly accurate fisher price motor curve graphs.  So I figured that it was fine, didn't care about any of the other confusing terms on the datasheet, and went ahead and soldered it all together.  This, however, is not the case.  If you don't RTFM, you won't learn things such as, while the FET's silicon may be able to handle 150A, the actual leads of the package that it is inside of will actually melt at 75A.  So that's pretty misleading, but whatever.

Next is the issue of heat dissipation.  Now I'm not the best at math, but basically what's required is to use the Rtheta factors on the data sheet to calculate the amount of heat the package can dissipate without melting.  As I've stated before, since I know I'm not the best at explaining things, here's a link (this will be a common thing, me linking you to helpful sites) that will help a great deal and walk you through the steps of calculating how much it current a FET can ACTUALLY handle.


I've found it to be very helpful, and realized that the FETs I was using could only handle about 20A before melting.  Read through it a couple of times to absorb everything.

Wednesday, March 2, 2011

2-4. Didn't Correctly Read Motor Curves and Crappy Soldering

So basically I misread the motor curves spreadsheet that I posted earlier in this blog.  I believed that the motors would run at 15A usually, however, little did I know that this was at the most efficient running of the motors.  As we all know, life is far less than peak efficiency and so it was more likely that the motor would run at 50A at times.  So long story short, RTFM.  Read the datasheets veeeerrrry carefully.

Second part which pretty much illegitimises the first part.  Forums are a spectacular place, especially engineering forums.  Odds are there's always someone who has done what you're doing and can help you a great deal.  That being said, there are also a lot of unhelpful people who make relatively meaningless posts. Nonetheless, it's still very important to carefully and fully read any threads that you may be looking at or that may be related to your project.  This was the case for the datasheet.  It is contained within a robotics forum, and only the first post.  The posts later in that thread, which I neglected to read until my first H Bridge had gone up in smoke, discussed the unlikeliness of much of the data that the motor curves showed.  It showed that the motor peaks at 150A which is a HUGE amount of current.  I eventually proved this illegitimacy to be true, as will come in a later blog post, but the reality is that the current drawn is far less than that.

In addition to reading through datasheets and forums, it's also a good idea to use your own judgement most of the time.  For one, the fuses on the stock power wheels batteries where 30A.  That alone should tell me that even the stall current (peak current) would be less than that.  And two, 150A running through the stock 14AWG wire would definitely start melting some things.  Considering that this is a children's toy, these dangerous conditions and amounts of current should have thrown up a read flag in my head, telling my that these were unlikely.  All in all, it's a good idea to make sure that your research is thorough so you don't make stupid mistakes like I do.

As for soldering, my circuit board is ugly, as most of you can see.  I used a knife to widen the holes so I could fit in a bigger gauge wire, in addition to an overall poor job of soldering with an old and very worn down iron.  A good soldering job takes time and a lot of practice.  Beautiful solder joints also show professionalism.  Since I am not qualified to show a soldering tutorial by any means, I'll just post a link to a very nice tutorial by the people over at sparkfun.  http://www.sparkfun.com/tutorials

They have a nice soldering tutorial in the bite sized primers section, in addition to many other good tutorials on basic electronics knowledge.  And now that I've gone over more of my faults as an electrical engineer, it's time to go study for a test.

Tuesday, March 1, 2011

1. Not turning on a MOSFET completely

Let me now address the first of my numerous and amateur mistakes in my first H Bridge design.  If you already read the All About Circuits forum post I put up, then this will just be a recap.  Essentially, what an N Channel MOSFET does, is compare its Gate voltage to its Source voltage.  For the ones I bought, the required voltage to fully turn on is 5V with respect to ground.

For the lower two FETs, this works out fine because the Source pin is tied to ground, and 5V, with respect to ground, is sent to the Gate, making the total difference 5V.  So these two FETs then have no problem turning on.  The real issue, however, arises with the upper two FETs.  Initially, the bottom two FETs turn on fine, and the 0V from ground propagates through the motor and to the Source pin of the upper FETs.  That way, when the top FET Gates receive a signal of 5V, they start to turn on.  However, since the motor in the bridge wants as much of the voltage as it can manage, this means that the Source pin of the FETs is going to increase in voltage and apply that voltage across the motor.  So eventually, the 5V difference between the Gate and Source pins will continue to get smaller and smaller.

THIS IS BAD!!!

When that happens the MOSFETs don't turn on all of the way, and the resistance will be far too high.  With power equaling resistance * current squared, the power being dissipated by the MOSFETs will shoot up.  Those suckers aren't made to take very much dissipation, and so they'll either melt or explode, like mine did, and release a ton of smoke!

To turn fully on, the MOSFETs need a high voltage, 5V, or whatever the recommended Gate voltage is, with respect to the source pin.  Since I'll be running my motors at 6V, that means the source pin will be about 6V for the upper FETs, assuming I use the same MOSFETs, which is unlikely, and 6V + 5V means that I'll need 11V at the Gate to get a 5V differential.

Two types of circuits that would work for a high side driver are listed below.


The top image shows the Gate of the Power FET hooked up to a pull down resistor.  Q1 is a regular transistor.  If a current is not fed into the transistor from the microcontroller pin, then the Gate sees the 0V of ground through the resistor.  However, when the MCU pin is set High, then the transistor turns on, and the current goes through the transistor, causing the 11V across the resistor, and charging the Gate of the FET, turning it on.  Due to the pull down resistor, The motor would then be normally off.

The bottom image shows the Gate hooked up to a pull up resistor.  When the transistor is off, the 11V would go through the resistor, charging the Gate.  However, when the transistor is turned on, the Voltage would all be dissipated through the resistor, causing 0V after the resistor which would then drain the Gate and then turn off the FET.  And so with the pull up resistor, the motor would normally be on.

These are my two options for the high side drivers of the H Bridge.  Now, all I have to decide is whether or not I want my motors to be normally off or normally on, though odds are I'll want them normally off so that the robot stops by default and won't try and run away if it decides to break.

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 http://www.modularcircuits.com/h-bridge_secrets1.htm 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.

http://www.chiefdelphi.com/forums/showthread.php?t=32442

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 http://www.digikey.com/ 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 www.allaboutcircuits.com 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.
http://forum.allaboutcircuits.com/showthread.php?t=49362

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
  6. POOR HEAT DISSIPATION
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 http://en.wikipedia.org/wiki/Rechargeable_battery#Table_of_rechargeable_battery_technologies
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.
http://www.batterystuff.com/tutorial_battery.html
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!

Tuesday, January 18, 2011

Basic Robot Rundown

So for this robot, I've broken the entire thing into four separate, but complementary systems.  I'll start at the bottom level and work my way up.

  1. The first level of the robot, and in my opinion the simplest (sorry MechE's!), is the mechanical level. It's comprised of the wheels, chassis, motors, etc.  Essentially I was lucky enough to get this level as one complete set, as the Power Wheels Jeep supports my every need.  The motors, while mainly mechanical, bridge us over to the next level.
  2. The electronics are the blood and guts of the robot.  They bring power throughout the entire thing, giving it life and movement.  Batteries pump power through the entire system, sending energy to the brains, motors, cameras, and any other electronics in the robotic system.
  3. Firmware is the third level and is right in between pure software and the electronics.  It's the set of commands that tell the hardware what to do, usually by passing a command given to it by the software.  The firmware usually resides, as it does in this 'bot, in a microcontroller.  A microcontroller/MCU/uC is essentially a very small computer.  The basic controller can be purchased for under $5, or an augmented one, which is easier to work with, will cost between $20-$100.
  4. Lastly is the pure software.  This is generally a nonexistent level on most amateur robots.  However, since I have no little voice in my head that tells me I'm biting off more than I can chew, I've decided to dream big, and will be installing an old laptop inside of the 'bot which will run the whole show.  While a microcontroller is fully capable of controlling the robot's lower functions, such as movement, tracking, and obstacle avoidance, the laptop will provide the robot with the potential of even greater possibilities!  I'm talking about grand things such as computer vision to keep track of particular people, environment mapping so the robot knows where it is, and voice recognition so it can here my commands of world domination (cue evil laughter).
So that's a basic rundown of how most robots tend to work, although level 4 can certainly be omitted.  However, I do understand that I'm terrible at explaining things, so if you have any questions, either ask in the comments or take a look at this fantastic website, where I learned most of what I know.

Monday, January 17, 2011

From the Ground Up

For starters on this project, let me show just what I'm starting out with.  Here are pictures of the Jeep in its current condition:

Here's the back axle of the jeep with the two presumably working motors and some sort of switch used to change gears.

This is the bar on the back of Jeep with two fake lights that I found impossible to get back on.  This bar looks like a really good place to add sensors such as sonic distance sensors or even stereoscopic vision!

This is the back of the Jeep.  The two things coming out of it are the seatbelts.  Safety first!

Here are the two 6V 9Ah batteries that came with the jeep.  They're very very old and even though I had hoped they still worked, they turned out to be duds.  As shown on the multimeter, they only display 2.8V after days of attempted charging.

The scary caution sticker!  It says here the Jeep is made to carry 130 lbs.  This gives me an upper limit to work with on everything I'll be adding, though I can't imagine everything will weigh over 50 lbs.

The inner dashboard of the car.

The front view of the Jeep.  Gotta love those flames!!!

The jeep with the trunk popped.  This is where the batteries were housed.  You can see the connector used to hook them up.

A side view of the car.  I wonder if I should add doors.

And finally the front steering system for the car.  The steering wheel is attached to that metal hook which in turn moves the long metal plate and steers the wheels.

Laying Down the Data

So just the other day, I was fortunate enough to receive a Power Wheels Jeep from my good friend, Ian.  Being the avid robotics fan that I am, I have since decided that I am going to use this Jeep as a robotics platform that I can build upon to form a fully functioning, autonomous vehicle.  I have named this project rUD2, a play off of R2D2, and after the University of Delaware which I am currently attending as a Computer Engineering and Computer Science sophomore.  I plan on using the robot to represent the ECE Department in the hope that I might get some funding from them.

My goals for this project include the following:

  1. To write this blog as a helpful tutorial for beginner through advanced roboticists interested in medium scale mobile robotics
  2. Use this robot as a platform for experimental technologies including non-lethal self defense, computer vision, gps tracking, self charging, artificial intelligence, full automation, and general bad-assery
  3. Develop the project to the point where it becomes a University backed robotics project that students who have a passion for robotics can participate in