go away spammer

Author Topic: Stepper motor, "step done" detection  (Read 3209 times)

0 Members and 1 Guest are viewing this topic.

Offline newInRoboticsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Stepper motor, "step done" detection
« on: February 06, 2012, 11:04:04 AM »
Hi again  ;D

I have a setup in which:
  • Software in PC sends command containing number of steps and speed to ATmega (via UART)
  • ATmega in turn drives steeper motor in accordance to that command

I is essential to make sure that new comand to stepper is issued only when it reaches position set by previous command. And here goes my question of how do I detect that stepper motor has finished the step?

I was thinking of using timer, however that would not ensure that final position was actually reached (maybe some steps were skipped because of the load).

Another thought was shaft encoder, however that would have to be placed on the shaft very precisely so that it gives "tick" when shaft gets very close to it's "step complete" position.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Pogertt

  • Full Member
  • ***
  • Posts: 60
  • Helpful? 3
  • Pogertt
Re: Stepper motor, "step done" detection
« Reply #1 on: February 06, 2012, 11:16:51 AM »

I was thinking of using timer, however that would not ensure that final position was actually reached (maybe some steps were skipped because of the load).

Another thought was shaft encoder, however that would have to be placed on the shaft very precisely so that it gives "tick" when shaft gets very close to it's "step complete" position.

To detect a missed step, and detect correct final position, you are looking to use a closed loop control system.

As a simple example, if each step command causes a counter value to increase by one count, and the encoder feedback causes the counter to decrease it's count by one, then as long as the motor moves on each step, the maximum value in the counter will be 1.  A counter value of 2 would indicate a commanded, but missed pulse.

Are you familiar with how a quadrature encoder works?

Pogertt
Mmmmmmmm....Cookies

Offline newInRoboticsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Stepper motor, "step done" detection
« Reply #2 on: February 06, 2012, 01:37:28 PM »
Hi Pogertt,

thanks for Your suggestion, it gave me some more ideas of how to make sure stepper reaches final position. My question still remains: is it possible to know when stepper completes single step?

Are there any current draw patterns which manifest when poles are aligned and when poles are in mid-step position? (I don't O'scope to test it).
« Last Edit: February 06, 2012, 01:43:07 PM by newInRobotics »
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Stepper motor, "step done" detection
« Reply #3 on: February 06, 2012, 02:01:00 PM »
No - you don't know when its done the step - since all thats happening is that a 'pulse' is given to the correct coils to try and make it move. If the motor is under a heavy load then it may not be able to turn at all. Only an encoder can tell you when it has moved. And finally: the encoder will tell you the shaft has rotated but since the wheels may 'skid' it doesn't mean that the robot has actually moved.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Pogertt

  • Full Member
  • ***
  • Posts: 60
  • Helpful? 3
  • Pogertt
Re: Stepper motor, "step done" detection
« Reply #4 on: February 06, 2012, 02:55:25 PM »
And finally: the encoder will tell you the shaft has rotated but since the wheels may 'skid' it doesn't mean that the robot has actually moved.

If you are interested in proving movement over ground, have the encoder mounted to a wheel that is free spinning on an axle that measures ground movement, rather than motor shaft movement then?

If the encoder is mounted to the motor shaft, it will only report a missed motor step. An axillary wheel that senses ground movement will detect both a missed motor step or a slip of the wheel on the terrain.
Mmmmmmmm....Cookies

Offline newInRoboticsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Stepper motor, "step done" detection
« Reply #5 on: February 06, 2012, 03:42:05 PM »
OK, I see. Probably encoder will have to be enough.

It's not a mobile robot, it's a CNC controlled from USB port as opposed to ones controlled form parallel port. I was thinking of implementing interrupt driven system where "completing" one step would trigger following step.

All that can be done with timer interrupts, however I was looking for something to check if step was successful, or was motor stalled somewhere in the middle.

Thanks for Your time guys  :)
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Stepper motor, "step done" detection
« Reply #6 on: February 06, 2012, 04:01:40 PM »
Hi,

how do I detect that stepper motor has finished the step?[/i]
Read Microchip app note 1307 (around midway through).


I was thinking of using timer, however that would not ensure that final position was actually reached (maybe some steps were skipped because of the load).
Whether you use the approach found in AN1307 or something else, you can make the controller issue either a busy signal until, or an acknowledge pulse when, the position is reached .


