I am using NEMA 17 stepper motor and TMC2208 driver. Previously I was dealing with rotational motion using this code, which was doing fine. I can change the speed however I want. The code (for 0.4 rpm) :
#include <MobaTools.h>
const byte stepPin = 2;
const byte dirPin = 5;
const byte enablePin = 8;
const unsigned int motorStepsPerRev = 200;
const unsigned int microstepMultiplier = 16;
const unsigned int STEPS_REVOLUTION = motorStepsPerRev * microstepMultiplier;
const unsigned int STEPS_0_4steps_PER_Second = motorStepsPerRev * microstepMultiplier * 4; // (0.4 rev/second = 4 rev/ ten_seconds)
MoToStepper stepper( STEPS_REVOLUTION, STEPDIR );
void setup()
{
Serial.begin(115200);
stepper.attach( stepPin, dirPin );
stepper.attachEnable(enablePin, 5, 0);
//stepper.setSpeed(4); // = 0.4 RPM speed in rpm /10
//stepper.setSpeedSteps(12800); // the number is steps per TEN seconds (not steps per 1 second)
stepper..setSpeedSteps(STEPS_0_4steps_PER_Second);
stepper.setRampLen(32);
stepper.setZero();
}
void loop()
{
stepper.rotate(1); // turn CW 4e4
}
But now I need a linear motion, which I am doing using belt-pulley. (I am using GT2 gear which has 20 teeth and 2 mm pitch.) I need 300-500 mm/min linear motion. I have developed some equation to use the code above, but I am not sure that will do it.
Have anyone worked on rotational to linear motion using belt-pulley?
Can you help me with a code by which I can get the desired speed I want?
Thanks in advance.