I want to make a simple drummer-robot. Just one stepper motor (SL42STH40-1684A, Nema 17, Current per phase: 1.68A,Holding torque: 3.6 Kg·cm (0.4 N·m),Moment of inertia: 54 g/cm^2) and a 15cm long fiberglass arm with a small wieght at the end.
I only want a steady beat of 25-60 bpm. Thats not even fast...
My problem is, that the motor is way too weak to turn if the arm is attatched... Without it, it works but after adding weight it´s not working, stuttering, loosing steps etc.
-increasing the current --> Less stuttering, but still loosing steps and still too slow.
-microstepping --> same as with full step, at least not really better
-increasing/decreasing motor voltage: not better
-decreasing/increasing the delayMicrosconds() in the code (not really better, slower turning when increasing, faster when decreasing but more stuttering)
I think the motor should be strong enough... Maybe a slower starting acceleration? Kind of ramping the acceleration up? How can I do this? I have a 3D Printer which I think needs way more torque and speed and it´s the same motor and same driver....
So, we know what the mounting holes look like. But, what color is it?
and a 15cm long fiberglass arm with a small wieght at the end.
A dwarf star is small. Is that what you used for the "wieght"?
I only want a steady beat of 25-60 bpm. Thats not even fast...
The number of beats per minute is a function of the number of steps that the motor needs to take. THAT is the number that is important. THAT is the number you failed to tell is.
I think the motor should be strong enough.
Well, talk to it then. Obviously, it disagrees with you. Or, it is just being lazy. Tell it to shape up!
I have a 3D Printer which I think needs way more torque and speed and it´s the same motor and same driver....
Facts are FAR more important than what you think.
Vref is 0,7V which equals to 1,75A which should be enough.
What Vref? As measured how? Using what power supply?
There are so many details missing from your post that it is impossible to determine what the problem is.
I wrote the Motor size, so that you guys have a general idea about the size of the motor opposed to the 15cm arm, sorry for providing additional information! I didn't weigh the "ball" at the end of the rod, it's about as heavy as a M5x14, and I can change it by screwing in different sized screws. Look at the picture.
The number of steps is variable. Depends on the bpm AND how big of an dirve-angle I have to use to gain enough speed to be loud enough. So yeah no concrete numbers here.
-"Facts are FAR more important than what you think."
Please tell me where I can find the facts. That's why I need help...
-"What Vref"
Since I posted a link using a A4988 driver you could guess which Vref I'd mean.
Thank you for not really helping me at all. It seems like you just ignored the last paragraph of my post
It appears that you are offended by the response to your request for help. Don't be. It is fairly typical for the experienced members of this forum to point out how the information you provided in your request for help does not match up with the information that is actually required to solve the issue.
This is not done out of spite. It is done because new forum members like yourself simply do not know how to describe the details accurately. The intent is to educate you so that you can give us what is needed to help you.
Now, let me throw in my 2 cents worth on the issue. Post the code. (don't forget to use code tags) This will let us see what you are trying to do.
I am curious, have you considered using acceleration? For high power or fast applications, this lets the motor get things moving with less tendency to skip steps.
I'm not really offended, I'm just adjusting to the tone And I don't see where I could give more Information. And he didn't ask for specific information, he just pointed out, that I give unnecessary. He could have told me to give this and that parameters etc. And I would have gladly supplied them.
Anyways
I don't have the code anymore, because I adjusted it and deleted it after it didn't work. (I don't know why... ^^) But it was the same as in the posted link. I only changed the pins (tried different ones).
"I am curious, have you considered using acceleration? For high power or fast applications, this lets the motor get things moving with less tendency to skip steps."
I asked this at the end of my post. How can I do this?
dodoka:
I asked this at the end of my post. How can I do this?
HAHAHAHAH I guess I skiped the last paragraph too!
There is a library for this. AccelStepper
I have not used it myself but I have read enough posts where it was the fix that I wanted to point it out.
Yes, AccelStepper. I just googled it.
Not all A4998 drivers have the same resistor values, and that of course affects the reference voltage at a given current. I bought cheap ones on ebay, and they were not the same specs as the more famous manufacturer. I had to use a magnifying glass to read the number on the surface mount resistors.
If you can find the specs for your stepper motor, it should give you torque specifications, that will allow you know if what you are trying to do is possible. You can buy steppers with gear boxes that multiply the torque, if more torque is needed, but of course that will slow them down proportionally.
vinceherman:
HAHAHAHAH I guess I skiped the last paragraph too!
No worries
There is a library for this. AccelStepper
I have not used it myself but I have read enough posts where it was the fix that I wanted to point it out.
Yes, AccelStepper. I just googled it.
Thank you! I already did a bit of research and also found AccelStepper as a possible solution. Didn't have time to test it though. But I'll look into it tomorrow.
@Northof49:
Yeah I searched for the right Vref value on the Reprap wiki. They said, that the current sensing resistor is 0,05Ohm on the original ones and about 0,1Ohm on Chinese ones. Since the drivers are from a Chinese 3D printer, I guess it could be a 0,1Ohm resistor. I have to check Almost forgot!
What voltage are you running the motor at?
Are you certain you have the motor wired up correctly? Check the continuity of the two coils with an ohmmeter and make sure it matches up with how you have it wired. Some motors have different layout for the stepper motor coils.
I managed to get the motor running without stuttering and without loosing steps
BUUUUT my code doesn´t work now^^
#include <AccelStepper.h>
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
// Definiere den Stepper mit den Pins
AccelStepper stepper(AccelStepper::DRIVER, 9, 8); //PIN 9 Step, PIN 8 DIR
// Definiere den LCD mit den Pins
//LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//Define
int en = 10;
int down = 0;
int up = 1;
int enter = 2;
int led1 = 3;
int led2 = 4;
bool warten = false;
//----------------------------------------------------------------------------------------------------------------------------
void setup()
{
//Definiere Pins
pinMode(en , OUTPUT);
pinMode(down , INPUT_PULLUP);
pinMode(up , INPUT_PULLUP);
pinMode(enter , INPUT_PULLUP);
pinMode(led1 , OUTPUT);
pinMode(led2 , OUTPUT);
//Definiere Stepper
stepper.setMaxSpeed(1000);
stepper.setAcceleration(5000);
// Initialisiere den lcd
//lcd.init();
//lcd.backlight();
stepper.move(50);
}
//----------------------------------------------------------------------------------------------------------------------------
void loop()
{
stepper.run();
if (stepper.distanceToGo() == 0){
if (warten == false){
stepper.move(50);
warten = true;
}
if (warten == true){
stepper.move(-50);
delay(1000);
warten = false;
}
}
}
It just goes in one direction with 1s delay. I want it to make a fast forward->backward motion, then wait for 1s and then fast forward->backward again and so on.
The commented LiquidCrystal_I2C lib and other pin definitions are for the future, where I plan to use a small display and buttons for a menu. For now, I just want it to play the drum with one fixed frequency
#include <AccelStepper.h>
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
// Definiere den Stepper mit den Pins
AccelStepper stepper(AccelStepper::DRIVER, 9, 8); //PIN 9 Step, PIN 8 DIR
// Definiere den LCD mit den Pins
//LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//Define
int en = 10;
int down = 0;
int up = 1;
int enter = 2;
int led1 = 3;
int led2 = 4;
bool warten = false;
//----------------------------------------------------------------------------------------------------------------------------
void setup()
{
//Definiere Pins
pinMode(en , OUTPUT);
pinMode(down , INPUT_PULLUP);
pinMode(up , INPUT_PULLUP);
pinMode(enter , INPUT_PULLUP);
pinMode(led1 , OUTPUT);
pinMode(led2 , OUTPUT);
//Definiere Stepper
stepper.setMaxSpeed(1000);
stepper.setAcceleration(5000);
// Initialisiere den lcd
//lcd.init();
//lcd.backlight();
stepper.move(50);
Serial.begin(9600);
}
//----------------------------------------------------------------------------------------------------------------------------
void loop()
{
stepper.run();
if (stepper.distanceToGo() == 0){
if (warten == false){
stepper.move(-50);
warten = true;
Serial.print("Plus");
Serial.print(stepper.distanceToGo());
}
else{
stepper.move(50);
Serial.print("Minus");
Serial.print(stepper.distanceToGo());
warten = false;
}
}
}
Like this?
Now the stepper moves forward and backward (yay!), buts doesn´t pause. I don´t know where to put the delay
I tried different places (inside the if/else afterwards) it stopped after the forward AND backward motion
Thanks for the tip with printing the values. I only programmed with Bascom Basic, where I didn´t use a serial output. Arduino is much easier in that regard
I get "Plus-50Minus50Plus-50Minus50Plus-50Minus50Plus-50Minus50Plus-50Minus50Plus-50Minus50Plus-50" on the monitor. "Plus-50" and "Minus50" alternating as expected.
Will I loose steps when I hit the drum? So I need an encoder, or drive back to an endstop after each hit, right? Or did I miss something?
Is it maybe much better to use a servo for this purpose? I wanted to use the stepper, because I had it laying around. But its also pretty loud (the tamburine resonates) when attatched to the holder. I tried microstepping. It´s better but still annoying. I´ll try to put a piece of foam between the mount and the stepper
With all the { and } lined up, it should be pretty easy to see where to put the delay() to make the stepper stop at each end of the travel.
Anywhere in the if block that tests that the motor is at the limit (distance to go is 0) is good. Of course, you don't want to make it conditional on the direction to go next, so that does limit your choices - before the if statement or after the else block. Either place would work.
On the other hand, if you are banging a drum, you do not want to pause with the weight on the drum head - that would defeat the purpose of having hit the drum.
So, I suspect that you want to wait only at one end of the travel. Which end that is, I couldn't say, since I don't know what your drummer looks like.
If I place it before the first if or after the else block, the program would be stopped after each step?
I'm not at home atm, I will try it but I think I tried it already and it didn't work.
Yes, I want to pause away from the drumhead. I can change the direction easily by turning the motor connector by 180 degrees or inverting the move To value (from 50 to -50 and vice versa). In my last reply there is a picture of the whole thing
If I place it before the first if or after the else block, the program would be stopped after each step?
You have an if statement with a body that contains an if statement with an else block. Whatever you put in the outer if body will happen when the stepper has completed stepping clockwise and when the stepper has completed stepping counterclockwise.
If you put the delay in the inner if body or the else body, the delay will happen only when the stepper has completed stepping clockwise or when the stepper has completed stepping counterclockwise.