author | Laurent Bessard |
Fri, 26 Apr 2013 23:23:09 +0200 | |
changeset 2138 | 79dc2d15c580 |
parent 2136 | 71fdfd4a12a3 |
child 2150 | 08514552944f |
permissions | -rw-r--r-- |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
1 |
/* |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
2 |
* Ethercat CIA402 node execution code |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
3 |
* |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
4 |
* */ |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
5 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
6 |
#include "ecrt.h" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
7 |
|
2122
03cf08190ac4
Fixed header files inclusion in CIA402 node template file
Laurent Bessard
parents:
2118
diff
changeset
|
8 |
#include "beremiz.h" |
03cf08190ac4
Fixed header files inclusion in CIA402 node template file
Laurent Bessard
parents:
2118
diff
changeset
|
9 |
#include "iec_types_all.h" |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
10 |
|
2094
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2092
diff
changeset
|
11 |
#include "accessor.h" |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
12 |
#include "POUS.h" |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
13 |
|
2034 | 14 |
IEC_INT beremiz__IW%(location)s_0; |
15 |
IEC_INT *__IW%(location)s_0 = &beremiz__IW%(location)s_0; |
|
16 |
||
17 |
%(MCL_headers)s |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
18 |
|
2059
b74955d211c7
fixed multiple cia402 instance symbol collision
Edouard Tisserant
parents:
2045
diff
changeset
|
19 |
static IEC_UINT __InactiveMask = 0x4f; |
b74955d211c7
fixed multiple cia402 instance symbol collision
Edouard Tisserant
parents:
2045
diff
changeset
|
20 |
static IEC_UINT __ActiveMask = 0x6f; |
b74955d211c7
fixed multiple cia402 instance symbol collision
Edouard Tisserant
parents:
2045
diff
changeset
|
21 |
static IEC_UINT __PowerMask = 0x10; |
b74955d211c7
fixed multiple cia402 instance symbol collision
Edouard Tisserant
parents:
2045
diff
changeset
|
22 |
static IEC_BOOL __FirstTick = 1; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
23 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
24 |
typedef enum { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
25 |
__Unknown, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
26 |
__NotReadyToSwitchOn, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
27 |
__SwitchOnDisabled, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
28 |
__ReadyToSwitchOn, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
29 |
__SwitchedOn, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
30 |
__OperationEnabled, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
31 |
__QuickStopActive, |
2077 | 32 |
__FaultReactionActive, |
33 |
__Fault, |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
34 |
} __CIA402NodeState; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
35 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
36 |
typedef struct { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
37 |
%(entry_variables)s |
2077 | 38 |
__CIA402NodeState state; |
39 |
axis_s* axis; |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
40 |
} __CIA402Node; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
41 |
|
2136
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
42 |
#define AXIS_UNIT_TO_USER_UNIT(param, type, name)\ |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
43 |
(IEC_##type)(param) * __CIA402Node_%(location)s.axis->name##RatioDenominator / __CIA402Node_%(location)s.axis->name##RatioNumerator |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
44 |
#define USER_UNIT_TO_AXIS_UNIT(param, type, name)\ |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
45 |
(IEC_##type)(param * __CIA402Node_%(location)s.axis->name##RatioNumerator / __CIA402Node_%(location)s.axis->name##RatioDenominator) |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
46 |
|
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
47 |
#define DEFAULT_AXIS_UNIT_TO_USER_UNIT(param) AXIS_UNIT_TO_USER_UNIT(param, LREAL,) |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
48 |
#define DEFAULT_USER_UNIT_TO_AXIS_UNIT(param) USER_UNIT_TO_AXIS_UNIT(param, DINT,) |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
49 |
#define TORQUE_AXIS_UNIT_TO_USER_UNIT(param) AXIS_UNIT_TO_USER_UNIT(param, LREAL, Torque) |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
50 |
#define TORQUE_USER_UNIT_TO_AXIS_UNIT(param) USER_UNIT_TO_AXIS_UNIT(param, INT, Torque) |
2091
d964dbc2c7b0
Adding support for extracting ActualVelocity from CIA402 nodes PDOs
Laurent Bessard
parents:
2088
diff
changeset
|
51 |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
52 |
static __CIA402Node __CIA402Node_%(location)s; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
53 |
|
2034 | 54 |
%(extern_located_variables_declaration)s |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
55 |
|
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
56 |
%(fieldbus_interface_declaration)s |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
57 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
58 |
int __init_%(location)s() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
59 |
{ |
2118
c317b1aaf920
Fixed bug when using real axis and simulated axis at the same time (got the same index)
Laurent Bessard
parents:
2104
diff
changeset
|
60 |
__FirstTick = 1; |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2036
diff
changeset
|
61 |
%(init_entry_variables)s |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
62 |
*(__CIA402Node_%(location)s.ModesOfOperation) = 0x08; |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
63 |
return 0; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
64 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
65 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
66 |
void __cleanup_%(location)s() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
67 |
{ |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
68 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
69 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
70 |
void __retrieve_%(location)s() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
71 |
{ |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
72 |
IEC_UINT statusword_inactive = *(__CIA402Node_%(location)s.StatusWord) & __InactiveMask; |
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
73 |
IEC_UINT statusword_active = *(__CIA402Node_%(location)s.StatusWord) & __ActiveMask; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
74 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2036
diff
changeset
|
75 |
if (__FirstTick) { |
2118
c317b1aaf920
Fixed bug when using real axis and simulated axis at the same time (got the same index)
Laurent Bessard
parents:
2104
diff
changeset
|
76 |
*__IW%(location)s_0 = __MK_Alloc_AXIS_REF(); |
c317b1aaf920
Fixed bug when using real axis and simulated axis at the same time (got the same index)
Laurent Bessard
parents:
2104
diff
changeset
|
77 |
__CIA402Node_%(location)s.axis = __MK_GetPublic_AXIS_REF(*__IW%(location)s_0); |
c317b1aaf920
Fixed bug when using real axis and simulated axis at the same time (got the same index)
Laurent Bessard
parents:
2104
diff
changeset
|
78 |
__CIA402Node_%(location)s.axis->NetworkPosition = %(slave_pos)d; |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2036
diff
changeset
|
79 |
%(init_axis_params)s |
2118
c317b1aaf920
Fixed bug when using real axis and simulated axis at the same time (got the same index)
Laurent Bessard
parents:
2104
diff
changeset
|
80 |
%(fieldbus_interface_definition)s |
2045 | 81 |
__FirstTick = 0; |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2036
diff
changeset
|
82 |
} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2036
diff
changeset
|
83 |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
84 |
// CIA402 node state computation |
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
85 |
__CIA402Node_%(location)s.state = __Unknown; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
86 |
switch (statusword_inactive) { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
87 |
case 0x00: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
88 |
__CIA402Node_%(location)s.state = __NotReadyToSwitchOn; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
89 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
90 |
case 0x40: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
91 |
__CIA402Node_%(location)s.state = __SwitchOnDisabled; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
92 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
93 |
case 0x0f: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
94 |
__CIA402Node_%(location)s.state = __FaultReactionActive; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
95 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
96 |
case 0x08: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
97 |
__CIA402Node_%(location)s.state = __Fault; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
98 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
99 |
default: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
100 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
101 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
102 |
switch (statusword_active) { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
103 |
case 0x21: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
104 |
__CIA402Node_%(location)s.state = __ReadyToSwitchOn; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
105 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
106 |
case 0x23: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
107 |
__CIA402Node_%(location)s.state = __SwitchedOn; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
108 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
109 |
case 0x27: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
110 |
__CIA402Node_%(location)s.state = __OperationEnabled; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
111 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
112 |
case 0x07: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
113 |
__CIA402Node_%(location)s.state = __QuickStopActive; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
114 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
115 |
default: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
116 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
117 |
} |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
118 |
if (__CIA402Node_%(location)s.state == __Unknown) { |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
119 |
return; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
120 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
121 |
|
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
122 |
// Default variables retrieve |
2096
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
123 |
__CIA402Node_%(location)s.axis->CommunicationReady = *(__CIA402Node_%(location)s.StatusWord) != 0; |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
124 |
__CIA402Node_%(location)s.axis->ReadyForPowerOn = __CIA402Node_%(location)s.state == __SwitchedOn || __OperationEnabled; |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
125 |
__CIA402Node_%(location)s.axis->PowerFeedback = __CIA402Node_%(location)s.state == __OperationEnabled; |
2136
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
126 |
__CIA402Node_%(location)s.axis->ActualPosition = DEFAULT_AXIS_UNIT_TO_USER_UNIT(*(__CIA402Node_%(location)s.ActualPosition)); |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
127 |
__CIA402Node_%(location)s.axis->ActualVelocity = DEFAULT_AXIS_UNIT_TO_USER_UNIT(*(__CIA402Node_%(location)s.ActualVelocity)); |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
128 |
__CIA402Node_%(location)s.axis->ActualTorque = TORQUE_AXIS_UNIT_TO_USER_UNIT(*(__CIA402Node_%(location)s.ActualTorque)); |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
129 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
130 |
// Extra variables retrieve |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
131 |
%(extra_variables_retrieve)s |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
132 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
133 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
134 |
void __publish_%(location)s() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
135 |
{ |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
136 |
IEC_BOOL power = ((*(__CIA402Node_%(location)s.StatusWord) & __PowerMask) > 0) && __CIA402Node_%(location)s.axis->Power; |
2034 | 137 |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
138 |
// CIA402 node state transition computation |
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
139 |
switch (__CIA402Node_%(location)s.state) { |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
140 |
case __SwitchOnDisabled: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
141 |
*(__CIA402Node_%(location)s.ControlWord) = (*(__CIA402Node_%(location)s.ControlWord) & ~0x87) | 0x06; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
142 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
143 |
case __ReadyToSwitchOn: |
2034 | 144 |
case __OperationEnabled: |
145 |
if (!power) { |
|
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
146 |
*(__CIA402Node_%(location)s.ControlWord) = (*(__CIA402Node_%(location)s.ControlWord) & ~0x8f) | 0x07; |
2034 | 147 |
break; |
148 |
} |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
149 |
case __SwitchedOn: |
2034 | 150 |
if (power) { |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
151 |
*(__CIA402Node_%(location)s.ControlWord) = (*(__CIA402Node_%(location)s.ControlWord) & ~0x8f) | 0x0f; |
2034 | 152 |
} |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
153 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
154 |
case __Fault: |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2041
diff
changeset
|
155 |
*(__CIA402Node_%(location)s.ControlWord) = (*(__CIA402Node_%(location)s.ControlWord) & ~0x8f) | 0x80; |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
156 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
157 |
default: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
158 |
break; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
159 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
160 |
|
2136
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
161 |
// CIA402 node modes of operation computation according to axis motion mode |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
162 |
switch (__CIA402Node_%(location)s.axis->AxisMotionMode) { |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
163 |
case mc_mode_cst: |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
164 |
*(__CIA402Node_%(location)s.ModesOfOperation) = 0x0a; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
165 |
break; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
166 |
case mc_mode_csv: |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
167 |
*(__CIA402Node_%(location)s.ModesOfOperation) = 0x09; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
168 |
break; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
169 |
default: |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
170 |
*(__CIA402Node_%(location)s.ModesOfOperation) = 0x08; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
171 |
break; |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
172 |
} |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
173 |
|
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
174 |
// Default variables publish |
2136
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
175 |
*(__CIA402Node_%(location)s.TargetPosition) = DEFAULT_USER_UNIT_TO_AXIS_UNIT(__CIA402Node_%(location)s.axis->PositionSetPoint); |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
176 |
*(__CIA402Node_%(location)s.TargetVelocity) = DEFAULT_USER_UNIT_TO_AXIS_UNIT(__CIA402Node_%(location)s.axis->VelocitySetPoint); |
71fdfd4a12a3
Added support for using CIA402 motion mode csp, csv and cst
Laurent Bessard
parents:
2128
diff
changeset
|
177 |
*(__CIA402Node_%(location)s.TargetTorque) = TORQUE_USER_UNIT_TO_AXIS_UNIT(__CIA402Node_%(location)s.axis->TorqueSetPoint); |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
178 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
179 |
// Extra variables publish |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2082
diff
changeset
|
180 |
%(extra_variables_publish)s |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
diff
changeset
|
181 |
} |