Serial PWM motor controller

Hello, my name is Cody Smith. I’m a member of the Palm Bay Pirates team 2023 FIRST robotics team. But I’m here for a bit of help on a personal project. Let me first say that I myself am new to electronics and robotics but have a big computer background. I’m a web designer and experienced 3D modeler.

A friend and I are attempting to build our own robot using an old 1GHz Pentium III Dell motherboard we got our hands on (we actually have four or so). We like to call this the “Dell Bot” project. After building on teams FTC bot we decided that we wanted to step up to the big boy league but we wanted to do it differently and on a budget. So we figured instead of paying a large amount of money for a micro controller that has next to no CPU power to just use the abundance of computer parts I have in my garage.

We have the Dell computer stripped down to bare components. Version 1 of this bot will be tethered for power and possibly communications. Version 2 will hopefully have a car battery on board to directly power the motherboard and various motors and be controlled via a wireless network card by a laptop. Version 3 will feature an arm, lights, speakers, a microphone and a USB webcam. A little note, we hope to use an omni-directional wheel system.

The biggest problem we’ve ran into is how to interface the motherboard or as I like to call it the mega controller (big micro controller) with the various DC motors we need. The rest is relatively easy.

The idea I had and hope to pull off is to make our own PWM output bread board. It would work by using the motherboards two serial ports (RS-232) hooked up to our own board to somehow create 10 or so PWM motor / servo outputs.

I’ve looked pretty deep into this and really found no help. I’m hoping to use Python to program the serial port(s) but still the whole thing has me scratching my head.

I’m wondering if anyone here has a better idea or could give me some insight on how PWM and/or serial ports work and communicate? Well, has anyone here attempted something like this before? Or maybe tell me I’m crazy for trying to do this lol.

Thanks,
-Smartkid

You could use a PIC microcontroller, like an 18F4550 that would connect over USB, show up as a serial port, and turn serial commands like A255 into an equivalant signal on PWM output a

The 18f2550/4550 series have lots of libraries for stuff just like this.

Cool project. Here’s what I’ve found.

Since you’re packing around a whole computer, you’re probably going to want motors along the lines of what’s used in FIRST (correct me if I’m wrong), meaning that a lot of the low-current motor controllers would fizzle and die. So from there, really the best option that I know of is going with the IFI Victor controllers. Since they’re controlled with servo PWM signals, you need a controller board like you said. There’s a bunch of different options for this, most have 8 or 16 outputs, a couple I’ve found are:

Pololu USB 16-Servo Controller
Super Servo Controller
There’s also several guides if you want to DIY (like this one)
For more just google serial servo controller

Good luck!
–Ryan

I’ll toss in a few as well:
USB controller
Another serial controller

If you’re investing in all your parts from scratch and not using anything scrounged from your FRC team, it’s worth looking into serial and USB H-Bridge motor controllers or even looking at stepper motors and controllers, though. Also, if you are scrounging, make sure your PWM generator is compatible with IFI signaling. They’re ever so slightly different from the R/C standard.

No way :ahh:

You guys have no idea how hard I’ve searched for something like this. I actually did find this article: http://www.rentron.com/SerialServo.htm and I’ve been to Parallax (their $100+, 20MHz micro controller kit was what inspired me to do this project). But I was a bit confused as to exactly what it was about, I was knee-deep in servo-micro controller-PWM articles. A USB PWM controller is even better!

A question: Is there a major difference between USB and RS-232 serial?

To what RyanCahoon said, “you’re probably going to want motors along the lines of what’s used in FIRST …] a lot of the low-current motor controllers would fizzle and die” Yes, the computer power supply uses 12V and 5V leads so the car battery we hope to use for power later on and the motors will all be 12V.

The design calls for 4 12V DC motors to move the bot in an omni wheel system which I’ve already had to make and program for a various school robotics competition coming up that I’m not allowed to give details about using Vex parts. hehe

The question that comes to mind though is do I really need to buy 4 $100+ speed controllers? I’ve worked on our teams FRC bot, what we’re hoping to do is about 1.5 times smaller then that and shouldn’t need quite as powerful motors.

Another small question that I’m sure someone here knows is, how long would you think a car battery would power the motherboard and the motors? It’s an important thing to consider, I know many factors apply but an estimate would be appreciated.

