Go Down

Topic: Problems to make more steps with a nema 17 button (Read 544 times) previous topic - next topic

juanmartin

hello good day, I am a bit new in arduino, I wanted to know if it is possible, with one (1) button, to make several sequences of steps (nema17). for example right, left left, right right, left ... thank you very much for helping me guys ... I'm complicated.

martinmedina10@gmail.com

IndianaTux

You will need a step motor driver but yes you simply detect the button press and do the sequence you want.

juanmartin

#2
Mar 28, 2018, 07:39 pm Last Edit: Mar 29, 2018, 04:20 am by juanmartin
hi Indiana ... if I'm using a shielf and in the one controller. you have some idea of how to do it ... I have this sketch but it does not work for me, it does not let me move to the left 200 steps and to the right 400 steps. something like that.


#define DISTANCE 500

int StepCounter = 0;
int Stepping = false;

void setup () {
   pinMode (6, OUTPUT); //dirreccion
   pinMode (3, OUTPUT); //step
   digitalWrite (6, LOW);
   digitalWrite (3, LOW);

   pinMode (A7, INPUT); // pin del boton1
   pinMode (A8, INPUT); // pin del boton 2
}

void loop () {
   if (digitalRead (A7) == LOW && Stepping == false)
   {
     digitalWrite (6, LOW);
     Stepping = true;
   }
   if (digitalRead (A8) == LOW && Stepping == false)
   {
     digitalWrite (6, HIGH);
     Stepping = true;
   }

   if (Stepping == true)
   {
     digitalWrite (3, HIGH);
     delay (1);
     digitalWrite (3, LOW);
     delay (1);

     StepCounter = StepCounter + 1;

     if (StepCounter == DISTANCE)
     {
       StepCounter = 0;
       Stepping = false;
     }
   }
}

estoy usando un arduino mega + shielf cnc+ driver A4988. motor paso a paso nema 17.

IndianaTux

Depends a lot on the motor driver your using. Also you don't have any debouncing on your switch.

Also comment your code, no idea which pin is what and what the different if clauses mean in your loop.

wvmarle

Debounce is not needed: upon press the sequence starts, but until it's done any subsequent presses on the same button don't do anything.

What is needed is pin labels indeed. No idea what it's doing.

Also details on the driver and motor used. Your code appears to put the stepper through 500 steps (in many steppers that would be 2 1/2 rotation) in 1 second, which may be too fast for the motor, depending on the motor and the load it has to move.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

juanmartin

lo que quiero hacer es que con un Boton hacer 5 movimientos. capaz tengo que cambiar el driver por un
driver l298n.

PaulS

Code: [Select]
if (StepCounter == DISTANCE)
Why would you compare the number of steps taken to a distance? The stepper did not move. The mechanism that the stepper controls might have moved, but the stepper is still attached to it's mounting bracket.
The art of getting good answers lies in asking good questions.

IndianaTux

Check this how-to on how using the L298N stepper driver with Arduino:

https://coeleveld.com/arduino-stepper-l298n/

juanmartin

thanks pauls ...

Indiantux excellent post ... I have everything written down and it seems that the l298 driver is the way ... I have to keep moving forward. thanks for giving me a hand eh a little more step for the project and that's a lot ...

Go Up