Step Motor Heating so muc

I made a watchwinder with using 28 BYJ-48 Geared Step Motor and ULN2003A Step Motor Driver Board and aurdino nano card.

code working well but when it's working step motor heats so much and melting my 3D printed arm.

do you have any suggestion to solve heating problem?

please find my code and wiring at below.

thanks in advance,

//-----Button variables
const int ledPin = 5;       // LED pin number
const int buttonPin = 4;    // Button NO pin number
int buttonState = 0;        // Button state

// Step motor variables
#define IN1 11              // Motor
#define IN2 10              // Driver
#define IN3 9               // Pin
#define IN4 8               // Connections

unsigned long startTime = 0;      // Motor start time
unsigned long motorDuration = 7200000; // 2-hour operation duration
unsigned long waitTime = 5000;    // Wait time after turning left or right (5 seconds)
int currentStep = 0;              // Current step of the motor
bool motorRunning = false;        // Variable to track if the motor is running
bool clockwise = true;            // Rotation direction (clockwise or counterclockwise)

void setup() {
  Serial.begin(9600);
  Serial.println("Connection Established");

  // Button pin configuration
  pinMode(ledPin, OUTPUT);          // Set LED pin as output
  pinMode(buttonPin, INPUT_PULLUP); // Set button pin as input with internal pull-up resistor

  // Step motor pin configuration
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  // Initially disable the motor
  DisableMotor();
}

void loop() {
  buttonState = digitalRead(buttonPin); // Read from button pin

  // Start or stop the motor when the button is pressed
  if (buttonState == LOW && !motorRunning) { // If button is pressed and motor is not running
    motorRunning = true;
    startTime = millis(); // Start the timer
    currentStep = 0;      // Reset steps
    clockwise = true;     // Initially rotate clockwise
    digitalWrite(ledPin, LOW); // Turn off the LED
  } else if (buttonState == HIGH && motorRunning) {
    motorRunning = false;
    DisableMotor();        // Disable the motor
    digitalWrite(ledPin, HIGH); // Turn on the LED
  }

  if (motorRunning) {
    unsigned long currentTime = millis();
    if (currentTime - startTime < motorDuration) { // If motor operation time has not expired
      RotateMotor360(clockwise); // Rotate 360 degrees
      delay(waitTime);           // Wait for 1 second
      DisableMotor();            // Disable the motor during waiting
      clockwise = !clockwise;    // Change the direction
    } else { // If motor operation time has expired
      motorRunning = false;
      DisableMotor(); // Disable the motor
      digitalWrite(ledPin, HIGH); // Turn on the LED
      Serial.println("Motor stopped");
    }
  }
}

// Function to rotate the step motor 360 degrees
void RotateMotor360(bool clockwise) {
  int stepsPerRevolution = 4096; // 512 steps for 360 degrees
  for (int i = 0; i < stepsPerRevolution; i++) {
    StepMotor(clockwise); // Perform a single step
    delay(2);             // Short delay between each step
  }
}

// Function for a single step of the step motor
void StepMotor(bool clockwise) {
  if (clockwise) {
    switch (currentStep) {
      case 0: digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
      case 1: digitalWrite(IN1, HIGH); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
      case 2: digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
      case 3: digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); break;
      case 4: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); break;
      case 5: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, HIGH); break;
      case 6: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); break;
      case 7: digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); break;
    }
  } else { // Counterclockwise rotation
    switch (currentStep) {
      case 0: digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); break;
      case 1: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); break;
      case 2: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, HIGH); break;
      case 3: digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); break;
      case 4: digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); break;
      case 5: digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
      case 6: digitalWrite(IN1, HIGH); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
      case 7: digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); break;
    }
  }
  currentStep = (currentStep + 1) % 8; // Cycle through steps from zero
}

// Function to disable the motor
void DisableMotor() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

How do you power your stepper? Usually the 28 BYJ-48 is a 5V stepper ( there are rare 12V versions - what is printed on the motor?). From your description I assume it is a 5V motor and you power it with too high voltage.

2 Likes

Try powering the Nano with a 5volt cellphone charger, connected to the USB socket.
Then power the ULN from the 5volt pin of the Nano.
A 5volt 28 BYJ-48 draws about 180mA per coil, so just ok for the Nano with that 2-coil drive.

If the setup is well balanced, then you could try a "one coil at the time" drive, by modifying the switch/case block to two sets of four. That will halve the current draw of the motor.
Leo..

Hello,

Yes my motor is 5 volt and i'm uslng 12 volt 2A oiwer supply to feed the system. When i tried to run the sytem from computer connection it was not work. I'll try phone charger again.

Do i need to change wiring to suuply power to motor driver?

And right there is why your stepper is heating up so much.

A 5V motor needs a 5V supply, not a 12V supply. At 12V, you're quite likely to be melting the interior wiring.

1 Like

Feeding 12V/5V=2.4 times the voltage into the same coil resistances would cause 2.4x the amps and 2.4^2=5.76x times the power input and heat output as designed.

1 Like

If the motor doesn't run on a 5volt supply, then the load might be too heavy or badly balanced. These motors are not that strong.
Leo..

Thank you for all your helps. I changed the charger with 5 volt and heating problem is solved.

Did you change the connection on the nano from Vin to 5V?

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