Stepper Motors


How to control stepper motors?

SilentStepStick TMC 2209

Step Configuration

CFG2/MS2CFG1/MS1SPREAD/MS3StepsInterpolationMode
GNDGNDGND1/81/256stealthChop
GNDVIOGND1/321/256stealthChop
VIOGNDGND1/641/256stealthChop
VIOVIOGND1/161/256stealthChop
GNDGNDVIO1/81/256spreadCycle
GNDVIOVIO1/321/256spreadCycle
VIOGNDVIO1/641/256spreadCycle
VIOVIOVIO1/161/256spreadCycle

Circuit

StepStick Circuit

Code

This is a simple test code for the stepper motor controller

int enPin = 4;
int dirPin = 2;
int stepPin = 3;
int stepAmount = 400;
int microSteps = 16; // 16 means 1/16, 32 means 1/32 etc.

void setup() {
  // put your setup code here, to run once:
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(enPin, OUTPUT);
  digitalWrite(dirPin, HIGH);
  digitalWrite(enPin, LOW);
}

void loop() {
  oneFullRotation();
  delay(1000);
}

void oneStep() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(100);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(100);
}

void oneFullRotation() {
  for (int i = 0; i < stepAmount * microSteps; i++) {
    oneStep();
  }
}

You can also use the vibration of the stepper motors as a feature. Koka Nikoladze is the master of this.

Other types of motors can also be tuned to play music: