# Beginner needs help choosing microcontroller platform & software

I mentioned this to illustrate that it is indeed possible, not that it is easy :-) What you mean by "motion control" is what is going to define wether you
can do it on a limited uC without too much effort, or if it would just be better (time saving) to use a more powerful uC.
In my case, motion control consisted in controlling several motors like this: they all start and stop at the same time, they all (can) run at different speeds. Imagine a robot with 6 degrees of freedom, where all motors have to run in unison so that all movements are smooth. That would be linear interpolation. One of the motors (the faster one) sets the pace and all others follow at a rate such that they will all stop together, no matter how big or small each motor movement is.
For the circular interpolation, I am basically coordinating two axes to draw a circle in any plane. This is all geared toward robotics and machine tools.
If you have different requirements, like motors not starting and stopping all together, setting acceleration curves, etc. you need a different approach obviously. Fastest is interrupt-based, either some sort of cooperative multitasking (or coroutines) or state machine. It is still possible to do that really fast. Well-written C can be as fast as assembly.
To put things in perspective, an atmega8535 at 16MHz hits 16Mips. It takes 8 clock cycles to get in and out of an interrupt routine. To take the example of some other poster on the thread, to manage a quadrature encoder you just need to catch an interrupt (some raising signal on a pin), check the state of the other quadrature signal, and increment or decrement the current count accordingly. So in assembler it would take about maybe 16 cycles. You could catch the quadrature signal up to... < 1MHz ! (and doing nothing else...). Adding tons of margin, saving time to actually do something useful, etc. and you realize that 10-20KHz quadrature is totally feasible. With a \$6 uC that will need almost no external components.
Using a multi-tasking kernel might be fast enough too and will make development easier by keeping the logic of the program simpler. There is one, open-source, for the AVR that I hear is really good (I have not tried it yet, but the numbers and look good). <http://www.barello.net/avrx/
You can use mechanical limit switches, yes. For less noise and more precise home position, use photo-interrupters. A cheap source of those is discarded floppy disk drives. Actually old floppy disk drives (specially the 5" 1/4 type) are a great source of electromechanical components. You could prototype your whole project with one :-)

conventional wisdom also said that one would never need more than 640KB or RAM in a PC, or that nobody wants to run several programs at the same time :-)
bruno
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
FORTH? I loved using FORTH on my Atari 800. I thought it was long obsolete!
Can anyone comment on the use of the 8051 family or perhaps the Hitachi H8 (which I think is used in the Lego Mindstorm System) as versus the AVR or PIC family of chips.
Are there any other series of microcontrollers that should be seriously considered? Zilog?

in
etc].
-------

