Help! Controlling stepper motor speed and direction

Hi ,

I am still a beginner, so i will explain in details

I have Arduino UNO , NEMA23 stepper motor with a driver A4899 , 2 switches , 5k potentiometer , 2 * 10k resistor and power supply 12 v 10 A for Vmot , GND mot , power for Arduino UNO board .

I used the following code and wiring , when i power my power supply the Arduino UNO start smoking so i disconnected power , i test it with usb cable ( blink code , control speed only code at the end ) it's working , when use power supply it does not respond .

Can anyone check the code and wiring , UNO power problem ?

//direction and speed
int StartButton = 2;
int DirectionButton = 4;
int Enable = 7;
int Direction = 8;
int stepPin = 9;
int customDelay,customDelayMapped;

void setup() 
{
pinMode(StartButton, INPUT);
pinMode(DirectionButton, INPUT);
pinMode(Enable, OUTPUT);
pinMode(Direction, OUTPUT);

}

void loop() { 
if(digitalRead(StartButton) == LOW){
digitalWrite(Enable, HIGH);
}
else{
digitalWrite(Enable, LOW);
}
if(digitalRead(DirectionButton) == HIGH){
       digitalWrite(Direction, HIGH);
      }
else{
      digitalWrite(Direction, LOW);
      }
  customDelayMapped = speedUp(); 
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(customDelayMapped);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(customDelayMapped);
}
int speedUp() {
  int customDelay = analogRead(A0); 
  int newCustom = map(customDelay, 0, 1023, 400,2000); 
  return newCustom;  
}

// speed
const int stepPin = 3;
const int dirPin = 4; 

int customDelay,customDelayMapped;
 
void setup() {
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  digitalWrite(dirPin,HIGH);
}
void loop() {
  
  customDelayMapped = speedUp();
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(customDelayMapped);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(customDelayMapped);
}
int speedUp() {
  int customDelay = analogRead(A0); 
  int newCustom = map(customDelay, 0, 1023, 400,2000); 
  return newCustom;  
}

when i power my power supply the Arduino UNO start smoking

Ouch !

What was smoking ?

What power supply was it and how did you connect it ?

UKHeliBob:
Ouch !

What was smoking ?

What power supply was it and how did you connect it ?

the voltage regulator next to power jack i think , but i could still power it from the jack , but does not respond to anything

it’s an external power supply 220 vac to 12 vdc 10 A , +ve to the pin

You should NOT be trying to power any motor from an Arduino 5v pin and a Nema 23 motor probably needs a large current. Indeed an A4988 driver may not be able to provide sufficient current, even if it was not coming from the Arduino.

Post a link to the datasheet for your stepper motor.

Have a read through these links
Stepper Motor Basics
Simple Stepper Code

...R

Hi

Sounds like you've burnt out the 5v regulator on the Uno. One of two things may have happened:-

  1. The regulator chip has blown open circuit. This may have saved the rest of the arduino. It may be possible to power it up via the USB port and it might work.

  2. The regulator chip has blown short circuit. This would have applied the 12V to the entire circuit and trashed the Arduino.

Either way I would replace the Uno.

Pololu have a useful resource for the A4988 here:-

Which includes this bare bones wiring diagram:-

Note that the 12V 10A supply should be connected directly to the VMOT and GND pins NOT via the Arduino. The Arduino should only be used to power up the VDD pin to supply the on-board logic.

Also check the spec sheet for your stepper motor as the A4988 is only rated for 1A into each coil. You may need something with a little more drive capacity such as the TB6600.

You might want to check the wiring of your motor windings you seem to have them in the order 1A(Red), 1B(Black), 2A(Red), 2B(Black) whereas the pinout of the A4988 is 1B(Black), 1A(red), 2A(Red), 2B(Black).

Robin2:
You should NOT be trying to power any motor from an Arduino 5v pin and a Nema 23 motor probably needs a large current. Indeed an A4988 driver may not be able to provide sufficient current, even if it was not coming from the Arduino.

Post a link to the datasheet for your stepper motor.

Have a read through these links
Stepper Motor Basics
Simple Stepper Code

...R

Thanks for the topics but while i was reading i come across this :-

Generally speaking specialized stepper motor driver boards only require two connections (plus GND) to the Arduino for step and direction signals.

