Stepper motor has high pitch sound when idle, and low torque when running.

Hi …

I hope you can help me.

Questions I’m struggling with:

-Why does the stepper motor produce a high pitch sound when idle ?

-The stepper motor doesn’t seem to have a high torque - with a single finger I can stop the rotation, how to solve that ?

Now to all the details.

I’m in the process of building a feeding station for my dog. I have built the setup, and have the electronics in place, and about to integrate it with HA.

It uses a ESP8266 - with a c program, that uses MQTT for ‘feeding’ tasks, and it is controlled from HA.

I have a setup, where I can send MQTT messages, and the stepper rotates the requested steps. So far so good.

This has raised these two issues.

When the stepper motor is not turning, it produces a high pitch sound. I don’t believe it is there when the stepper motor is running - it is noisy so it is hard to tell.

Guess when the motor is idle, it still has ‘power’ on to hold its positions, which is not needed. So could an option be to somehow turn off the motor ?

Second issue is that I thought I bought a motor with a high torque (0.55N.m) and it is powered with 12 volt, but I can hold/stop it from rotating with just one finger. How come ?

These are the components:

Stepper motor driver - A4988 A4988 Motor Driver Module - A4988DRIVERMOD

Stepper motor - 0.55N.m - 1.5A - NEMA17 Stepper motor - 0.55N.m - 1.5A - NEMA17 - 42BYGH47-401A

Power supply for the stepper motor - 12v 3A 12V 3A Adapter with DC jack - 12V3ADCADAPTER

ESP8266 is still powered with 5v, but the plan is to add a buck converter.

ESP8266, capacitor

Wiring:

Code:

The code is really simple - These are the sniffits that involves the stepper motor

(no include of stepper.h or similar)

int dirPin = D4;

int stepPin = D3;

void setup() {

// pins setup

pinMode(dirPin, OUTPUT);

pinMode(stepPin, OUTPUT);

In function that turns the stepper:

digitalWrite(dirPin, HIGH);

//Loop through one rotation

for(int x = 0; x < 200; x++)

{

digitalWrite(stepPin, HIGH);

delayMicroseconds(4000);

digitalWrite(stepPin, LOW);

delayMicroseconds(4000);

}

Code works. The stepper motor turns when a message is placed in mqtt.

So, how to get rid of the noise and to get more torque ?

Thanks

Regards Joern.

-Why does the stepper motor produce a high pitch sound when idle ?

Because it is working to hold its position as you suggest

So could an option be to somehow turn off the motor ?

Stop writing to it when no movement is required. You did not post a complete sketch so further advice is difficult

Second issue is that I thought I bought a motor with a high torque (0.55N.m) and it is powered with 12 volt, but I can hold/stop it from rotating with just one finger. How come ?

Try using the microspepping options provided by the driver board

Please follow the advice on posting code given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

If the code exceeds the 9000 character inline limit then attach it to a post

jborup: Second issue is that I thought I bought a motor with a high torque (0.55N.m) and it is powered with 12 volt, but I can hold/stop it from rotating with just one finger. How come ?

That suggests that you have not correctly set the current limit on the A4988 driver to match the 1.5 amps of your motor.

Note also that 1.5 amps is probably the upper limit for an A4988 without a heat sink and cooling fan. If the driver overheats it will shut down to protect itself - which might explain the low torque. If you suspect that is the problem try setting the current limit to (say) 1.2 amps.

...R Stepper Motor Basics Simple Stepper Code

First the code:

//Feeder for the dog.


#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include <NTPClient.h>


// wifi
const char* ssid = "zxcvbnm"; //type your WIFI information inside the quotes
const char* password = "zaq12wsxcde34rfv";
WiFiClient espClient;


// Time setup
WiFiUDP ntpUDP;
#define NTP_OFFSET   60 * 60      // In seconds
#define NTP_INTERVAL 60 * 1000    // In miliseconds
#define NTP_ADDRESS  "192.168.2.85"
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);




// MQTT
const char* mqtt_server = "192.168.2.85"; // IP address or dns of the mqtt
const char* mqtt_username = "joern"; //
const char* mqtt_password = "joern";
#define SENSORNAME "Feeder" 
const int mqtt_port = 1883; 
PubSubClient client(espClient);
// MQTT TOPICS 
const char* lastfed_topic = "home/feeder/lastfed"; // UTF date
const char* remaining_topic = "home/feeder/remaining"; //Remain % fix distance above
const char* feed_topic = "home/feeder/feed";  // command topic
const char* willTopic = "home/feeder/LWT";  // Last Will and Testiment topic


