1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// RBapp.h : Application-specific code for an application built
// on the Robotics Bus.
//
// To customize this template for your application,
// make a list of all the network-accessible variables used by the application,
// and place them in three places below.
//
// 1: Allocate space in EEPROM for any nonvolatile parameters.
//
// 2: Declare global variables in the RAM map, using RB_TYPEs UINT8, FLOAT, etc.
//
// 3: Populate the Object Dictionary with the index, permissions,
// and type of each variable. (perms are or'd with a media specifier).
//
// 4: In the dictionary, enter a pointer to each variable.
// This will be a simple constant for EEPROM, or a &myVar pointer to RAM.
//
// 5: Enter a text string to identify each object. Text labels can be 32
// characters long and should be entered inside quotes inside the
// dictionary table. The text string will be used by configuration utility
// program to create a friendly user interface for configuration.
//
// 6: Assign descriptive strings to any Process Messages you use.
//
// 7: In the Process Message Mapping table, include a default identifier,
// and the number of mappings, followed by a list of all mapped objects.

/* ----- revision history:
 2006-08-05, Jimmy Sastra: Today I started this revision history.
 Took out process messages for actualPos.  The bluetooth module could not keep up.

2006-08-07, Mike Park: Reinstated process messages for actualPos.  Frequency is set to a
low default and a variable in EEPROM allows user to modify frequency.

2007-02-13, Mike Park: 1 Hz neighbor information (piggybacked off of the heartbeat function)
toggled with object dictionary variable.
*/

/*************************************************************************
// DEFAULT NODE ID
***************************************************************************/

// *** DONT REMOVE, OK TO CHANGE ***
// NID to use when ROM is wiped clean.
// This can be changed and replaced in nonvolatile memory during operation.

#define RB_NODEID_DEFAULT 0x22
// WARNING: If this is 0 or > 253 RB_factory initialize will be 
//called repetetively and no changes in eeprom will be saved 
// this condition is because of the condition as set in RB_reset_from_eeprom()

/**************************************************************************
// EEPROM MAP
***************************************************************************/

// Assign addresses 0x00-0x7F (0-127) for variables stored in EEPROM,
// and be sure they are consistent with the Object Dictionary below.
// NOTE!! Addresses above 0x7F are used internally by the Robotics Bus (see RB.h).

#define SERVO_CAL_CMD_CENTER  2
#define SERVO_CAL_CMD_AMPLITUDE 4
//#define SERVO_KP 8
//#define SERVO_KD 10
#define SERVO_SPEED 12
#define SERVO_START_POS 14
#define FEEDBACK 8


/**************************************************************************
// RAM MAP
***************************************************************************/

// Global RAM variables used by application.
uint16 feed_freq;
sint16    actualPos;
sint16    servoPosCommand = 0;
uint8     servoSpeed;
bool      calMode;
uint16 	  feed_mult=1;
uint16 	  feed_int=0;
uint16     raw_adc =0;

/***************************************
	PROCESS MESSAGE MAPPINGS

   if used, they must be named:
   RB_RXMAPPING_0 - RB_RXMAPPING_3
   RB_TXMAPPING_0 - RB_TXMAPPING_3

****************************************/

CONST UINT8   RB_RXMAPPING_0_LENGTH  = 1;
CONST UINT16  RB_RXMAPPING_0_DEFAULT = RB_COMMAND + RB_NODEID_DEFAULT;
CONST pm_map  RB_RXMAPPING_0[] =
{
{0x1050, RB_TYPE_SINT16, &servoPosCommand},
{0x1052, RB_TYPE_UINT8, &servoSpeed},
};

CONST UINT8   RB_RXMAPPING_1_LENGTH  = 0;
CONST UINT16  RB_RXMAPPING_1_DEFAULT = RB_NULL;
CONST pm_map  RB_RXMAPPING_1[] = RB_UNUSED_MAP;

CONST UINT8   RB_RXMAPPING_2_LENGTH  = 0;
CONST UINT16  RB_RXMAPPING_2_DEFAULT = RB_NULL;
CONST pm_map  RB_RXMAPPING_2[] = RB_UNUSED_MAP;

CONST UINT8   RB_RXMAPPING_3_LENGTH  = 0;
CONST UINT16  RB_RXMAPPING_3_DEFAULT = RB_NULL;
CONST pm_map  RB_RXMAPPING_3[] = RB_UNUSED_MAP;

