ds402.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of the SCHUNK Canopen Driver suite.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany
12 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 
29 #ifndef DS402_H
30 #define DS402_H
31 
32 #include "Logging.h"
33 
34 namespace icl_hardware {
35 namespace canopen_schunk {
36 namespace ds402{
37 
38 static const uint16_t ID_CONTROL_WORD = 0x6040;
39 static const uint16_t ID_STATUS_WORD = 0x6041;
40 
42 {
43  //-1 ... -128 Manufacturer specific modes of operation
46  MOO_VELOCITY_MODE = 2, // not supported right now
55  //11 ... 127 reserved
56 };
57 
61 enum eState
62 {
63  // Do NOT change the order of these states!
72  STATE_FAULT // This does not show up in the diagram, but it is acquired from the statusword
73 };
74 
76 {
77  STATE_TRANS_INITIALIZE = 1, // 1, 7, 9, 10, 12
78  STATE_TRANS_SHUTDOWN = 2, // 2, 6, 8
79  STATE_TRANS_SWITCH_ON = 3, // 3, 5
83  // 0, 13 and 14 cannot be performed manually
84 };
85 
88 {
89  uint16_t switch_on : 1; // 0
91  uint16_t quick_stop : 1; // 2
97  uint16_t halt : 1; // 8
98  uint16_t reserved_0 : 1; // 9
99  uint16_t reserved_1 : 1; // 10
105 };
106 
109 {
112 };
113 
116 {
117  uint16_t ready_to_switch_on : 1; // 0
118  uint16_t switched_on : 1; // 1
119  uint16_t operation_enabled : 1; // 2
120  uint16_t fault : 1; // 3
121  uint16_t voltage_enabled : 1; // 4
123  uint16_t switch_on_disabled : 1; // 6
124  uint16_t warning : 1; // 7
126  uint16_t remote : 1; // 9
127  uint16_t target_reached : 1; // 10
128  uint16_t internal_limit_active : 1; // 11
133 };
134 
137 {
140 };
141 
143 {
144  uint32_t profile_position_mode : 1; // 0
145  uint32_t velocity_mode : 1; // 1
146  uint32_t profile_velocity_mode : 1; // 2
147  uint32_t profile_torque_mode : 1; // 3
148  uint32_t reserved_4 : 1; // 4
149  uint32_t homing_mode : 1; // 5
150  uint32_t interpolated_position_mode : 1; // 6
151  uint32_t cyclic_sync_position_mode : 1; // 7
152  uint32_t cyclic_sync_velocity_mode : 1; // 8
153  uint32_t cyclic_sync_torque_mode : 1; // 9
154  // 10..15 reserved
155  // 16..31 manufacturer specific
156 };
157 
160 {
163 };
164 
170 {
175 
180 
189 
194 
200 
208 
214 
215 
217  : profile_deceleration(0),
218  motion_profile_type(0),
219  change_set_immediately(false),
220  use_relative_targets(false),
221  use_blending(true)
222  {}
223 };
224 
230 {
234 
236  : homing_method(0), homing_speed_low(0), homing_speed_high(0) {}
237 
238  HomingModeConfiguration(int8_t method_, uint32_t speed_low_, uint32_t speed_high)
239  : homing_method( method_ ), homing_speed_low(speed_low_), homing_speed_high(speed_high) {}
240 };
241 
247 {
249 
251  {
252  POSITION_ENCODER = 0,
253  VELOCITY_ENCODER = 1
254  };
255 };
256 
262 {
266  : torque_slope(0), torque_profile_type(0) {}
267 };
268 
276 inline std::string deviceStatusString (const eState state)
277 {
278  switch (state)
279  {
281  {
282  return "NOT READY TO SWITCH ON";
283  break;
284  }
286  {
287  return "SWITCH ON DISABLED";
288  break;
289  }
291  {
292  return "READY TO SWITCH ON";
293  break;
294  }
295  case STATE_SWITCHED_ON:
296  {
297  return "SWITCHED ON";
298  break;
299  }
301  {
302  return "OPERATION ENABLED";
303  break;
304  }
306  {
307  return "QUICK STOP ACTIVE";
308  break;
309  }
311  {
312  return "FAULT REACTION ACTIVE";
313  break;
314  }
315  case STATE_FAULT:
316  {
317  return "FAULT";
318  break;
319  }
320  default:
321  {
322  // nothing. Will reach statement at end of function
323  }
324  }
325  return "Unknown status code. This should not happen!";
326 }
327 
328 inline std::string operationModeString (const eModeOfOperation mode)
329 {
330  switch (mode)
331  {
332  case MOO_HOMING_MODE:
333  {
334  return "HOMING_MODE";
335  }
337  {
338  return "MOO_INTERPOLATED_POSITION_MODE";
339  }
341  {
342  return "MOO_PROFILE_POSITION_MODE";
343  }
345  {
346  return "MOO_PROFILE_TORQUE_MODE";
347  }
348  case MOO_VELOCITY_MODE:
349  {
350  return "MOO_VELOCITY_MODE";
351  }
353  {
354  return "MOO_PROFILE_VELOCITY_MODE";
355  }
357  {
358  return "MOO_CYCLIC_SYNC_POSITION_MODE";
359  }
361  {
362  return "MOO_CYCLIC_SYNC_VELOCITY_MODE";
363  }
365  {
366  return "MOO_CYCLIC_SYNC_TORQUE_MODE";
367  }
368  default:
369  {
370  return "UNKNOWN_MODE_OF_OPERATION";
371  }
372  }
373 }
374 
375 inline eState stateFromStatusword (const ds402::Statusword& statusword)
376 {
377  uint8_t lsb = statusword.all & 0xFF;
378  if ( (lsb | 0b10110000) == 0b10110000)
379  {
381  }
382  else if ( (lsb | 0b10110000) == 0b11110000)
383  {
385  }
386  else if ( (lsb | 0b10010000) == 0b10110001)
387  {
389  }
390  else if ( (lsb | 0b10010000) == 0b10110011)
391  {
392  return STATE_SWITCHED_ON;
393  }
394  else if ( (lsb | 0b10010000) == 0b10110111)
395  {
396  return STATE_OPERATION_ENABLE;
397  }
398  else if ( (lsb | 0b10010000) == 0b10010111)
399  {
400  return STATE_QUICKSTOP_ACTIVE;
401  }
402  else if ( (lsb | 0b10110000) == 0b10111111)
403  {
405  }
406  else if ( (lsb | 0b10110000) == 0b10111000)
407  {
408  return STATE_FAULT;
409  }
410 
411  // if we reach this point, something is wrong!
412  LOGGING_ERROR (CanOpen, "Failed to get DS402 state from statusword! Something is probably wrong with the statusword. Returning STATE_FAULT" << endl);
413  return STATE_FAULT;
414 }
415 
416 }}} // end of NS
417 #endif // DS402_H
unsigned int uint32_t
Configuration parameters for a Profile_Position_Mode according to CiA DSP-402 V1.1 section 12...
Definition: ds402.h:169
signed char int8_t
data union for access to DSP 402 6041 statusword,
Definition: ds402.h:136
bit field for DSP 402 6041 statusword,
Definition: ds402.h:115
Configuration parameters for a Profile_Velocity_Mode according to CiA DSP-402 V1.1 section 16...
Definition: ds402.h:246
eState stateFromStatusword(const ds402::Statusword &statusword)
Definition: ds402.h:375
std::string deviceStatusString(const eState state)
Turns a status word into a status string according to the elmo DS-402 implementation guide chapter 6...
Definition: ds402.h:276
bool use_blending
If set to true, the device will blend over to a new setpoint. Defaults to true.
Definition: ds402.h:213
int16_t motion_profile_type
Type of ramp used for accelerating and decelerating. Defaults to linear.
Definition: ds402.h:193
bit field for DSP 402 6040 controlword,
Definition: ds402.h:87
#define LOGGING_ERROR(streamname, arg)
static const uint16_t ID_CONTROL_WORD
Definition: ds402.h:38
unsigned char uint8_t
bool use_relative_targets
This parameter influences the interpretation of new set points. If set to true, new set point positio...
Definition: ds402.h:207
float profile_acceleration
This will be used for both acceleration ramps.
Definition: ds402.h:179
ThreadStream & endl(ThreadStream &stream)
static const uint16_t ID_STATUS_WORD
Definition: ds402.h:39
std::string operationModeString(const eModeOfOperation mode)
Definition: ds402.h:328
def warning(args, kwargs)
Configuration parameters for a Profile_Torque_Mode according to CiA DSP-402 V1.1 section 17...
Definition: ds402.h:261
signed short int16_t
eState
DS402 states as described in Figure 6.3 in ELMO DS402 implementation guide V1.000.
Definition: ds402.h:61
bool change_set_immediately
If this is set to true the device will not ramp down at a setpoint if a following one is given...
Definition: ds402.h:199
data union for access to DSP 402 6040 controlword,
Definition: ds402.h:108
unsigned short uint16_t
HomingModeConfiguration(int8_t method_, uint32_t speed_low_, uint32_t speed_high)
Definition: ds402.h:238
data union for access to DSP 402 6041 statusword,
Definition: ds402.h:159
float profile_deceleration
This will be used for both acceleration ramps.
Definition: ds402.h:188
Configuration parameters for a Homing_Mode according to CiA DSP-402 V1.1 section 13.2.1.
Definition: ds402.h:229


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Mon Jun 10 2019 15:07:49