0320_palm_edc_ethercat_protocol.h
Go to the documentation of this file.
1 //
2 // © 2010 Shadow Robot Company Limited.
3 //
4 // FileName: 0320_palm_edc_ethercat_protocol.h
5 // Dependencies:
6 // Processor: PIC32
7 // Compiler: MPLAB® C32
8 //
9 // +------------------------------------------------------------------------+
10 // | This file is part of The Shadow Robot PIC32 firmware code base. |
11 // | |
12 // | It is free software: you can redistribute it and/or modify |
13 // | it under the terms of the GNU General Public License as published by |
14 // | the Free Software Foundation, either version 3 of the License, or |
15 // | (at your option) any later version. |
16 // | |
17 // | It is distributed in the hope that it will be useful, |
18 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 // | GNU General Public License for more details. |
21 // | |
22 // | You should have received a copy of the GNU General Public License |
23 // | along with this code repository. The text of the license can be found |
24 // | in Pic32/License/gpl.txt. If not, see <http://www.gnu.org/licenses/>. |
25 // +------------------------------------------------------------------------+
26 //
27 //
28 //
29 // Doxygen
30 // -------
31 //
42 //
43 
44 #ifndef PALM_EDC_0320_ETHERCAT_PROTOCOL_H_INCLUDED
45 #define PALM_EDC_0320_ETHERCAT_PROTOCOL_H_INCLUDED
46 
47 #include "../common/tactile_edc_ethercat_protocol.h"
48 #include "../common/ethercat_can_bridge_protocol.h"
49 #include "../common/common_edc_ethercat_protocol.h"
50 
51 
52 #define NUM_MUSCLES 40
53 #define NUM_PRESSURE_SENSORS_PER_MESSAGE 5
54 #define NUM_MUSCLE_DATA_PACKETS 8
55 
56 
57 // ========================================================
58 //
59 // F R O M M U S C L E D A T A T Y P E
60 //
61 // ========================================================
62 
63 
65 typedef enum
66 {
69 
73 
74 
75 
76 
77 // ========================================================
78 //
79 // S L O W D A T A
80 //
81 // ========================================================
82 
83 
84 typedef enum
85 {
95 
96 
99 
100 
101 
102 // ========================================================
103 //
104 // F L A G S
105 //
106 // ========================================================
107 
108 
109  // Non serious flags, Just for information. Control still works.
110  // -------------------------------------------------------------
111 
112 
113  // Serious flags cause the valves to be switched off
114  // ------------------------------------------------
115 #define MUSCLE_FLAG_BITS_NO_DEMAND_SEEN 0x0400
116 
117 
118 #define PALM_0300_EDC_SERIOUS_ERROR_FLAGS ( MOTOR_FLAG_BITS_NO_DEMAND_SEEN )
119 
120 #define PALM_0300_EDC_NO_DEMAND_TIMEOUT_MS 20
121 
123 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
124 
127  static const char* palm_0300_edc_error_flag_names[16] = { "No demand seen for more than 20ms", // 0x0400
128  };
129 #endif
130 
131 
132 
133 
134 
135 // ========================================================
136 //
137 // T O M U S C L E D A T A T Y P E
138 //
139 // ========================================================
140 
145 typedef enum
146 {
149 
152 
153 #define MUSCLE_SYSTEM_RESET_KEY 0x5200
154 
155 
156 
157 
158 #define MUSCLE_DEMAND_VALVES_RANGE_MIN -0x4
159 #define MUSCLE_DEMAND_VALVES_RANGE_MAX 0x4
160 
161 #define DIRECTION_TO_MUSCLE 0x01
162 #define DIRECTION_FROM_MUSCLE 0x02
163 
164 
165 #ifndef NO_STRINGS // The PIC compiler doesn't deal well with strings.
166 
169  static const char* to_muscle_data_type_names[16] = { "INVALID",
170  "Demand: Valves",
171  };
172 #endif
173 
174 
175 
178 
179 typedef union
180 {
181  struct
182  {
183  unsigned int L:4;
184  unsigned int M:4;
185  unsigned int H:4;
186  unsigned int padding:4;
187  } nibbles;
188 
190 
192 
193 
194 typedef union
195 {
196  struct
197  {
198  unsigned int pressure0_L:4;
199  unsigned int pressure0_M:4;
200  unsigned int pressure0_H:4;
201 
202  unsigned int pressure1_L:4;
203  unsigned int pressure1_M:4;
204  unsigned int pressure1_H:4;
205 
206  unsigned int pressure2_L:4;
207  unsigned int pressure2_M:4;
208  unsigned int pressure2_H:4;
209 
210  unsigned int pressure3_L:4;
211  unsigned int pressure3_M:4;
212  unsigned int pressure3_H:4;
213 
214  unsigned int pressure4_L:4;
215  unsigned int pressure4_M:4;
216  unsigned int pressure4_H:4;
217 
218  unsigned int padding:4;
219 
220  } packed;
221 
222  struct
223  {
228  }slow_0;
229 
230  struct
231  {
236  }slow_1;
237 
238  struct
239  {
244  int8u nothing[2];
245  }misc;
246 
247  //struct
248  //{
249  int8u raw[8];
250  //} raw;
252 
253 
254 
255 #define MESSAGE_ID_MUSCLE_DRIVER_ID_SHIFT_POS 5
256 
257 
258 
259 #define SENSORS_NUM_0320 ((int)36)
260 
262 #define JOINTS_NUM_0320 ((int)28)
263 
265 
266 
267 //#if (int)IGNORE > SENSORS_NUM
268 // #error Not enough sensors[] in ETHERCAT_DATA_STRUCTURE_0300_PALM_EDC_STATUS
269 //#endif
270 
272 typedef struct
273 {
274  EDC_COMMAND EDC_command;
275 
279  int16u sensors[SENSORS_NUM_0320+1];
280 
282 
286  MUSCLE_DATA_PACKET muscle_data_packet[NUM_MUSCLE_DATA_PACKETS];
290 
291 
292  int32u tactile_data_type;
293  int16u tactile_data_valid;
294  TACTILE_SENSOR_STATUS_v1 tactile[5]; //
295 
296  int16u idle_time_us;
297 
299 } __attribute__((packed)) ETHERCAT_DATA_STRUCTURE_0300_PALM_EDC_STATUS;
300 
301 
302 
304 typedef struct
305 {
306  EDC_COMMAND EDC_command;
307 
309 
311  int8u muscle_data[NUM_MUSCLES/2];
312 
313  int32u tactile_data_type;
314  //int32u tactile_data_type_1; //!< The host can request up to 2 different values per frame
315 
316 } __attribute__((packed)) ETHERCAT_DATA_STRUCTURE_0300_PALM_EDC_COMMAND;
317 
318 
319 
320 #define PALM_0300_ETHERCAT_COMMAND_HEADER_SIZE ( sizeof(EDC_COMMAND) + sizeof(FROM_MUSCLE_DATA_TYPE) + sizeof(int16s) )
321 
322 #define PALM_0300_ETHERCAT_STATUS_DATA_SIZE sizeof(ETHERCAT_DATA_STRUCTURE_0300_PALM_EDC_STATUS)
323 #define PALM_0300_ETHERCAT_COMMAND_DATA_SIZE sizeof(ETHERCAT_DATA_STRUCTURE_0300_PALM_EDC_COMMAND)
324 
325  // Now we need to be *sure* that the Host and the Slave definitely
326  // agree on the size of the EtherCAT packets, even if the host is a
327  // 64-bit machine or something. So we have these calculated sizes.
328  // The host and slave can ASSERT that the sizeof() the packets
329  // matches the agreed sizes.
330 #define ETHERCAT_STATUS_0300_AGREED_SIZE 236
331 #define ETHERCAT_COMMAND_0300_AGREED_SIZE 36
332 
333 
345 
346 #define PALM_0300_ETHERCAT_COMMAND_DATA_ADDRESS 0x1000
347 #define PALM_0300_ETHERCAT_CAN_BRIDGE_DATA_COMMAND_ADDRESS (PALM_0300_ETHERCAT_COMMAND_DATA_ADDRESS + PALM_0300_ETHERCAT_COMMAND_DATA_SIZE)
348 
349 #define PALM_0300_ETHERCAT_STATUS_DATA_ADDRESS (PALM_0300_ETHERCAT_CAN_BRIDGE_DATA_COMMAND_ADDRESS + ETHERCAT_CAN_BRIDGE_DATA_SIZE)
350 #define PALM_0300_ETHERCAT_CAN_BRIDGE_DATA_STATUS_ADDRESS (PALM_0300_ETHERCAT_STATUS_DATA_ADDRESS + PALM_0300_ETHERCAT_STATUS_DATA_SIZE)
351 
352 //#define NUM_CONFIGS_REQUIRED 5
353 
354 
355 #endif
unsigned short int16u
Important to know that this is the last one.
A zero is what happens if an EtherCAT packet doesn&#39;t get through, so it&#39;s considered a special case...
TO_MUSCLE_DATA_TYPE to_muscle_data_type
What type of data are we sending to the muscles?
FROM_MUSCLE_DATA_TYPE from_muscle_data_type
Which data does the host want from the muscles?
See FROM_MUSCLE_SLOW_DATA_TYPE.
Send with a demand value of 0x520x to reset muscle driver x.
This needs to be a #define for symmetry with SENSORS_NUM.
unsigned int int32u
Day/Month of assembly. E.G. 0x0A1F means October 31st.
unsigned char int8u
Did the local code have any uncomitted modifications at build time?
static const char * to_muscle_data_type_names[16]
For safety, this is not a data type.
#define SENSORS_NUM_0320
ADC reading pressure sensors.
static const char * palm_0300_edc_error_flag_names[16]
how long, in milliseconds, before it switches off the valves.
#define NUM_MUSCLE_DATA_PACKETS
FROM_MUSCLE_DATA_TYPE muscle_data_type
Number of CAN messages received / transmitted by this muscle driver + error counters.
EDC_COMMAND
The host can request different types of data from the palm.
For safety, this is not a valid request.


sr_external_dependencies
Author(s): Ugo Cupcic
autogenerated on Mon Feb 28 2022 23:50:40