CONST UINT8   RB_TXMAPPING_0_LENGTH  = 1;
CONST UINT16  RB_TXMAPPING_0_DEFAULT = RB_SENSOR + RB_NODEID_DEFAULT;
CONST pm_map  RB_TXMAPPING_0[] = 
{
{0x1051, RB_TYPE_SINT16, &actualPos}
};

CONST UINT8   RB_TXMAPPING_1_LENGTH  = 0;
CONST UINT16  RB_TXMAPPING_1_DEFAULT = RB_NULL;
CONST pm_map  RB_TXMAPPING_1[] =  RB_UNUSED_MAP;

CONST UINT8   RB_TXMAPPING_2_LENGTH  = 0;
CONST UINT16  RB_TXMAPPING_2_DEFAULT = RB_NULL;
CONST pm_map  RB_TXMAPPING_2[] = RB_UNUSED_MAP;

CONST UINT8   RB_TXMAPPING_3_LENGTH  = 0;
CONST UINT16  RB_TXMAPPING_3_DEFAULT = RB_NULL;
CONST pm_map  RB_TXMAPPING_3[] = RB_UNUSED_MAP;

/***************************************
	OBJECT DICTIONARY
****************************************/

CONST od_entry objectDictionary[] =
{ //                                                                                         "|<------ 32 char string ------>|"
{ 0x1000, RB_MEDIA_NONV | RB_PERM_READWRITE,	  RB_TYPE_IDENTITY,	 	RB_EEPROM_NODEID,   	   "V1.4"}, // name of device goes here
{ 0x1001, RB_MEDIA_NONV | RB_PERM_READWRITE,	  RB_TYPE_UINT16,	 	FEEDBACK,   	   "Feedback in Hz"},

{ 0x1050, RB_MEDIA_RAM | RB_PERM_READWRITE,	   RB_TYPE_SINT16,	    &servoPosCommand,       "poscomm"},
{ 0x1051, RB_MEDIA_RAM | RB_PERM_READONLY,	   RB_TYPE_SINT16,	    &actualPos,  	        "Actual Pos"},
{ 0x1052, RB_MEDIA_RAM | RB_PERM_READWRITE,    RB_TYPE_UINT8,       &ServoSpeed,            "Current speed"},

{ 0x1014, RB_MEDIA_RAM | RB_PERM_READONLY,	  RB_TYPE_UINT16,	      &raw_adc,               "rawADC"},
{ 0x1020, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_SINT16,        SERVO_CAL_CMD_CENTER,   "calccent"},
{ 0x1021, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_UINT16,        SERVO_CAL_CMD_AMPLITUDE,"calcamp"},

//{ 0x1024, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_UINT16,        SERVO_KP,"KP for position control"},
//{ 0x1025, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_UINT16,        SERVO_KD,"KD for position control"}, 
{ 0x1026, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_UINT16,        SERVO_SPEED,"Initial Speed at startup"},
{ 0x1027, RB_MEDIA_NONV | RB_PERM_READWRITE,  RB_TYPE_SINT16,        SERVO_START_POS,"Initial Position"}, 

{ 0x1060, RB_MEDIA_RAM | RB_PERM_READWRITE,	  RB_TYPE_BOOLEAN,	   &calMode,        "calMode"},

{ 0x1800, RB_MEDIA_ROM | RB_PERM_READONLY,   RB_TYPE_PM_CONFIG,    &RB_TXCONFIG_0,        "posfeed"}         // Tx PM Config
{ 0x1A00, RB_MEDIA_ROM | RB_PERM_READONLY,	  RB_TYPE_PM_MAPPING,   RB_NULL,              RB_NULL},                       // Tx Mapping

{ 0x1400, RB_MEDIA_ROM | RB_PERM_READONLY,   RB_TYPE_PM_CONFIG,    &RB_RXCONFIG_0,        "poscomm PMID"},         // Rx PM Config
{ 0x1600, RB_MEDIA_ROM | RB_PERM_READONLY,	  RB_TYPE_PM_MAPPING,   RB_NULL,              RB_NULL},                       // Rx Mapping
RB_END_OF_DICTIONARY // end of dictionary marker
};

//eof