• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

stepper motor pot control

Status
Not open for further replies.

dsc

Member
Hi guys,

I've put together a circuit which uses a pot to control a stepper motor, the position of the pot corresponds to the position of the motor within a 54deg range, ie. 0ohm = 0deg position, 10kohm = 54deg position (as you can guess I'm using a 10kohm pot). The main problem I'm having is noise which isn't a surprise as there's loads of switch happening in the circuit. So to battle it I used sample averaging, currently adding 8 samples and dividing the total by 8 to get the final ADC value. This made things a bit better, but still not perfect, the motor moves from one end to the other, but sometimes jumps around a spot if you fiddle with the pod and make small adjustments.

I'm using 6bit resolution, ditching the last 4 bits (4 times RRF). The circuit is very simple using only a pot and 5V ref straight from the 7805 that supplies the uC (16f877a)

Can you suggest anything I can use to reduce the noise even more? I was thinking of using 16 sample averaging, a 1uF cap on between the ground and the wiper and using a separate 7805 to get 5V ref (although it will still use the same transformer that the uC 7805 is using, so I'm not sure if it's going to change anything).

Additional question I have is regarding stepper motors and 1/4 step mode. To make the circuit quiet and generate less heat I'm turning off the ports that control 2 LMD18245 chips 5ms after a step is done. Is this a good thing or do I have to keep them powered all the time to actually hold the position? Am I correct to think that the power is needed to hold the motor in between it's
natural full steps?

Regards,
dsc.
 

Mr RB

Well-Known Member
Hi. Re the pot noise, just put a 1uF cap as you suggested, but put it as close as possible to the PIC ADC pin, and add a 1k resistor between the cap and the wiper of the pot. That will damp the voltage and remove all the line noise from the cabling. You may not need oversampling, I would doubt you need to average more than 2 samples.

I assume you are not using an old pot that is scratchy? :)

If you have not done it already, put a 0.1 or 0.22 uF cap real close to the PIC power pins. If the 7805 only powers the PIC and the pot, decouple it from the motor and driver chip power with a resistor before the 7805 input, 10-22 ohms should be ok. Obviously you should have caps on the input and output of the 7805 AND the one on the PIC power pins. Obviously try to keep the driver chips and especially wiring to the steppers as far from the PIC and pot wire as possible. If they are bipolar steppers you can twist each pair of stepper wires.

I'm not familiar with those particular stepper drivers but most accept step/direction inputs, so they will hold the motor position if you stop giving pulses in, BUT when you power down the port it may generate a \ poulse endge that may clock the step input, check this. I doubt the port will be driving any real current at all, so I cant see why you would power it down anyway.

Probably just whack that cap on that ADC input pin is the main thing you need.
Hope that helps.
 

dsc

Member
Hi Mr RB,

thanks for the tips! I've tried the cap and the resistor but sometimes the motor still gets some noise and jumps between two steps continuously. Of course touching the pot usually gets rid of the problem but that isn't a long term solution as the motor can get quite hot doing that for a while. I've the digital board (uC + pot) quite far away from the stepper motor and it's controls as those two parts are joint using a 3m cable. The pot is a brand new one, although not the highest quality:

Tyco Electronics | Passives | Resistors, Potentiometers or Control Knobs | Resistors, Variable Panel Mount | Wirewound

Previously I was switching off the outputs to the motor as the LMD chips were getting very hot after a while (currently they only have small heatsinks on them). I can't really do that as motor won't hold it's position on it's own and needs current flowing through the coils. As it's around 2A for each coil you can imagine the LMDs get quite hot after playing with the pot for a few minutes.

One thing I thought of other than using a 16 sample window average is to lower the resolution of the ADC, from 6 bits to 5 bits. This should get rid of that dreaded step-jumping and might work as well. I will try both software solutions tomorrow, but I guess I've done pretty much almost everything I could hardware-wise (of course except for using a proper filter and amplifier).

Regards,
dsc.
 

Mike - K8LH

Well-Known Member
Hi dsc,

Have you considered using a rotary encoder instead of a pot'? The ones I've used have a detent position when the AB outputs are either '00' or '11' and so when I use them as controls for a menu system I usually only use the three AB positions between the detents to determine direction of rotation. Also, the two different ones I've used have a built-in push button switch on the shaft.

Food for thought.

Kind regards, Mike
 
Last edited:

dsc

Member
Hi Mike,