Another thought was shaft encoder, however that would have to be placed on the shaft very precisely so that it gives "tick" when shaft gets very close to it's "step complete" position.
A couple of well placed SMD hall switches might be used if they can be embedded within the windings, or a rotary Hall detector perhaps, but check that app note out before you try something radical :)
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline newInRoboticsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Stepper motor, "step done" detection
« Reply #7 on: February 06, 2012, 04:55:35 PM »
Read Microchip app note 1307 (around midway through).
I had a quick look (closer look tomorrow). Were You talking about current measurements when coils are energised and when in decay? As far as I understand - it's not very helpful as in CNC coils are always energised. What I am looking  for is some sort of indication of when magnetic pole of the motor gets aligned with magnetic pole of the coil (if that make sense).

A couple of well placed SMD hall switches might be used if they can be embedded within the windings, or a rotary Hall detector perhaps, but check that app note out before you try something radical :)
I'm not sure how should I embed SMD Hall switches (and what I would achieve by doing so), but it sounds like it's not for my ability just yet.
Rotary Hall detector was one of my thoughts as well, I have dismissed it as it requires constant ADC pin sampling.

Another thought, wouldn't it be simpler to get motors that can easily deal with a bit more than expected loads and use only timer interrupt to advance steps?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Stepper motor, "step done" detection
« Reply #8 on: February 06, 2012, 08:44:30 PM »
Hi,

As far as I understand - it's not very helpful as in CNC coils are always energised.
Eh?
How does the motors move then? ;)


What I am looking  for is some sort of indication of when magnetic pole of the motor gets aligned with magnetic pole of the coil (if that make sense).
Yes, I think I know what you mean.
Rethorical question... Does the coil change its properties in any way when brought close to magnetic poles of same/opposite magnetic polarity to its own field? Would you be able to detect any possible changes?


I'm not sure how should I embed SMD Hall switches (and what I would achieve by doing so), but it sounds like it's not for my ability just yet.
Rotary Hall detector was one of my thoughts as well, I have dismissed it as it requires constant ADC pin sampling.
As long as you read/update once every revolution you're good and doing it by interrupt would be the obvious choice. If you only needs to move less than a full rev. just poll for the result - and forget A/D-C, you can get them with digital output.

Take a look at AustrianMicroSystems' range of rotary encoders (I don't know what resolution you want/need)

A hall switch should be placed in a position where the magnetic cams/teeth passes by, then you can read each full step it makes - half stepping and micro-steps cannot be resolved this way.


Another thought, wouldn't it be simpler to get motors that can easily deal with a bit more than expected loads and use only timer interrupt to advance steps?
Of course it would be simpler to use larger motors :)
That way you "only" need to assure ramp up, ramp down and keep the speed well under what cause it to skip.

Whether you use timer interrupts or delays will probably not make much difference, as long as you give it enough time to move.

As I understand it, you want to use a controller more or less as a "dumb" stepper control (low level layer), where the PC tells it to go eg. 1234 steps CCW and then wait for it to get there and then signal back that it's ready for the next command - is that about right?
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline newInRoboticsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Stepper motor, "step done" detection
« Reply #9 on: February 07, 2012, 02:43:59 AM »
As far as I understand - it's not very helpful as in CNC coils are always energised.
Eh?
How does the motors move then? ;)
Well, coil gets de-energised after motor makes a step, not before. To In order to de-energise one coil and energise the other one I have to know that the step was complete beforehand.

A hall switch should be placed in a position where the magnetic cams/teeth passes by, then you can read each full step it makes - half stepping and micro-steps cannot be resolved this way.
Reading every full step is exactly what I need as I will most likely be using stepper in two-coil excitation mode to get extra torque and drive CNC tool using threaded rods. Would I have to put Hall switch inside stepper or would it be enough to have it on the case of the motor?

As I understand it, you want to use a controller more or less as a "dumb" stepper control (low level layer), where the PC tells it to go eg. 1234 steps CCW and then wait for it to get there and then signal back that it's ready for the next command - is that about right?
That is exactly what I want to achieve.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Stepper motor, "step done" detection
« Reply #10 on: February 07, 2012, 06:48:20 PM »
Hi,

Would I have to put Hall switch inside stepper or would it be enough to have it on the case of the motor?
You'd have to get them very close to the rotor, as the narrow fields won't be able to penetrate through steel casing an energized coils.

It would be easier (mechanically speaking at least) to use either the non-energized coils (assuming 4 coils) for measuring, or experiment with the energized coils. While I haven't tried it, I think you'd be able to deduct a full step from the changes in the coils.
Try running a motor with a weak current (just a bit of bias for measuring, say 1mA or so) on the "non-energized" coils and throw a 'scope at it. Or measure the inductive kick as a coil moves past a pole set.

A stepper cannot function without leaving a magnetic "trail" (or several), you just have to find one that is easy to measure and then conjure up a way to measure the un-powered coils in synch.

Or... You can do what most people do and just use properly rated motors with somewhat conservative speeds - it's a matter of whether you build this just to get it working or you build it to experiment with the construction as well :)
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here