Arduino Uno 使用2204M驱动器驱动步进电机

实验效果

凌顺实验室(lingshunlab.com)演示实现如何使用KD2204M/SMB2204M驱动器驱动步进电机。

元件说明

WX20221210-1319172x4

特点:

  • 高性能,价格低,平稳性佳,低噪音,平稳性极好

  • 设有8档等角度恒力矩细分 ,最高 64/128 细分

  • 采用独特的控制电路,有效降低了噪音,增加了转动平稳性

  • 电流控制平滑,精准,电机发热小

  • 最高反映频率可达 200Kpps

  • 步进脉冲停止超过 400ms时,线圈电流自动减半,减少电机过热

  • 双极恒流斩波方式,使得相同的电机可以输出更大的速度和功率

  • 光电隔离信号输入/输出,抗干扰能力强

  • 驱动电流从 0.0A/相 到 1.5A/相 连续可调

  • 电压输入范国:DC6-30V 具有过压、欠压等出错保护功能

引脚说明

+ :输入信号公共端
PU :步进脉冲信号
DR :方向控制信号
MF :电机释放信号
+V :电源正 6V-30V
-V :电源负
+A :步进电机A相+
-A :步进电机A相-
+B :步进电机B相+
-B :步进电机B相-

BOM表

名称 数量
Arduino Uno x1
KD2204M/SMB2204M 电机驱动 x1
6V-30V电源 x1
跳线(杜邦线) 若干

接线图

WX20221210-1228282x3

2204M 驱动器 Arduino Uno 步进电机 6V-30V电源
+ <---> 5V
PU <---> 4
DR <---> 5
MF <---> 6
V+ <-----------------> +
V- <-----------------> -
A+ <-----> A+
A- <-----> A-
B+ <-----> B+
B- <-----> B-

程序代码

int step_pin = 4; // Enable
int dir_pin = 5; // Step
int enable_pin = 6; // Dir

int x;

void setup()
{
  pinMode(enable_pin,OUTPUT); 
  pinMode(step_pin,OUTPUT); 
  pinMode(dir_pin,OUTPUT); 
  digitalWrite(enable_pin,HIGH); // Set Enable low
}

void loop()
{

  digitalWrite(dir_pin,HIGH); // Set Dir high

  for(x = 0; x < 200; x++) // Loop 200 times
  {
      digitalWrite(step_pin,HIGH); // Output high
      delayMicroseconds(800); // Wait 1/2 a ms
      digitalWrite(step_pin,LOW); // Output low
      delayMicroseconds(800); // Wait 1/2 a ms
    }
  delay(2000); // pause one second

  digitalWrite(dir_pin,LOW); // Set Dir low

  for(x = 0; x < 200; x++) // Loop 200 times
  {
      digitalWrite(step_pin,HIGH); // Output high
      delayMicroseconds(800); // Wait 1/2 a ms
      digitalWrite(step_pin,LOW); // Output low
      delayMicroseconds(800); // Wait 1/2 a ms
    }
    delay(2000); // pause one second
}