And finally one last question, when working with Vex parts I noticed that the servos can work directly with the controller inputs (PWM output value of 0 set it all the way in one direction, PWM output of 255 spun it around the other way), do real servos work just like this? And do servos also need speed controllers (I assume yes and yes).

Thanks so much guys!
-Smartkid

It looks like minimum power dissipation on a P3 is around 20W. Max is 27W. Additional draw from the drives, etc would probably end up around 20W, so figure 40W to 47W from the PC, and just assume 100% efficiency for the power supply. That’s about 4A draw, at a minimum, assuming a very plain video card. If you’re using a car battery, they have a reserve capacity rating that says how long they’ll last with a 25A load. 80 minutes is typical, so you’d get something like 8 hours out of that on a good day. Of course real world loads will be a good bit higher when you’re running motors, etc. If you’re really looking for long runtimes, I’d invest in a deep-cycle or SLA battery, as those are designed for lower draw levels and more capacity. Car batteries are primarily design to push a very large amount of current for less than a minute without significantly shortening the battery’s life.

Yes. At least if you have to do the programming. RS-232 is dead simple on a PIC, or other microcontroller, especially if you are using a high-level language like PIC Basic Pro. While some PICs are USB capable, at least from what I have read, I have been hesitant to jump in as the protocols do seem to be a bit more complex.

The question that comes to mind though is do I really need to buy 4 $100+ speed controllers? I’ve worked on our teams FRC bot, what we’re hoping to do is about 1.5 times smaller then that and shouldn’t need quite as powerful motors.

There are a number of sub-$100 options. You could check out www.robotshop.ca or a number of other on-line robotics suppliers for options. Or you could take a look at building your own. Here are some links that might help, the first one is truly worth checking out:

http://www.mcmanis.com/chuck/Robotics/
http://www.barello.net/Papers/H-Bridge.pdf
http://www.armory.com/~rstevew/Public/Motors/H-Bridges/Blanchard/h-bridge.htm

There is also an online collaboration to create an “open source motor controller”, or try googling robotics clubs such as the Seattle Robotics Society. They have some excellent information and links on their web site.

Another small question that I’m sure someone here knows is, how long would you think a car battery would power the motherboard and the motors?

The short answer is “Long enough!” If you are thinking of doing deep discharges on the battery (beyond 20% of capacity), however, you may want to go with a deep cycle battery. If there is any danger of the the battery being tipped over, you probably want a gel cell. A typical car-sized deep cycle gel cell (such as used in Electrathon Racing) will have a capacity of 40 amp hours. IE you could theoretically draw 40 amps continuously for one hour. That should be more than enough to smoke your motors! On the other hand, if you are using a typical car battery with a 40 amp hour rating, you would only want to use 20% of that (8 amp hours… or 16 amps for half an hour) before recharging or risk quickly damaging the plates in the battery after just a few deep discharges. Perhaps there is an old FIRST battery sitting around that your team doesn’t need for a while, or perhaps you want to buy a new one when the KOP arrives.

And finally one last question, when working with Vex parts I noticed that the servos can work directly with the controller inputs (PWM output value of 0 set it all the way in one direction, PWM output of 255 spun it around the other way), do real servos work just like this? And do servos also need speed controllers (I assume yes and yes).

Well, first of all the VEX servos are “real” servos. If you are referring to Radio-Control servos, the answer is a qualified, “Yes, as far as I know.” When you refer to a PWM output of 0 or 255 you are referring to what fraction of the time the Pulse-Width-Modulated (PWM) signal is “high”. At 255 it is essentially always high, at 0 it is essentially always low, and at 127 it turns on and off rapidly, being high 50% of the time and low 50% of the time. Unless there was some weirdness to the VEX servos, I would expect the VEX output would work with any standard RC servo. The RC servos, like the VEX servos, would not need a separate speed controller. In fact, the Mini-RC system, from which IFI developed the VEX systems, was built around standard radio-control servo technology.

Sounds like you’ve got a great project ahead of you and lots to learn,

Good luck,

Jason

The general answer is you need to check the amp draw on your motors and compare it to the max current rating of the motor controller you’re considering. I was just warning against using something like this to power a decent sized motor. I pointed out the Victors because you’d be hard pressed to find a 40 Amp controller for a better price. If your motors are less, than feel free to use a less expensive controller. I looked at the robotshop.ca page Jason referred to, and there are several 25A controllers for under $100, but you’ll still be paying at least $75 per unit. I haven’t looked at the open source controlleres; you may be able to get the price down if you build one yourself.