// stepper
const int steps = 200; //REPLACEME this is the number of steps of the motor for a 360° rotation.
int dirPin = D4;
int stepPin = D3;




void setup() {
  // Serial setup
  Serial.begin(115200);


  // pins setup
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);


  setup_wifi();
  timeClient.begin();
  client.setServer(mqtt_server, mqtt_port);
  client.setCallback(callback);


}


void setup_wifi() {


  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);


  WiFi.mode(WIFI_STA);
  WiFi.setSleepMode(WIFI_NONE_SLEEP); // bit more power hungry, but seems stable.
  WiFi.hostname("feeder"); // This will (probably) happear on your router somewhere.
  WiFi.begin(ssid, password);


  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }


  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
/********************************** START CALLBACK*****************************************/
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");


  char message[length];
  for (int i = 0; i < length; i++) {
    message[i] = ((char)payload[i]);


  }
  message[length] = '\0';
  Serial.print("[");
  Serial.print(message);
  Serial.print("]");
  Serial.println();


  if (strcmp(message, "feed") == 0) {
    Serial.print("Feeding...");
    Serial.println();
    feedDog();
  } else {
    Serial.print("Unknown Message");
    Serial.println();
  }
}


// feeds
void feedDog() {
  //  digitalWrite(2, LOW); // Turn on onboard LED
  digitalWrite(dirPin, HIGH);  // dirPinble motors, i dont see the point in pwm with a stepper?


  
  //Loop through one rotation
  // Spin motor slowly
  //MS1=low, MS2=low, MS3=low - Full step is 200 steps
  //MS1=high, MS2=high, MS3=high - Sixteenth step - full turn is 3200 steps
   
  for(int x = 0; x < 3200; x++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(800);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(800);
  }
  delay(1000); // Wait a second
  
  timeClient.update();   // could this fail?
  String formattedTime = timeClient.getFormattedDate();
  char charBuf[20];
  formattedTime.toCharArray(charBuf, 20);
  client.publish(lastfed_topic, charBuf, true); // Publishing time of feeding to MQTT Sensor retain true
  Serial.print("Fed at: ");
  Serial.print(charBuf);
  Serial.println();
}




