Hi,
When I'm using the AccelStepper library to control this closed loop stepper motor, the motor ticks when turning, maybe ~5 ticks/sec. Depending on the speed of the motor the ticks become more (at higher speed) or less (at lower speed) powerful.
At a low speed (<500 steps/sec) the ticks can only be detected by holding the motor and feeling the ticks. However, at greater speeds (>1000) you can also hear them and see the motor "house" move a little bit with each tick.
I'm not 100% certain but it seems like the ticking frequency is the same independent of speed. So if I tell the motor to make 3 revolutions, a slower speed will result in more ticks total because more time is needed to complete the revolutions.
Neither using the stepper library that comes with the Arduino IDE nor manually setting the pulse pin HIGH and LOW in a loop results in any ticking. Therefore I don't think it is the motor that is faulty.
This is the code I'm using:
#include <AccelStepper.h>
AccelStepper stepper(1, 7, 6);
long receivedPosition = 0;
long receivedSpeed = 0;
char receivedCommand;
bool newData, runAllowed = false;
void setup()
{
Serial.begin(9600); //define baud rate
}
void loop()
{
checkSerial();
moveStepper();
}
void moveStepper()
{
if (runAllowed == true)
{
if (stepper.currentPosition() != receivedPosition)
{
stepper.runSpeedToPosition();
}
else
{
runAllowed = false;
}
}
}
void checkSerial()
{
if (Serial.available() > 0)
{
receivedCommand = Serial.read();
newData = true;
}
if (newData == true)
{
// RUN
if (receivedCommand == 'r')
{
runAllowed = true;
receivedPosition = Serial.parseFloat(); //value for the steps
receivedSpeed = Serial.parseFloat(); //value for the speed
stepper.moveTo(receivedPosition);
stepper.setMaxSpeed(receivedSpeed);
stepper.setSpeed(receivedSpeed);
}
}
newData = false;
}
Everything seems to work fine except for the ticking issue. Does anyone have any idea why this happens?