Code to drive a CNC machine via a PC LPT port lookalike 25 pin 'D', experiment in 'PC/Mach3' replacement. Designed to compile and run on mbed LPC1768, Freescale KL25Z and Freescale KL46Z. Proved on LPC1768 and KL25Z, problem with serial port on KL46Z. Reads subset of 'G Codes' through usb/serial port and drives 3 stepper/servo drives for X, Y and Z, also similar Step/Dir outputs for spindle motor control. Emulates PC LPT, outputs 'charge pump', proved driving Seig KX3 CNC mill

Dependencies:   MODSERIAL mbed

Committer:
JonFreeman
Date:
Fri Jan 31 11:16:21 2014 +0000
Revision:
0:5d0f270bfc87
Child:
1:66ee619f206b
First wip, tested on KL25 and KL46

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonFreeman 0:5d0f270bfc87 1 #define axis_speeds_buffsize 20
JonFreeman 0:5d0f270bfc87 2
JonFreeman 0:5d0f270bfc87 3 struct axis_speeds_element {
JonFreeman 0:5d0f270bfc87 4 signed long x, y, z, a, duration_ticks;
JonFreeman 0:5d0f270bfc87 5 bool ready;
JonFreeman 0:5d0f270bfc87 6 } ;
JonFreeman 0:5d0f270bfc87 7
JonFreeman 0:5d0f270bfc87 8 struct singleGparam { // Place to put all we know about 'x' or 'j' etc parameter from G Code line
JonFreeman 0:5d0f270bfc87 9 double dbl;
JonFreeman 0:5d0f270bfc87 10 unsigned long ul;
JonFreeman 0:5d0f270bfc87 11 int i, c;
JonFreeman 0:5d0f270bfc87 12 bool changed; // Flagged true when new value for this axis found in Gcode line, false otherwise
JonFreeman 0:5d0f270bfc87 13 } ;
JonFreeman 0:5d0f270bfc87 14
JonFreeman 0:5d0f270bfc87 15 struct Gparams { // Where possibly messy G code line gets ordered and sorted into
JonFreeman 0:5d0f270bfc87 16 struct singleGparam x, y, z, i, j, r, a, b, c, d; // After sorting, know where to find any X, Y etc values !
JonFreeman 0:5d0f270bfc87 17 } ;
JonFreeman 0:5d0f270bfc87 18
JonFreeman 0:5d0f270bfc87 19 struct digital_readouts {
JonFreeman 0:5d0f270bfc87 20 signed int x, y, z, a, b, c; // Allow up to six dros
JonFreeman 0:5d0f270bfc87 21 bool dro_output; // To enabe / disable output to terminal
JonFreeman 0:5d0f270bfc87 22 } ;
JonFreeman 0:5d0f270bfc87 23
JonFreeman 0:5d0f270bfc87 24 extern const double n_for_onemmpermin, feed_rate_max, feed_rate_min, spindle_min, spindle_max;
JonFreeman 0:5d0f270bfc87 25 extern const long pulses_per_mm, max_mm_per_min, interrupt_period_us;