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

extintf.h

Go to the documentation of this file.
00001 #ifndef EXTINTF_H
00002 #define EXTINTF_H
00003 
00004 /*
00005   extintf.h
00006 
00007   Declarations of external interfaces to encoders, DACs, limit switches,
00008   estops, etc. These functions are expected to be provided by board
00009   implementations. Query functions give range of axes supported, etc.
00010 
00011   Modification history:
00012 
00013   2-Aug-2001  FMP added extAioStart,Wait
00014   13-Mar-2000 WPS added unused attribute to parport_h to avoid
00015   'defined but not used' compiler warning, and added (void) to functions
00016   with no arguments to avoid 'declaration is not a prototype' compiler
00017   warnings.  7-Aug-1998 FMP changed extInit/Quit() to
00018   extDio/Aio/MotInit/Quit()
00019   31-Mar-1998  FMP added analog IO stuff
00020   25-Nov-1997 FMP changed extLimitSwitchRead to extPos,NegLimit...
00021   3-Nov-1997   FMP added extEstopWrite()
00022   24-Oct-1997  FMP added digital I/O stuff
00023   15-Oct-1997  FMP added extEstopRead()
00024   01-Aug-1997  FMP changed encoder counts from int to double
00025   28-Jul-1997  FMP added extLimitSwitchRead()
00026   20-Jun-1997  FMP created
00027 */
00028 
00029 /* ident tag */
00030 #ifndef __GNUC__
00031 #ifndef __attribute__
00032 #define __attribute__(x)
00033 #endif
00034 #endif
00035 
00036 static char __attribute__((unused)) extintf_h[] = "$Id: extintf.h,v 1.3 2001/08/02 21:02:40 proctor Exp $";
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #if 0
00043 } /* a dummy match on one above */
00044 #endif
00045   
00046 /* Init/quit functions */
00047 
00048 /*
00049   extDioInit(const char * stuff)
00050 
00051   Call once before any of the other digital IO functions are called.
00052   'stuff' argument can be used to pass board-specific stuff like config
00053   files.
00054   */
00055 extern int extDioInit(const char * stuff);
00056 
00057 /*
00058   extDioQuit()
00059 
00060   Call once, after which point no other functions will be called until
00061   after a call to extDioInit().
00062   */
00063 extern int extDioQuit(void);
00064 
00065 /*
00066   extAioInit(const char * stuff)
00067 
00068   Call once before any of the other analog IO functions are called.
00069   'stuff' argument can be used to pass board-specific stuff like config
00070   files.
00071   */
00072 extern int extAioInit(const char * stuff);
00073 
00074 /*
00075   extAioQuit()
00076 
00077   Call once, after which point no other functions will be called until
00078   after a call to extAioInit().
00079   */
00080 extern int extAioQuit(void);
00081 
00082 /*
00083   extMotInit(const char * stuff)
00084 
00085   Call once before any of the other motion IO functions are called.
00086   'stuff' argument can be used to pass board-specific stuff like config
00087   files.
00088   */
00089 extern int extMotInit(const char * stuff);
00090 
00091 /*
00092   extMotQuit()
00093 
00094   Call once, after which point no other functions will be called until
00095   after a call to extMotInit().
00096   */
00097 extern int extMotQuit(void);
00098 
00099 /* DAC functions */
00100 
00101 /*
00102   extDacNum()
00103 
00104   returns number of DACs in system.
00105   */
00106 extern int extDacNum(void);
00107 
00108 /*
00109   extDacWrite(int dac, double volts)
00110 
00111   writes the value to the DAC at indicated dac, 0 .. max DAC - 1.
00112   Value is in volts. Returns 0 if OK, -1 if dac is out of range.
00113   */
00114 extern int extDacWrite(int dac, double volts);
00115 
00116 /*
00117   extDacWriteAll(int max, double * volts)
00118 
00119   writes the values to the DAC range. Values are array of DAC outputs
00120   in volts. Returns 0 if OK, -1 if not max is out of range. This is
00121   provided for systems in which DACs can be written all at once for
00122   speed or synchronicity. max is number of DACs, so for dacs 0..3
00123   max would be 4.
00124   */
00125 extern int extDacWriteAll(int max, double * volts);
00126 
00127 /* Encoder functions */
00128 
00129 /*
00130   extEncoderIndexModel()
00131 
00132   Returns the type of encoder indexing done by the board.
00133 
00134   The handling of index pulses for encoder homing is problematic. There
00135   are two models (at least) for how incremental encoders can be homed
00136   off the index pulse. The first assumes the encoder index pulse sets
00137   a flag when it occurs, but the count value doesn't change. The controller
00138   polls on this flag, and when it is seen to be latched the controller
00139   reads the position and uses this as an offset. There is a latency that
00140   makes this less accurate than the second method, in which the occurrence
00141   of the index pulse resets the count automatically. The problem is that
00142   the controller logic is different for the two methods, so if you replace
00143   a board which does it the first way with one that does it the second,
00144   you need to recode the logic. The function "extEncoderIndexModel()"
00145   returns the model used by the board, so at least you can detect it
00146   and if you have coded up both types you can switch automatically.
00147 
00148   EXT_ENCODER_INDEX_MODEL_MANUAL
00149   indicates that the index pulse sets a latch flag, but you have to
00150   read this and then the encoder value and handle offsets yourself.
00151   The board won't change its count value on the index pulse.
00152 
00153   EXT_ENCODER_INDEX_MODEL_AUTO
00154   indicates that the index pulse zeros the encoder count automatically.
00155   */
00156 
00157 /* flags defined bit-exclusive for OR'ing if board can do multiple ways */
00158 #define EXT_ENCODER_INDEX_MODEL_MANUAL 0x00000001
00159 #define EXT_ENCODER_INDEX_MODEL_AUTO   0x00000002
00160 
00161 extern unsigned int extEncoderIndexModel(void);
00162 
00163 /*
00164   extEncoderSetIndexModel(unsigned int model)
00165 
00166   For boards that support multiple index models, select which one
00167   is to be used. Returns 0 if OK, -1 if model can't be supported.
00168   */
00169 extern int extEncoderSetIndexModel(unsigned int model);
00170 
00171 /*
00172   extEncoderNum()
00173 
00174   returns number of encoders in system.
00175   */
00176 extern int extEncoderNum(void);
00177 
00178 /*
00179   extEncoderRead(int encoder, double * counts)
00180 
00181   Stores the encoder's counts in counts arg. Returns 0 if
00182   OK or -1 if encoder is out of range. encoder is in range
00183   0 .. max encoder - 1.
00184   */
00185 extern int extEncoderRead(int encoder, double * counts);
00186 
00187 /*
00188   extEncoderReadAll(int max, double * counts)
00189 
00190   Stores the range of encoders' counts in counts array. Returns 0 if
00191   OK or -1 if the max is greater than number of encoders. max is
00192   number of encoders, so for encoders 0..3 max would be 4.
00193   */
00194 extern int extEncoderReadAll(int max, double * counts);
00195 
00196 /*
00197   extEncoderResetIndex(int encoder)
00198 
00199   Resets index latching for the indicated axis. Returns 0 if OK or -1
00200   if the index is out of range. This applies to both
00201   EXT_ENCODER_INDEX_MODEL_MANUAL and EXT_ENCODER_INDEX_MODEL_AUTO.
00202   For the first, it resets the latch flag. For the second, it enables
00203   zeroing on the next index. encoder is range 0..max encoder - 1.
00204   */
00205 extern int extEncoderResetIndex(int encoder);
00206 
00207 /*
00208   extEncoderReadLatch(int encoder, int * flag)
00209 
00210   For EXT_ENCODER_INDEX_MODEL_MANUAL, stores 1 if index has latched
00211   the flag, 0 if not. For EXT_ENCODER_INDEX_MODEL_AUTO, stores 1 if
00212   the encoder has been zeroed. Returns 0 if OK, -1 if not valid.
00213   */
00214 extern int extEncoderReadLatch(int encoder, int * flag);
00215 
00216 /*
00217   extEncoderReadLevel(int encoder, int * index)
00218 
00219   For EXT_ENCODER_INDEX_MODEL_MANUAL, stores 1 if encoder is on
00220   the index pulse right now, 0 if not. Useful for slow polling
00221   to get more accuracy since the manual model has latency.
00222 
00223   Not valid for EXT_ENCODER_INDEX_MODEL_AUTO. Returns 0 if OK,
00224   -1 if not valid.
00225   */
00226 extern int extEncoderReadLevel(int encoder, int * flag);
00227 
00228 /* Limit switch functions */
00229 
00230 /*
00231   extMaxLimitSwitchRead(int axis, int * flag)
00232   extMinLimitSwitchRead(int axis, int * flag)
00233 
00234   sets *flag to 0 if the limit switch is not tripped, i.e., everything
00235   is fine, 1 if the limit switch is tripped, i.e., the axis went
00236   too far in the associated direction.
00237 
00238   Maximum is defined as the direction in which encoder values increase,
00239   minimum is the other direction.
00240 
00241   Returns 0 if OK, -1 if not valid (axis is out of range).
00242   */
00243 extern int extMaxLimitSwitchRead(int axis, int * flag);
00244 extern int extMinLimitSwitchRead(int axis, int * flag);
00245 
00246 /*
00247   extHomeSwitchRead(int axis, int * flag)
00248 
00249   sets *flag to 0 if the home switch is not tripped, i.e., everything
00250   is fine, 1 if the home switch is tripped.
00251 
00252   Returns 0 if OK, -1 if not valid (axis is out of range).
00253   */
00254 extern int extHomeSwitchRead(int axis, int * flag);
00255 
00256 /* Amp functions */
00257 
00258 /*
00259    extAmpEnable(int axis, int enable)
00260 
00261    enables or disables amplifier for indicated axis; enable flag is
00262    1 to enable, 0 to disable
00263 
00264    Returns 0 if OK, -1 if not valid (axis is out of range)
00265    */
00266 extern int extAmpEnable(int axis, int enable);
00267 
00268 /*
00269   extAmpFault(int axis, int * fault)
00270 
00271   Copies into 'fault' the fault state of the amplifier. 1 is faulted,
00272   0 is OK.
00273 
00274   Returns 0 if OK, -1 if not valid (axis out of range)
00275   */
00276 extern int extAmpFault(int axis, int * fault);
00277 
00278 /*
00279   Digital I/O model
00280 
00281   If you need to call board-specific code to set up the analog I/O
00282   registers, do it in extInit().
00283 
00284   "index" begins at 0.
00285 
00286   Code for each implementation should shift index up into appropriate
00287   register so that it matches initialization and R/W setup in extInit().
00288 
00289   Returns 0 if OK, -1 if error (invalid index).
00290   */
00291 
00292 /* returns the max input index, output index; max bytes, shorts, and words */
00293 extern int extDioMaxInputs(void);       /* index < this for extDioRead() */
00294 extern int extDioMaxOutputs(void);      /* index < this for extDioWrite(),Check() */
00295 
00296 /* reads value of digital input at index, stores in value */
00297 extern int extDioRead(int index, int *value);
00298 
00299 /* writes value (non-zero means 1, 0 is 0) at digital out at index */
00300 extern int extDioWrite(int index, int value);
00301 
00302 /* reads value of digital OUT at index, stores in value. Useful
00303    for checking values of previous writes. Returns 0 if OK, -1 if
00304    bad index or can't read if they're write-only. */
00305 extern int extDioCheck(int index, int *value);
00306 
00307 /* byte, short, and word reads, writes. Index starts at 0, indexes up
00308    through bytes, short ints, and ints */
00309 extern int extDioByteRead(int index, unsigned char *byte);
00310 extern int extDioShortRead(int index, unsigned short *sh);
00311 extern int extDioWordRead(int index, unsigned int *word);
00312 extern int extDioByteWrite(int index, unsigned char byte);
00313 extern int extDioShortWrite(int index, unsigned short sh);
00314 extern int extDioWordWrite(int index, unsigned int word);
00315 extern int extDioByteCheck(int index, unsigned char *byte);
00316 extern int extDioShortCheck(int index, unsigned short *sh);
00317 extern int extDioWordCheck(int index, unsigned int *word);
00318 
00319   /*
00320     Analog I/O model
00321 
00322     Analog I/O presumes units of volts. In your implementations of these
00323     functions you need to linearize as appropriate.
00324 
00325     If you need to call board-specific code to set up the analog I/O
00326     registers, do it in extInit().
00327 
00328     "index" begins at 0.
00329 
00330     Code for each implementation should shift index up into appropriate
00331     register so that it matches initialization and R/W setup in extInit().
00332 
00333     Returns 0 if OK, -1 if error (invalid index).
00334   */
00335 
00336   /* returns the max input index, output index */
00337   extern int extAioMaxInputs(void);       /* index < this for extAioRead() */
00338   extern int extAioMaxOutputs(void);      /* index < this for extAioWrite(),Check() */
00339 
00340 /* starts an analog input conversion */
00341 extern int extAioStart(int index);
00342 
00343 /* waits for conversion */
00344 extern void extAioWait(void);
00345 
00346 /* reads value of analog input at index, stores in volts */
00347 extern int extAioRead(int index, double *value);
00348 
00349 /* writes value in volts to analog out at index */
00350 extern int extAioWrite(int index, double volts);
00351 
00352 /* reads value of analog OUT at index, stores in volts. Useful
00353    for checking values of previous writes. Returns 0 if OK, -1 if
00354    bad index or can't read if they're write-only. */
00355 extern int extAioCheck(int index, double *volts);
00356 
00357 #ifdef __cplusplus
00358 }
00359 #endif
00360 
00361 #endif /* EXTINTF_H */

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