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

pmac.h

Go to the documentation of this file.
00001 
00002 #ifndef PMAC_H
00003 #define PMAC_H
00004 
00005 #include "rcs_defs.hh"
00006 
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 /*
00012   Modification history:
00013 
00014   14-Nov-1995  Fred Proctor added probing interfaces
00015   13-Nov-1995  Fred Proctor reworked for 8 axes with better DPRAM mapping
00016   6-Oct-1995  Fred Proctor added X_OFFSET, etc.
00017   20-Jul-1995  Fred Proctor added pmac_target_pos()
00018   18-Jul-1995  Fred Proctor added pmac_reset()
00019   24-Mar-1995 Sandor Szabo moved pmac.c specific macros into pmac.c.
00020   This will minimize recompiles to *.cc files when low level changes
00021   made to pmac.c (e.g., changing PMAC_IO_ADDR).
00022   15-Mar-1995  Fred Proctor pulled pmac_enable,disable_spindle() into
00023   here
00024   15-Feb-1995  Fred Proctor added pmac_print_error() prototype
00025   13-Feb-1995  Fred Proctor added 4th axis DP RAM indices
00026   25-Jan-1995  Fred Proctor added TICKS_PER_INCH, TICKS_PER_REV
00027   24-Jan-1995  Fred Proctor changed AXIS_MAX from 3 to 4, to support
00028   servoed spindle
00029   ??? Fred Proctor created
00030   */
00031 
00032 #define PMAC_MSG_LEN 256        /* max chars per message to PMAC; make
00033                                    this a multiple of 4 */
00034 
00035 typedef enum {PMAC_ACK=0, PMAC_ERR, PMAC_BUF_TOO_SMALL,
00036                 PMAC_BAD_PARAMS, PMAC_TIMEOUT,
00037                 PMAC_INVALID_COMM_PARAMS,
00038                 PMAC_WRITE_TIMEOUT } PMAC_RETURN_VAL;
00039 
00040 /* system paramters for servo-- take care to match these to PMAC config
00041    file, e.g., mill.pmc or other files which contains I-vars defs, etc. */
00042 
00043 #define AXIS_MAX 4              /* max axis used */
00044 
00045 #ifdef lynxosPC
00046 /* ptr to PMAC DP RAM */
00047 extern  void *pmac;
00048 #endif
00049 
00050 /* sets DP RAM base address. Call before pmac_init() */
00051  int  pmac_set_base_addr(unsigned int addr);
00052 
00053 /* sets IO port address. Call before pmac_init() */
00054  int   pmac_set_io_addr(unsigned int addr);
00055 
00056 /* sets DP RAM ptr for internal use */
00057  void  pmac_init();
00058 
00059 /* clears pmac DP RAM ptr, freeing up shared memory */
00060  void   pmac_exit();
00061 
00062 #ifdef lynxosPC
00063 /*
00064   Get logical address of physical dual-ported RAM.
00065 
00066   name is a string which is stored in an OS table;
00067   base is the actual physical address;
00068   size is the size in bytes of the DP RAM.
00069 
00070   Returns a void *, analogous to malloc(), or (void *) 0 if no
00071   memory can be allocated.
00072   */
00073  void *pmac_get(char *name, void *base, long int size);
00074 
00075 /*
00076   Returns the void * to the beginning of valid PMAC memory (the first
00077   800 bytes are reserved for future use).  Return of 0 indicates error.
00078   */
00079   void *pmac_valid_base();
00080 
00081 /*
00082   Returns the void * to the beginning of the message area; return
00083   of 0 indicates error.
00084   */
00085  void *pmac_msg_base();
00086 
00087 /*
00088   Returns the void * to the beginning of PMAC memory which can be used
00089   as scratch area for writing.  Return of 0 indicates error.
00090   */
00091  void *pmac_data_base();
00092 
00093  #endif
00094  /*
00095   Detach from and remove physical memory definition.
00096 
00097   name is the name used for pmac_get;
00098   base is the pointer returned by pmac_get.
00099   */
00100   void pmac_free(char *name, void *base);
00101 
00102 typedef unsigned char PMAC_UINT8;
00103 typedef unsigned short PMAC_UINT16;
00104 typedef unsigned long PMAC_UINT32;
00105 
00106 
00107 /*
00108   Read contents of dual-ported RAM as a character,
00109   8 bits on LynxOS/386.
00110 
00111   base is a pointer, pmac_get() <= base < size;
00112   index is number of characters up from base.
00113 
00114   Returns unsigned char found at indexed location.
00115   */
00116   PMAC_UINT8 read_pmac_uint8(int index);
00117 
00118 /*
00119   Write a character into dual-ported RAM,
00120   8 bits on LynxOS/386.
00121 
00122   base is a pointer, pmac_get() <= base < size;
00123   index is number of characters up from base.
00124   val is unsigned char to write at indexed location.
00125   */
00126  void write_pmac_uint8(int index, PMAC_UINT8 val);
00127 
00128 /*
00129   Read contents of dual-ported RAM as a short integer,
00130   16 bits on LynxOS/386.
00131 
00132   base is a pointer, pmac_get() <= base < size;
00133   index is number of short integers up from base.
00134 
00135   Returns unsigned short found at indexed location.
00136   */
00137  PMAC_UINT16 read_pmac_uint16(int index);
00138 
00139 /*
00140   Write a short integer into dual-ported RAM,
00141   16 bits on LynxOS/386.
00142 
00143   base is a pointer, pmac_get() <= base < size;
00144   index is number of short integers up from base.
00145   val is unsigned short integer to write at indexed location.
00146   */
00147  void write_pmac_uint16(int index, PMAC_UINT16 val);
00148 
00149 /*
00150   Read contents of dual-ported RAM as an integer,
00151   32 bits on LynxOS/386.
00152 
00153   base is a pointer, pmac_get() <= base < size;
00154   index is number of integers up from base.
00155 
00156   Returns unsigned integer found at indexed location.
00157   */
00158  PMAC_UINT32 read_pmac_uint32(int index);
00159 
00160 /*
00161   Write an integer into dual-ported RAM,
00162   32 bits on LynxOS/386.
00163 
00164   base is a pointer, pmac_get() <= base < size;
00165   index is number of integers up from base.
00166   val is unsigned integer to write at indexed location.
00167   */
00168  void write_pmac_uint32(int index, PMAC_UINT32 val);
00169 
00170 /*
00171   Read contents of dual-ported RAM as a float,
00172   32 bits on LynxOS/386.
00173 
00174   base is a pointer, pmac_get() <= base < size;
00175   index is number of floats up from base.
00176 
00177   Returns float found at indexed location.
00178   */
00179  float pmac_readfloat(int index);
00180 
00181 /*
00182   Write a float into dual-ported RAM,
00183   32 bits on LynxOS/386.
00184 
00185   base is a pointer, pmac_get() <= base < size;
00186   index is number of floats up from base.
00187   val is float to write at indexed location.
00188   */
00189  void pmac_writefloat(int index, float val);
00190 
00191 /*
00192   msg should be terminated with a "\xD\0" -- this is the syntax
00193   expected by the PMAC board.  Make sure I3=2 on the PMAC-- this
00194   sets the protocol this routine expects.
00195   */
00196  PMAC_RETURN_VAL pmac_writemsg(const char *msg, char *reply, int len);
00197 
00198 /* resets the PMAC to EEPROM settings */
00199  PMAC_RETURN_VAL pmac_reset();
00200 
00201 /* pmac_sendstring assumes that PMAC has been initialized elsewhere */
00202  int pmac_sendstring(const char *string);
00203 
00204 /* put the PMAC in online mode */
00205  int pmac_online();
00206 
00207 /* put the PMAC in program mode */
00208  int pmac_program();
00209 
00210 /* Returns 1 if the axis is in position, 0 if it is not, or -1
00211    if there is an error (bad axis number) */
00212 int pmac_in_position(int axis);
00213 
00214 /* Returns 1 if the axis is at home, 0 if it is not, or -1
00215    if there is an error (bad axis number) */
00216  int pmac_at_home(int axis);
00217 
00218 /* Returns -1, 0, or 1 if the axis is at neg, not, or pos hardware limit */
00219  int pmac_at_limit(int axis);
00220 
00221 /* Returns -1, 0, or 1 if the axis is at neg, not, or pos software limit */
00222  int pmac_at_sw_limit(int axis);
00223 
00224 /*
00225   Returns 1 if a PMAC motion program is running, 0 if not.
00226   Heuristics:  program running bit is 0.
00227   */
00228  int pmac_prog_running();
00229 
00230 /* returns the position of the specified axis */
00231  double pmac_pos(int axis);
00232 
00233 /* returns the target position of the specified axis */
00234  double pmac_target_pos(int axis);
00235 
00236 /* pass the reply buffer of the PMAC when you get PMAC_ERR, and
00237    this prints a line with a more descriptive error, as documented
00238    in PMAC manual for I-var I6, pp. 5-7, 5-8*/
00239  void pmac_print_error(int dperr, const char *reply);
00240 
00241 /* speed is in RPMs, gear is 1=low, 2=med, 3=hi */
00242  void pmac_spindle_speed(double speed, int gear);
00243 
00244  int pmac_enable_spindle();
00245  int pmac_disable_spindle();
00246  int pmac_spindle_is_open_loop();
00247 
00248 /* Probing */
00249  int pmac_probe_on();
00250  int pmac_probe_off();
00251  int pmac_probe_tripped(int axis);
00252  int pmac_probe_clear(int axis);
00253  int pmac_probe_value(int axis);
00254 
00255 /* PMAC system and DP RAM indices */
00256 
00257 /*
00258   To add another DP RAM variable:
00259   1.  Add the index in table below, noting $DXXX address.
00260   2.  code up the function in pmac.c, using dpram_readint(), etc.
00261   3.  edit .pmc file and put the M var assignment and copying into
00262       the PLC loop. Use the $DXXX for the DP RAM, and the M var
00263       assignment from PMAC documentation.
00264       */
00265 
00266 /* Note mapping of DP RAM and indices:
00267 
00268    DPRAM  IX
00269    -----  --
00270    $D241   0
00271    $D242   1
00272    $D243   2
00273    $D244   3
00274    $D245   4
00275    $D246   5
00276    $D247   6
00277    $D248   7
00278    $D249   8
00279    $D24A   9
00280    $D24B  10
00281    $D24C  11
00282    $D24D  12
00283    $D24E  13
00284    $D24F  14
00285    $D250  15
00286    $D251  16
00287    $D252  17
00288    $D253  18
00289    $D254  19
00290    $D255  20
00291    $D256  21
00292    $D257  22
00293    $D258  23
00294    $D259  24
00295    $D25A  25
00296    $D25B  26
00297    $D25C  27
00298    $D25D  28
00299    $D25E  29
00300    $D25F  30
00301    $D260  31
00302    $D261  32
00303    $D262  33
00304    $D263  34
00305    $D264  35
00306    $D265  36
00307    $D266  37
00308    $D267  38
00309    $D268  39
00310    $D269  40
00311    $D26A  41
00312    $D26B  42
00313    $D26C  43
00314    $D26D  44
00315    $D26E  45
00316    $D26F  46
00317    $D270  47
00318    $D271  48
00319    $D272  49
00320    $D273  50
00321    $D274  51
00322    $D275  52
00323    $D276  53
00324    $D277  54
00325    $D278  55
00326    $D279  56
00327    $D27A  57
00328    $D27B  58
00329    $D27C  59
00330    $D27D  60
00331    $D27E  61
00332    $D27F  62
00333    $D280  63
00334    $D281  64
00335    $D282  65
00336    $D283  66
00337    $D284  67
00338    $D285  68
00339    $D286  69
00340    $D287  70
00341    $D288  71
00342    $D289  72
00343    $D28A  73
00344    $D28B  74
00345    $D28C  75
00346    $D28D  76
00347    $D28E  77
00348    $D28F  78
00349    $D290  79
00350    $D291  80
00351    $D292  81
00352    $D293  82
00353    $D294  83
00354    $D295  84
00355    $D296  85
00356    $D297  86
00357    $D298  87
00358    $D299  88
00359    $D29A  89
00360    $D29B  90
00361    $D29C  91
00362    $D29D  92
00363    $D29E  93
00364    $D29F  94
00365    $D3A0  95
00366    $D2A1  96
00367    $D2A2  97
00368    $D2A3  98
00369    $D2A4  99
00370    $D2A5  100
00371    $D2A6  101
00372    $D2A7  102
00373    $D2A8  103
00374    $D2A9  104
00375    $D2AA  105
00376    $D2AB  106
00377    $D2AC  107
00378 
00379    */
00380 
00381 /* Motor 1 */
00382 #define ANALOG_1_OUT 0
00383 #define AMP_EN_1_OUT 1
00384 #define HOME_FLAG_1 2
00385 #define NEG_LIM_1 3
00386 #define POS_LIM_1 4
00387 #define PROG_RUNNING_1 5
00388 #define OPEN_LOOP_1 6
00389 #define AMP_EN_1 7
00390 #define IPOS_1 8
00391 #define HOMED_1 9
00392 #define ACT_POS_1 10
00393 #define TARGET_POS_1 11
00394 #define SW_LIM_1 12
00395 #define SW_POS_LIM_1 13
00396 #define SW_NEG_LIM_1 14
00397 #define UNUSED_1 15
00398 #define CAPTURE_READY_1 16
00399 #define HOME_OFFSET_1 17
00400 
00401 /* Motor 2 */
00402 #define ANALOG_2_OUT 20
00403 #define AMP_EN_2_OUTPUT 21
00404 #define HOME_FLAG_2 22
00405 #define NEG_LIM_2 23
00406 #define POS_LIM_2 24
00407 #define PROG_RUNNING_2 25
00408 #define OPEN_LOOP_2 26
00409 #define AMP_EN_2 27
00410 #define IPOS_2 28
00411 #define HOMED_2 29
00412 #define ACT_POS_2 30
00413 #define TARGET_POS_2 31
00414 #define SW_LIM_2 32
00415 #define SW_POS_LIM_2 33
00416 #define SW_NEG_LIM_2 34
00417 #define UNUSED_2 35
00418 #define CAPTURE_READY_2 36
00419 #define HOME_OFFSET_2 37
00420 
00421 /* Motor 3 */
00422 #define ANALOG_3_OUT 40
00423 #define AMP_EN_3_OUT 41
00424 #define HOME_FLAG_3 42
00425 #define NEG_LIM_3 43
00426 #define POS_LIM_3 44
00427 #define PROG_RUNNING_3 45
00428 #define OPEN_LOOP_3 46
00429 #define AMP_EN_3 47
00430 #define IPOS_3 48
00431 #define HOMED_3 49
00432 #define ACT_POS_3 50
00433 #define TARGET_POS_3 51
00434 #define SW_LIM_3 52
00435 #define SW_POS_LIM_3 53
00436 #define SW_NEG_LIM_3 54
00437 #define UNUSED_3 55
00438 #define CAPTURE_READY_3 56
00439 #define HOME_OFFSET_3 57
00440 
00441 /* Motor 4 */
00442 #define ANALOG_4_OUT 60
00443 #define AMP_EN_4_OUT 61
00444 #define HOME_FLAG_4 62
00445 #define NEG_LIM_4 63
00446 #define POS_LIM_4 64
00447 #define PROG_RUNNING_4 65
00448 #define OPEN_LOOP_4 66
00449 #define AMP_EN_4 67
00450 #define IPOS_4 68
00451 #define HOMED_4 69
00452 #define ACT_POS_4 70
00453 #define TARGET_POS_4 71
00454 #define SW_LIM_4 72
00455 #define SW_POS_LIM_4 73
00456 #define SW_NEG_LIM_4 74
00457 #define UNUSED_4 75
00458 #define CAPTURE_READY_4 76
00459 #define HOME_OFFSET_4 77
00460 
00461 /* Motor 5 */
00462 #define ANALOG_5_OUT 80
00463 #define AMP_EN_5_OUT 81
00464 #define HOME_FLAG_5 82
00465 #define NEG_LIM_5 83
00466 #define POS_LIM_5 84
00467 #define PROG_RUNNING_5 85
00468 #define OPEN_LOOP_5 86
00469 #define AMP_EN_5 87
00470 #define IPOS_5 88
00471 #define HOMED_5 89
00472 #define ACT_POS_5 90
00473 #define TARGET_POS_5 91
00474 #define SW_LIM_5 92
00475 #define SW_POS_LIM_5 93
00476 #define SW_NEG_LIM_5 94
00477 #define UNUSED_5 95
00478 #define CAPTURE_READY_5 96
00479 #define HOME_OFFSET_5 97
00480 
00481 /* Motor 6 */
00482 #define ANALOG_6_OUT 100
00483 #define AMP_EN_6_OUT 101
00484 #define HOME_FLAG_6 102
00485 #define NEG_LIM_6 103
00486 #define POS_LIM_6 104
00487 #define PROG_RUNNING_6 105
00488 #define OPEN_LOOP_6 106
00489 #define AMP_EN_6 107
00490 #define IPOS_6 108
00491 #define HOMED_6 109
00492 #define ACT_POS_6 110
00493 #define TARGET_POS_6 111
00494 #define SW_LIM_6 112
00495 #define SW_POS_LIM_6 113
00496 #define SW_NEG_LIM_6 114
00497 #define UNUSED_6 115
00498 #define CAPTURE_READY_6 116
00499 #define HOME_OFFSET_6 117
00500 
00501 /* Motor 7 */
00502 #define ANALOG_7_OUT 120
00503 #define AMP_EN_7_OUT 121
00504 #define HOME_FLAG_7 122
00505 #define NEG_LIM_7 123
00506 #define POS_LIM_7 124
00507 #define PROG_RUNNING_7 125
00508 #define OPEN_LOOP_7 126
00509 #define AMP_EN_7 127
00510 #define IPOS_7 128
00511 #define HOMED_7 129
00512 #define ACT_POS_7 130
00513 #define TARGET_POS_7 131
00514 #define SW_LIM_7 132
00515 #define SW_POS_LIM_7 133
00516 #define SW_NEG_LIM_7 134
00517 #define UNUSED_7 135
00518 #define CAPTURE_READY_7 136
00519 #define HOME_OFFSET_7 137
00520 
00521 /* Motor 8 */
00522 #define ANALOG_8_OUT 140
00523 #define AMP_EN_8_OUT 141
00524 #define HOME_FLAG_8 142
00525 #define NEG_LIM_8 143
00526 #define POS_LIM_8 144
00527 #define PROG_RUNNING_8 145
00528 #define OPEN_LOOP_8 146
00529 #define AMP_EN_8 147
00530 #define IPOS_8 148
00531 #define HOMED_8 149
00532 #define ACT_POS_8 150
00533 #define TARGET_POS_8 151
00534 #define SW_LIM_8 152
00535 #define SW_POS_LIM_8 153
00536 #define SW_NEG_LIM_8 154
00537 #define UNUSED_8 155
00538 #define CAPTURE_READY_8 156
00539 #define HOME_OFFSET_8 157
00540 
00541 #define CS_PROG_RUNNING 160
00542 #define CS_IPOS 161
00543 
00544 #define SPINDLE_SPEED ANALOG_4_OUT /* same as motor 4 */
00545 
00546 /* axis offsets */
00547 #define OFFSET_1 162
00548 #define OFFSET_2 163
00549 #define OFFSET_3 164
00550 
00551 #define CAPTURED_1 171          /* look here for X when ready */
00552 #define CAPTURED_2 172          /* look here for Y */
00553 #define CAPTURED_3 173          /* look here for Z */
00554 
00555 
00556 #ifdef __cplusplus
00557 }
00558 #endif
00559 
00560 #endif          /* PMAC_H */

Generated on Sun Dec 2 15:56:51 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001