Motorshield - first step goes in reverse or stays still

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Motorshield - first step goes in reverse or stays still

Post by Euphy »

Hello everyone, I've got a couple of small steppers (20 steps per revolution) that I'm driving through a motorshield. Works brilliant, and I think I've had no problems when I've used different steppers.

When I step, often the first step in the run is either in reverse (so I try to step 6 steps, but the first one goes backwards - so I only end up stepping four steps in the right direction), or it's missing entirely (the first step is the step the motor is already on, I think, so I get five steps in the right direction). It does not happen if I keep the motors energized, that is, it only happens after issuing a motor.release() instruction.

If I do a run of six steps (looping: motorb.step(6, BACKWARD, DOUBLE); motorb.release();) then every one begins with a reverse step.
If I do a series of five steps (looping: motorb.step(5, BACKWARD, DOUBLE); motorb.release();) then the motor starts ok, but sometimes rolls back one step at the end. If it doesn't roll back, then the first step of the next run misfires - the rotor is moved to the same position it's already at.
If I do a series of four steps (looping: motorb.step(4, BACKWARD, DOUBLE); motorb.release();) then the motor works fine, four steps time after time.

I'm not sure what's going on - it seems like the sequence of steps (the power going to the motor) has got out of sync with the position of the rotor. It happens when I'm using two power supplies (one for arduino, one for motorshield) or sharing. Now these little steppers are BANNED bin stuff, and I'm using them to run a loop of string, so there is some tension, and when the motors are .release()ed, then there often is a little backlash. I can do my best to eliminate this from the mechanical design, but it's only a fraction of the size of a step, so I don't know if that's entirely the problem.

Any ideas for a way I can compensate for this?

Cheers folks!
Sandy Noble

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit_support_bill »

What type of motor is it? Are you sure you have it wired right? On a 6 or 8 wire motor it is possible to misidentify the center tap or get a coil reversed.

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

Hi, sorry I didn't mention did I. It's an odd small five wire stepper motor, with two coils, one of which has a centre tap. The centre tap is not connected, just the two coils. Some stuff:
http://profmason.com/?p=173
http://www.instructables.com/id/Drive-a ... processor/
about the motors.

There is a mention in the instructable bit about
It doesn't really matter where in the cycle you start, although the motor might turn backwards one step before it gets going in the right direction. So in your example, you stopped the motor with RED energized. If you then went back to BLACK, it would take one step backwards so that it was lined up with BLACK. At that point, you'd continue the cycle either to BLUE or RED, and that would determine the direction that the motor rotated. As for BLUE... It would be 50/50 whether it goes clockwise or counter-clockwise.
Which is exactly what I thought might be happening - I don't know much about how the software works though. Does the AFMotor library keep track of which was the last step taken - and which is the next in the sequence? The standard arduino stepper library seems to do that, but then the circuit I'm using (tom igoe's two-wire design) doesn't have any kind of .release(), and I've tried the accelstepper library which also doesn't seem to be able to turn off. Need a more advanced circuit for that I think.

Cheers!
Sandy Noble

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit_support_bill »

It's an odd small five wire stepper motor, with two coils, one of which has a centre tap. The centre tap is not connected, just the two coils.
5-wire motors are typically electrically similar to a 6-wire motor with joined center-taps. These should be wired with the center taps to the ground terminal.

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

It's actually just one of the coils that has the centre tap - not sure what application it's designed for.

Anyway, I think my problem is that when I step six times, (A, B, C, D, A, B), then .release(), the motor is left aligned in the "B" position. Then when I start stepping again, the sequence starts again at A, so it goes backwards. Is there a way of telling the AFStepper library to start on a particular step? If you see what I mean?


Cheers, happy new year!
sn

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit_support_bill »

I see what you mean. The release resets the latch state, and the next step command starts over at the first phase.

You could hack the library to remember latch_state on release() and restore it on the next step() command. Or maybe have a function which returns latch_state and can be passed back in as an optional argument to step().

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit »

please re-download the library from git. we (coincidentally!) fixed this today with some other great updates. let us know if it works

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

Rock and roll, I'll give it a shot later. I've kind of solved the problem simply by saving up my steps until I've got a batch of four to fire off at once, but it's a bit of a kludge I could do without.

Thanks folks, brilliant product btw.

If anyone's interested, this motorshield is driving a linear clock that I've written up as an instructable: http://www.instructables.com/id/Linear-Clock/. Currently open for votes, so visits/votes very welcome!!

Sandy Noble

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit »

nice work! we'll post it on the blog

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

Brilliant thanks!

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

Hi, I've had a trial of this, works great at picking up where it left off. Doesn't do it when I'm using the accelStepper library though - is there a away to do that? I am doing a .release() on the AFMotor object that the AccelStepper object is based on to release the motors. I don't strictly need the accelstepper library, but those moving together bits sure are nice!

Cheers!
sn

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit »

hmm we havent dug into the accelstepper library to figure out why, we made a pretty minor change so we assume the issue is somewhere in the library!

Euphy
 
Posts: 19
Joined: Sat Aug 28, 2010 10:41 am

Re: Motorshield - first step goes in reverse or stays still

Post by Euphy »

Fair point. Using the AccelStepper, the behaviour is actually worse than simply forgetting where it ended up - it seems a lot more random.
http://www.youtube.com/watch?v=eevK1LyanIE if you're interested - this is:

Code: Select all

void loop() 
{
  if (accelHour.distanceToGo() == 0)
  {
    hourHand.release(); // this is the AFMotor object
    delay(1000);
    position += 4;
    accelHour.moveTo(position); // this is the AccelStepper object
  }
    
  accelHour.run();
}
I'm not that concerned about this.. but in case you are keeping a list! Would it be worth me getting in touch with Mike McCauley about this?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Motorshield - first step goes in reverse or stays still

Post by adafruit »

yup! please contact the library writer, like we said, we only made it afmotor compatible :)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”