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

--- a/cnc.h	Thu Feb 06 08:45:02 2014 +0000
+++ b/cnc.h	Thu Feb 20 09:27:18 2014 +0000
@@ -1,3 +1,8 @@
+#define ESTOP   0x100   //  bits used in input reading
+#define XLIM    1
+#define YLIM    2
+#define ZLIM    4
+#define UNKN    8
 const   double  TWO_PI = 8.0 * atan(1.0);
 const   double  epsilon = 1e-5;
 struct  pirbufgrain {
@@ -19,11 +24,6 @@
     struct  singleGparam   x, y, z, i, j, r, a, b, c, d;   //  After sorting, know where to find any X, Y etc values !
 }   ;
-struct  digital_readouts    {   //  DROs keep count of 'Step' positive edges detected in interrupt handler
-    signed long x, y, z;    //  Could easily expand up to six or more dros
-    bool    dro_output;             //  To enabe / disable output to terminal
-}   ;
-extern  const double  n_for_onemmpermin, feed_rate_max, feed_rate_min, spindle_min, spindle_max;
+extern  const double  n_for_onemmpermin, feed_rate_max, feed_rate_min, spindle_min, spindle_max, spindle_factor;
 //extern  const   long  pulses_per_mm, max_mm_per_min, interrupt_period_us;
 extern  const   double  pulses_per_mm, max_mm_per_min, interrupt_period_us;