Шаговый двигатель управление wifi

Nodemcu esp8266 stepper motor NEMA 17 controlled over WiFi

This tutorial is about controlling stepper motor over WiFi through desktop or mobile web browser using nodemcu esp8266 WiFi module. Nodemcu will work as a server and it will serve a web page. Web page contains the stepper motor control buttons. Stepper motor takes steps to complete one full 360 degree rotation. Number of steps required to complete one full rotation depends on the particular motor step angle. Normally step angles are 0.9 degree and 1.8 degree per step. Stepper motors are capable of delivering high torque at small angles. They consume high power in order to produce high torque. Their small steps made them popular to be used in projects where high accuracy is required. They are popularly used in car manufacturing industry. Stepper motors drives robotic arms used in car manufacturing. Stepper motor drive arms in such a precise angle that an arm can easily insert a small nut in car parts where ever is required. Stepper motors are also the main part of 3D printers. Even normal printers and disk drivers uses stepper motors to accurately rotate the discs.

NEMA 17 Stepper Motor

Stepper motors are dc brush less motor. Stepper motors are divided in two general categories uni polar stepper motors and bipolar stepper motors. You can find many tutorials on internet which explains the difference between the two. For this project i am going to use bipolar stepper motor. Bipolar stepper motor which i am going to use in the project is NEMA 17. Nema 17 is popular 4 wires 2 coils stepper motor. Its step angle is 1.8 degree. So for one complete rotation it takes 200 steps (200 x 1.8 = 360). Normal power consumption of NEMA 17 is 5 to 12 volts and it drains 1 to 1.5 amperes of continuous current when load is attached to it.
Four wires of the NEMA 17 are colored differently. Normally wires are red, blue, green and black. Red and blue represents first coil and green and black represents second coil. In some motors blue is replaced with yellow and black with grey. If you are going to use NEMA 17 in a diy project first please make sure the correct coil pair with colors.

A4988 stepper motor driver

Stepper motors consumes lot of power while moving loads. When their is no load current consumption is drastically reduced. To supply the amount of power discussed above to stepper motor(NEMA 17 12 volts 1.5 amperes) we need and external power source. With external power source we also need a circuit which can control the motor rotation perfectly and easily. Traditionally a combination of transistors or mosfets know as H-Bridge circuit is used to control the stepper motor with microcontrollers. Making an H-Bridge circuit and testing it is a time consuming task. Now a days variety of pre-assembled H-Bridge boards or motor controller drivers are available in market. They are not only cheap but are also easy to work with. For this project i decided to use one of the pre-assembled H-Bridge stepper motor driver board. The stepper motor driver which i selected for the project is A4988. A4988 is a bipolar stepper motor driver. Power requirements of A4988 is 3.3 volts to 5 volts. It can easily drive a two coiled stepper motor. External power is supplied to it and its internal H-Bridge circuit divides the power among the coils when coils are energized.
I explained each and every pin of of A4988 bipolar stepper motor driver in an another tutorial. Pin configuration and steeper motor rotation mode is also explained in the tutorial. I suggest you to please take that tutorial first in order to get familiarize with A4988 driver and its operations requirements. If you go through that small tutorial and its part on A4988 motor driver you can easily understand the code and circuit diagram below.

Читайте также:  Wifi дисплей mac os

Project Circuit diagram

9 volt battery is connected between Vmot and gnd pins of A4988 motor driver. 9 volts are enough to energize NEMA 17 coils. Stepper motor coils are connected to 1A, 1B, 2A and 2B pins of A4988 stepper motor driver. A4988 driver is powered by nodemcu 3.3 volt output power rail. Step pin of A4988 is connected to D3 pin or GPIO-0 of nodemcu esp866 12e. Dir pin of A4988 is connected to D4 of nodemcu WiFi module. Reset and Sleep pins are interconnected. A4988 mode pins Ms1, Ms2 and Ms3 are left open. In this configuration motor is set in full step mode. Enable pin is also left open. It is internally pulled down and the module always remain in enable mode. I again encourage you to please take the tutorial recommended above other wise you can not understand the circuit discussed earlier and code code going to discussed further.

Nodemcu esp8266 12 e controlling stepper motor over WiFi

Coming to wards the project code. First the ESP8266WiFi library is included in the code. This library initializes the server and WiFi of nodemcu esp8266 WiFi module. Than the SSID and PASSWORD of the WiFi is required to which you want to connect you nodemcu WiFi module. It will be you home router WiFi password and ssid if you are going to test the diy project at home. Please enter the password and ssid in code before moving forward. Enter the ssid and password in the double quotes.

const char* ssid = “Your SSID”;
const char* password = “Your Wifi Password”;

Next the A4988 control pins are defined. Step pin of A4988 stepper motor driver is connected to GPIO-0 or D3 pin of nodemcu WiFi module. Direction pin of A4988 is connected to GPIO-2 of D4 pin of nodemcu esp8266 board.

Читайте также:  Системный блок wifi адаптер

