PDA

View Full Version : Accurate control of stepper motor



Picstar
- 27th February 2012, 03:41
Hello All,
I am trying to accurately control the position of a stepper motor using either a variable resistor or maybe some type of rotary encoder. I have written the code and have had some luck
but I can't seem to get my system operating right, mostly I think because I'm using the POT command and variable resistor. The ideal system would turn the stepper motor 1/2 turn with the full swing of the variable resistor or encoder, and then slowly return to its original position as the v. resistor is turned back down. There are probably separate controllers that already do this but I prefer banging my head against the wall. So, any help would be greatly appreciated.

mackrackit
- 27th February 2012, 03:55
You will have better luck using the ADC command, the POT command is not always best. And make sure the variable resistor is linear, it will be easier to code for.

Demon
- 27th February 2012, 18:24
Well, if you want to bang your head a little harder, have you considered using a rotary encoder instead of a pot? Then you don't have to worry about linearity, ADC, pot reaching end of travel, etc.

Count the pulses going, and then back. Something like these:

http://www.ebay.ca/itm/ws/eBayISAPI.dll?ViewItem&item=380410565135

http://www.sure-electronics.net/DC,IC%20chips/CS-CO043_2_b.jpg

I have yet to use one of these so I can't comment on their downsides. My order should get here any day.

Robert

gadelhas
- 27th February 2012, 18:58
Well, if you want to bang your head a little harder, have you considered using a rotary encoder instead of a pot? Then you don't have to worry about linearity, ADC, pot reaching end of travel, etc.

Count the pulses going, and then back. Something like these:

http://www.ebay.ca/itm/ws/eBayISAPI.dll?ViewItem&item=380410565135



I have yet to use one of these so I can't comment on their downsides. My order should get here any day.

Robert

Hi Robert;

I used one of those this last days. They are not bad for the price. I'll put the code as soon as i can on the wiki.

aratti
- 27th February 2012, 20:43
You can Find the code for reading a two channels optical encoder (in quadrature) @ http://www.picbasic.co.uk/forum/showthread.php?t=12911

Post 28 or 27.

Cheers

Al.