赞
踩
文章分类:
https://blog.csdn.net/freewebsys/category_5782941.html
前面讨论了相关的技术调研。

或者这样的:

第一次折腾,价格便宜就行。
https://detail.1688.com/offer/656424665619.html

v3 雕刻机扩展板+ A4988套件 21 元:
https://detail.1688.com/offer/710743362308.html

http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/arduino-cnc-shield/#other-pins

直接使用 arduino 安装库组件,然后编程即可。
同时文章里面还you 接线方式:

然后连接电机进行供电:


需要一个 12 v 的供电电源,高电压会导致抖动。 42 步进电机电压是 12 v。
因为是特别针对 Wemos D1 R32 ESP32 +Arduino CNC Shield v3 这个进行的引脚配置。
要是标准的arduino 可以参考 太极创客的文章:
http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/arduino-cnc-shield/#other-pins
主要是引脚的不同,其他都一样。
选择 wemos d1 r32 版本:

| Arduino Uno CNC Shield | D1 R32 - ESP32 |
|---|---|
| D0 RX | RX0 |
| D1 TX | TX0 |
| D2 X-STEP | IO26 |
| D3 Y-STEP | IO25 |
| D4 Z-STEP | IO17 |
| D5 X-DIR | IO16 |
| D6 Y-DIR | IO27 |
| D7 Z-DIR | IO14 |
| D8 EN | IO12 拆掉CNC板子上的10K上拉电阻 |
| D9 X-、X+ | IO13 |
| D10 Y-、Y+ | IO05 |
| D11 Z-、Z+ | IO23 |
| D12 A-STEP、SpinEn | IO19 |
| D13 A-DIR、SpinDir | IO18 |

代码:
/* Arduino CNC电机扩展板驱动4个NEMA17步进电机示例程序 http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/arduino-cnc-shield/#other-pins By 太极创客(http://www.taichi-maker.com) 2019-03-10 @2023.09.09 修改,只适配 Wemos D1 R32 ESP32 +Arduino CNC Shield v3 方案 */ #include <AccelStepper.h> //本示例程序使用AccelStepper库 // 定义电机控制用常量 const int enablePin = 12; // 使能控制引脚 const int xdirPin = 16; // x方向控制引脚 const int ydirPin = 27; // y方向控制引脚 const int zdirPin = 14; // z方向控制引脚 const int xstepPin = 26; // x步进控制引脚 const int ystepPin = 25; // y步进控制引脚 const int zstepPin = 17; // z步进控制引脚 const int moveSteps = 100; //测试电机运行使用的运行步数 const int stepperMaxSpeed = 550; const int stepperAcceleration = 55; AccelStepper stepper1(1,xstepPin,xdirPin);//建立步进电机对象1 AccelStepper stepper2(1,ystepPin,ydirPin);//建立步进电机对象2 AccelStepper stepper3(1,zstepPin,zdirPin);//建立步进电机对象3 void setup() { Serial.begin(115200); pinMode(xstepPin,OUTPUT); // Arduino控制A4988x步进引脚为输出模式 pinMode(xdirPin,OUTPUT); // Arduino控制A4988x方向引脚为输出模式 pinMode(ystepPin,OUTPUT); // Arduino控制A4988y步进引脚为输出模式 pinMode(ydirPin,OUTPUT); // Arduino控制A4988y方向引脚为输出模式 pinMode(zstepPin,OUTPUT); // Arduino控制A4988z步进引脚为输出模式 pinMode(zdirPin,OUTPUT); // Arduino控制A4988z方向引脚为输出模式 pinMode(enablePin,OUTPUT); // Arduino控制A4988使能引脚为输出模式 digitalWrite(enablePin,LOW); // 将使能控制引脚设置为低电平从而让 // 电机驱动板进入工作状态 stepper1.setMaxSpeed(stepperMaxSpeed); // 设置电机最大速度 stepper1.setAcceleration(stepperAcceleration); // 设置电机加速度 stepper2.setMaxSpeed(stepperMaxSpeed); // 设置电机最大速度 stepper2.setAcceleration(stepperAcceleration); // 设置电机加速度 stepper3.setMaxSpeed(stepperMaxSpeed); // 设置电机最大速度 stepper3.setAcceleration(stepperAcceleration); // 设置电机加速度 pinMode(2, OUTPUT); } void loop() { // 控制步进电机1往复运动 if (stepper1.currentPosition() == 0 ){ stepper1.moveTo(moveSteps); digitalWrite(2, HIGH); // turn LED on } else if ( stepper1.currentPosition() == moveSteps ){ stepper1.moveTo(0); digitalWrite(2, LOW); // turn LED off } // 控制步进电机2往复运动 if ( stepper2.currentPosition() == 0 ){ stepper2.moveTo(moveSteps); } else if ( stepper2.currentPosition() == moveSteps ){ stepper2.moveTo(0); } // 控制步进电机3往复运动 if ( stepper3.currentPosition() == 0 ){ stepper3.moveTo(moveSteps); } else if ( stepper3.currentPosition() == moveSteps ){ stepper3.moveTo(0); } stepper1.run(); // 1号电机运行 stepper2.run(); // 2号电机运行 stepper3.run(); // 3号电机运行 }
https://www.bilibili.com/video/BV1uP41187EJ/
【研究开源机器臂】组装个步进电机机械臂,使用Wemos D1 R32 ESP32 Arduino开发板和CNC Shield v3控制版,成功控制3D打印机械臂
低成本实现200多元实现,终于调试好了。
主要花费是3d打印的开源机械臂,170-180左右。
控制芯片使用:Wemos D1 R32 ESP32 +Arduino CNC Shield v3
工具使用 arduino + ESP32 + AccelStepper 库进行开发
目前还有一点抖动,估计是电压过高导致的,使用了24v电压,但是 42 电机估计只能用12v 电压。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。