Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Stepper Motor

10. November 2010

Lass den Stepper jede Sekunde einen Schritt im Uhrzeigersinn machen und alle fünf Sekunden wieder an den Ausgangspunkt zurückkehren. Film Stepper Motor
<pre>/*
Pololu A4983 Stepper Driver + Mercury Motor SM-42BYG011-25 Stepper Motor

This code lets the stepper motor turn as fast as possible.
Use it to measure the current (Ampere) at the motor's power supply.
And limit the current with the little potentiometer on the stepper driver.
According to the specification (http://www.sparkfun.com/datasheets/Robotics/SM-42BYG011-25.pdf)
it's 0.33A
If you do not limit the current the motor will be damaged!!!
*/

// Constants ------------------------------------
#define DIR 3                   // Direction Pin
#define STEP 2                  // Constant
#define BUT 4                   // Direction Button

// Variables ------------------------------------

int counter = 0;

// Setup ----------------------------------------
void setup(){
pinMode(DIR, OUTPUT);         // Direction is an output
pinMode(STEP, OUTPUT);        // Step is an output
}

// Loop -----------------------------------------
void loop(){
stepOnce();                 // Step
}

// Function Definition ---------------------------
// the specifications says the low to high transition
// must be at least 1 microsecond
void stepOnce(){
if (counter &lt; 5) {
digitalWrite(DIR, HIGH);    // set direction

digitalWrite(STEP, HIGH);
delay(1000);
digitalWrite(STEP, LOW);
delay(1);

counter++;
} else if (counter &lt; 10) {
digitalWrite(DIR, LOW);    // set direction

digitalWrite(STEP, HIGH);
delay(1);
digitalWrite(STEP, LOW);
delay(1);

counter++;
} else {
counter = 0;
}
}