Stepper and servo motor control, with a PIC. Where to start?

Status
Not open for further replies.

Jeff7

Lifer
Jan 4, 2001
41,596
20
81
A project at work has me a bit interested in some of this stuff. The simple version of the project is:
Move a backstop using forward and backward buttons, but when it's in the stop position, the motor needs to hold its position.

More complex version:
Enter a value into a controller, and have the motor move to that position, using some manner of linear encoder, likely an optical one, something like this.

I'd like to use a PIC chip, either PIC18 or PIC32, to control this whole mess, and use Microchip's MPLAB compiler.


What's a good, and not terribly-expensive, way to get started on learning the basics of motor control in this manner?
I would have limited access to a circuit board router in order to make something like a breakout board to give some convenient pinouts for the PIC32 (TQFP package), for some breadboarding.
 

Lithium381

Lifer
May 12, 2001
12,452
2
0
A PIC18 would probably be a better platform for you, as it's available in DIP package and has plenty of horsepower for what youre trying to do. There may be similar projects online that can help give you an idea. The link DRAKO gave is pretty sweet, i had never seen that document before, but it gives a good overview. there are lots of hobby sites dedicated to robot-making, that could provide you with a lot of insight. i only very recently got into the hobby. if there is anything i can do to help, PM me.
 

Jeff7

Lifer
Jan 4, 2001
41,596
20
81
I would use a DIP package PIC, and just bread board the design up. Stay away from surface mount parts.

And here's a tips doc from microchip that may be helpful to you, or not :)

http://ww1.microchip.com/downloads/en/devicedoc/41233A.pdf
Well...I'd also like to use this as a chance to get acclimated to the PIC32, which only comes in a surface mount package. I've already got access to a breakout board that has standard 0.100" pinheaders on it, and I could simply get a circuitboard routed out that would provide some manner of pinout interface, or whatever I'd need.
Though, well, I don't know how different it is working with the PIC32 vs one of their 18F line.
And I've got myself a nice breadboard already. Cheaper, too. :p

I've already worked with the 12F675, 16F72, 18F2520, and 18F4520. (The latter two are nearly the same - the 4520 just has more I/O pins, and I believe more memory as well.)
However, I've done all the programming using CCS' PIC-C compiler. It has some nice things that make programming easier, but this also can make it tough to access the really low-level functions of the PIC, without diving into assembly language. So I'd like to get acquainted with Microchip's MPLAB compiler. It's free, and, well, it's Microchip's own compiler, so what better thing to use than that on their microcontrollers? :)


And I shall certainly read the motor control app note PDF. Thank you for that.
 

Drako

Lifer
Jun 9, 2007
10,697
161
106
Well...I'd also like to use this as a chance to get acclimated to the PIC32, which only comes in a surface mount package. I've already got access to a breakout board that has standard 0.100" pinheaders on it, and I could simply get a circuitboard routed out that would provide some manner of pinout interface, or whatever I'd need.
Though, well, I don't know how different it is working with the PIC32 vs one of their 18F line.
And I've got myself a nice breadboard already. Cheaper, too. :p

I've already worked with the 12F675, 16F72, 18F2520, and 18F4520. (The latter two are nearly the same - the 4520 just has more I/O pins, and I believe more memory as well.)
However, I've done all the programming using CCS' PIC-C compiler. It has some nice things that make programming easier, but this also can make it tough to access the really low-level functions of the PIC, without diving into assembly language. So I'd like to get acquainted with Microchip's MPLAB compiler. It's free, and, well, it's Microchip's own compiler, so what better thing to use than that on their microcontrollers? :)


And I shall certainly read the motor control app note PDF. Thank you for that.

Sounds to me like you should get these:

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=DM320003-2-ND

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=876-1000-ND
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
Stepper motors are really easy. You just power each coil in order and the motor will rotate that many degrees or step.
You can use the pic chips you already have. You just need something that can drive the motor power since pics limit at around 20ma.
I use the ULN2004A chips. You can get them off ebay cheap.
Then you just pull a pin high for each wire on the motor you want to turn on. Let the motor turn then pull the pin back low. Move to the next pin in the sequence and continue.
So to do a full rotation you would have to do
pin 1 - H L
pin 2 - H L
pin 3 - H L
pin 4 - H L

And repeat for every revolution.
 

PottedMeat

Lifer
Apr 17, 2002
12,363
475
126
Stepper motors are really easy. You just power each coil in order and the motor will rotate that many degrees or step.
You can use the pic chips you already have. You just need something that can drive the motor power since pics limit at around 20ma.
I use the ULN2004A chips.

those are handy. just remember they're limited to ~500mA per driver, anything else and you'll need an output MOSFET/BJT at the rated current and a separate diode clamp.
 
Status
Not open for further replies.