well I need something which is capable of generating at least 120 different positions and the pot is great for this as you can pretty much define how much various 'positions' it gives you simply by changing the resolution (default would be 1024 with 10 bit resolution, then 512 with 9bit and so on). The reason behind this is that the motor moves only in a pretty tight range of 120 1/4 step which is around 54deg.

Regards,
dsc.
 

Mike - K8LH

Well-Known Member
dsc,

You can use as many rotary encoder 'steps' as you like but I won't push it any further. I just wanted to make you aware of an alternative and maybe help you get those creative juices flowing.

Good luck on your project.

Kind regards, Mike
 

dsc

Member
Hi Mike,

how does it work precisely? is it something similar to rotary encoders used on stepper motors (with some sort of light sensitive element and a round plate with marks on it?). The other problem I might have with such an approach is using more than 1 pin as I only have PORT E free on the PIC (everything else is taken:|).

Of course thanks for the suggestion!

Regards,
Tom
 

Mr RB

Well-Known Member
Rotary encoders have 2 outputs and 1 common, they require 2 digital inputs on your micro.
They are typically switches, the ones i have here are 24 detents x4 combinations so you can decode 96 steps per knob rotation.

Did you fix the update time? This should be slow so your steppers won't jitter on the spot, or if it jitters it will be slow. Slowing the update time and some ADC averaging over a few samples should leave you jitter free.

Re the LMD chips heat, all stepper chips get a bit toasty. But most good ones have a "low power" feature, normally one pin you activate to make the driver go to 1/2 current mode, which is about 1/4 of the heat generated. This is for your exact situation, to "hold" the motor in position.
 

dsc

Member
Hi guys,

so it looks like I will have to use a rotary encoder as the pot doesn't really work well when you turn the knob slowly. When approaching the position on which the motor should change it's position it jitters between two steps which is caused by noise. Now I could probably add some more filtering, but still when turning the pot slowly it's going to jitter a little bit.

With a rotary encoder I don't have to worry about any of that as I simply check the 2bit signal and sense what way it's turning. The only problem with them is that they tend to be quite expensive. I bought a cheap one from ebay which has 20 positions, but the slightly better ones cost £8-10 or more. A 128position one would be nice, but I don't really won't to spend a lot of money on it, as it's really only a control knob.

Regards,
dsc.
 
This encoder has been mentioned on this forum before (take a search). Shipping across the pond can get expensive, so add a graphic lcd (also mentioned here), or something else to your liking, to make it worth your while.
 

Mr RB

Well-Known Member
Altronics in australia has them for about $4.50 USD, they have a fluted shaft suitable for using as a rotary knob on project front panels etc. The ones I got seem to be about 96 steps/rev I think they are 24 x4 step.
 

millwood

Banned
once you do that Mr. RB suggested, there shouldn't be any "pulse" coming into the ADC pin.

it may be a software issue / driver issue that the motor is hunting?
 

dsc

Member
Hi guys,

I've thought about it some more and it seems like I will have problems with rotary encoders as well. First thing is how fast you can turn the knob without loosing positions. Second thing is debouncing which isn't complicated, but needs time and my application is a bit time-limited.

To be honest the pot seems like the best idea, simple to use and gives high torque so you don't turn the knob too fast. I think I'm getting loads of noise from the LMD chips, they are handling 2A each and switching a lot when the motor moves. Now I've added some code that actually detects if the position change is caused by a sudden transition (noise near the transition position) or a permanent move of the knob. I will test it today and see if it works or not.

Regards,
dsc.
 

millwood

Banned
6 bits mean 64 steps over 54 degrees or 420 steps over 360 degrees: those are going to be pricey encoders at that kind of resolution.

using the pot is the right way to go - you just need to filter out the contact noise: which looks like you have. just make sure that you don't overdo it because if you do, the voltage input to the adc pin will be delayed.

I would go back and look at the sampling algorithm: if the sampled voltage is much lower than the previous average (let's say 20% more or less), you throw out that sample. this prevents a sudden reading when the wiper goes open.
 

dsc

Member
re

Hi guys,

yeah the knob (be it encoder or pot) is there to control the motor. It should work a bit like a valve simulator, you turn the knob the motor moves and there's a valve attached to the motor so it moves with it.

So to answer your question, yes it will be operated by hand.

Regards,
dsc.
 

vinod467

New Member
Pot

to reduce noise u can make use of precision pot 1kohms-1 turn(1k1t)
then u can use signal conditioning circuit.. where u can callibrate your 0 to 5v to equivallent 0-360degree.. your 10-bit adc will give u 00-1024 levels.

i am also working on the project...

all the best.,
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top