On the topic of USB vs. Serial: On the PC end of things, USB really depends on how the device is set up. I noticed on the Pololu board that they’re basically running a little USB-Serial module and it just looks like another serial port on the computer anyway. The one advantage to using USB over pure serial is USB is, of course, more modern and (in my experience) is less finicky with connection settings - no baud rate, stop bits, parity, etc to deal with.

Hope I’ve helped some instead of just muddying the waters.

–Ryan

Once again, wow. I’ve had to learn 90% of everything I know about computers, computer hardware, programming, web design, Photoshop, 3D Studio Max, etc. myself. I haven’t taken any school computer class yet that I have actually learned anything in, they all teach very basic stuff, stuff that I considered below me.

However our schools robotics team is completely different. The first programming lesson they gave use showed us how basic binary worked in 8 bit applications and how PWM variables work in the Vex kits (and all robotics). My point is simple, I absolutely love the FIRST program. My brain has opened up and sucked in every drop of information it can from our schools robotics program. I’m basically the leader of FTC team #509 and will most likely be doing a large portion of the FRC bots programming this year.

So theres a bit of info about me. Back to the Dell Bot project…

After looking at the pages you guys showed me I’ve decided to attempt to build my own serial based motor controller from this article: http://www.rentron.com/SerialServo.htm

The main motivation is price and learning more about the basics of how this stuff works. I like getting knee-deep in these projects, just how I work. The idea is to build two of these and program them independently. One will power the components on the base (wheels, etc) the other will handle the arm and claw we hope to build.

One question about that article, the diagram shows a PIC: http://www.rentron.com/Files/Stamp/pc-servo2.gif

I’ve located this PIC and priced it (around $5, not bad) but won’t I need to program the PIC itself before it does anything?

Another small question, the diagram shows one pin from the microchip connecting to each PWM output, well it’s my understanding that PWN cables have three wires (black, white and red). If the microchip only outputs to one wire then I’m guessing that it’s the white one and that black and red are battery and ground?

Also, what is a 4MHz Ceramic Resonator? I’ve looked one up, a little $1 part that I’ve seen before but what does it do?

On the subject of the battery. I’ve done my homework on car batteries. I knew that the batteries weren’t designed to be completely discharged and I will take care to ensure that the battery we use won’t get that low. But I didn’t know how long it would last, please trust me 8 hours is PLENTY :slight_smile:

However two questions here:

  • I need a way to recharge the battery without a car, I’d like to build a battery charger that could charge it using a household 120V AC plug. How simple would that be? I assume I can’t just plug one end of the plug to the + and - ends of the battery.

  • I’d like to be able to make something, perhaps a small LCD screen that could tell me the amount of charge left in the battery. So that I never drain it all the way and so that when it’s charging we know when it’s done. I believe the drop in voltage is how you can tell the amount of charge left? Like when the Vex controllers show voltage on the little LCD.

Again thanks guys, I know this project is a big one but I feel that the experience and end result is well worth the effort. I’ll make it a point to post pictures later and I may even make a little web page dedicated to the project so that others can have a reference.

-Smartkid

This probably wont help you, but I think I will post it anyway. It seems sort of relevant.

There is a neat project in the book 101 SPY GADGETS FOR THE EVIL GENIUS

It’s on page 85 though 89. and is titled Project 41-Manual Controlled Servo Base.

It looks pretty neat. It uses a 555 timer to help controll the PWM’s. I have no idea as to how you would interface the circuit with a computer though.







We’ll I don’t know about using a full fledged LCD, although that would be cool… and my encouragement if you decide to try. But, you might want to look into a Digital Panel Meter, or a regular panel meter. They are a simple solution giving you an idea of how much charge you have left.

All Electronics has some pretty affordable ones. In fact we used one on our FRC robot last year. Ours was the only one that had one, and the engineer who inspected our robot kind of liked it.

www.allelectronics.com





A ceramic resonator is a low cost ocillator, usually used as a clock in a curcuit where the frequency of that clock does not have to be super accurate.

