linear acruator code!

Hi,
Can someone provide me arduino uno code(sketch) for stepper motor. I am using nema 17 bipolar steppr motor and L298n driver for stepper motor. So i need hlp about code that should run my simple linear actuator...
Code should do next-
need stepper motor to do 200-500 times rotation forward, then stop,after that, delay 30 seconds, and 200-500 turn rotation backward, then stop. something like that).
I need this for opening , and delay 30 sec, then closing automaticly...
thx
vojotic

Sounds like that's something you could code yourself.

There are stepper motor examples in the arduino IDE.

Which stepper motor exactly? 500 turns will take a long time driven from an L298, several
minutes possibly.

vojotic,

I’d ditch the driver you are going to use and use an Adafruit motor shield V2.

You then have to download the Adafruit Motor Shield V2 library.

In the Arduino IDE, go to examples and highlight Adafruit_Motor_Shield_V2_Library then scroll down to Stepper Test.

That sketch will do what you want.

A few people on this forum do not advocate using the Adafruit Motor Shield. I reckon it’s terrific and when driving my Nema17 stepper, doesn’t even get warm after hours of use. If it works, I can’t see the problem.

Ken

thx Ken,
i will try, and i will share my opinion

thx

What speed do you want the motor to turn?

What are the specs of the motor?

MarkT:
Which stepper motor exactly? 500 turns will take a long time driven from an L298, several
minutes possibly.

Mark,
I am using this stepper motor http://www.shinano.com/motors/docs/SKC_Full-line_Catalog.pdf (on page 7-nema17)
Because i am new in this, i will ask maybe stupid question

  1. when i use this basic code:

Stepper Motor Control - one revolution

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.

Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println(“counterclockwise”);
myStepper.step(-stepsPerRevolution);
delay(500);
}

It works ok,
But when i try to change number of steps, in this line-const int stepsPerRevolution = 200( to 400 or 1000…etc) stepper motor is bugging(doing something unpredictable, buzzing, haotic rotation)
But if i lower the rpm in linear progresion in this orde:- const int stepsPerRevolution = 400-myStepper.setSpeed(30), or const int stepsPerRevolution = 800-myStepper.setSpeed(15), its rotating at 60rpm all the time.
i just want to rotate 10000 steps at speed of 60 rpm, but i cant do that.

I repeat which motor are you using? There are 13 possibilities on that page of that brochure.

Oh dear.

Your going about this all the hard way (unless you are doing this for academic purposes). I agree with earlier posts... use the addafruit driver or the easy driver. There are lots of them out there.

They work like this (most)...

You hook up your motor.
Hook up your motor power
Hook up 2 wires to output pins (I'll call them a and b) blink pin a and it moves forward a step. blink pin b it moves back a step.

They are cheap reliable and easy to use. Save the time... do it the easy way. If you have any old Floppy drives or cd roms they have one in there even (if money is tight)

Good luck!

MarkT:
I repeat which motor are you using? There are 13 possibilities on that page of that brochure.

(on page 7-nema17) i wrote it.