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

extsmdromot.c

Go to the documentation of this file.
00001 /*
00002   extsmdromot.c
00003 
00004   Dispatcher of external motion functions to parallel port stepper motor
00005   implementation, based on original extsmmot.c, but using the DRO digital
00006   readout board for actual encoder feedback.
00007 
00008   Modification history:
00009 
00010   13-Mar-2000 WPS added unused attribute to ident to avoid 'defined but not used' compiler warning.
00011   24-Feb-2000  FMP created from extsmmot.c
00012   */
00013 
00014 #include "extintf.h"            /* these decls */
00015 #include "parport.h"            /* parallel port funcs */
00016 #include "dro.h"                /* DRO functions */
00017 
00018 /* ident tag */
00019 #ifndef __GNUC__
00020 #ifndef __attribute__
00021 #define __attribute__(x)
00022 #endif
00023 #endif
00024 
00025 static char __attribute__((unused)) ident[] = "$Id: extsmdromot.c,v 1.2 2000/10/27 20:34:42 terrylr Exp $";
00026 
00027 #define STEPPER_MAX 6           /* can only handle 6 motors */
00028 
00029 int extMotInit(const char * stuff)
00030 {
00031   if (0 != pptDioInit(0)) {
00032     return -1;
00033   }
00034 
00035   if (0 != LS7266Init()) {
00036     return -1;
00037   }
00038 
00039   return 0;
00040 }
00041 
00042 int extMotQuit()
00043 {
00044   return pptDioQuit();
00045 }
00046 
00047 int extDacNum()
00048 {
00049   return 0;
00050 }
00051 
00052 int extDacWrite(int dac, double volts)
00053 {
00054   return 0;
00055 }
00056 
00057 int extDacWriteAll(int max, double * volts)
00058 {
00059   return 0;
00060 }
00061 
00062 int extEncoderSetIndexModel(unsigned int model)
00063 {
00064   return 0;
00065 }
00066 
00067 int extEncoderNum()
00068 {
00069   return 0;
00070 }
00071 
00072 int extEncoderRead(int encoder, double * counts)
00073 {
00074   if (encoder < 0 ||
00075       encoder >= DRO_MAX) {
00076     *counts = 0.0;
00077   }
00078   else {
00079     *counts = (double) LS7266Read(encoder);
00080   }
00081 
00082   return 0;
00083 }
00084 
00085 int extEncoderReadAll(int max, double * counts)
00086 {
00087   int t;
00088 
00089   for (t = 0; t < max; t++) {
00090     if (t >= DRO_MAX) {
00091       counts[t] = 0.0;
00092     }
00093     else {
00094       counts[t] = (double) LS7266Read(t);
00095     }
00096   }
00097 
00098   return 0;
00099 }
00100 
00101 int extEncoderResetIndex(int encoder)
00102 {
00103   return 0;
00104 }
00105 
00106 int extEncoderReadLatch(int encoder, int * flag)
00107 {
00108   *flag = 1;                    /* always on "index pulse" */
00109 
00110   return 0;
00111 }
00112 
00113 int extEncoderReadLevel(int encoder, int * flag)
00114 {
00115   return 0;
00116 }
00117 
00118 int extAmpEnable(int axis, int enable)
00119 {
00120   return 0;
00121 }
00122 
00123 int extAmpFault(int axis, int * fault)
00124 {
00125   return 0;
00126 }
00127 
00128 /*
00129   We gang the max limits onto 1, mins onto another, and homes onto a third:
00130 
00131   (DioRead)
00132   0  1-6 joints lim + (S3)
00133   1  1-6 joints lim - (S4)
00134   2  1-6 joints home  (S5)
00135   3  unused
00136   4  unused
00137 */
00138 
00139 int extMaxLimitSwitchRead(int axis, int * flag)
00140 {
00141   if (axis < 0 || axis >= STEPPER_MAX) {
00142     *flag = 0;
00143     return 0;
00144   }
00145 
00146   pptDioRead(0, flag);
00147 
00148   return 0;
00149 }
00150 
00151 int extMinLimitSwitchRead(int axis, int * flag)
00152 {
00153   if (axis < 0 || axis >= STEPPER_MAX) {
00154     *flag = 0;
00155     return 0;
00156   }
00157 
00158   pptDioRead(1, flag);
00159 
00160   return 0;
00161 }
00162 
00163 int extHomeSwitchRead(int axis, int * flag)
00164 {
00165   if (axis < 0 || axis > STEPPER_MAX) {
00166     *flag = 0;
00167     return 0;
00168   }
00169 
00170   pptDioRead(2, flag);
00171 
00172   return 0;
00173 }

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