In the setup function control pins are declared as output. Arduino ide serial monitor is initialized at 115200 baud rate. Server is started and web page IP is published. I will talk more about it after code. In the loop function the main program logic is running. In the loop function server is waiting for a client request. As soon as the server receives the client request it manipulates it and responds to request.

Just make the circuit and download the above code in it. Before uploading the code to nodemcu first make sure correct board is selected. After downloading the code in nodemcu open the arduino serial monitor from arduino ide. As soon as you open the serial monitor you will see nodemcu requesting your router for an IP assignment. After IP assignment nodemcu will start its server. After server startup the address of the server will be printed on serial monitor window. This address is actually the address of web page which contains the stepper motor controls. You have to enter this address in your browser to access the web page.

Picture

HTTP web page address example is given on the upper right corner. One most important thing. Server (nodemcu, esp8266) and client (mobile, desktop, laptop or notebook) must be connected to same WiFi network. If any one of the module client or server is connected to another network, web page will note appear in your browser. Once you enter the IP in browser following web page will appear in the browser.

Stepper motor WiFi control with nodemcu esp8266

Web page has two buttons one is forward and the other is backward. If you press the forward button motor will move 50 steps a head. If you press backward motor will change its direction and start taking 50 steps backward. Recall we are using NEMA 17 stepper motor and it take 200 steps to complete one rotation. So if i move motor 50 steps on each button press. It means i am moving stepper motor shaft by 90 degree on each button press. A for loop is run 50 times to allow stepper motor to take 50 steps. So now in our case stepper motor is taking 4 steps to complete 360 degree rotation or 1 step to move 90 degree.

Picture

Future Recommendations
This tutorial is a simple tutorial on how to control stepper motor over WiFi using nodemcu WiFi module. In future you can test other modes of stepper motor rotation steps 1/4, 1/8 and 1/16 micro steps. You can also manually enter steps in web page and move the motor according to the entered number. A bar can be inserted in web page and motor position can be controlled through it using AJAX web development language.

Читайте также:  What is wifi password key

Download the project code. Folder contains nodemcu arduino code .ino file. Code is open source one can use and change it. Please provide us your feed back on the tutorial.

You may also like:

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.

You must be logged in to post a comment.

Источник

Шаговый двигатель управление wifi

Если вы только начинаете осваивать систему MajorDoMo и чего-то не знаете или не можете понять, то задавайте свои вопросы в этой ветке.

karapus Сообщения: 37 Зарегистрирован: Вс фев 25, 2018 1:50 pm Благодарил (а): 5 раз Поблагодарили: 2 раза

Подскажите как совместить Wifi-iot и ШД?

Сообщение karapus » Вс сен 15, 2019 1:55 pm

Всем привет. Хочу поставить шаговый двигатель на заслонку на воздушный клапан в квартире. Самый простой для его управления через МЖД вижу esp8266+wifiiot. Может кто-нибудь сталкивался с вопросом управления ШД через эту прошивку, или может подсказать код в самой прошивке на подключение и управление ШД? Шаговый двигатель NEMA17, драйвер соответствующий — управление через PUL, DIR и ENA. Заранее спасибо за дельный совет.

TrDA Сообщения: 147 Зарегистрирован: Ср сен 27, 2017 9:13 pm Откуда: MSK Благодарил (а): 235 раз Поблагодарили: 38 раз

Re: Подскажите как совместить Wifi-iot и ШД?

Сообщение TrDA » Пт окт 04, 2019 1:57 pm

1. Можно и на wifi-iot, без проблем, я делал на 28BYJ-48 (ESP8266+драйвер ULN2003).
Для увеличения мощности (у меня время открытия 2 минуты):
— на 5V двигатель подавалось 7.5V.
— на 12V двигатель подавалось 19.0V.
— концевики не использовал.
— из-за увеличенного напряжения, моторы и драйвера сильно греются.
— управление через MD, по расписанию.
— далее перешёл на NEMA-17 (см. ниже п.2)
Подробнее по прошивке тут:
https://wifi-iot.com/p/wiki/46/

2. Во второй версии проекта (в первой, мощности не хватало), использую NEMA-17 (ESP8266+драйвер A4988 + плата подключения).
— прошивку брал тут (немного её переделал под NEMA-17 + драйвер A4988):
https://github.com/andreypopov/blinds-p . inds-popov
— подробности тут:
https://sprut.ai/client/blog/654
— все компоненты покупал на Али.
— схемы подключения в Гугле.

3. Сейчас, уже есть прошивка для ESP8266 + A4988 + NEMA-17 от:
https://github.com/arendst/Sonoff-Tasmota
Смотреть начиная с версии 6.6.0.11 (Add support for A4988 stepper-motor-driver-circuit), в разделе Development (я пока её сам не тестировал, но скоро займусь).

Удачи.
Спрашивайте, не стесняйтесь.

За это сообщение автора TrDA поблагодарили (всего 2): Sergey.Chek (Пт окт 04, 2019 7:38 pm) • Step40 (Вс окт 06, 2019 7:57 am)

Источник

Оцените статью
Adblock
detector