This project contains software to control a 3-axis CNC Machine.
It consists of two components: A C++ project designed to be compiled and
run on Arduino (located at arduino_scripts/Motor_Shield_Controller
),
and a Python 3 GUI to interface with the Arduino from a desktop
(located at ardupy_gui/motor_text_gui
). The GUI can be run from either
Linux or Windows, but has only been tested extensively on Linux.
This program reads integers as ASCII from the serial port, then moves stepper motors along the x/y/z axes using a gShield.
The following steps are perfomed during each loop() of the program:
- Read a byte from serial. If it froms a complete integer, push that
integer to a stack (Handled by
SerialInts.cpp
) - Step motors 1 step towards their destination, if needed (handled by
TripleMotors.cpp
) - Update the current instruction if a complete instruction has been passed (i.e. 3 complete ascii integers have been passed in).
- Perform an action based on the current instruction (see the next
section for details)
- Some instructions (eg Move) create temporary states, these are not currently documented
Instructions to be sent over serial are formed
from 3 null zero (indicated by \0
) - separated ASCII integers.
1 \0 X \0 Y \0
: Move to X,Y
2 \0 MS \0 0 \0
: Wait MS
milliseconds after each subsequent move
3 \0 dX \0 dY \0
: Move dX,dY
relative to current position
(don't wait)
4 \0 Z \0 0 \0
: Move vertical axis to Z
5 \0 dZ \0 0 \0
: Move vertical dZ
relative to current position
6 \0 Spd \0 0 \0
: Set stepper speed to Spd cm/s.
Messages returned by the program over serial:
Steppers Ready.
at the beginning of the program.
Arrived at X, Y
whenever both axes arrive at a new destination
(such that they're both stopped)
Delay set to MS
whenever a new delay is set
All required packages for the Arduino software are contained within the repository.
The progam should be ready to compile and upload in the Arduino IDE. Instructions can be found here.
This program provides a graphical interface for control of the CNC machine.
The graphical interface depends on two external Python packages, both of which can be obtained from PyPI:
- Download and install the latest version of Python 3, or install it from a package manager.
- Clone this package, or download it as a zip and extract it.
- Run the commands
pip install cefpython3
andpip install pySerial
from a command prompt. cd
into this package's directory from the command prompt.- Run the command
python setup.py install
. - To invoke the GUI, run the
run_ardupy.cmd
batch file, or therun_ardupy.sh
shell script.