Car batteries usually have 40 Amp hours.
20% of that is 8 Amp hours.
The battery would only last 8 hours if only 1 Amp is being drawn. The CIM motors will draw far more than that (upwards of 132 Amps at stall for each motor :ahh: ). At that current (not advised) you would get under 4 minutes before you would surpass the 20% draw on the battery. Now you shouldn’t be drawing that much current, but calculating and budgeting the amount of current you draw and calculating how long your battery will last will tell you what type of battery (car/marine) you’ll need.

The battery is something for later. I don’t have the money for it and the charging equipment right now. Honestly, I’m broke. It’ll be a while before I can get any of this off the ground but time is something I have a lot of.

My dad seems to think that a car battery is massive overkill and too heavy. It’s become a bit of a joke now.

The more pressing matter is the motor controller circuit I hope to build…

I’ve located this PIC and priced it (around $5, not bad) but won’t I need to program the PIC itself before it does anything?

Another small question, the diagram shows one pin from the microchip connecting to each PWM output, well it’s my understanding that PWN cables have three wires (black, white and red). If the microchip only outputs to one wire then I’m guessing that it’s the white one and that black and red are battery and ground?

After looking at the pages you guys showed me I’ve decided to attempt to build my own serial based motor controller from this article: http://www.rentron.com/SerialServo.htm

Good on ya’ mate! That’ll keep you busy for a while.

One question about that article, the diagram shows a PIC: http://www.rentron.com/Files/Stamp/pc-servo2.gif

I’ve located this PIC and priced it (around $5, not bad) but won’t I need to program the PIC itself before it does anything?

Yes, you will need to program the PIC. Fortunately there are a number of simple PIC programming circuits you can build. One that I have had luck with (note the caveats on the main page) is the NoPPP (No Parts Pic Programmer) There are also other designs available. Googling “DIY PIC Programmer” or something similar should get you good results. Some of the newer PICs (the 16f627a, for instance) offer Low Voltage Programming, but that still requires that you program them with a “high voltage” (12v) programmer at least once to set them into LVP mode. Some of the newer PICs also have internal timing circuits, removing the need for a ceramic or crystal resonator unless you require highly precise timing. The catch in using a newer PIC, however, is that if the code is written for a 16f84, then you don’t want to have to re-write it. You’ve got enough to do on this project, already!

Another small question, the diagram shows one pin from the microchip connecting to each PWM output, well it’s my understanding that PWN cables have three wires (black, white and red). If the microchip only outputs to one wire then I’m guessing that it’s the white one and that black and red are battery and ground?

Yes.

Also, what is a 4MHz Ceramic Resonator? I’ve looked one up, a little $1 part that I’ve seen before but what does it do?

This controls the timing for the base level of operations on the PIC. If you put a 10MHz resonator on the PIC, you would essentially be “overclocking” it. As the resonator “vibrates” the voltage changes, providing a stable timing circuit to the PIC. The PIC then uses this to control all communications and data movement within the chip. You can actually use the frequency of the resonator to determing how long it will take the PIC to execute any specific machine language command quite accurately.

  • I need a way to recharge the battery without a car, I’d like to build a battery charger that could charge it using a household 120V AC plug. How simple would that be? I assume I can’t just plug one end of the plug to the + and - ends of the battery.

Well, no… but it is almost that simple. All you need is a DC voltage source of about +13.6 volts or so. A variable power supply, a “wall wart” transformer of the kind that takes up all the space on your power bars when you plug in the scanner, speakers, etc., or the battery charger used by your FRC team will all work well. You can also find trickle chargers, and fairly cheap car battery chargers at a hardware/automotive store like Canadian Tire (not that you have a Canadian Tire in Palm Bay, but you definitely have something similar. UAP-NAPA dealers might be a good start point.) Just be cautious that if you are using a “dumb” charger (ie a constant voltage source, or anything that does not specifically advertise itself as either a trickle charger - where the current is so low that it doesn’t much matter - or a smart charger) then you have to be careful to not overcharge the battery. The scientific way to determine a car battery’s charge is by measuring the density of the electrolyte (acid). Your school’s auto shop probably has a small turkey-baster like device for doing this.

  • I’d like to be able to make something, perhaps a small LCD screen that could tell me the amount of charge left in the battery. So that I never drain it all the way and so that when it’s charging we know when it’s done. I believe the drop in voltage is how you can tell the amount of charge left? Like when the Vex controllers show voltage on the little LCD.

