ESP14 as GCODE interpreter?

A project log for RigTig's Big 3D Printer

A DIY 3D printer (big volume, inexpensive, lightweight and portable).

rigtigRigTig 02/23/2017 at 07:123 Comments

Rather than Arduino and ESP8266, I wonder if ESP14 might work as a GCODE interpreter. Mmm...looks like a job for Forth, so I got hold of eForth (for the STM8) from another project (thanks to Thomas @TG9541 - see It looks like the GCODE interpreter is going to be about 3K of code on top of about 4.5K of eForth. Not a fancy interpreter by any means but it'll work (I believe).

I decided to implement each GCODE command as a Forth word. For example, the GCODE M17 command is to enable the motors, and has no parameters. Its implementation is trivial, as follows:

: M17;
  \ enable motors

GCODE interpretation rules generally say to quietly ignore any GCODE command that does not apply to the particular machine, but Forth typically aborts operation if an unknown command is received. So, we want to change the outer interpreter. This is easy in eForth, thus:

\ GCODE interpreter
\ no prompt; ignore undefined words
: GEV ( -- )
and include the following in the initialisation routine
 \ change interpreter over for GCODE
  ' GEV 'EVAL !
The forward kinematics and reverse kinematics routines are coded but untested. I've had a lot of fun with VARIABLEs and have finally reached a good way forward for this project. Just a little more coding and then some serious testing on ESP14, with both CPUs running Forth. Now that will be fun!


Thomas wrote 02/28/2017 at 03:22 point

A really smart idea of re-using the Forth outer interpreter! Nice!

Edit: if you use this method on STM8EF, please be aware of COMPIQ which tests if 'EVAL points to $INTERPRET :-)

  Are you sure? yes | no

Thomas wrote 03/01/2017 at 06:53 point

Re-using composing words of the interpreter can be complicated by the HAS_CPNVM feature. I guess that some words, like COMPIQ, will require minor changes, e.g. test for "not $COMPILE" instead of "$INTERPRET".

  Are you sure? yes | no