Command line to stop stepper from drawing current

I'm using a nano to power a 28byj48 steeper.
it get very hot.
I've heard there is a way to stop the stepper from drawing current when not turning. i do not need it to hold position.
can someone please tell me what command line i need to insert to achieve this and where to put it?
thank you

The Arduino should not power anything, other than perhaps an LED or two. Always use a separate power supply for motors and servos.

The stepper is controlled by turning on and off the current to the coils, in sequence. To turn off all the coils, you will need to modify the program that you forgot to post.

I did not forget to post my program. I was hoping it would just be a simple thing like " just put "this" here".
but nothing i get involve in is ever simple so i shouldnt be surprised.
here is my sketch
#include <ezButton.h>

#include <AccelStepper.h>

#define FULLSTEP 4

#define STEP_PER_REVOLUTION 2048 // this value is from datasheet

#define DIRECTION_CCW -1

#define DIRECTION_CW 1

#define STATE_MOVE 1

#define STATE_MOVING 2

#define STATE_STOP 3

#define STATE_DELAY 4

#define INFINITE 0x00FFFFFF

ezButton limitSwitch_1(7); // create ezButton object that attach to pin 7;

ezButton limitSwitch_2(6); // create ezButton object that attach to pin 6;

// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence

AccelStepper stepper(FULLSTEP, 8, 10, 9, 11);

int stepperState = STATE_MOVE;

int direction = DIRECTION_CW;

unsigned long delayStartTime = 0;

int lastTouchedSW = 0;

long targetPos = 0;

void setup() {

Serial.begin(9600);

Serial.println(F("####### SYSTEM STARTED #######"));

limitSwitch_1.setDebounceTime(50); // set debounce time to 50 milliseconds

limitSwitch_2.setDebounceTime(50); // set debounce time to 50 milliseconds

stepper.setMaxSpeed(800.0); // set the maximum speed

stepper.setAcceleration(800.0); // set acceleration

stepper.setSpeed(800); // set initial speed

stepper.setCurrentPosition(0); // set position

Serial.print(F("state -> "));

Serial.println(stepperState);

}

void loop() {

limitSwitch_1.loop(); // MUST call the loop() function first

limitSwitch_2.loop(); // MUST call the loop() function first

if (limitSwitch_1.isPressed()) {

if (lastTouchedSW != 1) {

  Serial.println(F("The limit 1 switch: UNTOUCHED -> TOUCHED"));

  stepperState = STATE_STOP;

  Serial.print(F("state -> "));

  Serial.println(stepperState);

  lastTouchedSW = 1;

}

}

if (limitSwitch_2.isPressed()) {

if (lastTouchedSW != 2) {

  Serial.println(F("The limit 2 switch: UNTOUCHED -> TOUCHED"));

  stepperState = STATE_STOP;

  Serial.print(F("state -> "));

  Serial.println(stepperState);

  lastTouchedSW = 2;

}

}

switch (stepperState) {

case STATE_MOVE:

  targetPos = direction * INFINITE;

stepper.setCurrentPosition(0); // set position

stepper.moveTo(targetPos);

  stepperState = STATE_MOVING; // next state

  Serial.print(F("target pos -> "));

  Serial.println(targetPos);

  Serial.print(F("state -> "));

  Serial.println(stepperState);

  break;

case STATE_MOVING:

  if (stepper.distanceToGo() == 0) {

  stepper.setCurrentPosition(0); // set position

  stepper.moveTo(targetPos);

}

  break;

case STATE_STOP:

  stepper.stop();

  direction *= -1; // reverse the direction

  delayStartTime = millis();

  stepperState = STATE_DELAY; // next state

  Serial.print(F("state -> "));

  Serial.println(stepperState);

  Serial.print(F("direction -> "));

  Serial.println(direction);

  break;

case STATE_DELAY:

  if ((unsigned long)(millis() - delayStartTime) > 15000) { // 15 seconds

    stepperState = STATE_MOVE; // next state

    Serial.print(F("state -> "));

    Serial.println(stepperState);

  }

  break;

}

stepper.run(); // MUST be called in loop() function

}

Use code tags

You can say this after you read the posting guidelines . . . :thinking:


Make 8, 10, 9, 11 inputs when you want the motor not conduct current.

im new to this and dont know how to do that.

Please edit your post to add code tags.

nothing i get involve in is ever simple so i shouldnt be surprised.

It is simple to accomplish your goal, but the process has nothing at all to do with the "command line". Your assumptions are the problem.

The AccelStepper library has features for a driver that has an 'Enable' pin but I don't think yours does. I think your best bet is to set the four outputs to LOW (if you set them to inputs, your output drivers will have floating inputs).

   digitalWrite(8, LOW);
   digitalWrite(9, LOW);
   digitalWrite(10, LOW);
   digitalWrite(11, LOW);

The AccelStepper library should turn one or more back on when you take a step.

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