Como aumentar velocidad de un stepp motor

hola a todos tengo un problema con este sketch, no puedo hacer que el motor valla mas rápido es un 28byj48, he trasteado en todos los parámetros y nada. si alguien puede ayudarme se lo agradecería. saludos

#include <Stepper.h> 
 
const int stepsPerRevolution = 500; 
 
//Inicializa a biblioteca utilizando as portas de 8 a 11 para 
//ligacao ao motor 
Stepper myStepper(stepsPerRevolution, 8,10,9,11);

// Defines Trig and Echo pins of the Ultrasonic Sensor
const int trigPin = 13;
const int echoPin = 12;
// Variables for the duration and the distance
long duration;
int distance;

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  myStepper.setSpeed(20);
  Serial.begin(9600);
}
void loop() {
    for(int i=0;i<=360;i++){  
       myStepper.step(-5.69);
       delay(30);
       distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree
  
       Serial.print(i); // Sends the current degree into the Serial Port 
       Serial.print(","); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
       Serial.print(distance); // Sends the distance value into the Serial Port
       Serial.print("."); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
    }
    for(int i=360;i>0;i--){  
       myStepper.step(5.69);
       delay(30);
       distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree
  
       Serial.print(i); // Sends the current degree into the Serial Port
       Serial.print(","); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
       Serial.print(distance); // Sends the distance value into the Serial Port
       Serial.print("."); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
    }
}
// Function for calculating the distance measured by the Ultrasonic sensor
int calculateDistance(){ 
  
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH); 
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
  distance= duration*0.034/2;
  return distance;
}



Moderador:
Por favor, lee las Normas del foro y publica/edita tu código/error usando etiquetas de código.
Ve a edición, luego selecciona todo el código que has publicado/editado, lo cortas y click en (<CODE/>)


Cambia esto pero no dejes de editar tu primer post.

myStepper.setSpeed(60);   // Incrementa la velocidad del motor a 60 RPM
1 Like

mil disculpas era mi primer post y ya lo corregi. ojala me puedan ayudar

Ya te respondí.

1 Like

hola. nada amigo le pongo 60 y va igual de lento, aqui adjunto el video en el que me baso

uso el mismo sketch motor y driver pero el mio va a menos de la mitad de velocidad

Pero para que le metes esos delay(30)?
La velocidad la controla el comando que te indiqué pero ese delay(30) detiene todo.

Mira este sketch de los ejemplos de la librería <Stepper.h>
https://github.com/arduino-libraries/Stepper/blob/master/examples/stepper_speedControl/stepper_speedControl.in

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the Stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;  // number of steps the motor has taken

void setup() {
  // nothing to do inside the setup
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 100);
  }
}

Otra cosa que podes cambiar para aumentar la velocidad es la cantidad de pasos por revolución.

const int stepsPerRevolution = 500; 
// a esto
const int stepsPerRevolution = 200;   // si bajas la cantidad de pasos irá mas rápido.
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.