the
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
I doubt you'll ever find a single piece of hardware that's perfect for everything, and it's not uncommon to use a variety of tools to accomplish a variety of tasks. Your xDOF camera crane is a major piece of work if you need to throttle a heavy piece of equipment acround a stage with any accuracy. I doubt a single microcontroller, with the possible exception of something DSP-based, will work, and maybe even then one MC per axis or two.
So...the thing is not to worry about it. Find a platform that's flexible enough to move to the next level, without having to relearn everything. I'd probably go with the AVR Butterly as a starter tool. It's cheap, supports GCC (and Bascom, if you want it), and is designed to be a development introduction to the AVR core. I mean, how can you go wrong for \$20, and it even comes with an LCD! You don't use a separate programmer with it; just a cable and included software. For \$100 you could buy five Butterflys, one for each axis of a 5DOF motion control crane.
Since Bascom is a variant of QBasic, if you're already familiar with that, it won't be a steep learning curve, and even if you decide to go to C later on, it's more of a matter of learning some different syntax. With any language you need to understand how the hardware does its thang -- how the registers work, the limits of input capture pins, how to work the hardware timers and interrupts, etc.
AVR Freaks (http://www.avrfreaks.net /) is where you want to go for anything AVR-related. They have tutorials, links to tutorials and books, and a very popular forum. Nice bunch of people. Don't expect a book like the ones for the Basic Stamp. Parallax has done an amaxing job of providing great documentation on their product, but from the sounds of it, the Stamp won't have the horsepower you need down the road.
-- Gordon
MrMJPEG wrote:

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

This looks interesting; thanks for pointing it out.
One thing that's still not clear to me: what sort of cable are you talking about, and will the included software run on my Mac OS X machine? If not, is the whole thing useless, or can I download other software for it somewhere else?
Thanks, - Joe
,------------------------------------------------------------------. | Joseph J. Strout Check out the Mac Web Directory: | | snipped-for-privacy@strout.net http://www.macwebdir.com | `------------------------------------------------------------------'
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
More work for Mac users, but (supposidly) it can be done. You will need a USB-to-serial converter, as the Butterfly is programmed serially -- common on newer MCUs with a built-in bootloader. You will need to snag the AVR-GCC tookset for the Mac. Check out AVRFreaks; they may have some pointers. AFAIK, Atmel's toolsets are all PC based.
While we're on the subject, all you really need is an old PC with a Pentium III and 256M or so of RAM. You can probably find these at Goodwill for <\$100. Get a copy of WinXP Home if it's not on there already. Assuming your Mac also uses a USB mouse and keyboard, you could share them with the PC using a \$30 Belkin KVM switch. You don't need much here, and it's generally easier to find PC-based IDEs and programmers.
-- Gordon
Joe Strout wrote:

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

I'll second that. I found a used Dell for around \$75 including 17" monitor. Its much easier because it runs most of the software thats out there and it also has two DB9 serial ports -- which almost all MCU dev boards require.
--
|\/| /| |2 |<
mehaase(at)gmail(dot)com
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
I rarely throw away old PC's, but I do cannibalize them. SO I have a PII/300 & Athlon 866 collecting dust in my basement.
I like the AVR/Butterfly suggestion. AVR vs. PIC reminds me of the old Amiga vs. PC argument of 15 years ago. One is clearly superior but the other is in wider use. Although this time I don't see the AVR disappearing.
The motion control discussion by blueeyedpop is WAY over my head at this point. But thanks! I just mentioned it to show where I want to end up. That's YEARS away. I know there are all sorts of considerations I didn't mention like counterweights, regidity, encoding (do you need encoders to find a home position with geared stepper motors?) along with memory and joystick interfacing.
Here's roughly how I'd like to progress -Blinking LED / Thermometer / LCD driver -Servo control -Stepper control -Single Geared stepper controling a platform upon which a camera will be mounted. Program determines movement. Verify accuracy of multiple runs. -Potentiometer control added. -Add ability to save data to internal memory (if possible) and repeat recorded moves.
I expect just the above to last a year or so. Then there'd be recording to external memory. After that, adding muliple axis. Maybe networking.
Thanks for all the help! It is comforting knowing there are knowledgable people out there to help. But, I'd REALLY like to know, what the heck IS a bootloader?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
MrMJPEG wrote:

We're not going to tell you! <g> Seriously, spend some time around AVRFreaks or read one of the many tutorials on programming the PIC or AVR, and you'll learn this and much more -- because there is MUCH more to learn!
Suffice it to say, consider that every time a PC starts (boots) it has to reload its software into its blank memory. It uses a firmware BIOS for this. The same with a microcontroller that uses a standard serial port for loading softweare into it. At the very least the MCU has to have basic software resident in it to tell it to listen on this port for new instructions. AVRs don't have a firmware BIOS, but they can be made to reserve a portion of its Flash memory for this wake-up-and-take-my-new-program code.
I'm sure the explanation on AVRFreaks is much better and more concise. It's what you get for asking questions here! <g>
-- Gordon
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
My first motion control project, and first real microcontroller project was a 2 axis system. H Bridges, motors, A/D converters, gears, the works.
It can't hurt to plunge in as deep as you care to. For the record , the second was a single axis, then I went on to a three axis, four axis, and five axis, and a bunch of multi-axis wierdos. For the record, FORTH was in all but two of them.
The easiest of them had the bigger micros in them. There is nothing more fustrating than coding in assembly to get the speed you need. There is nothing more painful than cutting functionality to save room.
The big mistakes beginners make is not recognizing what is simple and what is complex. A big scary 16 bit micro may look bigger and scarier than a Pic or an 8 bit AVR, but personally I would rather do what I need with a 16 or 32 bit micro that is seemingly more difficult, than have to operate in a tiny little 8 bit box...
The most important thing is having a roadmap to follow. If you can start in with good examples, you are nearly guaranteed success.
Sure, starting in on an 8 bit micro can't hurt, but never be afraid to throw everything out and start over, it is often the fastest path.

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Thanks. I have a serial adapter already; sounds like I should be in good shape.

Yes, but then I'd have to actually *use* Windows, which I find find unpleasant -- and what's the point of a hobby if it's unpleasant?
I may break down and do that someday, but I'll put it off as long as possible.
Thanks, - Joe
,------------------------------------------------------------------. | Joseph J. Strout Check out the Mac Web Directory: | | snipped-for-privacy@strout.net http://www.macwebdir.com | `------------------------------------------------------------------'
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
On Tue, 06 Dec 2005 18:29:28 -0800, Gordon McComb wrote:

My limited experience has shown the GCC stuff is easier to get going under Linux than a Linux emulator on M\$.
Debian provides a nice GUI sitting on top of XWindows, and it is free. I have recently repurposed a 600 mhz celeron laptop. W 64 mb ram, it is happy w/o the gui, w/128 mb ram, it is fune running the gui
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
For your moco project, you are going to need timers. At least one timer pin per axis, and up 4 per axis, depending on the architecture you intend to use. (unless you bit bang, but that can be exceedingly unpleasant)
a minimal timer pin usage would be 1 timer pin and 1 GPIO pin to do decent step/direction control. THe unfortunate thing is that S/D control is evil. There is no feedback, and the step line often becomes a noise antenna... This assumes an external step/direction amplifier.
Two timer lines can allow an external amplifier to be driven with complimentary pin PWM. this is also enough to get a stepper motor going if you drive an amp directly.
Three timer pins, if of the correct flavors, would allow you to do quadrature feedback on two of them, and locked ani-phase motor control on the 3rd
Four timer pins of the appropriate flavor will allow you to do quadrature feedback on two of them, and complimentary PWM on the other two.
A 2 axis mo co system, on the cheap, is non trivial, but you can start messing with smaller micro controllers.
A Pluga A Pod at \$100, is not a bad way to go. You can close a servo loop, drive a servo motor, and take commands via CAN, SPI, or serial.
The CF interface will be one of the areas that is tough. It is a parallel device, and thus eats up a lot of pins. The SD memory is serial at least.
I suggest playing, but there will come a point where you should stop building on a lesser micro, and redirect your efforts towards what you really need. The biggest, most frequent mistake I see, is people overloading their microcontrollers, when they should be redirecting.

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
blueeyedpop wrote:

You can do hard real-time motion control of any number of axis using one timer only for all axis.
Think interpolation of motion between axis, not independent square wave generation...
bruno
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Ok, true, integrating a PWM pulse gives you a varying signal, but I wouldn't use it to drive an amp for motion control...

decent
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
hmm... I am not really following you. I am not talking about generating some continuous signal from a PWM. I meant interpolating in the sense that one stepper motor stepping rate derives from another one, thus one stepper "interpolates" the other stepper movement within it's own limits. Imagine you want to draw a line on an XY table, one stepper controls each axis. The stepper controlling the axis having the most movement is used as reference. For each step, a decision is made: do I step the other stepper or not ? You can scale this to any dimension, i.e. any number of steppers.
That is basically line drawing in a discontinuous manner, i.e. rasterizing. Look up the Bresenham line rasterizing algorithm. To have complex movements, small patches of straight lines can be 'drawn' after each other.
In my project, I also handled circles directly because it is more efficient and there are better algorithms to do circles than approximation by straight line.
bruno
blueeyedpop wrote:

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
right, but to control the motor itself, unless you are bit banging on an interrupt, a timer is a very handy way to generate the pulse.

wave
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

I am also looking for a good micro-controller development platform for a "show-bot" that I presently have tethered to an old PC running DOS.
I was looking through the Digicom Catalogue and saw what appears to be a complete Z8 development kit, including MCU and Board for just \$50 CAN (I guess about \$40 USD). That appears to be much cheaper than the PIC or AVR kits.
Also are there any comments on the use of 8051 or H8 series?
Are not the 8051s an industry standard and the H8 used in the Lego Mindstorms?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

`------------------------------------------------------------------'
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
UFO Joe wrote:

cost of a starter dev kit for AVR is the cost of one AVR uC. Let me explain: - C compiler: free, AVR-GCC - Programmer software: free, avrdude (for example) - hardware programming interface: free, (everybody has a parallel port cable lying around, right ?) no additional components necessary.
:-)
bruno
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Huh? You mean you plug the "chip" directly onto the end of a parallel cable?
Or, do you mean that it programs via 8 data lines that you can fairly easily hard-wire to the end of a modified printer cable.
Or, is the AVR a mini-board with chip mounted?
Thanks for the quick response!

<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

## Site Timeline

• ### EV Warrior motor: stall torque of 691 oz-in = X operating torque ?

• - next thread in General Robotics Forum
• ### Servo drive signals for HP 7978 tape drive controller

• - last updated thread in General Robotics Forum

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.