This would be nice, and once you’ve finished all the rest of this project I suspect you will have no problem building one of these. But do the meat and potatos first, and save this for dessert.

Good luck,

Jason

Extremely useful information, thanks dtengineering.

To Daniel_LaFleur:

Car batteries usually have 40 Amp hours.
20% of that is 8 Amp hours.

Yes but what I said is that the battery cannot be drained lower then 20% charge. So if I’m right then that gives me 80% usable charge with is 32 Amp hours. Of course I’m the newbie here, maybe I’m wrong.

While I’m here, whats the difference between a stepper motor and a regular DC motor? I remember finding a small stepper motor in a hard drive and doing a bit of research on it but besides that their foreign to me.

Also, where would be a good place to look for cheap DC motors? I need something in between Vex motor size and FRC motor size. We’ll call Vex small and FRC extra large, I want a medium.

Thanks,
-Smartkid

http://colony105.com/sk/DB_1.jpg

I went ahead and whipped up a small 3D model showing what I have in mind for the bot design. This model is very incomplete but it does show the computer components to scale. The red part is the frame and wheels I hope to build for the project later on. The whole thing is about 24in x 24in x 16in. I believe that I’ve allowed plenty of room for custom made electronic components and a car battery.

The design allows the motors to be in their own little area in the omni-directional wheel pattern. I’m going to have to figure out a way to make my own omni wheels but at least I know what I’m doing there.

Any comments? :slight_smile:

Yes but what I said is that the battery cannot be drained lower then 20% charge. So if I’m right then that gives me 80% usable charge with is 32 Amp hours.

The figure of 20% is somewhat arbitrary, and refers to the amount of charge that you can use from a car battery without eventually causing damage to the plates. So you CAN extract 100% of the charge and drain a car battery to zero… but the deeper you drain it the more rapidly damage accumulates. Looking at what you have in mind, a car battery will be more than sufficient. I suggest that the power source is not going to be the “bottleneck” that holds you back.

While I’m here, whats the difference between a stepper motor and a regular DC motor? I remember finding a small stepper motor in a hard drive and doing a bit of research on it but besides that their foreign to me.

Did your “bit of research” include checking wikipedia? Simply googling “stepper motors” brought that up as one of the first links. Remember to read to the bottom of the wiki entry for the links if you don’t get it just from the article. One of the reasons you are getting good answers to your questions is that you have done some research and are asking intelligent questions. Please don’t stop now. You might have luck for some of this at howstuffworks as well, or by googling “stepper vs. servo”.

Also, where would be a good place to look for cheap DC motors? I need something in between Vex motor size and FRC motor size. We’ll call Vex small and FRC extra large, I want a medium.

Did you look for motors at the robot shops such as www.robotshop.ca as mentioned earlier in this thread? You may also wish to try out banebots. You will probably be wanting a gear motor of some kind unless you are planning to build your own gearbox… which is probably more expensive than just buying the gearmotor. I can’t promise that you will find any gear motors that fit your definitition of “cheap”, however.

Perhaps you need to contemplate what is important about your project. Is it the size of the project, or the skills you are learning? Scaling back the size of your robot to use vex sized components (there’s your omni wheels for you…) could be done without losing any of the educational or technical value and may put the project within your financial reach.

You may also wish to consider checking books such as “Robot Builder’s Bonanza” from your library and reading them before carrying on further.

Jason

If you’re looking for motors and any of this other stuff, find out if you have an electronics surplus or hobby store in your area. They’re somewhat more rare than they used to be, but they’re often a good resource for parts and motors if they exist. There’s one in houston that has a decent selection of all sorts of surplus motors for pretty ridiculously cheap prices. Amazingly there’s apparently one in your town. Check out AstroToo

Thanks again. I did do a Wikipedia search on stepper motors, at the time I really didn’t understand much of that article but now I should be much better off.

As far as the Vex parts go, well I don’t personally own any of those either. I do have some of my schools vex parts but those are just to work on our FTC bot for this year. I would consider using the vex parts but I’d still want to use the motherboard instead of the vex microcontroller. Which could still be done however it would make a rather large vex bot.

But in this case small might be good. The question is will the vex motors be able to handle moving the computer components and a battery to power the whole thing… I don’t think so.

I think it’s time for me to stop asking questions and start finding answers on my own. You guys have been so helpful, thanks!

-Smartkid