Skip to content

A RESTful API server for driving serial based CNC devices

Notifications You must be signed in to change notification settings

yendo-eng/cncserver

 
 

Repository files navigation

CNC server

A Node.js based RESTful API to serial interface control for plotters, originally created for the WaterColorBot, currently aimed at EBB controller based plotters from Evil Mad Scientist Laboratories like Axidraw, Eggbot, and other DIY implementations.

The purpose of the project is to abstract the nitty-gritty details for controlling a drawing robot, and utilizing proven web technologies, to simplify the interface and make drawing bots easier and more useful, either at your desk with a GUI, or via your own script running remotely.

Features

CNC Server is an application that sits on a computer connected to your serial based CNC peripheral and provides a simple RESTful API to access common CNC/plotter functions. These controls manifest as an abstracted method of controlling the bot to do what you ask while sanity checking and keeping crashes down to a minimum.

  • Fast HTTP server via Express
  • Runs great on even modest hardware. Raspberry Pi verified!
  • Self manages absolute pen position for relative motion plotter controllers.
  • Multiple API endpoints allow full control, motor overrides and "tool" changes. Read the documentation and implement your own client!
  • An even simpler API allows for Scratch programming support, with examples.
  • Accepts direct X/Y absolute pen positions as percentage of total width/height.
  • Client agnostic! We don't care what controls the bot, as long as it follows the rules. See it in use by US President Barack Obama on an iPad!
  • Configuration file and argument driven (see example here), allows for server customization to fit almost any style of bot using a supported controller.

Installation

Install Node.js

Unless you already have it installed, either download the installer for your operating system, or use node version manager. We recommend using at least version 18+, although lower versions may work.

CNC server files

  • For easy updating from master: Use the handy GUI! Click the "Clone in Mac/Windows" button at the top of the GitHub repo homepage. When new code updates come along, just click the refresh/sync button and you'll be up to date!
  • For quick use: Download the files here, unzip them to a handy folder, and you're ready to run!
  • For developers looking to improve it: Fork the repo, make your changes in a branch, and submit a pull request! We're always looking for contributions that make things better for everyone, fix issues, or add features!

Installing NPM Dependencies

With your system setup and everything else installed, open a terminal and make your way to the cncserver folder, and enter npm install (you may need to preface that with a sudo command on Mac/Linux). For Mac, building node-serialport requires make, which comes with Xcode, a free download.

Running

CNC Server currently only supports the late model EBB and its command set. Of the devices that use it, the WaterColorBot, the EggBot, and AxiDraw have reliable support. More devices to come soon!

Plug in your device, and from the terminal in the cncserver repository root folder, start the server with the command npm start, and you've got it!

Once the server is up and running, the API should now be available at http://localhost:4242. The 4242 is the port on the local computer, which you can easily change in the configuration shown below.

Configuration

By default, CNC Server hosts the API on the localhost port 4242 and attempts to autodetect the correct serial port to connect to for the given bot configuration. If you want to tweak these settings or any other global configuration permanently, just edit the config.ini file that is generated on first run and stored in the same folder as cncserver.js. If you want to make temporary config adjustments, just pass the same config names and values when executing. Common examples might include:

# Change the hosting port to HTTP default, and force the serial port (no equals)
node cncserver --httpPort 80 --serialPath /dev/ttyUSB1243

# Change bot type to EggBot, and invert the X motor axis (with equals)
node cncserver --botType=eggbot --invertAxis:x=true

Problems?

Stuck on something? Submit an issue! Click the issues tab and see if someone is covering your question or problem, if not, ask away! Someone will be around to help soon.

Know how to fix a problem? Or want to add a new feature?? Submit a pull request! Just fork the repo using the button on the cncserver github homepage, and this will give you your own version of cncserver. Make your change in a few commits to your branch, then click the pull request button at the top! Talk about what changes you made and submit. A maintainer of the project will check your work, possibly ask you to fix a few more things, and then if all is well, your work will be merged into the project!

ETC.

All code MIT licensed. Created by TechNinja, with support and collaboration from Evil Mad Scientist.

About

A RESTful API server for driving serial based CNC devices

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.5%
  • HTML 8.5%