Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

extsmmot.c

Go to the documentation of this file.
00001 /*
00002   extsmmot.c
00003 
00004   Dispatcher of external motion functions to parallel port stepper motor
00005   implementation. Does not include DIO or AIO external functions.
00006   Implements the DAC and encoder functions with stubs that return 0.
00007   Only touches the limit and home switch functions, by looking at the
00008   parallel port.
00009 
00010   Only supports 6 joints.
00011 
00012   Modification history:
00013 
00014   13-Mar-2000 WPS added unused attribute to ident to avoid 'defined but not used' compiler warning.
00015   24-Feb-2000  FMP put stepperCount[] in here, which is used for simulated
00016   encoder feedback with extEncoderRead(), extEncoderReadAll(). Made
00017   extEncoderReadLatch() return 1 always, since the "encoders" are always
00018   on an index pulse alignment.
00019   2-Aug-1999  FMP added 6 joint support.
00020   2-Sep-1998  FMP returned 0's for axes outside range 0..2
00021   10-Aug-1998  FMP put all max limits on input 0, mins on input 1, and homes
00022   on input 2
00023   7-Aug-1998  FMP created
00024   */
00025 
00026 #include "extintf.h"            /* these decls */
00027 #include "parport.h"            /* parallel port funcs */
00028 #include "emcmot.h"
00029 
00030 /* ident tag */
00031 #ifndef __GNUC__
00032 #ifndef __attribute__
00033 #define __attribute__(x)
00034 #endif
00035 #endif
00036 
00037 static char __attribute__((unused))  ident[] = "$Id: extsmmot.c,v 1.4 2001/05/14 18:35:06 wshackle Exp $";
00038 
00039 #define STEPPER_MAX 6           /* can only handle 6 motors */
00040 
00041 /*
00042    FIXME-- declaration for global in emcmot, used in the encoder
00043    read function. Is there a better way to do this?
00044 */
00045 extern EMCMOT_DEBUG *emcmotDebug;
00046 
00047 int extMotInit(const char * stuff)
00048 {
00049   if (0 != pptDioInit(0)) {
00050     return -1;
00051   }
00052 
00053   return 0;
00054 }
00055 
00056 int extMotQuit()
00057 {
00058   return pptDioQuit();
00059 }
00060 
00061 int extDacNum()
00062 {
00063   return 0;
00064 }
00065 
00066 int extDacWrite(int dac, double volts)
00067 {
00068   return 0;
00069 }
00070 
00071 int extDacWriteAll(int max, double * volts)
00072 {
00073   return 0;
00074 }
00075 
00076 int extEncoderSetIndexModel(unsigned int model)
00077 {
00078   return 0;
00079 }
00080 
00081 int extEncoderNum()
00082 {
00083   return 0;
00084 }
00085 
00086 int extEncoderRead(int encoder, double * counts)
00087 {
00088   if (encoder < 0 ||
00089       encoder >= STEPPER_MAX) {
00090     *counts = 0.0;
00091   }
00092   else {
00093     *counts = (double) emcmotDebug->stepperCount[encoder];
00094   }
00095 
00096   return 0;
00097 }
00098 
00099 int extEncoderReadAll(int max, double * counts)
00100 {
00101   int t;
00102 
00103   for (t = 0; t < max; t++) {
00104     if (t >= STEPPER_MAX) {
00105       counts[t] = 0.0;
00106     }
00107     else {
00108       counts[t] = (double) emcmotDebug->stepperCount[t];
00109     }
00110   }
00111 
00112   return 0;
00113 }
00114 
00115 int extEncoderResetIndex(int encoder)
00116 {
00117   return 0;
00118 }
00119 
00120 int extEncoderReadLatch(int encoder, int * flag)
00121 {
00122   *flag = 1;                    /* always on "index pulse" */
00123 
00124   return 0;
00125 }
00126 
00127 int extEncoderReadLevel(int encoder, int * flag)
00128 {
00129   return 0;
00130 }
00131 
00132 int extAmpEnable(int axis, int enable)
00133 {
00134   return 0;
00135 }
00136 
00137 int extAmpFault(int axis, int * fault)
00138 {
00139   return 0;
00140 }
00141 
00142 /*
00143   We gang the max limits onto 1, mins onto another, and homes onto a third:
00144 
00145   (DioRead)
00146   0  1-6 joints lim + (S3)
00147   1  1-6 joints lim - (S4)
00148   2  1-6 joints home  (S5)
00149   3  unused
00150   4  unused
00151 */
00152 
00153 int extMaxLimitSwitchRead(int axis, int * flag)
00154 {
00155   if (axis < 0 || axis >= STEPPER_MAX) {
00156     *flag = 0;
00157     return 0;
00158   }
00159 
00160   pptDioRead(0, flag);
00161 
00162   return 0;
00163 }
00164 
00165 int extMinLimitSwitchRead(int axis, int * flag)
00166 {
00167   if (axis < 0 || axis >= STEPPER_MAX) {
00168     *flag = 0;
00169     return 0;
00170   }
00171 
00172   pptDioRead(1, flag);
00173 
00174   return 0;
00175 }
00176 
00177 int extHomeSwitchRead(int axis, int * flag)
00178 {
00179   if (axis < 0 || axis > STEPPER_MAX) {
00180     *flag = 0;
00181     return 0;
00182   }
00183 
00184   pptDioRead(2, flag);
00185 
00186   return 0;
00187 }
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 

Generated on Sun Dec 2 15:27:40 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001