viernes, 12 de abril de 2013

CONTROL DE UN MOTOR PASO A PASO BIPOLAR INALÁMBRICAMENTE (XBEE) CON ARDUINO Y LABVIEW (2º PARTE)

En esta 2º parte de éste proyecto vamos a utilizar la librería stepper.h que proporciona arduino para el gobierno sencillo de motores paso a paso:

/*
 Stepper Motor Controller
 language: Wiring/Arduino

 This 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.

 Created 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     // change this depending on the number of steps
                                         // per revolution of your motor
#define motorPin1 13
#define motorPin2 12


// initialize of the Stepper library:


Stepper myStepper(motorSteps, motorPin1,motorPin2);

void setup() {
  // set the motor speed at 60 RPMS:
 
  const int pwm_cha = 3;
  const int pwm_chb = 11;
  pinMode(pwm_cha, OUTPUT);
  pinMode(pwm_chb, OUTPUT);
  digitalWrite(pwm_cha, HIGH);
  digitalWrite(pwm_chb, HIGH);
   
  myStepper.setSpeed(100);

                                                         // Initialize the Serial port:
  Serial.begin(9600);

}

void loop()
{
  Serial.println("En un Sentido");
  myStepper.step(200);
  delay(500);

  Serial.println("En el otro");
  myStepper.step(-200);
  delay(500);
}


En el video que figura a continuación explico básicamente como funciona el programa y lo que debes modificar para adecuarlo al tipo de motor paso que tengas:

http://www.youtube.com/watch?v=KSfRjcf1JTk



No hay comentarios:

Publicar un comentario