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

1 产品特征:

在这里插入图片描述

2 电气接口:

在这里插入图片描述

3 arduino与驱动器连接:

在这里插入图片描述
连接方式采用共阳方式:

                 驱动器                        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 <Stepper.h>

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 (mikem@airspayce.com)
// Copyright (C) 2009 Mike McCauley
// $Id: ConstantSpeed.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>
#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();
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值