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

ppmc.h

Go to the documentation of this file.
00001 #ifndef PPMC_H
00002 #define PPMC_H
00003 
00004 /*
00005   ppmc.h
00006 
00007   Parallel Port Motion Control decls
00008 
00009   Modification history:
00010 
00011   17-Sep-2000 JME started conversion from STG.c
00012   
00013 */
00014 
00015 /* ident tag */
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  Number of axes in system defaults to 4. If PPMC_8_AXES is defined
00027  by compiler directive or other means, code will support 8 axes,
00028  e.g., -DPPMC_8_AXES.
00029 
00030  Analog input is an option, normally not present. If STG_ANALOG_INPUT is
00031  defined by compiler directive or other means, code will support analog
00032  input, e.g., -DSTG_ANALOG_INPUT
00033  */
00034 #ifdef PPMC_8_AXES
00035 #define PPMC_MAX_AXIS 8
00036 #else
00037 #define PPMC_MAX_AXIS 4
00038 #endif
00039 /*
00040   Base address defaults to 0x378 i.e. lpt1
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 /* decls for external interface */
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          /*  EPP address to read first byte of encoder counter */
00119 #define ENCCNT1    0x03
00120 #define ENCCNT2    0x06
00121 #define ENCCNT3    0x09
00122 
00123 #define ENCCTRL_0  0x03          /* EPP address of encoder control register */
00124 #define ENCRATE_0  0x04          /* interrupt rate register, only on master encoder */
00125 #define ENCISR_0   0x0C         //index sense register
00126 #define ENCLOAD_0  0x00          /* EPP address to write into first byte of preset register
00127                                         for channels 0 - 3 */
00128 
00129 
00130 
00131 #define ENCCNT4    0x10          /* EPP addr of first chan of 2nd encoder board */
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          /* EPP address of encoder control register for board 2 */
00139 #define ENCISR_1   0x1C         //index sense register
00140 
00141 #define DAC_0      0x20          /* EPP address of low byte of DAC 0 */
00142 #define DAC_1      0x22
00143 #define DAC_2      0x24
00144 #define DAC_3      0x26
00145 
00146 #define DAC_4      0x30          /* EPP addr of first chan of DAC board 2 */
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          /* EPP address of digital inputs */
00161 #define DIN_1      0x41
00162 
00163 #define DOUT_0     0x50          /* EPP address of digital outputs */
00164 #define DOUT_1     0x51
00165 
00166 #define NO_BOARD       1
00167 #define BOARD_PRESENT  0
00168     
00169 //we don't have dio yet, so can't home or limit
00170 /* Uncomment any of the following declarations to inhibit
00171    the use of home switches or index pulses when homing, or to
00172    ignore limit switches if you don't have them. */
00173 
00174 /* Uncomment NO_HOME_SWITCH if you want homing sequence to
00175    ignore the home switch, and only use the index pulse for homing.
00176    This has the effect of making the home switches always appear tripped. */
00177  #define NO_HOME_SWITCH
00178 
00179 /* Uncomment NO_INDEX_PULSE if you want homing sequence to
00180    ignore the index pulse, and only use the home switch for homing.
00181    This has the effect of making the index pulse always appear present. */
00182 /* #define NO_INDEX_PULSE */
00183 
00184 /* Uncomment NO_LIMIT_SWITCH if you don't have limit switches.
00185    This has the effect of making the positive and negative travel
00186    limit switches never appear tripped. */
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

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