Stepper Details
Manufacturer Part Number | 17HS15-1704S |
---|---|
Step Angle | 1.8° |
Step Accuracy | 5% |
Holding Torque | 44Ncm(62.32oz.in) |
Rated Current/phase | 1.7A |
Phase Resistance | 1.86ohms |
Driving Voltage | 12-24VDC |
Inductance | 3.55mH±20%(1KHz) |
Weight | 280g |
Hi, I'm building a display piece that has a rotating component. I need the motor to run as quietly as possible which is why I've selected a stepper motor for this application. I'm using a Nano connected to TMC2208 driver, NEMA 17 motor and a couple of push buttons. At the moment I am driving the Nano VIA USB and the TMC2208 via desktop power suppy at 5V however in the final version there will be a dedicated 5V power supply.
I've developed a circuit and code which I understand should incrementally increase and decrease the speed with each button press. One button increases speed in the CW direction whilst the other increases the speed in the CCW direction. From zero the motor will begin to spin either CW or CCW direction.
What I am experiencing is that the motor will spin at each speed increment up to the max speed limit. It will slow back down when the alternate button is pressed, however when attempting to spin in the opposite direction it will stutter and jitter. If enough speed is applied it eventually turns albiet roughly.
Video of the out put https://streamable.com/hffp8u
I've experimented with changing the wiring of the stepper motor, the only difference I find is that either CW or CCW runs smoothly and the opposite direction runs roughly.
I've tried driving the motors using simple digitalrights to the direction and step pins and get the same behaviour.
I've tried various stepper motors (all same make) and TMC2208 drivers to make sure I dont have faulty components and nothing changes the output.
Code is below. I understand that using AccelStepper library that speeds greater than 1000 are unreliable however dropping the speed below 1000 doesn't change the behaviour either.
Quick note, I dont have momentary switches, just push button so I've coded the input so the buttons only register once when pushed.
This is my first Arduino project so I'm a bit lost at the moment.
#include <AccelStepper.h>
const int UPBUTTON = 7;
const int DOWNBUTTON = 9;
int upButtonState = 0;
int downButtonState = 0;
int speed = 0;
int maxSpeed = 8000;
int speedStepValue = 1000;
bool upButtonActive = false;
bool downButtonActive = false;
AccelStepper stepper1(1, 2, 5); // (Type of driver: with 2 pins, STEP, DIR)
void setup() {
stepper1.setMaxSpeed(maxSpeed + 1);
stepper1.setSpeed(0);
pinMode (UPBUTTON, INPUT);
pinMode (DOWNBUTTON, INPUT);
}
void loop() {
stepper1.runSpeed();
upButtonState = digitalRead(UPBUTTON); // Reading button status / input
if (upButtonState == HIGH && !upButtonActive) // Condition to check button input
{
speed += speedStepValue;
if (speed > maxSpeed){
speed = maxSpeed;
}
stepper1.setSpeed(speed);
upButtonActive = true;
}
else if(upButtonState == LOW && upButtonActive)
{
upButtonActive = false;
}
downButtonState = digitalRead(DOWNBUTTON); // Reading button status / input
if (downButtonState == HIGH && !downButtonActive) // Condition to check button input
{
speed -= speedStepValue;
if (speed < -maxSpeed){
speed = -maxSpeed;
}
stepper1.setSpeed(speed);
downButtonActive = true;
}
else if(downButtonState == LOW && downButtonActive)
{
downButtonActive = false;
}
}
I've also trialed some simpler code using "moveTo" function but I get the same results:
#include <AccelStepper.h>
AccelStepper stepper1(1, 2, 5);
int target;
void setup() {
target = -8000;
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(200);
stepper1.setSpeed(1000);
stepper1.moveTo(target);
}
void loop() {
if (stepper1.distanceToGo() != 0) {
stepper1.run();
}
else {
// we have reached our target position.
// pause 1 second and then reverse direction:
delay(1000);
target *= -1;
stepper1.moveTo(target);
}
}