Buenas tardes
El cisne es una granja-pasteleria, de las buenas buenas, hacian unos suizos pa cagarse.
Ahora ya no puedo gastarmelas ahi, soy diabetico y tengo que cuidarme.
Me he pillado un sketch y he empezado a mirarlo, Para la primera prueba creo que me ira bien, he cambiado algunos parametros, me gustaria que me confirmarais que son correctos ...
/*
Stepper Motor Controller
language: Wiring/ArduinoThis program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 and 9 of the Arduino.The motor moves 100 steps in one direction, then 100 in the other.
he cambiado el valor a 3000, bueno a 2996Created 11 Mar. 2007
Modified 7 Apr. 2007
by Tom Igoe*/
// define the pins that the motor is attached to. You can use
// any digital I/O pins.#include <Stepper.h>
#define motorSteps 200 // (360/3,75)change this depending on the number of steps
// he colocado 200 que es lo que corresponde a mi motor // per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define ledPin 13// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);void setup() {
// set the motor speed at 60 RPM
(1 REV/SEG NECESITO 30 VUELTAS POR CICLO- TARDARA 30 SEG.):
myStepper.setSpeed(60);// Initialize the Serial port:
Vale serial por USB????
Serial.begin(9600);// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}void loop() {
// Step forward 3000 steps:
Serial.println("Forward");
myStepper.step(2996); // es correcto quitarle 4 pasos???, en el sketch original pone para 100-->>96
delay(500); // Esta orden creo que sobra, debe de ir una orden "stop"?// Step backward 3000 steps:
Serial.println("Backward");
myStepper.step(-2996);
delay(500);}
// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}
He visto otro sketch que define el avnce retroceso del motor con otras funciones, cual es la buena, o la mas correcta, vamos la mejor de las dos
Sketch:
/* Motor paso a paso 5VDC+ controladora UNL2003 */
int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int delayTime = 15; // delay que determina el tiempo cada vez que cambia de paso
int buttonPin = 2;
int estado = 0;void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
estado = digitalRead(buttonPin);
if(estado==HIGH)
{
digitalWrite(motorPin1, LOW); // sentido anti-horario
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
}
else
{
digitalWrite(motorPin1, HIGH); // sentido agujas del reloj
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
}/* Colabo Redfox y J*/
Con respecto a la precision si divido 1,5 mm entre 200 pasos me da 0'0075, una precision mas de 100 veces la que necesito.
No debes comparar mi proyecto con tu CNC, es como comparar un renault 4/4 y un BMW actual, son dos temas distintos y que solo tienen en comun que hay una mesa que se mueve.
Saludos
Juanma
Valencia