/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1987, 1991 by John E. Lloyd and Vincent Hayward.	    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include "mk3.c"

/* Table of parameters which are loaded into the joint microprocessors
   by controller start-up time. */

/* RAM Parameters (for PUMA only) */

#define  ADDR	    0x0200 /* 001000 memory address to read with readm	*/
#define  PGAIN      0x0d00 /* 006400 position error servo gain (0 to 7)*/
#define  WHLSIZ     0x0500 /* 002400 no. of encoder counts times 4	*/
#define  ESCALE     0x0600 /* 003000 encoder count scale factor	*/
#define  PENVELOPE  0x0700 /* 003400 position envelope		        */
#define  ATHRESH    0x0900 /* 004400 acceleration threshold		*/
#define  INTSCL	    0x0b00 /* 005400 log 2 of the # of ticks per sample*/
#define  NINTER	    0x0c00 /* 006000 number of ticks per sample	*/
#define  KGAIN	    0x0d00 /* 006400 proportional gain		        */
#define  IGAIN	    0x0e00 /* 007000 integration gain		 	*/
#define  ASCALE	    0x0f00 /* 007400 acceleration scale		*/
#define  VDECAY	    0x1000 /* 010000 velocity averaging constant	*/
#define  VGAIN	    0x1100 /* 010400 velocity average gain		*/
#define  ADAMPGAIN  0x1200 /* 011000 accelartion damping gain		*/
#define  SCALE	    0x1300 /* 011400 output scale			*/
#define  ITERM      0x1400 /* 012000 integration term			*/
#define  CURPOS     0x2300 /* 021400 current position (2 bytes) 	*/
#define  POSERR     0x2800 /* 024000 current position error (2 bytes)	*/
#define  POSTOL     0x5700 /* 053400 position tolerance (2 bytes)	*/
#define  INTTOL     0x5900 /* 054400 integration tolerance (2 bytes)	*/
#define  CURVEL     0x7000 /* 070000 current velocity (2 bytes)	*/

unsigned short defaultRamTable [][7] =
	{ WHLSIZ,		0x80,  0x80,  0x80,  0xe8,  0xe8,  0xe8,
	  ESCALE,		   2,     2,     2,     1,     0,     0,
	  PENVELOPE, 		0xf4,  0xf4,  0xf4,  0xe8,  0xe8,  0xe8, 
	  PENVELOPE+0400,	0x01,  0x01,  0x01,  0x03,  0x03,  0x03, 
	  ATHRESH, 		0xaa,  0xaa,  0xbe,  0x8a,  0x8a,  0x2a, 
	  ATHRESH+0400,		   0,     0,     0,  0x02,  0x02,  0x03, 
	  INTSCL, 		   5,     5,     5,     5,     5,     5,
	  NINTER, 		0x40,  0x40,  0x40,  0x40,  0x40,  0x40,

	  IGAIN, 		   8,     8,     8,     6,     6,     6, 
	  ASCALE, 		   3,     3,     3,     0,     0,     0, 
	  VDECAY,		   5,     5,     5,     2,     2,     2, 
	  VGAIN, 		   5,     5,     5,     4,     4,     4, 
	  ADAMPGAIN,  		   0,     0,     0,     1,     1,     1, 
	  SCALE, 		   0,     0,     0,     2,     2,     2, 
	  POSTOL, 		0x28,  0x28,  0x28,  0x28,  0x28,  0x28, 
	  POSTOL+0400, 		   0, 	  0,     0,     0,     0,     0, 
	  INTTOL, 		0x32,  0x32,  0x32,  0x32,  0x32,  0x32, 
	  INTTOL+0400, 		   0, 	  0,     0,     0,     0,     0,
#ifdef notdef
	  ITERM, 		   0,     0,     0,     0,     0,     0, 
	  ITERM+0400, 		   0,     0,     0,     0,     0,     0, 
	  ITERM+01000, 		   0,     0,     0,     0,     0,     0, 
#endif

	  -1,			   0,     0,     0,     0,     0,     0};

int varClkRate = 1;		/* system clock rate can be changed */
int varClkParam = 6;		/* parameter used in changing clock rate */
int baseClkRate = 28;		/* nominal system clock rate (.1 msec.). */
int jntClkRate = 18;		/* joint servo rate (.1 msec.). */
