Hi everyone, my english is not very good, so i will write this in spanish and english.
Spanish
Es mi primer tema subido a esta plataforma, entonces no sé cómo tengo que subir el código o si está bien subido o no, espero recibir una retroalimentación con respecto a eso. Explico mi proyecto de forma resumida, quiero controlar un motor para que al girar vaya perforando una manguera, no es necesario que este motor funcione de manera constante, mientras que el otro motor haga mover la manguera, todo esto funcionara con engranajes, mis motores son NEMA 23 con paso de ángulo 1,8°, el controlador es un DM542, y un Arduino uno (Cabe destacar que esta programación me fui guiando con varias que vi en internet). El problema es que el motor que debería hace girar a la manguera se guía por la programación que deberia ser para la perforadora, entonces no se como solucionar eso.
English
It's my first theme uploaded to this platform, so I don't know how I have to upload the code, I hope to receive feedback on that. I explain my project in a summarized way, I want to control a motor so that when it rotates it drills a hose, it is not necessary for this motor to work constantly, while the other motor makes the hose move, all this will work with gears, my motors are NEMA 23 with 1.8° step angle, the controller is a DM542, and an Arduino uno (It should be noted that this programming was guided by several that I saw on the internet). The problem is that the motor that should turn the hose is guided by the programming that should be for the drill, so I don't know how to solve that.
```cpp
#include <Stepper.h>
#define x_paso 9
#define x_dire 8
#define x_habi 0
#define y_paso 3
#define y_dire 2
#define y_cont 1
int tiempo = (2000); // Cuanto tiempo tarda en moverse
int retardo = (300); // Entre menor el número más rapido se mueve
int NOTIEMPO = (1500;// Cuanto tiempo tarda en moverse
int retardo_2 = (300); // Entre menor el número más rapido se mueve
void setup() {
pinMode(x_paso, OUTPUT); //PULSOS
pinMode(x_dire, OUTPUT); //DIRECCIÓN
pinMode(x_habi, OUTPUT); // ENABLE
pinMode(y_paso, OUTPUT);
pinMode(y_dire, OUTPUT);
pinMode(y_cont, OUTPUT);
}
void loop() {
giro(x_paso, x_dire, x_habi);
giro(y_paso, y_dire, y_cont);
}
void giro(int paso_, int dire_, int habi_) {// MOTOR PERFORADOA
digitalWrite(habi_, LOW);
digitalWrite(dire_, LOW);
for (int i = 0; i < tiempo; i++) {
digitalWrite(paso_, HIGH);
delayMicroseconds(retardo);
digitalWrite(paso_, LOW);
delayMicroseconds(retardo);
}
for (int i = 0; i < tiempo; i++) { // da pasos por un tiempo
digitalWrite(paso_, LOW);
}
delay(10);
}
void giro_2(int paso, int dire, int cont) {// MOTOR MOVIMIENTO
digitalWrite(cont, LOW);
digitalWrite(dire, LOW);
for (int j = 0; j > NOTIEMPO; j++) {
digitalWrite(paso, HIGH);
delayMicroseconds(retardo_2);
digitalWrite(paso, LOW);
delayMicroseconds(retardo_2);
}
for (int j = 0; j > NOTIEMPO; j++) {
digitalWrite(paso, LOW);
}
}