00001 #ifndef PPMC_H
00002 #define PPMC_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __GNUC__
00017 #ifndef __attribute__
00018 #define __attribute__(x)
00019 #endif
00020 #endif
00021
00022
00023 static char __attribute__((unused)) ppmc_h[] = "$Id: ppmc.h,v 1.1 2001/08/23 20:54:33 paul_c Exp $";
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifdef PPMC_8_AXES
00035 #define PPMC_MAX_AXIS 8
00036 #else
00037 #define PPMC_MAX_AXIS 4
00038 #endif
00039
00040
00041
00042 #define DEFAULT_PPMC_BASE_ADDRESS 0x378
00043 extern unsigned short STG_BASE_ADDRESS;
00044 #define ppmc_base_addr STG_BASE_ADDRESS
00045
00046
00047
00048 extern int ppmcMotInit(const char * stuff);
00049 extern int ppmcMotQuit(void);
00050
00051 extern int ppmcDacNum(void);
00052 extern int ppmcDacWrite(int dac, double volts);
00053 extern int ppmcDacWriteAll(int max, double * volts);
00054
00055 extern int ppmcEncoderSetIndexModel(unsigned int model);
00056 extern int ppmcEncoderNum(void);
00057 extern int ppmcEncoderRead(int encoder, double * counts);
00058 extern int ppmcEncoderReadAll(int max, double * counts);
00059 extern int ppmcEncoderResetIndex(int encoder);
00060 extern int ppmcEncoderReadLatch(int encoder, int * flag);
00061 extern int ppmcEncoderReadLevel(int encoder, int * flag);
00062
00063 extern int ppmcMaxLimitSwitchRead(int axis, int * flag);
00064 extern int ppmcMinLimitSwitchRead(int axis, int * flag);
00065
00066 extern int ppmcHomeSwitchRead(int axis, int * flag);
00067
00068 extern int ppmcAmpEnable(int axis, int enable);
00069 extern int ppmcAmpFault(int axis, int * fault);
00070
00071 extern int ppmcDioInit(const char * stuff);
00072 extern int ppmcDioQuit(void);
00073
00074 extern int ppmcDioMaxInputs(void);
00075 extern int ppmcDioMaxOutputs(void);
00076 extern int ppmcDioRead(int index, int *value);
00077 extern int ppmcDioWrite(int index, int value);
00078 extern int ppmcDioCheck(int index, int *value);
00079 extern int ppmcDioByteRead(int index, unsigned char *byte);
00080 extern int ppmcDioShortRead(int index, unsigned short *sh);
00081 extern int ppmcDioWordRead(int index, unsigned int *word);
00082 extern int ppmcDioByteWrite(int index, unsigned char byte);
00083 extern int ppmcDioShortWrite(int index, unsigned short sh);
00084 extern int ppmcDioWordWrite(int index, unsigned int word);
00085 extern int ppmcDioByteCheck(int index, unsigned char *byte);
00086 extern int ppmcDioShortCheck(int index, unsigned short *sh);
00087 extern int ppmcDioWordCheck(int index, unsigned int *word);
00088
00089 extern int ppmcAioInit(const char * stuff);
00090 extern int ppmcAioQuit(void);
00091
00092 extern int ppmcAioMaxInputs(void);
00093 extern int ppmcAioMaxOutputs(void);
00094 extern int ppmcAioRead(int index, double *volts);
00095 extern int ppmcAioWrite(int index, double volts);
00096 extern int ppmcAioCheck(int index, double *volts);
00097
00098 typedef union
00099 {
00100 unsigned short Word;
00101 struct {unsigned char high, low;} Byte;
00102 } WORDBYTE;
00103
00104 typedef union
00105 {
00106 long Long;
00107 unsigned char Byte[4];
00108 } LONGBYTE;
00109
00110 typedef union
00111 {
00112 unsigned long all;
00113 struct {unsigned char A, B, C, D;} port;
00114 } IO32;
00115
00116
00117
00118 #define ENCCNT0 0x00
00119 #define ENCCNT1 0x03
00120 #define ENCCNT2 0x06
00121 #define ENCCNT3 0x09
00122
00123 #define ENCCTRL_0 0x03
00124 #define ENCRATE_0 0x04
00125 #define ENCISR_0 0x0C //index sense register
00126 #define ENCLOAD_0 0x00
00127
00128
00129
00130
00131 #define ENCCNT4 0x10
00132 #define ENCCNT5 0x13
00133 #define ENCCNT6 0x16
00134 #define ENCCNT7 0x19
00135 #define ENCRATE_1 0x14
00136
00137 #define ENCLOAD_1 0x10
00138 #define ENCCTRL_1 0x13
00139 #define ENCISR_1 0x1C //index sense register
00140
00141 #define DAC_0 0x20
00142 #define DAC_1 0x22
00143 #define DAC_2 0x24
00144 #define DAC_3 0x26
00145
00146 #define DAC_4 0x30
00147 #define DAC_5 0x32
00148 #define DAC_6 0x34
00149 #define DAC_7 0x36
00150
00151 #define DAC_MODE_0 0x2C
00152 #define DAC_WRITE_0 0x28
00153
00154 #define DAC_MODE_1 0x3C
00155 #define DAC_WRITE_1 0x38
00156
00157
00158
00159
00160 #define DIN_0 0x40
00161 #define DIN_1 0x41
00162
00163 #define DOUT_0 0x50
00164 #define DOUT_1 0x51
00165
00166 #define NO_BOARD 1
00167 #define BOARD_PRESENT 0
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 #define NO_HOME_SWITCH
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 #define NO_LIMIT_SWITCH
00188
00189
00190
00191 #define _500_MICROSECONDS 500
00192 #define _1_MILLISECOND 1000
00193 #define _2_MILLISECONDS 2000
00194 #define _3_MILLISECONDS 3000
00195 #define _4_MILLISECONDS 4000
00196 #define _5_MILLISECONDS 5000
00197 #define _10_MILLISECONDS 10000
00198 #define _100_MILLISECONDS 100000L
00199 #define _1_SECOND 1000000L
00200 #define MAX_PERIOD -1L
00201
00202 void SelAddr(unsigned int port);
00203 void WriteData(unsigned char byte);
00204 void WriteData16(unsigned short word);
00205 unsigned short ReadData(void);
00206 unsigned short SelRead(unsigned int port);
00207 void SelWrt(unsigned int port, unsigned char byte);
00208 void SelWrt16(unsigned int port, unsigned short word);
00209
00210 short DACQuit(void);
00211 short DACInit(void);
00212 int DIOQuit(void);
00213 int DIOInit(void);
00214 int EncoderQuit(void);
00215 int EncoderInit(void);
00216 int EncoderLatch(void);
00217 int ppmcAioQuit(void);
00218 int ppmcAioMaxInputs(void);
00219 int ppmcAioMaxOutputs(void);
00220 #endif