void reconnect() {
  // Loop until we're reconnected, i may wanna check for pushbutton here somewhere in case of wifi disaster?
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect(SENSORNAME, mqtt_username, mqtt_password, willTopic, 1, true, "Offline")) {
      client.publish(willTopic, "Online", true);
      Serial.println("connected");
      // ... and resubscribe
      client.subscribe(feed_topic);;
    } else {
      Serial.print("MQTT failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}


void loop() {


  if (!client.connected()) {
    reconnect();
  }


  client.loop();
  delay(100);
}

I have to set the MS1+2+3 to high. The stepper moves less, and there might be more torque - but still very easy to hold back the shaft and it comes with clicks, as if something is stepping over.

Regarding the current - I do have a heatzink at the A4988 - and measuring the amp… Guess that is to intercept one of the lines to the stepper … it says -0.76 (when multimeter set for 10A) and goes to 0 when running, when moter stops, it goes back to -0.76 (yes - not my expertice ;-).
So this should be increased by turning the screw ?

Thanks for responding.

-Joern

jborup: Regarding the current - I do have a heatzink at the A4988 - and measuring the amp.. Guess that is to intercept one of the lines to the stepper ... it says -0.76 (when multimeter set for 10A) and goes to 0 when running, when moter stops, it goes back to -0.76 (yes - not my expertice ;-). So this should be increased by turning the screw ?

The Pololu A4988 web page has good instructions for setting the current limit. But make sure to allow for the possibility that your A4988 may have different values for the current sense resistors.

Be VERY CAREFUL never to connect or disconnect the wires between the motor and the stepper driver while the driver is powered up. The driver will be instantly destroyed.

...R

Thanks for link. Did follow the recommendation. Here they say that the Current Limit = Vref x 2. Max A for motor is 1½. Max for driver is 1 A. So guess the max should be 1A. So Vref should be at max 0.5 volt. - it had the value of .75 before. Did not change the torque of the motor.

As noted - the driver board has a 1 A and the motor has a 1½ A. So there might be a problem here.

DRV8825 Motor Driver Module - has a 1.5 A per coil. TB67S109 Motor Driver Module - has a a 3 A per coil.

Would these be a better choice for my stepper motor ? or what would you recommend of motor (and driver if needed) to get one with some torque for turning a wheel ?

/Joern.

Before spending more money, you should be getting good torque with 1 amp being provided for a 1.5 amp motor. And you should be able to increase the current for an A4988 above 1 amp - try 1.2 amps or 1.4 amps.

Current Limit = Vref x 2.

Are the current sense resistors on your A4988 the same value as on the Pololu A4988 ?

...R

Thanks for responding. As mentioned before, this is not my area of expertise, but it is fun and interesting.

Regarding the 'current sense resistors ’ looking at spec that I can find (www.allegromicro.com/~/media/Files/Datasheets/A4988-Datasheet.ashx?la=en) I can’t find anything that looks like the 50/68 mohm as in the pololu - I can se a Output On-Resistance with a 320-430 mohm… looks wrong.

The suggestion was to try for 1.4 amp - that would be 750 mV - Same as the default value - so I tried that, and then turned it at bit more and more… got it to max 1500 mV - and now the stepper starts to move a bit, and when I lower delayMicroseconds(500); it starts to turn a bit - with dogfood in the setup.

But still not working. 2 out of 3 times it will not turn… just vibrates - but not clicking from the motor… so we are almost there when the motor does the work.

Another thing - the wire - special the skinny dupont wires from breadboard to the stepper motor wires get really hot. and the A4988 driver also gets hots…

And the output from the ESP8366 is now this - guess the heat ?

9:33:14.230 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
19:33:14.276 -> 
19:33:14.276 -> Soft WDT reset
19:33:14.276 -> 
19:33:14.276 -> >>>stack>>>
19:33:14.276 -> 
19:33:14.276 -> ctx: cont
19:33:14.276 -> sp: 3ffffd10 end: 3fffffc0 offset: 01a0
19:33:14.276 -> 3ffffeb0:  3ffe8796 00000000 00205d00 402068b9  
19:33:14.276 -> 3ffffec0:  4010031c 0000014a 3ffee488 40100345  
19:33:14.276 -> 3ffffed0:  40204954 3ffee488 0000014a 402011c5  
19:33:14.276 -> 3ffffee0:  40204954 3ffee69c 3ffe8794 40204c2d  
19:33:14.276 -> 3ffffef0:  00000004 3fffff10 3ffee69c 40204cf4  
19:33:14.276 -> 3fffff00:  00000004 3fffff10 3ffee69c 402012f3  
19:33:14.276 -> 3fffff10:  64656566 3ffee400 00000016 40201290  
19:33:14.276 -> 3fffff20:  3ffef348 00000000 3ffee48c 402059d6  
19:33:14.325 -> 3fffff30:  3fffff60 00000001 00000002 00000018  
19:33:14.325 -> 3fffff40:  0000811a 00000010 3ffee48c 402072e0  
19:33:14.325 -> 3fffff50:  0000811a 00000000 3ffee48c 40203ca4  
19:33:14.325 -> 3fffff60:  007a1201 723c565d 00000000 3ffee7e0  
19:33:14.325 -> 3fffff70:  00000000 3ffee840 00000064 402059a0  
19:33:14.325 -> 3fffff80:  3fffdad0 00000000 3ffee48c 3ffee7e0  
19:33:14.325 -> 3fffff90:  3fffdad0 00000000 3ffee48c 40201408  
19:33:14.325 -> 3fffffa0:  feefeffe feefeffe 3ffee7a0 40205ab8  
19:33:14.325 -> 3fffffb0:  feefeffe feefeffe 3ffe8508 40100cb1  
19:33:14.325 -> <<<stack<<<
19:33:14.325 -> 
19:33:14.325 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
19:33:14.373 -> 
19:33:14.373 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
19:33:14.373 -> 
19:33:14.373 -> load 0x4010f000, len 3584, room 16 
19:33:14.373 -> tail 0
19:33:14.373 -> chksum 0xb0
19:33:14.373 -> csum 0xb0
19:33:14.373 -> v2843a5ac
19:33:14.373 -> ~ld
19:33:14.465 -> 
19:33:14.465 -> Connecting to zxcvbnm
19:33:15.074 -> .......
19:33:18.907 -> WiFi connected

Is the conclusion that the driver has been max’ed for what it can deliver, and it is not enough ?
Should I step up to something bigger/better ? Stepper motor is not hot, so I guess that one is still capable.

Biger driver ?

/Joern

jborup: Regarding the 'current sense resistors ' looking at spec that I can find (www.allegromicro.com/~/media/Files/Datasheets/A4988-Datasheet.ashx?la=en) I can't find anything that looks like the 50/68 mohm as in the pololu - I can se a Output On-Resistance with a 320-430 mohm... looks wrong.

It won't be in the datasheet. The datasheet is only about the Allegro chip. There are several other components on the A4988 board.

You need to look at the codes on the current sense resistors on your A4988 boards. You can Google surface mount resistor codes to figure out what the values are.

...R