Graphical Plotting Simulator
Joshua Salecich - 23/06/2018

One of my primary interests outside of Electrical and Computer Engineering is Woodworking. Over the Summer of 2017/2018 I found myself looking into CNC machines and the inner workings of the aforementioned. I was offered the opportunity to extend upon this interest in one of my Semester 1 2018 courses (CSSE3010).

An embedded systems design course at its core - CSSE3010 also required the student to interact with a CNC machine to draw 2D graphics (compass rose shapes, polygons). However, with minimal access to (albeit faulty) CNC routers an extension task was to develop a graphical plotter - to make testing other features possible without direct CNC access.

The selected language for this task is Python as it is most definitely my strongest object orientated language at this point in time. In addition to this G-Code is the computer code language used to control the simulated CNC. A specification in addition to this is that the python script reads the G-Code commands from the serial terminal aswell as an in built entry box (within the GUI). Below, a small demonstration of a square drawing is shown.

Features
Supported G-Code Commands
G20 Set units to imperial (inches).
G21 Set units to metric (millimetres - default).
G28 Homing command. Coordinates following it are executed prior to homing.
G90 Absolute mode - goes to the given coordinate.
G91 Increment mode - adds given coordinate to current coordinate.
Serial Input

With the use of Python 3.0 module PySerial reading input from a connected device is a possibility. Whether, this is via radio, infra-red communication or even simply entering G-Code into the terminal. This was achieved by creating a concurrent thread which consistently reads from the selected serial port (with the assistance of a mutex). If data is acquired it's sent through to the main "Plotter" class which then handles the command and processes the movement.

Source