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

Thu Feb 20 09:27:18 2014 +0000
As used to produce Lissajous patterns for EiM articles.  XYZ axis good, Axis A not implemented, spindle 'S' working.  Using MODSERIAL, therefore no longer compatible with KL46Z, good for KL25Z and Mbed LPC1768

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonFreeman 2:b3c668ec43ac 1 #define ESTOP 0x100 // bits used in input reading
JonFreeman 2:b3c668ec43ac 2 #define XLIM 1
JonFreeman 2:b3c668ec43ac 3 #define YLIM 2
JonFreeman 2:b3c668ec43ac 4 #define ZLIM 4
JonFreeman 2:b3c668ec43ac 5 #define UNKN 8
JonFreeman 1:66ee619f206b 6 const double TWO_PI = 8.0 * atan(1.0);
JonFreeman 1:66ee619f206b 7 const double epsilon = 1e-5;
JonFreeman 1:66ee619f206b 8 struct pirbufgrain {
JonFreeman 1:66ee619f206b 9 double x,
JonFreeman 1:66ee619f206b 10 y,
JonFreeman 1:66ee619f206b 11 z,
JonFreeman 1:66ee619f206b 12 c,
JonFreeman 1:66ee619f206b 13 f_rate;
JonFreeman 1:66ee619f206b 14 } ;
JonFreeman 0:5d0f270bfc87 15
JonFreeman 0:5d0f270bfc87 16 struct singleGparam { // Place to put all we know about 'x' or 'j' etc parameter from G Code line
JonFreeman 0:5d0f270bfc87 17 double dbl;
JonFreeman 0:5d0f270bfc87 18 unsigned long ul;
JonFreeman 0:5d0f270bfc87 19 int i, c;
JonFreeman 0:5d0f270bfc87 20 bool changed; // Flagged true when new value for this axis found in Gcode line, false otherwise
JonFreeman 0:5d0f270bfc87 21 } ;
JonFreeman 0:5d0f270bfc87 22
JonFreeman 0:5d0f270bfc87 23 struct Gparams { // Where possibly messy G code line gets ordered and sorted into
JonFreeman 0:5d0f270bfc87 24 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 25 } ;
JonFreeman 0:5d0f270bfc87 26
JonFreeman 2:b3c668ec43ac 27 extern const double n_for_onemmpermin, feed_rate_max, feed_rate_min, spindle_min, spindle_max, spindle_factor;
JonFreeman 1:66ee619f206b 28 //extern const long pulses_per_mm, max_mm_per_min, interrupt_period_us;
JonFreeman 1:66ee619f206b 29 extern const double pulses_per_mm, max_mm_per_min, interrupt_period_us;