• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Buczący silnik
#1
Hej. Mam taki programik.

// simple stepper motor control 
// only x axis is used for dolly
#define EN 8 // stepper motor enable
#define X_DIR 5// x axis direction control
#define Y_DIR 6// y axis direction control
#define Z_DIR 7// z axis direction control
#define X_STP 2// x axis step control
#define Y_STP 3// y axis step control
#define Z_STP 4// z axis step control

/*
// step(): to control direction and steps of stepper motor
// parameter: dir for direction control, 
//                   dirPin maps to DIR pin of stepper motor,
//                   stepperPin maps to STEP pin of stepper motor
// return value: none
*/

void step(boolean dir, byte dirPin, byte stepperPin, int steps)
{
  digitalWrite(dirPin, dir);
  delay(50);
  for (int i = 0; i < steps; i++) {
    digitalWrite(stepperPin, HIGH);
    delayMicroseconds(800);
    digitalWrite(stepperPin, LOW);
    delayMicroseconds(800);
  }
}

void setup (){
  // setup stepper motor I/O pin to output
  pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
  pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
  pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
  pinMode(EN, OUTPUT);
  digitalWrite(EN, LOW);
}

void loop (){
  // 200 steps per turn
  step(false, X_DIR, X_STP, 0); // run 360 mm
  step(false, Y_DIR, Y_STP, 200); 
  step(false, Z_DIR, Z_STP, 0); 
  delay(1000);
  step(true, X_DIR, X_STP, 0);  // run 360 mm in reverse direction
  step(true, Y_DIR, Y_STP, 0); 
  step(true, Z_DIR, Z_STP, 0); 
  delay(1000);
}


Niestety po załadowaniu silniczek tylko buczy. Tak jakby obracał się w jedną i drugą stronę.
Arduino mega 2560
Silnik d3725802 
STP-43d1006-01 
1,8 /step 4,7V 0,85 A
Zasilacz 19V 3.5 A
 
Odpowiedź
  


Wiadomości w tym wątku
Buczący silnik - przez emil1319 - 20-02-2018, 00:55
RE: Buczący silnik - przez Smaczek - 20-02-2018, 09:16
RE: Buczący silnik - przez emil1319 - 20-02-2018, 09:18
RE: Buczący silnik - przez Smaczek - 20-02-2018, 09:21
RE: Buczący silnik - przez emil1319 - 20-02-2018, 09:29
RE: Buczący silnik - przez emil1319 - 20-02-2018, 20:44
RE: Buczący silnik - przez Smaczek - 20-02-2018, 22:02

Skocz do:


Przeglądający: 1 gości