endstops

hi someone knows how to program a fiscal switch to make a endstop for pap motors ? like a 0 for the beginning of the program. the function is that i want is to look a 0 to start from there all the times the soft have a problem or a restart

thanks agus.

What exactly is a "fiscal switch"?

You might need to make a less specialized explanation if you get no answers.

fiscal switch? pap motors?

You want something to 0 when something hits an end stop?

What exactly is a "fiscal switch"?

My impression was that that was supposed to be physical switch. No idea what a pap motor is, though.

sorry for mi bad english, i from argentina. pap motor here we said like that, but sorry is a " step motor " mi idea is that all the motors start from a specific point. like the printers that founds the 0. mi idea was that in the rail of the motor at the end, i want to put a switch or button that show the end of the rail to de program so when the program stars the motors goes directly to the switch so the arduino receive that the motor is in the end of the rail. and then the other part of the program runs normaly.

this is for security so when the arduino shuts down or if i have to reset the arduino, the program will position the step motors

NOW I KNOW WHAT I WANT !!! i a home position for the step motors now the problem how should i do that ?

ow should i do that ?

Seems pretty simple to me. Step once. Test if the limit switch has been hit. If not, repeat the above two steps.

Hi, as PaulS says.

(1) Check if stepper is at HOME (2) "IF" not HOME then make stepper backup towards the home position go back to (1), "IF" it is HOME then (3). (3) Continue to rest of sketch.

Tom... :)

If the stepper is moving something with strong end stops, then you could skip the limit switch and drive the motor to the end stop using more steps than the full span step range.

Printers use an opto-interrupter for this function

zoomkat: If the stepper is moving something with strong end stops, then you could skip the limit switch and drive the motor to the end stop using more steps than the full span step range.

If there's a coupling, that's a great way to eventually loosen it.

If there's a coupling, that's a great way to eventually loosen it.

I think you misspelled break.

hey dudes thank all of you for answer to me !! here Magicd a member of arduino forum pass me a code of a homing for steps motors ! now the question is ! is this code flexible for bipolar o unipolar motors ? because of the line " AccelStepper stepper1(1, 6, 5); " there have 3 pins and i need 4… then how can i do to put all this code only in one proces and then to continue with a void loop ? i mean i onlly want this routine only when the arduino start o restart only one time and then that the oders process continue commonly.

#include <AccelStepper.h>

AccelStepper stepper1(1, 6, 5);

const int homeButton = 2;
const int ledPin = 13;
byte hBval;


void setup(){
  stepper1.setMaxSpeed(500); //nice and slow for testing
  stepper1.moveTo(-3200);
  stepper1.setAcceleration(500);
  pinMode(homeButton, INPUT);
  pinMode(ledPin, OUTPUT);
  stepperHome(); //runs routine to home motor
}
void loop(){
  stepper1.moveTo(5000); // random position to end for testing
  stepper1.runToPosition();
  delay(1000);
  stepper1.moveTo(0);
  stepper1.runToPosition();
  delay(1000);
}
//contributed by Runaway Pancake 9/2/13
void stepperHome(){ //this routine should run the motor
  hBval = digitalRead(homeButton);
  while (hBval == HIGH)
  {
    //backwards slowly till it hits the switch and stops
    stepper1.moveTo(-3200);
    stepper1.run();
    digitalWrite(ledPin, LOW); //indicates it's doing something
    hBval = digitalRead(homeButton);
  }
  digitalWrite(ledPin, HIGH); //indicates it's doing something
  stepper1.setCurrentPosition(0); //should set motor position to zero and go back to main routine
}

PaulS:

ow should i do that ?

Seems pretty simple to me. Step once. Test if the limit switch has been hit. If not, repeat the above two steps.

Or test first in case the movement is already 'parked' at the end.

aguskussrow, be sure to check you have the same stepper but not all stepper commands use all the wires. There are many good web sites/pages about motors and arduino/avr.

Here is a start, I can't find my link to Grumpy Mike's pages, got to get more organized.

http://arduino.cc/en/reference/stepper http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/