参考:步进电机相关文章
Control Position and Speed of Stepper Motor using Android Bluetooth App, A4988 Driver, & Arduino
Control Position and Speed of Stepper Motor:
Control Position and Speed of Stepper Motor using Android Bluetooth App, A4988 Driver, & Arduino- I have been using Unipolar and Bipolar Stepper motors for quite a long time in different beginners, intermediate, and advanced level projects. The A4988 Stepper Motor Drivers and the Nema17 Bi-polar Stepper Motors are becoming very popular and this is the reason they are frequently used in CNC machine, handwriting machines, 3D printers, etc. To control different complex processes we usually enter different parameters using keypads or touch screens which greatly increases the project overall cost. In this project, I am not going to using any keypads or touchscreen for entering the direction, speed, and limit values. I will only use an android cell phone application.
使用 Android 蓝牙应用程序、A4988 驱动器和 Arduino 控制步进电机的位置和速度-- 我在不同的初级、中级和高级项目中使用单极和双极步进电机已经有很长一段时间了。 A4988 步进电机驱动器和 Nema17 双极步进电机正变得非常流行,这也是它们经常用于数控机床、手写机、3D 打印机等的原因。 为了控制不同的复杂过程,我们通常使用键盘或触摸屏输入不同的参数,这大大增加了项目的总体成本。 在本项目中,我不会使用任何键盘或触摸屏来输入方向、速度和限值。 我将只使用安卓手机应用程序。
In my previous tutorial “Arduino CNC Shield V3.0 and A4988 Hybrid Stepper Motor Driver + Joystick” I used the CNC shield with Arduino and covered the maximum basic things including the technical specifications and how to use the male headers and how to use the CNC shield in custom made projects. If you are a beginner and you have never used the CNC shield then I highly recommend read my previous article which also explains how to control the speed and direction of the stepper motor automatically and then how to use a joystick to control a stepper motor.
在我之前的教程 "Arduino CNC Shield V3.0 和 A4988 混合式步进电机驱动器 + 操纵杆 "中,我将 CNC 屏蔽与 Arduino 结合使用,并介绍了最基本的内容,包括技术规格、如何使用公头以及如何在定制项目中使用 CNC 屏蔽。 如果您是初学者,从未使用过 CNC 防护罩,我强烈建议您阅读我之前的文章,其中还介绍了如何自动控制步进电机的速度和方向,以及如何使用操纵杆控制步进电机。
I have also used the same CNC shield with the Nodemcu ESP8266 Wifi Module this way the two Hybrid Stepper motors can be controlled from anywhere around the world using the cell phone application designed in Blynk. You will learn a lot of new things in this article, like for example, how to control the speed and limits of the stepper motor using the sliders, how to manually adjust the starting position of the stepper motor using a potentiometer, and how to control a stepper motor using the Joystick on the blynk application.
Before, I am going to explain how to make your own small size and low cost wireless Bluetooth controlled Stepper Motors controller, first a few words about the sponsor for sending me such high quality PCB.
我还将相同的 CNC驱动板与 Nodemcu ESP8266 Wifi 模块结合使用,这样就可以通过 Blynk 设计的手机应用程序在全球任何地方控制两个混合步进电机。 你将在本文中学到很多新知识,例如,如何使用滑块控制步进电机的速度和限位,如何使用电位器手动调整步进电机的起始位置,以及如何使用 Blynk 应用程序上的操纵杆控制步进电机。 介绍如何制作自己的小尺寸、低成本无线蓝牙控制步进电机控制器。
About the Sponsor, JLCPCB:
In this tutorial, you will learn how to use the most popular A4988 Stepper Motor drivers and HC05 Bluetooth Module with Arduino to control the NEMA17 Hybrid Stepper Motors wirelessly using an Android cell phone Application designed in Android studio. The different parameters like the set position, limit, and speed are entered wirelessly which greatly reduces the hardware cost, as there is no need to interface touch screens and keypads. Using the Android App we can set the starting position of the stepper motor, enter 0 or 1 to set the starting position, when I press the set position button it moves the shaft of the stepper motor only 1 step at a time, if this thing annoys you, then you can also specify the exact position you want to move to, for which you will need to modify the program a little, for now I will continue with only 1 step at a time, but don’t worry I will explain everything in the programming, so you will have no problem in modifying the code…After the starting position has been set, next you will need to enter the limit and speed. If any of these two parameters is missing the stepper motor won’t work. Limit sets the maximum number of steps, and you have full control over this, you can change this limit in real time and the same thing applies to the speed. Speed is basically the delay time, greater the number the slower the shaft rotates. Each time you enter a new value the buttons should be pressed to send the value to the Arduino board.
在本教程中,您将学习如何使用最流行的 A4988 步进电机驱动器和 HC05 蓝牙模块以及 Arduino,通过使用 Android studio 设计的 Android 手机应用程序无线控制 NEMA17 混合式步进电机。 通过无线方式输入不同的参数,如设定位置、限位和速度,大大降低了硬件成本,因为无需连接触摸屏和键盘。 使用 Android 应用程序,我们可以设置步进电机的起始位置,输入 0 或 1 即可设置起始位置,当我按下设置位置按钮时,步进电机的轴每次只移动一步,如果这让你不爽,那么你也可以指定你想要移动到的确切位置,为此你需要稍微修改程序,现在我将继续每次只移动一步,不过别担心,我会在编程中解释一切,所以你在修改代码时不会有任何问题…设置好起始位置后,接下来需要输入限位和速度。 如果缺少这两个参数中的任何一个,步进电机将无法工作。 限值设置最大步数,您可以完全控制,并实时更改限值,速度也是如此。 速度基本上就是延迟时间,数值越大,轴转动得越慢。 每次输入新值时,都应按下按钮,将值发送到 Arduino 板。
You might be thinking how Arduino knows if the value I am sending is for the direction control, or for setting the limit or for the speed? Well I am sending the following commands,
您可能会想,Arduino 如何知道我发送的值是用于方向控制、设置限位还是用于速度控制? 我发送的命令如下
direction,1,#
position,400,#
speed,1000,#
which consists of the identifiers “direction, position, and speed” and the actual values. I am using commas as the delimiter and the # sign to tell the Arduino that the command is completed. Then on the Arduino side we split the messages and store the identifiers and values in their respective variables to control the stepper motor. I will explain this in the programming.
The reason I designed this low cost stepper motor controller is to help you easily understand the very basics so that you can design your own stepper motor controller rather than using the CNC shield. Moreover, it seems quite impractical to use the CNC shield when you need to control one or two stepper motors. There can be situations when you need to control more than 4 stepper motors, while the CNC shield can be used to control 4 stepper motors at the same time. So, in a situation like this you will need to design your own stepper motor controller.
As the stepper motor I am using has the step angle of 1.8 degrees and as I am using the A4988 stepper motor driver in the full step configuration, so, for 1 complete revolution I will need 200 steps as 1.8 x 200 = 360.
Currently, this stepper motor controller can control two stepper motors at the same time, but you can easily modify this project to control multiple stepper motors. I am sure, now you have got the idea of what you are going to learn after watching this video.
Without any further delay, let’s get started!!!
其中包括标识符 "方向、位置和速度 "以及实际值。 我使用逗号作为分隔符,并用 # 号告诉 Arduino 命令已完成。 然后,在 Arduino 端,我们分割信息,并将标识符和值存储到各自的变量中,以控制步进电机。 我将在编程中解释这一点。 我设计这个低成本步进电机控制器的原因是为了帮助您轻松了解最基本的知识,这样您就可以设计自己的步进电机控制器,而不是使用 CNC。 此外,当您需要控制一个或两个步进电机时,使用 CNC似乎浪费了。 在某些情况下,您可能需要控制 4 个以上的步进电机,而 CNC可用于同时控制 4 个步进电机。 因此,在这种情况下,您需要设计自己的步进电机控制器。 由于我使用的步进电机的步距角为 1.8 度,而且我使用的是全步进配置的 A4988 步进电机驱动器,因此,转一圈需要 200 步,即 1.8 x 200 = 360。该步进电机控制器可以同时控制两个步进电机,但您可以轻松修改该项目以控制多个步进电机。
Links:
Arduino Nano USB-C Type (Recommended)
A4988 Stepper Motor Driver Specs & Pinout:
The A4988 Stepper Motor Driver is a complete micro-stepping motor driver with built-in translator for easy operation. It is designed to operate bipolar stepper motors in full-, half-, quarter-, eighth-, and sixteenth-step modes, with an output drive capacity of up to 35V and ±2A as per the datasheet. The A4988 includes a fixed off-time current regulator which has the ability to operate in Slow or Mixed decay modes.
The translator is the key to the easy implementat