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

stg.h

Go to the documentation of this file.
00001 #ifndef STG_H
00002 #define STG_H
00003 
00004 /*
00005   stg.h
00006 
00007   Servo To Go board decls
00008 
00009   Modification history:
00010 
00011   2-Aug-2001  FMP added stgAdcStart,Wait,Read function decls
00012   13-Mar-2000 WPS eliminated function declaration isn't a prototype compiler
00013   warning by putting in the (void) for functions with no arguments.
00014   28-Oct-1999  FMP added EncoderLatch() function
00015   20-Oct-1998  FMP fixed decl of RawDAC(), previously RawDac()
00016   7-Aug-1998  FMP changed stgInit/Quit() to stgMotInit/Quit(), added decls
00017   for stgDio/AioInit/Quit()
00018   31-Mar-1998  FMP added analog IO stuff
00019   26-Mar-1998  FMP added STG_BASE_ADDRESS value
00020   7-Nov-1997  FMP added stgAmpFault()
00021   25-Sep-1997  FMP added digital IO stuff
00022   19-Sep-1997  FMP removed number of axes, base address and put defaults
00023   in .c file. Now these can be overridden with -DSTG_8_AXES and
00024   -DSTG_BASE_ADDRESS=0x300, for example
00025   31-Jul-1997  FMP added StartADC, RawADC
00026   10-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 
00037 static char __attribute__((unused)) stg_h[] = "$Id: stg.h,v 1.6 2001/10/30 23:34:05 paul_c Exp $";
00038 
00039 /*
00040  Number of axes in system defaults to 4. If STG_8_AXES is defined
00041  by compiler directive or other means, code will support 8 axes,
00042  e.g., -DSTG_8_AXES. Note that only 6 axes are really supported, since
00043  there is not enough digital IO for limit and home switches for all 8.
00044 
00045  Analog input is an option, normally not present. If STG_ANALOG_INPUT is
00046  defined by compiler directive or other means, code will support analog
00047  input, e.g., -DSTG_ANALOG_INPUT
00048  */
00049 
00050 /*
00051   Base address defaults to 0x200
00052   */
00053 #define DEFAULT_STG_BASE_ADDRESS 0x200
00054 extern unsigned short STG_BASE_ADDRESS;
00055 extern int FIND_STG_BASE_ADDRESS;
00056 
00057 
00058 /* decls for external interface */
00059 
00060 extern int stgMotInit(const char * stuff);
00061 extern int stgMotQuit(void);
00062 
00063 extern int stgAdcNum(void);
00064 extern int stgAdcStart(int adc);
00065 extern void stgAdcWait(void);
00066 extern int stgAdcRead(int adc, double * volts);
00067 
00068 extern int stgDacNum(void);
00069 extern int stgDacWrite(int dac, double volts);
00070 extern int stgDacWriteAll(int max, double * volts);
00071 
00072 extern int stgEncoderSetIndexModel(unsigned int model);
00073 extern int stgEncoderNum(void);
00074 extern int stgEncoderRead(int encoder, double * counts);
00075 extern int stgEncoderReadAll(int max, double * counts);
00076 extern int stgEncoderResetIndex(int encoder);
00077 extern int stgEncoderReadLatch(int encoder, int * flag);
00078 extern int stgEncoderReadLevel(int encoder, int * flag);
00079 
00080 extern int stgMaxLimitSwitchRead(int axis, int * flag);
00081 extern int stgMinLimitSwitchRead(int axis, int * flag);
00082 
00083 extern int stgHomeSwitchRead(int axis, int * flag);
00084 
00085 extern int stgAmpEnable(int axis, int enable);
00086 extern int stgAmpFault(int axis, int * fault);
00087 
00088 extern int stgDioInit(const char * stuff);
00089 extern int stgDioQuit(void);
00090 
00091 extern int stgDioMaxInputs(void);
00092 extern int stgDioMaxOutputs(void);
00093 extern int stgDioRead(int index, int *value);
00094 extern int stgDioWrite(int index, int value);
00095 extern int stgDioCheck(int index, int *value);
00096 extern int stgDioByteRead(int index, unsigned char *byte);
00097 extern int stgDioShortRead(int index, unsigned short *sh);
00098 extern int stgDioWordRead(int index, unsigned int *word);
00099 extern int stgDioByteWrite(int index, unsigned char byte);
00100 extern int stgDioShortWrite(int index, unsigned short sh);
00101 extern int stgDioWordWrite(int index, unsigned int word);
00102 extern int stgDioByteCheck(int index, unsigned char *byte);
00103 extern int stgDioShortCheck(int index, unsigned short *sh);
00104 extern int stgDioWordCheck(int index, unsigned int *word);
00105 
00106 extern int stgAioInit(const char * stuff);
00107 extern int stgAioQuit(void);
00108 
00109 extern int stgAioMaxInputs(void);
00110 extern int stgAioMaxOutputs(void);
00111 extern int stgAioStart(int index);
00112 extern void stgAioWait(void);
00113 extern int stgAioRead(int index, double *volts);
00114 extern int stgAioWrite(int index, double volts);
00115 extern int stgAioCheck(int index, double *volts);
00116 extern int stgModel(void);
00117 
00118 typedef union
00119 {
00120   unsigned short                          Word;
00121   struct   {unsigned char    high, low;}  Byte;
00122 } WORDBYTE;
00123 
00124 typedef union
00125 {
00126   long           Long;
00127   unsigned char  Byte[4];
00128 } LONGBYTE;
00129 
00130 typedef union
00131 {
00132   unsigned long               all;
00133   struct {unsigned char  A, B, C, D;} port;
00134 } IO32;
00135 
00136 extern unsigned short BaseFind(void);
00137 extern void SetIrq(short nRequestedIrq);
00138 extern short int Initialize(short int nReqInt);
00139 extern int StartADC(unsigned short wAxis);
00140 extern short RawADC(unsigned short wAxis);
00141 extern void EncoderInit(void);
00142 extern void SelectInterruptPeriod(long);
00143 extern void ResetIndexLatch(void);
00144 extern void SelectIndexAxis(unsigned char byAxis, unsigned char byPol);
00145 extern unsigned char CurrentIRR(void);
00146 extern int IndexPulseLatch(void);
00147 extern int RawDAC(short nAxis, double volts);
00148 extern int EncoderLatch(void);
00149 extern int EncReadAll(LONGBYTE * lbEnc);
00150 extern long RawDI(void);
00151 extern void RawDO(unsigned char byBitNumber, unsigned char bySet0or1, unsigned short nPort);
00152 extern void RawDOAll(IO32 xOutBits);
00153 extern void DIODirection(unsigned short nSwDir);
00154 
00155 #define CNT0_D     0x00
00156 #define CNT1_D     0x01
00157 #define CNT0_C     0x02
00158 #define CNT1_C     0x03
00159 #define CNT2_D     0x04
00160 #define CNT3_D     0x05
00161 #define CNT2_C     0x06
00162 #define CNT3_C     0x07
00163 #define CNT4_D     0x08
00164 #define CNT5_D     0x09
00165 #define CNT4_C     0x0a
00166 #define CNT5_C     0x0b
00167 #define CNT6_D     0x0c
00168 #define CNT7_D     0x0d
00169 #define CNT6_C     0x0e
00170 #define CNT7_C     0x0f
00171 #define DAC_0      0x10
00172 #define DAC_1      0x12
00173 #define DAC_2      0x14
00174 #define DAC_3      0x16
00175 #define DAC_4      0x18
00176 #define DAC_5      0x1a
00177 #define DAC_6      0x1c
00178 #define DAC_7      0x1e
00179 #define ADC_0      0x410
00180 #define ADC_1      0x412
00181 #define ADC_2      0x414
00182 #define ADC_3      0x416
00183 #define ADC_4      0x418
00184 #define ADC_5      0x41a
00185 #define ADC_6      0x41c
00186 #define ADC_7      0x41e
00187 #define DIO_A      0x400
00188 #define DIO_B      0x402
00189 #define BRDTST     0x403
00190 #define DIO_C      0x404
00191 #define MIO_1      0x406
00192 #define DIO_D      0x401
00193 #define INTC       0x405
00194 #define MIO_2      0x407
00195 #define ODDRST     0x407
00196 #define TIMER_0    0x408
00197 #define TIMER_1    0x40a
00198 #define TIMER_2    0x40c
00199 #define TMRCMD     0x40e
00200 #define ICW1       0x409
00201 #define ICW2       0x40b
00202 #define OCW1       0x40b
00203 #define OCW2       0x409
00204 #define OCW3       0x409
00205 #define IRR        0x409
00206 #define ISR        0x409
00207 #define IMR        0x40b
00208 
00209 #define IXEVN      0x80
00210 #define IXODD      0x40
00211 #define LIXEVN     0x20
00212 #define LIXODD     0x10
00213 #define EOC        0x08
00214 #define TP0        0x04
00215 #define USR_INT    0x02
00216 #define TP2        0x01
00217 
00218 #define AUTOZERO   0x80
00219 #define IXLVL      0x40
00220 #define IXS1       0x20
00221 #define IXS0       0x10
00222 #define USRINT     0x08
00223 #define IA2        0x04
00224 #define IA1        0x02
00225 #define IA0        0x01
00226 
00227 #define  IRQSL   0x84
00228 
00229 #define A_OUT      0x10
00230 #define B_OUT      0x02
00231 #define C_LOW_OUT  0x01
00232 #define C_HI_OUT   0x08
00233 #define D_OUT      0x04
00234 
00235 #define _500_MICROSECONDS        500
00236 #define _1_MILLISECOND           1000
00237 #define _2_MILLISECONDS          2000
00238 #define _3_MILLISECONDS          3000
00239 #define _4_MILLISECONDS          4000
00240 #define _5_MILLISECONDS          5000
00241 #define _10_MILLISECONDS         10000
00242 #define _100_MILLISECONDS        100000L
00243 #define _1_SECOND                1000000L
00244 #define MAX_PERIOD               -1L
00245 
00246 #define NO_BOARD       1
00247 #define BOARD_PRESENT  0
00248 
00249 
00250 
00251 #endif

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