Driving PM55L motor with TMC2160 driver

I have a PM55L stepper motor connected to a TMC2160 controller, driven by Arduino uno.
I used the code below to drive it. It runs in both directions, but the motor gets very hot, very fast. What could the problem be?

I am fairly new to arduino and coding and have a fair knowledge of electronics. I set the controller dip switches as follows M0-0, M1-0,M2-0,M3-0,M4-0,M5-1,M6-1

Code for Stepper.
int dirpin = 8;
int steppin = 9;
int enable = 7;

void setup() {
// put your setup code here, to run once:
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
digitalWrite(enable, HIGH);
}

void loop() {
// put your main code here, to run repeatedly:
int i;
digitalWrite(dirpin, HIGH); //Set the direction
delay(100);

for (i=0;i<4000;i++) {
digitalWrite(steppin, LOW);
delayMicroseconds(400);
digitalWrite(steppin, HIGH);
delayMicroseconds(400);
}

digitalWrite(dirpin, LOW);
delay(100);

for (i=0;i<4000;i++) {
digitalWrite(steppin, LOW);
delayMicroseconds(400);
digitalWrite(steppin, HIGH);
delayMicroseconds(400);
}

}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Your topic was MOVED to its current forum category as it is more suitable than the original

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.