How to write a program to control a linear movable rail

Hello guys,
I am a novice in using arduino. I want to implement a SAR system that moves on a linear rail system of length 2.3m. I want to write a program to control ustepper which uses arduino IDE. Please can anyone help me with the coding.
Regards

best way is to start with the stepper library included in the ide and follow some tutorials under learning it is not difficult

The code depends on the hardware (motor, motor driver, wiring, power supplies), which you forgot to describe.

I wanted to use a Nema 17 stepper motor and uses a ustepper to control it. The rail is about 2m long and I want to move it linearly for up to 10 positions. The ustepper board is a simplify board that is used to control the stepper motor. Detail of the ustepper can be found in the link http://ooznest.co.uk/uStepper-Controller-Board?search=u%20stepper

Regards

Have you read all the documentation on the µStepper website that you linked to.
Have you downloaded their Arduino library and tried their examples?

As far as I can see they provide all the info you need to get started.

...R

Yeh I downloaded the library and install it. I tried all the 3 examples given on 3D printer, arm control. However, being a novice in using arduino that is why I asked if anyone can help me with code on how to control the movement of a linear rail using ustepper.
Regards

mohammedb600:
Yeh I downloaded the library and install it. I tried all the 3 examples given on 3D printer, arm control. However, being a novice in using arduino that is why I asked if anyone can help me with code on how to control the movement of a linear rail using ustepper.

Help us out here ...

I have no idea what the example programs are like. Post one of them that is most like you want to do and then explain what you want to happen that is different from the example.

Although you have not said so, I presume the examples worked?

...R

Sorry for the late reply. Yeh the examples given worked however, non of the examples is/are used to control a moving rail. They only used ustepper to program it. Belo is an example of a continuous robot control given.

#include <uStepper.h>

#define MAXACCELERATION 1500 //Max acceleration = 1500 Steps/s^2
#define MAXVELOCITY 1100 //Max velocity = 1100 steps/s

uStepper stepper(MAXACCELERATION, MAXVELOCITY);

void setup() {
// put your setup code here, to run once:
stepper.setup();
Serial.begin(115200);
stepper.runContinous(CCW);
}

void loop() {
char cmd;
// put your main code here, to run repeatedly:
while(!Serial.available());
Serial.println("ACK!");
cmd = Serial.read();
if(cmd == '1') //Run continous clockwise
{
stepper.runContinous(CW);
}

else if(cmd == '2') //Run continous counter clockwise
{
stepper.runContinous(CCW);
}

else if(cmd == '3') //Stop without deceleration and block motor
{
stepper.hardStop(HARD);
}

else if(cmd == '4') //Stop without deceleration and don't block motor
{
stepper.hardStop(SOFT);
}

else if(cmd == '5') //Stop with deceleration and block motor
{
stepper.softStop(HARD);
}

else if(cmd == '6') //Stop with deceleration and don't block motor
{
stepper.softStop(SOFT);
}
}

As mine is entirely different, that is why I request for an expert that help me program how I can move a rail using the ustepper. I want to move the 5 or 10 cm and stops for 10 seconds, moves again until I cover the entire length of the rail.
Please can you assist me. Forgive my ignorance because I am a novice in arduino.
Regards

For the future please use the code button </> so your code looks like this and is easy to copy to a text editor

#include <uStepper.h>

#define MAXACCELERATION 1500         //Max acceleration = 1500 Steps/s^2
#define MAXVELOCITY 1100           //Max velocity = 1100 steps/s

uStepper stepper(MAXACCELERATION, MAXVELOCITY);

void setup() {
  // put your setup code here, to run once:
  stepper.setup();
  Serial.begin(115200);
  stepper.runContinous(CCW);
}

void loop() {
  char cmd;
  // put your main code here, to run repeatedly:
  while(!Serial.available());
  Serial.println("ACK!");
  cmd = Serial.read();
  if(cmd == '1')                      //Run continous clockwise
  {
    stepper.runContinous(CW);
  }
 
  else if(cmd == '2')                 //Run continous counter clockwise
  {
    stepper.runContinous(CCW);
  }
 
  else if(cmd == '3')                 //Stop without deceleration and block motor
  {
    stepper.hardStop(HARD);
  }
 
  else if(cmd == '4')                 //Stop without deceleration and don't block motor
  {
    stepper.hardStop(SOFT);
  }
 
  else if(cmd == '5')                 //Stop with deceleration and block motor
  {
    stepper.softStop(HARD);
  }
 
  else if(cmd == '6')                 //Stop with deceleration and don't block motor
  {
    stepper.softStop(SOFT);
  }
}

If you want someone to write a program for you then you should ask in the Gigs and Collaborations section of the Forum and be prepared to pay.

If you want to write the program yourself then it seems that the example code probably has most of the ingredients you need. If you have a stepper motor controlling something with linear movement it is still just a question of how many steps to make it move.

Write a short program to make your rail move back and forward say 200 steps. If it does not work then post the program that you tried.

...R

Thanks. I will try the other section as you suggested.