and this is not what i read in the manual of A4988

Enable Input (¯E¯ ¯N¯ ¯A¯ ¯B¯ ¯ L¯E¯ ). This input turns on or off all of the
FET outputs. When set to a logic high, the outputs are disabled.
When set to a logic low, the internal control enables the outputs
as required. The translator inputs STEP, DIR, and MSx, as well as
the internal sequencing logic, all remain active, independent of the
¯ E¯N¯ ¯A¯ ¯B¯ ¯ L¯ Einput state.

i was trying to use enable pin on A4988 with the direction pin , as i didn't manage to put limit switches , to spacifiy the direction , so i programmed pin 7 ( enable to drive ) is high if pin 2 ( start motor ) low , pin 8 follow pin 4 for direction control ( cw / ccw )

IanCrowe:
Hi

Sounds like you've burnt out the 5v regulator on the Uno. One of two things may have happened:-

  1. The regulator chip has blown open circuit. This may have saved the rest of the arduino an it may be possible to power it up via the USB port and it might work.

  2. The regulator chip has blown short circuit. This would have applied the 12V to the entire circuit and trashed the Arduino.

Either way I would replace the Uno.

Pololu have a useful resource for the A4988 here:-

Pololu - A4988 Stepper Motor Driver Carrier

Which includes this bare bones wiring diagram:-

Note that the 12V 10A supply should be connected directly to the VMOT and GND pins NOT via the Arduino. The Arduino should only be used to power up the VDD pin to supply the on-board logic.

Also check the spec sheet for your stepper motor as the A4988 is only rated for 1A into each coil. You may need something with a little more drive capacity such as the TB6600.

You might want to check the wiring of your motor windings you seem to have them in the order 1A(Red), 1B(Black), 2A(Red), 2B(Black) whereas the pinout of the A4988 is 1B(Black), 1A(red), 2A(Red), 2B(Black).

this is the wiring

i still can power the arduino from both usb and power jack , i tested it with simple blink code and it works

m_abdelraouf:
i was trying to use enable pin on A4988 with the direction pin , as i didn't manage to put limit switches , to spacifiy the direction , so i programmed pin 7 ( enable to drive ) is high if pin 2 ( start motor ) low , pin 8 follow pin 4 for direction control ( cw / ccw )

With an A4988 you do not need to use the enable pin unless you wish to disable the motor-driver - in other words to get it to stop powering the motor which means that the motor can be rotated by hand and will lose its position.

The enable pin is not a substitute for a limit switch and code that stops sending step pulses when the limit switch is triggered.

We are still waiting for you to post a link to the datasheet for your motor.

...R

Robin2:
With an A4988 you do not need to use the enable pin unless you wish to disable the motor-driver - in other words to get it to stop powering the motor which means that the motor can be rotated by hand and will lose its position.

The enable pin is not a substitute for a limit switch and code that stops sending step pulses when the limit switch is triggered.

We are still waiting for you to post a link to the datasheet for your motor.

...R

I got it from a friend and i don't have a datasheet for it

Are you sure you have the model number correct? I could not find much info when I Googled the model number.

From a little browsing it seems that the motor might be rated at 1.3v and 1.2 amps which would suggest a coil resistance of about 1 ohm. Can you measure the coil resistance with your multimeter?

If 1.2amps is the correct current then an A4988 driver will be suitable.

...R

the motor is the same in the link .

the resistance is 1.1 ohm .

and i run the motor with the arduino after the smoke from the arduino appeared using the code of potentiometer only ( no control of direction )

m_abdelraouf:
and i run the motor with the arduino after the smoke from the arduino appeared using the code of potentiometer only ( no control of direction )

I don't understand.

...R

Robin2:
I don't understand.

...R

i can run the code of controlling motor speed with the smoked arduino ( powered from the usb ).

what is wrong with the code of controlling direction and speed that made the arduino voltage regulator smoke ?

m_abdelraouf:
what is wrong with the code of controlling direction and speed that made the arduino voltage regulator smoke ?

I have no idea as I was not there to see what you were doing when it happened. Things like that can be very difficult to diagnose, especially if the evidence is gone.

My stepper motors can be controlled with speed and direction using A4988 drivers without any harm coming to the Arduino.

...R