Arm Mbed OS support forum

Intializing the xEN pin causes my stepper motor to hold in place, regardless of xSTP, xDIR, or xEN

Im trying to get my steppers to spin with the SKR 1.3V using the LPC1768 chip to spin its stepper motors but enabling xDIR, and xSTP does nothing, while just enable xEN with no code causes the motor to hold in place!

#include "mbed.h"

DigitalOut xEN(P2_1); //Pin 74 of LPC

int main(){
}

Not-initializing the xEN but still using the xDIR/xSTP pins will cause the motors to do nothing instead.

I’ve tried confirming what combination of enabling and disabling will make the motors spin with this:

#include "mbed.h"

DigitalOut xEN(P2_1); //Pin 74 of LPC
DigitalOut xSTP(P2_2); //Pin 73 of LPC
DigitalOut xDIR(P2_6); //Pin 67 of LPC



void spinattempt()
{
    for(int i = 0; i < 3; i++){
        xEN = 0;
        thread_sleep_for(1000);
        xEN = 1;
        thread_sleep_for(1000);
    }
    xEN = 0;
    for(int i = 0; i < 3; i++){
        xDIR= 0;
        thread_sleep_for(1000);
        xDIR = 1;
        thread_sleep_for(1000);
    }
    for(int i = 0; i < 3; i++){
        xSTP = 0;
        thread_sleep_for(1000);
        xSTP = 1;
        thread_sleep_for(1000);
    }

}

int main() {

xEN = 0;
xDIR = 0;
xSTP = 0;
//Should keep spinning till I unplug the SKR V1.3
while(1) {
    spinattempt();
}
}

but it does nothing. except hold the motor in place.

Is there something I need to do with the pin definitions or something else i’m missing?
SKR 1.3V schematic

I solved it!

Aparently, thread_sleep_for(1000) wasn’t working for me, but wait(); was.

Also, the wait interval I used was too short, Setting wait to 0.001 caused it to spin! Im not sure why, but I think my motor is microstepping instead of full stepping on my board despite the board bieng set to STP/DIR mode

Working code

#include “mbed.h”

DigitalOut xEN(P2_1); //Pin 74 of LPC
DigitalOut xSTP(P2_2); //Pin 73 of LPC
DigitalOut xDIR(P2_6); //Pin 67 of LPC

//DigitalOut yEN(P2_8); //Pin 65 of LPC
//DigitalOut ySTP(P0_19); //Pin 59 of LPC
//DigitalOut yDIR(P0_20); //Pin 58 of LPC

int main() {

xDIR = 0;
xEN = 0;
for(int i = 0; i < 20000; i++){

    xSTP = 1;
    wait(0.001);
    xSTP = 0;
    wait(0.001);
}

}