7TPSM4220微型步进电机驱动器--ARDUINO驱动

1 产品特征:

7TPSM4220微型步进电机驱动器--ARDUINO驱动_第1张图片

2 电气接口:

7TPSM4220微型步进电机驱动器--ARDUINO驱动_第2张图片

3 arduino与驱动器连接:

7TPSM4220微型步进电机驱动器--ARDUINO驱动_第3张图片
连接方式采用共阳方式:

                 驱动器                        ARDUINO                             信号类型
                 1                                                                   VCC   12v或者24v供电
                 2                                 GND                          GND 共地
                 3                                 4                              共阳设置,置HIGH
                 4                                 3                             DIR,方向
                 5                                 2                              STEP,步进脉冲
                 6                                 5(或者不接)                EN,脱机信号,置HIGH使能,LOW脱机

4 驱动方式:

1,采用ARDUINO 的STEPPER库,优点:简单,缺点:阻塞式控制,占用资源大
2,采用AccelStepper库,优点:功能强大,缺点:较复杂
AccelStepper库链接http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

AccelStepper significantly improves on the standard Arduino Stepper library in several ways:

  • Supports acceleration and deceleration
  • Supports multiple simultaneous steppers, with independent concurrent stepping on each stepper
  • API functions never delay() or block
  • Supports 2, 3 and 4 wire steppers, plus 3 and 4 wire half steppers.
  • Supports alternate stepping functions to enable support of AFMotor (https://github.com/adafruit/Adafruit-Motor-Shield-library)
  • Supports stepper drivers such as the Sparkfun EasyDriver (based on 3967 driver chip)
  • Very slow speeds are supported
  • Extensive API
  • Subclass support

STEPPER库的例程如下:


/*
 Stepper Motor Control - one revolution

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 - 11 of the Arduino.

 The motor should revolve one revolution in one direction, then
 one revolution in the other direction.


 Created 11 Mar. 2007
 Modified 30 Nov. 2009
 by Tom Igoe

 */

#include 

const int stepsPerRevolution = 400;  // 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);
Stepper myStepper(stepsPerRevolution, 4, 5);

void setup() {
  // set the speed at 60 rpm:
   pinMode(6,OUTPUT); // Enable
  myStepper.setSpeed(2000);
   digitalWrite(6,HIGH); // Set Enable low
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  /*
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
  */
}

AccelStepper库的例程如下:

AccelStepper::DRIVER (1) means a stepper driver (with Step and Direction pins).
If an enable line is also needed, call setEnablePin() after construction.

// ConstantSpeed.pde
// -*- mode: C++ -*-
//
// Shows how to run AccelStepper in the simplest,
// fixed speed mode with no accelerations
/// \author  Mike McCauley ([email protected])
// Copyright (C) 2009 Mike McCauley
// $Id: ConstantSpeed.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include 
#define LED 13

bool State=0;
//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(AccelStepper::DRIVER); // AccelStepper::DRIVER (2 pins) on 2, 3

void setup()
{  
   stepper.setMaxSpeed(1000);
   stepper.setSpeed(50);  
   pinMode(4,OUTPUT);
   digitalWrite(4,HIGH);
}

void loop()
{  
   stepper.runSpeed();
 }

你可能感兴趣的:(ARDUINO)