Thanks Alot everyone for the replies.
@Robin2 MDBT40 is 32bit ARM-M0 microprocessor similar to due. I am using arduino IDE to upload firmware to it.
I am using the example code which is provided in accelstepper library. Please check the code below:
// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
#define MOTOR_A_ENABLE_PIN 16
#define MOTOR_A_STEP_PIN 12
#define MOTOR_A_DIR_PIN 13
// Define a stepper and the pins it will use
AccelStepper stepper(1, MOTOR_A_STEP_PIN, MOTOR_A_DIR_PIN);
void setup()
{
// Change these to suit your stepper if you want
stepper.setMaxSpeed(6000);
stepper.setAcceleration(12000);
stepper.moveTo(2000);
}
void loop()
{
// If at the end of travel go to the other end
if (stepper.distanceToGo() == 0)
stepper.moveTo(-stepper.currentPosition());
stepper.run();
}
The value of setMaxSpeed(6000); is based on calculation and stepper.setAcceleration(12000); is based on trial and error.
edgemoron:
I believe acceleration is steps per second per second so 12000 is out of the ball park and across the river, start with a more conservative value (500?) and work your way up. Also seems like the max steps per second for a 16 MHz processor is around 4000, sounds like your motor is missing lots of steps and falling behind.
The stepper motor moves very fast when there is no acceleration. For acceleration, when the keeping the maxspeed to 6000, if the acceleration is 500 then motor moves very very slow. As I increase the acceleration, the motor rotates faster. However, the speed is very slow till the acceleration is below 6000. When the acceleration exceeds 6000, the motor start moving faster and after some value (~12000) speed saturates to a constant speed.
MarkT:
Max acceleration and top speed of a stepper need to be experimentally determined with the motor under
load, since miss-stepping depends on many factors including inertia and resonance of the load, supply
voltage, microstepping factor and so forth.
Once you've found the max values that work, back-off about 20% to guarantee reliable operation.
Note that the AccelStepper library has a top step rate thats pretty low (read the source file comments),
since it uses floating point calculations.
@MarkT I can see the torque is enough. AccelStepper: AccelStepper Class Reference
In the performance section its mentioned that "Gregor Christandl reports that with an Arduino Due and a simple test program, he measured 43163 steps per second using runSpeed(), and 16214 steps per second using run();"
@weldsmith I didnt try "target.setMinPulseWidth(xx)." will try this to incorporate in my code.
MarkT:
There isn't a meaningful calculation, unless you are prepared to measure torsional inertia and damping
across a range of frequencies in situ (you don't have the equipment for this) and simulate the composite
system of motor + load in something like matlab.
Trial and error is how its done.
This might be difficult for me
.
Is the calculation for maximum speed correct?
Am I on right direction?