Skip to content
4 axis CNC, 3D, Laser Controller
G-code C++ JavaScript C HTML Visual Basic Other
Branch: master
Clone or download
Latest commit 7dbfe55 Sep 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Compiled on platform IO VsCode Jun 25, 2018
gcode update Feb 16, 2019
old freebasic prototyping Dec 31, 2017
wemosminiboard Add files via upload May 29, 2018
.gitignore Compiled on platform IO VsCode Jun 25, 2018
DIO2.c some fix May 6, 2019
LICENSE Create LICENSE Sep 12, 2019 Update Mar 14, 2019
common.cpp some fix May 6, 2019
common.h some fix May 6, 2019
config_pins.h yesss Jul 10, 2019
eprom.cpp yesss Jul 10, 2019
eprom.o Emulate Temp can be used for heater without sensor ! Mar 11, 2019
epromsetting.epr fix gcode parsing, pc gcode simulation graphics Jan 9, 2018
gcode.cpp yesss Jul 10, 2019
gcode.h yesss Jul 10, 2019
gcode.o Emulate Temp can be used for heater without sensor ! Mar 11, 2019
gcodesave.cpp yesss Jul 10, 2019
motion [motion.exe].PRJ yes Feb 2, 2019
motion.cpp yesss Jul 10, 2019
motion.h some fix May 6, 2019
motion.o Emulate Temp can be used for heater without sensor ! Mar 11, 2019
motors.h MESH BILINEAR AUTO LEVEL Mar 13, 2019
myboards.h some fix May 6, 2019
nonlinear.h auto level Mar 13, 2019
pid.cpp Compiled on platform IO VsCode Jun 25, 2018
pid.h some fix May 6, 2019
platformio.ini Update Mar 31, 2019
temp.cpp yesss Jul 10, 2019
temp.o Emulate Temp can be used for heater without sensor ! Mar 11, 2019
timer.h some fix May 6, 2019


I make this project to learn about the controller.


simple multi axis motor controller for use in cnc project. This project is possible because other people work:

  • Teacup (gcode parsing, sersendp_f)
  • notgrbl (simple serial reading)
  • google

its not 100% exact code, but i have read lots of their code, so my code will effected by them


feature i need to have in this software is: (* implemented)

  • per axis max feedrate *
  • path planner (backward and forward) *
  • step per mm for each axis *
  • motor stepper hardware layer using GPIO and ShiftRegister *
  • GCODE parser and processing *
  • 4 axis X Y Z E *
  • eeprom configuration (step/mm, accel, travel accel, jerk, max axis) *
  • implement endstop reading (xmin xmax , etc)*
  • implement Probing Z ()*
  • implement Mesh autolevel ()*
  • Endstop configuration using EEPROM *
  • heater with PID E0 PWM or Bang Bang*
  • temp sensor math model (heating pid without real sensor) *
  • Async temp reading *
  • config files contain board definition to set pins and parameter *
  • G0 and G1 can have different acceleration (travel vs feed/extrude) *
  • backlash compensation *
  • Config for inverted motor and endstop *
  • interrupt timing * (for AVR, ESP8266, STM32F103)
  • NEW: Laser constant burn per step, by only turn on the laser on specific time then turn off on each motor step *
  • NEW: G7 Raster data for Laser Engraving for optimum speed laser engraving *
  • NEW: M290 Baby stepping for 3d printing *
  • NEW: M206 Pxxx [sss] xxx=380 400 450 470 configure wifi and telegram client, M504 to show setting*
  • NEW: Retract conversion, just set the retract speed to 1 on slicer it will be converted to retract setting on eeprom. *
  • NEW: M2 will stop the code immediately, without waiting buffer emptied, but still know the correct position *
  • IDEA: Implement clever gcode sender that pre-compile the gcode by doing path planner and send the plan to the firmware


  • Nano V3 328p * tested
  • Mega 2560 * Tested
  • Wemos D1 mini * Tested
  • STM32 bluepill * tested


Yes, its support EEPROM and modification in repetier host.


Still work in progress, especially for ESP8266 Progress:

  • Websocket server at port 81, receive Ping Pong communication
  • Html gcode sender tools, integrated with CNC gcode generator. (open the http://ipaddress)
  • Have print and run gcode for CNC
  • Still have lag, i dont know where is the problem, maybe my Access point ?

Drive system

  • implemented LINEAR
  • Cartesian*
  • Corexy*
  • Corexz*
  • XYYZ* (dual motor for Y that can do individual movement when homing)

NONLINEAR -Delta* -Deltasian* -Scara


Subpixel bresenham algorithm, will increase the resolution of the bresenham especially on low speed movement. just like AMASS on GRBL.

Non linear slicing happen in the core of movement. By implementing a virtual step/mm and calculate real step in the motion loop. So 1 Gcode will save in 1 path buffer, then segmented when this buffer is active.

for now it already use timer interrupt, but still can use polling mode using micros() to control the timing (especially for new mcu that we dont know how to use timer, or for simulation in pc)..


Project files: karyacontroller.project - just for editing in codelite karyacontroller.ino - arduino ide motion [motion.exe].PRJ - for quincy IDE, we can show graphics of the motion simulation here

Original code is in freebasic, you can check the old folder


5-3-2019 Auto level using MESH bilinear interpolation.

10-12-2018 image Able to upload gcode to internal wemos flash, and start print without pc, without sdcard

20-5-2018 image New PCB using Wemos D1 mini, the smallest CNC/3D board ! not tested yet.

12-5-2018 Backplanner using grbl code, minimum corner using repetier code.

recode backlash algorithm laser cutting co2 work (m3 S100 to turn on laser on G1) fix timer problem on very slow speed (below 1)

i share my stm32 board too image


I change the feedrate acceleration algorithm, previously using mainloop that calculate f by adding it with a*dl , which dl is from 1/f, this cause problem cannot reach the target velocity.

Now it use inversesquare of accumulative value from acceleration, which is maybe costly on the mainloop, but more easy on path planner.

Also i have make the analog read better by able to pool more than 1 analogread and keep the result on buffer.

Also i plan to use more library, such as DIO2.

You can’t perform that action at this time.