-
Notifications
You must be signed in to change notification settings - Fork 0
/
StarLib.fun
181 lines (171 loc) · 7.18 KB
/
StarLib.fun
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{REDUND_ERROR} FUNCTION EuclideanModuloFLT : REAL (*Implements Euclidean Modulo*)
VAR_INPUT
Dividend : REAL; (*Modulo Dividend*)
Divisor : REAL; (*Modulo Divisor*)
END_VAR
END_FUNCTION
{REDUND_ERROR} FUNCTION EuclideanModuloINT : INT (*Implements Euclidean Modulo*) (*$GROUP=User,$CAT=User,$GROUPICON=User.png,$CATICON=User.png*)
VAR_INPUT
Dividend : INT; (*Modulo Dividend*)
Divisor : INT; (*Modulo Divisor*)
END_VAR
END_FUNCTION
FUNCTION_BLOCK slStarCalcTarget (*Synchronous function block that calculates the position of the sync positions*)
VAR_INPUT
TargetIndex : USINT; (*Index to generate a position for*)
PeriodCount : USINT; (*Number of periods to monitor*)
Enable : BOOL; (*Calculate when true*)
StarwheelPosition : {REDUND_UNREPLICABLE} REAL; (*Position of the starwheel in degrees*)
StarwheelVelocity : {REDUND_UNREPLICABLE} REAL; (*Velocity of the starwheel in degrees per second*)
Parameters : REFERENCE TO slStarCalcTargetParType; (*Calculation parameters*)
END_VAR
VAR_OUTPUT
Valid : BOOL; (*Position is valid*)
TrakPos : REAL; (*Position on the trak*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarCalcTargetInternalType; (*Internal data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarPocketSync (*Synchronize a shuttle with a pocket*)
VAR_INPUT
TargetIndex : USINT; (*Index to generate a position for*)
PeriodCount : USINT; (*Number of periods to monitor*)
Enable : BOOL; (*Enable syncing to the pocket*)
Axis : {REDUND_UNREPLICABLE} McAxisType; (*Shuttle to sync with pocket*)
Sync : BOOL; (*Synchronize on rising edge*)
Parameters : REFERENCE TO slStarPocketSyncParType; (*Pocket Sync Parameters*)
StarwheelPosition : REAL; (*Position of the starwheel in degrees*)
StarwheelVelocity : REAL; (*Velocity of the starwheel in degrees per second*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*Function Block is busy and must continue to be called*)
Active : BOOL; (*The function block is active and ready for sync*)
InSync : BOOL; (*The shuttle is in synchronization with the target position*)
Done : BOOL; (*The shuttle is through the starwheel*)
TargetPosition : REAL; (*The current target position*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarPocketSyncInternalType; (*Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarSync (*Star synchronization*)
VAR_INPUT
Sector : REFERENCE TO McSectorType; (*Sector for starwheel*)
Assembly : REFERENCE TO McAssemblyType;
ProcessPointStart : REFERENCE TO McProcessPointType; (*Process point at the start of the sync*)
Enable : BOOL; (*Enable starwheel*)
SkipPockets : BOOL; (*Skip pockets when true*)
DisablePockets : BOOL; (*Disable configured pockets when true*)
StarwheelPosition : {REDUND_UNREPLICABLE} REAL; (*Position of the starwheel in degrees*)
StarwheelVelocity : {REDUND_UNREPLICABLE} REAL; (*Velocity of the starwheel in degrees per second*)
Parameters : REFERENCE TO slStarSyncParType; (*Queue parameters*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*The function block is busy and must continue to be called*)
ReadyForStart : BOOL; (*The function block is ready for starwheel movement*)
Active : BOOL; (*Starwheel is active*)
Handle : UDINT; (*Starwheel internal data handle*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarSyncInternalType; (*Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarRecovery (*Recover shuttles in the starwheel*)
VAR_INPUT
Sector : REFERENCE TO McSectorType; (*Sector for starwheel*)
Assembly : REFERENCE TO McAssemblyType;
Parameters : REFERENCE TO slStarRecoveryParType; (*Starwheel recovery parameters*)
Handle : UDINT; (*Starwheel internal data handle*)
Enable : BOOL; (*Enable recovery process*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*The function block is busy and must continue to be called*)
ReadyForStart : BOOL; (*The function block is ready for starwheel movement*)
Done : BOOL; (*Recovery is complete*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarRecoveryInternalType; (*Internal Data*)
StarInternal : REFERENCE TO slStarSyncInternalType; (*Star Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarGetShuttle (*Get the shuttle in a starwheel that is between two positions*)
VAR_INPUT
TrakPositionStart : REAL; (*Start position to look for the shuttle*)
TrakPositionEnd : REAL; (*End position to look for the shuttle*)
Handle : UDINT; (*Handle of the star sync to evaluate*)
Enable : BOOL; (*Execute on a rising edge*)
END_VAR
VAR_OUTPUT
Valid : BOOL; (*The shuttle and position are valid*)
ShuttlePresent : BOOL; (*A shuttle is present between the two positions*)
Axis : McAxisType; (*Shuttle Axis*)
Position : REAL; (*Target position of the shuttle*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarGetShuttleInternalType; (*Internal Data*)
StarInternal : REFERENCE TO slStarSyncInternalType; (*Star Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarDiag (*Star diagnostics*)
VAR_INPUT
Handle : UDINT; (*Starwheel handle*)
Enable : BOOL; (*Enable outputting diagnostics*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*The function block is busy and must continue to be called*)
Valid : BOOL; (*The Diagnostic data is valid*)
Diag : slStarDiagType; (*Diagnostic information*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarDiagInternalType; (*Internal Handle*)
StarInternal : REFERENCE TO slStarSyncInternalType; (*Star Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarDiagLastStateError (*Get the last state before an error*)
VAR_INPUT
Handle : UDINT; (*Starwheel handle*)
Enable : BOOL; (*Enable capturing the last state before an error*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*The function block is busy and must continue to be called*)
Valid : BOOL; (*The Diagnostic data is valid*)
LastStates : slStarDiagStateType; (*Last states recorded before an error*)
ErrorIDs : slStarDiagErrorIDType; (*Error IDs recorded on the last error*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarDiagLastStateInternalType; (*Internal Handle*)
StarInternal : REFERENCE TO slStarSyncInternalType; (*Star Internal Data*)
END_VAR
END_FUNCTION_BLOCK
FUNCTION_BLOCK slStarDiagStateTrace (*Trace the starwheel states*)
VAR_INPUT
Handle : UDINT; (*Starwheel handle*)
Enable : BOOL; (*Enable capturing the last state before an error*)
END_VAR
VAR_OUTPUT
Busy : BOOL; (*The function block is busy and must continue to be called*)
Valid : BOOL; (*The State data is valid*)
StateData : slStarDiagStateTraceStatesType; (*State trace*)
Error : BOOL; (*An error occurred*)
ErrorID : DINT; (*ID of the error that occurred*)
END_VAR
VAR
Internal : slStarDiagStateTraceInternalType; (*Internal Handle*)
StarInternal : REFERENCE TO slStarSyncInternalType; (*Star Internal Data*)
END_VAR
END_FUNCTION_BLOCK