Hi, my name is Lex. I'm a contractor and i am "trying" to build an automated fence for my saws. I am doing this by using a stepper motor to convert rotational steps to linear movement. Which is what led me to arduino. I have taken a few basic online stepper motor tutorials and I am a bit stumped as of now and thought joining the forum and sharing info would be beneficial for me. So... my setup. I am using a 20 tooth pulley with a 2mm pitch belt so one full rotations will give me 40mm of linear movement. I have a NEMA 23 1.8 degree stepper with the driver set at 1/16 step. So 40mm/3200steps so .0125mm per steps. I am working on the code and need to be able to tell my stepper how far to move in one direction. For example if i want to move the "fence" 350mm. I need my stepper to move 350/0.125mm, so 28000 steps. Could someone help me with the code for this. And is there a way i can save the position so once i move the fence it will calculate from there. If someone could help me get going in the right direction i would much appreciate it. And if you could link any threads that may help, or if there is any readily available software (I am using mac) please share.
#include <Stepper.h>
int stepsPerRevolution=800; // 1 Rev equals 40mm //
int motSpeed=120;
int dt=1000;
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myStepper.setSpeed(motSpeed);
myStepper.step(1500*20); // Moving 1.5m right //
delay(dt);
}
void loop() {
}
sketch_apr04a.ino (301 Bytes)