ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

EE Expert Darren Ashby
SpacersProduct Engineering

Click Here to Go to the Product Engineering ArchiveClick Here to Go to Darren Ashby's Main EE Expert PageClick Here to Go to the Guides and Experts Main Page

TOP SECRET Motor Control
by Darren Ashby

Lately I’ve been a lot of talk and no app (happens to the best engineers when they go PHM1). So, I thought I should get back to my engineering roots a little. I recently discovered a need for a precise motor control, one that could set a specific level as well as modulate the output. I thought, hey, this would make a great little project. Something fun that would stretch my design muscles.

Before I go further, I must let you know that this device is TOP SECRET. I cannot reveal its purpose. You may guess all you want, but don’t ask me to tell you 'cause I won’t. If you wonder why I can’t tell you, remember a little hype never hurt anyone.

The device I have in mind sounded like a great application of the Atmel Tiny15, a really neat little chip with a lot of bang for your buck. I figured some of you out there might have your own secret use for it. You can get the tiny programmer, the STK100, at Digikey if they have any in. Last I checked, there were 0 in stock. The programmer is cheap enough for a poor man like me to own. I guess you’ll have to ask your local rep, or try going to Atmel for a sample. I got some from Thorsen Rocky Mountain in SLC.

The Skinny on The Tiny

First of all, it has an internal oscillator, no need to find room for, or deal with, a crystal. It maximizes the output pins too—nice when all you have are 8 pins.

It also has a PWM output, perfect for DC brush motor control. And lest you think it a wimp, the PWM supports up to 150-Khz PWM frequency, not bad for an internal oscillator!

Now top it off with not one or two, but FOUR, ADC inputs including a differential input to the ADC. If that isn’t enough, you can have a comparator too, if you care for one when you already have a 10-bit ADC.

Oh, by the way, did I tell you that any of the inputs could be basic I/O too? Talk about your multiple configurations!

And yet one more thing, the program memory is flash, so your prototype involves just one chip till you're done. Gone are the days of, "Oops, I shouldn’t have burned that code!" When you start hooking up bigger motors you also discover that it is nice not risking your computer by hooking your emulator up to a motor. It’s even in-circuit programmable.

To sum it up, I’d say it’s kinda like an op-amp with some brains. Maybe it’s the "Bob Pease" in me, but you’ll realize how great a compliment that is if you read some of my op-amp articles. I tell you, the specs on this chip rock! The first time I saw it, I thought this would be perfect for a motor control. Its only detriment is that it has 6 pins of I/O, but that’s the hazards of such a small package. Besides, you can configure the various pins depending on the function you require. How many times have you had a control project where you thought, If I had just a tiny (no pun intended2) little micro here, it could handle all this work for me without going to the trouble of a bunch of circuit design or redesign?"

Back to the Project

As I said, I wanted a digital motor control that I could increment in small discrete steps, and would output the desired voltage and even add a little modulation.

The output was easy. I tied a transistor to the PWM output. Now I could handle the motor I wanted to turn. The inputs took a little more thought though. Here is the heart of the control.

Figure 1: Device Control Schematic
Figure 1: Device Control Schematic

First I thought I might take advantage of the differential ADC inputs to monitor the voltage across the motor. On a DC brush motor, controlling the voltage is important, as the speed is directly proportional to the voltage applied3. As the motor is loaded, the voltage across the motor will change (depending on the output impedance of your device); however, in this case the load does not vary much. So I figured I could save the pins and use them for something else.

I wanted to do a couple of modulation schemes on the output of my tiny little control, including steady state, sine wave, pulse, saw tooth, and a few other treats. But one thing they all have in common is a need to vary the output voltage as well, at a given modulation frequency. So I figure I'll need at least two controls and a mode button. "Hey" I thought, "here is a perfect chance to use those ADC inputs." I’ll just hook up a pot for each control. But I rejected that option. I could do the whole project with some op-amp and a bunch of resistors if that were the case. And I did this project to understand the Tiny 15, so I ought to use its capabilities a little better. Besides, I wanted precise digital control, and you get that with buttons.

I/O Mapping

I started by mapping some of the desired traits of my design; it should be battery powered. (Needs a sleep mode so I don’t have to remember to turn it off.) I should have a user interface that is easy and intuitive without need for a complex display. So I settle on one LED output, to indicate operating mode (everyone is doing a 1 LED display these days!) 1 switch to change mode, 2 switches to change base voltage up or down, and 2 switches to change modulation frequency up or down.

Let see... 1 PWM output, plus 1 led, plus 5 switches, that equals 7 I/O!? I don’t know about you, but I see a problem. There must be a better way. So why not use an analog input to get digital signals. In fact, a lot of portable CD players do just that. (Besides, it gives me a reason to use the ADC.) So I put all the switches on one line like this.

Figure 2: Multiple Switches on One Output
Figure 2: Multiple Switches on One Output

Theoretically you could get over 500 different switches with the 10-bit ADC that this little guy has, but you really ought to put some space between the voltage levels, or the bad guy "tolerance" might show up and cause headaches. That’s OK, I set 8 levels and only use 5 for now. Always be prepared for more I say. If you like this type of interface, fellow EE Expert Robert Ashby (yes, we are related) goes into more detail in his article "Doubling Up on Inputs." He even wrote a program to help you figure out if you have overlap problems.

Whew, all that brainwork frees up 3 lines. So I’ll hook the differential inputs back up just for kicks. (Who knows? maybe I’ll want try a little feedback.) Now toss in an extra LED for diagnostics and what ever else strikes my fancy. I’d show you a final schematic, but I can’t reveal everything. Don’t forget that this is a TOP SECRET project. A wise man said, "The things that come to those who wait may be the things left by those who got there first." I want to be there first!

Photo Opportunity

Here is a picture of the TSMC in its prototype stage. It definitely is tiny, could you imagine the size if I’d used surface mount parts?

Figure 3: TSMC Prototype
Figure 3: TSMC Prototype

Well, hardware is done, and the game is afoot. Tune in next time. We’ll talk software.


Notes

  1. PHM means Pointy Hair Manager. I was promoted to management a few years ago, there have been times since then that I swear I can feel my brain cells deteriorating.
  2. Well, maybe just a little pun intended! :)
  3. Please see my article on DC motor control for more information.

Product Engineering Archive

Guides and Experts   Analog Avenue   EDA Tools   PLD   DSP   EDA   Embedded Systems   Power   Test
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