Go Down

Topic: Stepper motor too weak (Read 1 time) previous topic - next topic

dodoka

#15
Nov 01, 2018, 11:18 am Last Edit: Nov 01, 2018, 11:35 am by dodoka
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 :)

But it sure does look sexy, doesn´t it :P




Cheers

dodoka

You COULD print the value returned by distanceToGo(), to see that it actually hits 0.

If I print distanceToGo() in the main loop, I only get gibberish (a lot of random numbers coming in fast)  :/

PaulS

I think that your code layout is not doing you any favors. Compare your code to this reformatted code.
Code: [Select]
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;
}

}

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.
The art of getting good answers lies in asking good questions.

dodoka

Hmm,

I can't follow you...

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 ;)




PaulS

Quote
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.
The art of getting good answers lies in asking good questions.

dodoka

Code: [Select]
#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(20000);
  stepper.setAcceleration(90000);
  // Initialisiere den lcd
  //lcd.init();                       
  //lcd.backlight();
  stepper.move(400);
  delay(1500);
}

//----------------------------------------------------------------------------------------------------------------------------

void loop()
{
  stepper.run();
  if (stepper.distanceToGo() == 0)
  {
    if (warten == false)
    {
      stepper.move(-405);
      warten = true;
      delay(1300);
    }
    else
    {
      stepper.move(405);
      warten = false;
    }
  } 
}


This is working :) Now I only have the problem, that the stick is on the drumhead a bit too long. Just have to optimize the ideal stepper steps. Maybe implement the endstop, so that it regains track of its position when it looses steps by hitting the drum at higher speeds.

Thank you very much for your help! ;)

vinceherman

Will I loose steps when I hit the drum? So I need an encoder, or drive back to an endstop after each hit, right?
I have been thinking about this.  I wonder if using a setup similar to a piano key would solve the possibility of skipping steps during the drum strike.
The piano key pushes the hammer which strikes the string.  But that push stops just before the strike, and the hammer continues on to strike the string though inertia.

https://en.wikipedia.org/wiki/Action_(piano)

dodoka

#22
Nov 01, 2018, 07:52 pm Last Edit: Nov 01, 2018, 08:01 pm by dodoka
I wonder if using a setup similar to a piano key would solve the possibility of skipping steps during the drum strike.
The piano key pushes the hammer which strikes the string.  But that push stops just before the strike, and the hammer continues on to strike the string though inertia.
https://en.wikipedia.org/wiki/Action_(piano)
I thought about this too, but if it´s possible, I want to keep it as simple as possible... So if I can manage it, I´d like to have it only driven by the stepper motor. Nearly ever drum robot I saw uses servos. I´m sure that they are easier to control, but the stepper should be "better"m right? I only need a steady beat. Nothing fancy. The drum I´m using is a really cheap one, maybe a better one will automatically sound louder and better ;)


Brainstorm:

Accelerate the drumstick and disabling the stepper driver before impact, so that intertia drives it into the drum and back :) Then it falls back to the floor and it gets accelerated again. No need for counting the exact steps and no need for additional mechanical parts :D

ChrisTenone

Looking at your picture, might it need less torque if the motor is above the drum instead of below it?

It would still look cool.
What, I need to say something else too?

vinceherman

but if it´s possible, I want to keep it as simple as possible...
Yeah, there is nothing simple about the piano key mechanism.

dodoka

#25
Nov 02, 2018, 02:36 pm Last Edit: Nov 02, 2018, 11:07 pm by dodoka
Looking at your picture, might it need less torque if the motor is above the drum instead of below it?
Thats a good Idea! Only the mount would be a bit more complicated :)

I tried the inertia-style approach. Works like a charm :D





Video of it working:   Klick

I maybe need a more flexible arm (now its a fiberglass one), then the sound wouldn´t be so dull. But other then that I´m happy for now :) Thanks again for the help!



Johan_Ha

@Johan_Ha Sorry^^ It was late and I didnt want to search for an online pic-hoster.

I just used the address of your attached file in the image tag. You can do the same.
____________________

If you ask for help and write 'u' instead of 'you' because you think it's convenient, I will write 'no' instead of 'yes'. For same reasons.

Go Up