25 Mar 10:55
machctl: r14 - sys
Author: vedge
Date: 2008-03-25 06:55:16 -0300 (Tue, 25 Mar 2008)
New Revision: 14
Added:
sys/cnc.h
Log:
import missing file
Added: sys/cnc.h
===================================================================
--- sys/cnc.h (rev 0)
+++ sys/cnc.h 2008-03-25 09:55:16 UTC (rev 14)
@@ -0,0 +1,135 @@
+/* $OpenBSD$ */
+/* Public domain */
+
+#ifndef _SYS_CNC_H_
+#define _SYS_CNC_H_
+
+#include <sys/stdint.h>
+
+#define CNC_BUF_SIZE 1024 /* size of instruction buffer */
+#define CNC_MAX_AXES 3 /* max axes (min. 1) */
+#define CNC_NAXES CNC_MAX_AXES
+#define CNC_MAX_SPINDLES 2 /* max spindles */
+#define CNC_MAX_ESTOPS 13 /* max e-stops/limit switches */
+
+enum cnc_axis {
+ CNC_X, CNC_Y, CNC_Z,
+ CNC_A, CNC_B, CNC_C
+};
+
+typedef uint64_t cnc_step_t;
+typedef int64_t cnc_pos_t;
+typedef int64_t cnc_time_t;
+
+enum cnc_insn_type {
+ /* servo(4) operations */
+ CNC_MOVE, /* coordinated move to given position */
+ CNC_SET_INTERP, /* set interpolation mode */
+ /* spindle(4) operations */
+ CNC_SPINDLE_DIR, /* change current direction */
+ CNC_SPINDLE_SPEED, /* set revolutions per minute */
+ CNC_SPINDLE_START, /* start spindle rotation */
+ CNC_SPINDLE_STOP, /* stop spindle rotation */
+ /* atc(4) operations */
+ CNC_ATC_PREPARE, /* prepare tool for next change */
+ CNC_ATC_CHANGE, /* change tool in spindle */
+ /* laser(4) operations */
+ CNC_LASER_ON, /* TTL trigger high */
+ CNC_LASER_OFF, /* TTL trigger low */
+ CNC_LASER_CURRENT, /* set steady-state current */
+ /* pickplace(4) operations */
+ CNC_PICKPLACE_REEL, /* advance specified reel */
+ CNC_PICKPLACE_SUCTION, /* enable suction cup vacuum */
+ CNC_PICKPLACE_RELEASE, /* release suction cup vacuum */
+ /* miscellaneous */
+ CNC_PREEMPT, /* delay (with interrupts reenabled) */
+ CNC_DWELL, /* precise delay (no interrupts) */
+ CNC_COOL_MIST, /* toggle mist coolant */
+ CNC_COOL_FLOOD, /* toggle flood or thru-tool coolant */
+ CNC_COOL_VORTEX, /* toggle vortex tube */
+ CNC_LAST_INSN
+};
+
+/* Mode of interpolation between coordinates */
+enum cnc_interp_mode {
+ CNC_INTERP_LINEAR, /* linear interpolation */
+ CNC_INTERP_LAST
+};
+
+/* Velocity curve generation algorithm */
+enum cnc_velocity_mode {
+ CNC_VEL_BLENDED_SCURVE, /* blended s-curve (second-order) */
+ CNC_VEL_SQUARED_SINE, /* squared sine (third-order) */
+};
+
+/* Position vector */
+typedef struct cnc_vector {
+ cnc_pos_t v[CNC_NAXES];
+} cnc_vec_t;
+
+/*
+ * Kinematic limits. These values must be adjusted based on the physical
+ * limits of the motors and of the load they are driving.
+ */
+struct cnc_kinematics {
+ int k_Ts; /* third-order jerk limit (ms) */
+ int k_Vmax; /* maximum velocity (steps/sec) */
+};
+
+/* Program instruction */
+struct cnc_insn {
+ enum cnc_insn_type i_type;
+ union {
+ struct {
+ cnc_vec_t i_pos; /* relative target coords */
+ u_long i_v0; /* minimum velocity (steps/s) */
+ u_long i_F; /* maximum velocity (steps/s) */
+ u_long i_Amax; /* max acceleration (steps/ms^2) */
+ u_long i_Jmax; /* max jerk (steps/ms^3) */
+ } i_move;
+ struct {
+ int i_id; /* name of spindle */
+ int i_dir; /* 1=CW, -1=CCW */
+ u_int i_speed; /* speed in RPM */
+ } i_spindle;
+ enum cnc_interp_mode i_interp_mode; /* for SET_INTERP */
+ cnc_step_t i_delay; /* for DWELL and PREEMPT */
+ struct {
+ int i_atc_id; /* name of ATC controller */
+ int i_tool_idx; /* name of tool */
+ int i_tgt_spindle; /* name of target spindle */
+ } i_atc;
+ int i_laser_current; /* for LASER_CURRENT */
+ int i_pickplace_reel; /* for PICKPLACE_REEL */
+ } i_arg;
+#define i_pos i_arg.i_move.i_pos
+#define i_F i_arg.i_move.i_F
+#define i_v0 i_arg.i_move.i_v0
+#define i_Amax i_arg.i_move.i_Amax
+#define i_Jmax i_arg.i_move.i_Jmax
+#define i_interp_mode i_arg.i_interp_mode
+#define i_spindle_id i_arg.i_spindle.i_id
+#define i_spindle_dir i_arg.i_spindle.i_dir
+#define i_spindle_speed i_arg.i_spindle.i_speed
+#define i_delay i_arg.i_delay
+#define i_atc_id i_arg.i_atc.i_atc_id
+#define i_atc_tool_idx i_arg.i_atc.i_tool_idx
+#define i_atc_tgt_spindle i_arg.i_atc.i_tgt_spindle
+#define i_laser_current i_arg.i_laser_current
+ TAILQ_ENTRY(cnc_insn) prog;
+};
+
+#define CNC_EXECPROG _IO('C', 0)
+#define CNC_RESETPROG _IO('C', 1)
+#define CNC_GETPOS _IOR('C', 2, struct cnc_vector)
+#define CNC_SETPOS _IOWR('C', 3, struct cnc_vector)
+#define CNC_GETNSERVOS _IOR('C', 4, int)
+#define CNC_GETNSPINDLES _IOR('C', 5, int)
+#define CNC_GETKINLIMITS _IOR('C', 6, struct cnc_kinematics)
+#define CNC_SETKINLIMITS _IOWR('C', 7, struct cnc_kinematics)
+#define CNC_GETTIMEBASE _IOR('C', 8, u_long)
+#define CNC_SETTIMEBASE _IOWR('C', 9, u_long)
+#define CNC_CALTIMEBASE _IOWR('C', 10, u_long)
+#define CNC_GETNESTOPS _IOR('C', 11, int)
+
+#endif /* !_SYS_CNC_H_ */
RSS Feed