close-circle
Close
0%
0%

ESP8266 Stepper Driver

A cable-less connection for stepper motor control, using Forth

Similar projects worth following
close
Rather than connect with an ethernet cable, how about sending the control for a stepper motor using WiFi? Still have to supply power to each stepper, but that is much simpler than distributing control through wires. This becomes useful when the distance between stepper motors can be variable.

Besides, I get to play with ESP8266 in the form of ESP12E. I decided to use a Forth language, and I haven't used Forth for many years. What fun!!

The hardware elements are off-the-shelf, so I have decided to allocate this to software.

Forth

The first Forth I found that runs on the ESP8266 is PunyForth. I am still exploring it, but it seems to have lots of tools to work with ESP8266 capabilities.

I was having trouble figuring out how to determine how big the final code is as far as the 1K challenge is concerned, since a Forth environment is so extensible that the line between what is the system and what is user code is very indistinct. When this is completed, all the code will be included in the uploaded binary stored in with the base code uploaded with the esptool. Now that the rules are published, then the whole Forth interpreter is counted as far as memory space is concerned. So that excludes this project from a legitimate entrant to the 1K challenge, but I'll press ahead with it anyway because it may be useful to others anyway.

I suspect the source code will be under 1K, let alone the final code. And the final code includes the headers, which are only needed to build more code. Besides, PunyForth does not support headerless code (at least not yet!).


Hardware

I have a couple of ESP-12E dev boards and several bare ESP-12E boards, so I intend to develop code to put onto a ESP-12E driving either a ULN2003 board or an A8266 driver. Maybe both, just because I can. If you have a preference, let me know and I'll do that first. The stepper can be whatever you want to drive using either board, with relevant power supply.

UDP test client.py

To send UDP message from another machine connected to WiFi network to ESP

x-python - 251.00 bytes - 12/18/2016 at 01:41

download-circle
Download

ESP8266-ULN2003-driver-v1-2.forth

Added handler for WiFi. Now accepts command lines from UDP connection.

forth - 4.01 kB - 12/18/2016 at 01:38

download-circle
Download

ESP8266-ULN2003-driverv1-0-uncommented.forth

Removed comments just speeds up loading slightly, plus shows how little code is really needed. It is still 1098 bytes in the file, so maybe a few more comments and whitespace need to go just to get it under 1K bytes of source code!

forth - 1.07 kB - 12/07/2016 at 12:53

download-circle
Download

ESP8266-ULN2003-driver-v1-0-tests.forth

Kept the comments and the tests in here. Usually just copy the relevant test line into the serial monitor as needed.

forth - 1.96 kB - 12/07/2016 at 12:53

download-circle
Download

ESP8266-ULN2003-driver-v1-0.forth

Version 1.0 with lots of comments, including some tests.

forth - 2.90 kB - 12/07/2016 at 12:53

download-circle
Download

  • 1 × 28BYJ-48 stepper motor
  • 1 × ULN2003 driver board
  • 1 × ESP12E development board
  • 1 × 5V power supply For steppper

  • Testing v1.0

    RigTig12/07/2016 at 13:47 0 comments

    Reworked code to better use the existing words in PunyForth, and actually did some testing on a 28BYJ-48 stepper motor using a ULN2003 driver. Version 1.0 of code is working fine from serial monitor. See video at https://vimeo.com/194805134.

    I decided to create a source file with minimal comments in an attempt to get the code under 1K bytes of source. Well the fist edit achieved 1098 bytes, and there are still some comments and whitespace I can cut out. Of course, I can also reduce the source code size by using much shorter names for the newly defined words, but that can be even more cryptic to read. Still it is an option, and I may need it, just to prove a point.

    Just as an example of the usage for the topmost word, you type in 2 numbers and the word 'move'. The first number is the time for the move to take, in microseconds. The second number is the distance in micrometres (um) to move. So, if you wish to move 40 millimetres (40mm = 40000um) in 1 second (1000000uSec), then you type

    1000000 40000 move
    and it happens. Well, kind of approximately; the actual move might be up to a step short of the distance and the time might be a few microseconds longer, but quite ok for this project. Now, keep the numbers you try within the capability of the stepper motor, because there is no checking in this code (at least not yet) if you overstep (pun intended) the rather slow little stepper (28BYJ-48).

    Talking of steps, the next step in this project is to give the commands via wifi.

View project log

Enjoy this project?

Share

Discussions

Daren Schwenke wrote 10/05/2017 at 08:46 point

Not so useful for hard real-time applications like 3D printing, but this would probably work perfectly for simple animatronics via DMX.  Like making a skeleton dance to music for example or controlling an XY spotlight.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates