Professional Documents
Culture Documents
0 - FB UFM V5 (TwinCat 2 Und 3) - EN
0 - FB UFM V5 (TwinCat 2 Und 3) - EN
Platform TwinCat-2
Platform TwinCat-3
Copyright
Date: 08/03/18
Copyright by
Promess Montage- und Prüfsysteme GmbH
Nunsdorfer Ring 29
D-12277 Berlin
Federal Republic of Germany
1 Introduction ............................................................................................................................................. 3
2 General Use of Function Modules ........................................................................................................ 4
3 Parallel Operation ................................................................................................................................... 4
3.1 UFM_CycleStart ................................................................................................................................ 5
3.2 UFM_GetMoveParams ...................................................................................................................... 5
3.3 UFM_Home........................................................................................................................................ 6
3.4 UFM_Jog ........................................................................................................................................... 6
3.5 UFM_Move ........................................................................................................................................ 6
3.6 UFM_ReadMeasuredValues ............................................................................................................. 7
3.7 UFM_ReadMeasuredValuesExt ........................................................................................................ 7
3.8 UFM_ReadPartId ............................................................................................................................... 8
3.9 UFM_ReadUser ................................................................................................................................. 8
3.10 UFM_ReadValueSources .................................................................................................................. 9
3.11 UFM_ReadVariables ......................................................................................................................... 9
3.12 UFM_ResetError .............................................................................................................................. 10
3.13 UFM_ReadVariablesExt .................................................................................................................. 10
3.14 UFM_SelectProgram ....................................................................................................................... 10
3.15 UFM_SelectSignalSource ................................................................................................................ 11
3.16 UFM_SetKeyboardLock ................................................................................................................... 11
3.17 UFM_SetMoveParams .................................................................................................................... 12
3.18 UFM_SetUserInputs ........................................................................................................................ 12
3.19 UFM_GetUserOutputs ..................................................................................................................... 12
3.20 UFM_Station .................................................................................................................................... 13
3.21 UFM_Wheel ..................................................................................................................................... 15
3.22 UFM_WritePartId ............................................................................................................................. 15
3.23 UFM_WriteUser ............................................................................................................................... 15
3.24 UFM_WriteValueSources ................................................................................................................ 16
3.25 UFM_WriteVariables ........................................................................................................................ 16
3.26 UFM_WriteVariablesExt .................................................................................................................. 17
3.27 UFM_SetPiezoState ........................................................................................................................ 18
4 Data Types and Constants ..................................................................................................................19
4.1 UFM_Loglevel (Constants) ............................................................................................................. 19
4.2 UFM_AnalogComparisonOperator (ENUM) .................................................................................... 19
4.3 UFM_AnalogTestDirection (ENUM) ................................................................................................ 19
4.4 UFM_DataSample (STRUCT) ......................................................................................................... 20
4.5 UFM_IoDataArray (ALIAS) .............................................................................................................. 20
4.6 UFM_MovementParameters (STRUCT) ......................................................................................... 21
4.7 UFM_MoveMode (ENUM) ............................................................................................................... 21
4.8 UFM_OverloadComparisonOperator (ENUM) ................................................................................. 22
4.9 UFM_SignalSource (ENUM)............................................................................................................ 22
4.10 UFM_StationStatus (STRUCT)........................................................................................................ 23
4.11 UFM_UserRights (STRUCT) ........................................................................................................... 24
5 Appendix ...............................................................................................................................................25
5.1 Appendix A – Error List .................................................................................................................... 25
5.2 Appendix B : Value Sources ............................................................................................................ 27
1
5.3 Appendix C – Demo Program .......................................................................................................... 31
2
Introduction
1 Introduction
The UFM-5 library allows users to easily control one or more UFM-5 NC stations
made by PROMESS using a PLC on the TwinCAT 3 platform from Beckhoff
Automation. In addition to providing basic functionality (loading and running user
programs created on a PC, movement commands, various types of data transfer),
the library also supports many other special functions (including status queries,
user login via PLC).
// ...
(* Start of homing
*)
ufmHome(Execute := true);
3
General Use of Function Modules
With the exception of the special UFM_Station module, all other function modules
follow the pattern known from Beckhoff:
• Modules are activated by a rising slope at the Execute input in idle state
• Next, the module changes to active status: The Busy output remains set until
the operation has been successfully completed – in which case the Done output
will be set – or an error or timeout occurs. In the latter case, the Error output is set
and the error is issued at the ErrorId output (see Appendix A – Error List)
• After terminating, all modules issue the time required for execution at the
LastExecutionTime output (or until aborting).
• All modules have a Timeout input that overwrites the default timeout. Default
values: UFM_CycleStart and UFM_Home 2 minutes, UFM_Move 3 minutes,
otherwise 5 seconds. After the timeout period elapses, execution will be stopped –
only UFM_Jog and UFM_Wheel are not halted by a timeout.
3 Parallel Operation
Thus if you receive local timeout errors, you should activate the modules serially so
that they do not block each other. Note here that the order of providing (internal)
access to the field bus is independent of the activation order and depends instead
on the order of calls made by active modules in the PLC cycle.
4
Parallel Operation
3.1 UFM_CycleStart
Outputs
3.2 UFM_GetMoveParams
This function module gets the current parameter values for jogging, handwheel and
target positioning. To change the parameters, we recommend first retrieving them
using UFM_GetMoveParams, modifying them as required, and then writing them
back using UFM_SetMoveParams.
Type Description
Outputs
5
Parallel Operation
3.3 UFM_Home
3.4 UFM_Jog
This function module starts jog mode. After activation, the module remains active
until both direction parameters are set to FALSE. The direction parameters can be
changed during execution, but both must not be set simultaneously to TRUE.
3.5 UFM_Move
This function module moves the spindle to a configured value. The default values
are used for this purpose (V=10mm/s, overload=10% of nominal load) but these
can be overwritten using UFM_SetMoveParams. Each time this function module is
activated, these values are automatically reset to their defaults.
6
Parallel Operation
3.6 UFM_ReadMeasuredValues
Outputs
3.7 UFM_ReadMeasuredValuesExt
Outputs
7
Parallel Operation
3.8 UFM_ReadPartId
The first two part IDs, referred to as segments here, are maximum 20 characters
long. The third part ID can have up to 80 characters.
Outputs
3.9 UFM_ReadUser
This function module reads the currently logged in user together with his rights.
Type Description
Outputs
8
Parallel Operation
3.10 UFM_ReadValueSources
This function module reads up to seven value sources. (See Appendix B : Values
Sources)
Outputs
3.11 UFM_ReadVariables
Outputs
9
Parallel Operation
3.12 UFM_ResetError
Confirms acknowledged errors in the control by setting the Reset Bit, as long as ok
and NOK are high. If there is no error confirm, when the module is activated, the
module terminate advance (without error)
3.13 UFM_ReadVariablesExt
Import up to 64 varaiables.
Note for the execution speed: each 7 variables can be read internally at the same
time.
Value range: 1 - 64
Count BYTE 1 Number of variables to be read.
Value range: 1 - 64
Ausgänge
Data ARRAY[1..64] Data that has been read. Attention: The
OF REAL indexes of the output array are
correspondig to the indexes of the
variables
3.14 UFM_SelectProgram
This function module selects the program to be executed. As a side effect, the
contents of the current variable will be reset.
10
Parallel Operation
3.15 UFM_SelectSignalSource
This function module determines one of three signal sources for a specific type of
signal source.
The actual values of the signal sources can be read by the station status.
3.16 UFM_SetKeyboardLock
This function module sets or removes a keyboard lock. If the keyboard lock is
active, all movements that can be started using PC software will be blocked.
11
Parallel Operation
3.17 UFM_SetMoveParams
This function module sets the parameters for jogging, handwheel and target
positioning.
3.18 UFM_SetUserInputs
This function module writes 32-bit data to be processed in a user program. Note:
Data written in a user program can be read using UFM_Station.Status.
3.19 UFM_GetUserOutputs
12
Parallel Operation
3.20 UFM_Station
The UFM_Station function module is not used to perform a specific operation but
instead acts as a link between the application modules and the NC station. A
module of the UFM_Station type is declared for each station. Next, this is assigned
to the mapped memory area for the field bus IO data, and the various application
modules are directly linked to it:
// ...
After initialization, the module can be called to query the current status of the NC
station.
Furthermore, UFM_Station can also be used to write log files directly from PLC.
For this, the corresponding inputs must be configured (see table) and the module
must be called during each PLC cycle. Example:
ufmStation(
LogFileName := 'C:\Temp\UfmLog.txt',
LogNetId := '192.168.170.110.1.1',
LogLevel := LOGLEVEL_DEBUG
);
13
Parallel Operation
Outputs
14
Parallel Operation
3.21 UFM_Wheel
This function module activates the handwheel function. If the handwheel is active,
no other movements can be activated. The standard values are used for this
purpose (V=10mm/s, overload=10% of nominal load). These parameters can be
modified using UFM_SetMoveParams, but after activation these are automatically
reset to the default values.
3.22 UFM_WritePartId
This function module writes a part ID. There are three part IDs, whereby the first
two each have max. 20 characters. The third part ID can have up to 80 characters.
3.23 UFM_WriteUser
15
Parallel Operation
3.24 UFM_WriteValueSources
This function module is used to write up to seven value sources. - Note that not all
value sources are writeable. Attempting to write to a non-writeable value source
will lead to an ERR_TIMEOUT_REMOTE error.
3.25 UFM_WriteVariables
16
Parallel Operation
3.26 UFM_WriteVariablesExt
Writes up to 64 variables
Note for the execution speed: each 7 variables can be read internally at the same
time.
Inputs
Import up to 64 varaiables.
Note for the execution speed: each 7 variables can be read internally at the same
time.
Value range: 1 - 7
Outputs
Data ARRAY[1..64] Data that has been read. Attention: The
OF REAL indexes of the output array are
correspondig to the indexes of the
variables
17
Parallel Operation
3.27 UFM_SetPiezoState
This function can be used to avoid for example the Reset state at program
change.
Attention
A boosted drift of the piezo signal might occur if the amplifier is not set to Reset
mode.
Please note that the state can differ to the last set state, because the state can be
set by the UFM for example by Program Start or the Jog function.
18
Data Types and Constants
This function module determines the extent of the log file to be written. See input
LogLevel of UFM_Station module.
This function module specifies the operator to be used for checking the termination of a target positioning.
ancoGreaterOrEqual >=
ancoLessOrEqual <=
This function module is used to specify the test direction when quitting a target positioning in analog mode.
tdDown
tdUp
19
Data Types and Constants
20
Data Types and Constants
This function module specifies the parameters for the target positioning, jog and
handwheel functions.
This function module determines the movement mode for UFM_Move and
UFM_Wheel
modePosition Move: If the Move function is being used, the movement first has to
be completely defined before commencing with the movement.
modeAnalog Move: This function is identical to positioning but it stops when the
signal limit is reached.
Handwheel: Operation is identical to Analog Move with the
21
Data Types and Constants
ocoGreaterOrEqual >= x
ocoLessOrEqual <= x
sstPosition Position
sstForce Force
sstSlope Slope
sstSlope_2 Slope 2
22
Data Types and Constants
Current status of NC station. This function module is used for the output Status of
UFM_Station.
23
Data Types and Constants
PiezoOperationalState BOOL Current state of the piezo output set by the function
UFM_SetPiezoState. (Can be used for diagnostic
purpose)
This function module defines the permission levels for a logged in user of UFM-5.
24
Appendix
5 Appendix
ERR_NO_ERROR 0 No error.
ERR_IO_DATA_CHANGED_WHILE_BUSY 4 The IO data range of the assigned station was changed while
the application module was active.
ERR_TIMEOUT_REMOTE 6 The timeout period for the operation has expired after
starting the (internal) handshake with the NC station. Assign
a larger timeout value to the application module.
ERR_TIMEOUT_LOCAL 7 The timeout period for the operation has expired before
starting the (internal) handshake with the NC station. The
likely cause of error is that too many application modules are
being used at the same time and that these are blocking
each other. Ensure that the application modules are
activated successively in an appropriate manner. (For more
on this, refer to the section Parallel Operation)
25
Appendix
ERR_CYCLE_ERROR 27 The program cyce or the single program steps could not be
executed. Some of the possible causes include an overload
or emergency off. Be sure to check the status of the station
module for more information on the cause of error.
ERR_DB_HEALTHY_MISSING 28 At cycle start the flag "DB_Healthy" was not set by the PC
software. This flag is requested at cycle start to prevent the
possible loss of data.
26
Appendix
Signal IOs
VSRC8_NULL 0
VSRC8_POSITION 1
VSRC8_FORCE 2
VSRC8_TIME 3
VSRC8_VIN0 4
VSRC8_VIN1 5
VSRC8_VIN2 6
VSRC8_VIN3 7
Free
VSRC8_SLOPE 9
VSRC8_SLOPE2 10
VSRC8_LIVEIN 11
VSRC8_LIVEOUT 12
VSRC8_VOUT0 13
VSRC8_VOUT1 14
VSRC8_UNUSED_SIO 15
Gauging Values
VSRC8_GVAR00_X 16
VSRC8_GVAR00_Y 17
VSRC8_GVAR00_STATUS 18
VSRC8_GVAR01_X 19
VSRC8_GVAR01_Y 20
VSRC8_GVAR01_STATUS 21
VSRC8_GVAR02_X 22
VSRC8_GVAR02_Y 23
VSRC8_GVAR02_STATUS 24
VSRC8_GVAR03_X 25
VSRC8_GVAR03_Y 26
VSRC8_GVAR03_STATUS 27
VSRC8_FIRST_GVAR 16
VSRC8_LAST_GVAR 63
27
Appendix
Variables
VSRC8_VAR00 64
VSRC8_LAST_VOLATILE_VAR 121
VSRC8_FIRST_NONVOLATILE_VAR 122
VSRC8_VAR63 127
VSRC8_FIRST_VAR 64
VSRC8_LAST_VAR 127
VSRC8_NUM_VARS 64
VSRC8_NUM_VOLATILE_VARS 6
User Inputs
VSRC8_USER_IN0 128
VSRC8_USER_IN15 143
VSRC8_FIRST_USER_IN 128
VSRC8_LAST_USER_IN 143
VSRC8_NUM_USER_IN 16
User Outputs
VSRC8_USER_OUT0 144
VSRC8_USER_OUT15 159
VSRC8_FIRST_USER_OUT 144
VSRC8_LAST_USER_OUT 159
VSRC8_NUM_USER_OUT 16
Move
VSRC8_MOVE_POS 160
VSRC8_MOVE_SPEED 161
VSRC8_MOVE_OVERLOAD 162
VSRC8_MOVE_CONFIG 163
VSRC8_MOVE_SIGNAL 164
VSRC8_MOVE_WHEEL_RATIO 165
VSRC8_MOVE_ACCEL 166
Step Parameters
VSRC8_SIGNAL_LIMIT 167
VSRC8_POS_TARGET 168
VSRC8_POS_SPEED 169
VSRC8_DELAYTIME 170
28
Appendix
Acquisition Information
VSRC8_ACQ_MINX_X 171
VSRC8_ACQ_MINX_Y 172
VSRC8_ACQ_MAXX_X 173
VSRC8_ACQ_MAXX_Y 174
VSRC8_ACQ_MINY_X 175
VSRC8_ACQ_MINY_Y 176
VSRC8_ACQ_MAXY_X 177
VSRC8_ACQ_MAXY_Y 178
VSRC8_ACQ_MINY2_X 179
VSRC8_ACQ_MINY2_Y2 180
VSRC8_ACQ_MAXY2_X 181
VSRC8_ACQ_MAX2Y_Y2 182
VSRC8_ACQ_VIOLATION_UL_VALID 183
VSRC8_ACQ_VIOLATION_UL_X 184
VSRC8_ACQ_VIOLATION_UL_Y 185
VSRC8_ACQ_VIOLATION_LL_VALID 186
VSRC8_ACQ_VIOLATION_LL_X 187
VSRC8_ACQ_VIOLATION_LL_Y 188
VSRC8_ACQ_DELTA_X 189
Trigger
VSRC8_TRIGGERS_DONE 190
VSRC8_TRIGGER0_POS 191
VSRC8_TRIGGER1_POS 192
VSRC8_TRIGGER2_POS 193
VSRC8_TRIGGER3_POS 194
VSRC8_TRIGGER4_POS 195
VSRC8_TRIGGER5_POS 196
VSRC8_TRIGGER6_POS 197
Tara
VSRC8_TARA_SIO_FORCE 204
VSRC8_TARA_SIO_TIME 205
VSRC8_TARA_SIO_VIN0 206
VSRC8_TARA_SIO_VIN1 207
VSRC8_TARA_SIO_VIN2 208
VSRC8_TARA_SIO_VIN3 209
Step Information
VSRC8_STEP_INITIAL_ABSOLUTE_POS 210
VSRC8_STEP_ABORT_CONDITION 211
29
Appendix
VSRC8_STEP_PREPOSITION_SIGNAL 212
VSRC8_STEP_TRESHOLD_SIGNAL 213
VSRC8_STEP_TRESHOLD_POS 214
VSRC8_STEP_CONTROL_TIME 215
VSRC8_STEP_CONTROL_POS 216
VSRC8_FILTER_FORCE 220
VSRC8_FILTER_VIN0 221
VSRC8_FILTER_VIN1 222
VSRC8_FILTER_VIN2 223
VSRC8_FILTER_VIN3 224
VSRC8_FILTER_FIRST 220
VSRC8_FILTER_LAST 224
VSRC8_HOME_POSITION 230
Basic Information
VSRC8_FALSE 240
VSRC8_TRUE 241
VSRC8_PRG_NUMBER 242
VSRC8_STEP 243
VSRC8_MOTOR_CURRENT 244
VSRC8_CYCLETIME 245
VSRC8_DRIVE_RUNTIME 246
VSRC8_STATUS_OK 247
VSRC8_STATUS_NOK 248
VSRC8_VOLATILE_CYCLES 250
VSRC8_NONVOLATILE_CYCLES 251
VSRC8_OK_CYCLES 252
VSRC8_NOK_CYCLES 253
VSRC8_COMPENSATION 254
30
Appendix
For the TwinCat 3 platform in the following demo program the array
initialization has to be adjusted by encircled squared brackets.
(*
Demo program for the UFM-5 PLC library for the TwinCat-2/3 platforms.
Declaration part.
*)
PROGRAM PRG_Demo
VAR
(* UFM station proxy. Declare one instance for each UFM station you work with.
Each instance needs to be assigned its own IO variables (see below).
*)
ufmStation : UFM_Station;
(* Connected IO variables
*)
(* todo! - currently using globals of the same name instead
*
UfmInData AT%I* : UFM_IoDataArray;
UfmOutData AT%Q* : UFM_IoDataArray;
*)
(* UFM POU's for different tasks
*)
ufmHome : UFM_Home;
ufmSelectProgram : UFM_SelectProgram;
ufmWritePartId : UFM_WritePartId;
ufmWriteVars : UFM_WriteVariables;
ufmUserInput : UFM_SetUserInputs;
ufmCycleStart : UFM_CycleStart;
ufmReadMeasuredValues : UFM_ReadMeasuredValues;
31
Appendix
(*
Demo program for UFM-5 library for the TwinCat-2/3 platforms.
Implementation part.
*)
CASE state OF
(* Initialization
*)
0 : (* Assign IO variables to UFM station proxy. Optionally configure logging output of the library.
*)
ufmStation(
InDataPtr := ADR(UfmInData),
OutDataPtr := ADR(UfmOutData),
LogFileName := 'C:\Temp\UfmLog.txt',
LogNetId := '192.168.170.110.1.1',
LogLevel := UFM_LOGLEVEL_TRACE
);
(* Assign the POU's for the respective use cases to the station
proxy. (Needs to be done only once, not for each activation.)
*)
ufmHome(StationPtr := ADR(ufmStation));
ufmSelectProgram(StationPtr := ADR(ufmStation));
ufmWritePartId(StationPtr := ADR(ufmStation));
ufmWriteVars(StationPtr := ADR(ufmStation));
ufmUserInput(StationPtr := ADR(ufmStation));
ufmCycleStart(StationPtr := ADR(ufmStation));
ufmReadMeasuredValues(StationPtr := ADR(ufmStation));
(* Start homing
*)
ufmHome(
(* Don't forget to reset Execute to FALSE before the next activation:
*)
Execute := TRUE,
(* Overwrite the default timeout value of 2 minutes
*)
Timeout := T#10S
);
state := 1;
(* Homing
*)
1 : (* Activated POU's need to be invoked each cycle:
*)
ufmHome();
IF ufmHome.Error THEN
ufmError := ufmHome.ErrorId;
ELSIF ufmHome.Done THEN
(*
Start user program selection, if no program has been
selected yet. We check this via the station proxy's
Status output. To have the station update its Status
output, we have to invoke the station POU first.
*)
ufmStation();
IF ufmStation.Status.CurrentProgram <> 1 THEN
ufmSelectProgram(Execute := TRUE, ProgramNo := 1);
state := 2;
ELSE
32
Appendix
(*
Skip program selection, directly start writing all three segments of the part id in a loop
*)
ufmWritePartId(
Execute := TRUE,
PartIdIndex := currentPartIdSegment,
Value := partIdSegments[currentPartIdSegment]
);
state := 3;
END_IF
END_IF
33
Appendix
END_IF
(* Writing variables
*)
4 : ufmWriteVars();
IF ufmWriteVars.Error THEN
ufmError := ufmWriteVars.ErrorId;
ELSIF ufmWriteVars.Done THEN
(*
Start writing user input (16 bit)
*)
ufmUserInput(Execute := TRUE, Value := 42);
state := 5;
END_IF
(* Writing user input
*)
5 : ufmUserInput();
IF ufmUserInput.Error THEN
ufmError := ufmUserInput.ErrorId;
ELSIF ufmUserInput.Done THEN
(*
Start user program. Not in single-step mode, but
full cycle execution.
*)
ufmCycleStart(Execute := TRUE, SingleStep := FALSE);
state := 6;
END_IF
34
Appendix
END_IF
(* Done, no errors
*)
100 :
;
END_CASE
(* Have the station proxy update its logging and status output.
Switch off logging, if some logging error is detected (invalid path,
missing rights, ...)
*)
IF state > 0 THEN
ufmStation();
IF ufmStation.LoggingErrorId > 0 THEN
ufmStation.LogFileName := '';
END_IF
END_IF
35
Index
UFM_ReadMeasuredValuesExt .......................... 7
D
UFM_ReadPartId ................................................. 8
Demo Program ...................................................32
UFM_ReadUser ................................................... 8
E UFM_ReadValueSources .................................... 9
Error List .............................................................26 UFM_ReadVariables............................................ 9
U UFM_SelectProgram ......................................... 11
UFM_SetKeyboardLock ..................................... 12
UFM_AnalogComparisonOperator .....................20
UFM_SetMoveParams....................................... 13
UFM_AnalogTestDirection..................................20
UFM_SetUserInputs .......................................... 13
UFM_CycleStart ................................................... 5
UFM_SignalSource ............................................ 23
UFM_DataSample ..............................................21
UFM_Station ...................................................... 14
UFM_GetMoveParams ......................................... 5
UFM_StationStatus ............................................ 24
UFM_Home .......................................................... 6
UFM_UserRights ............................................... 25
UFM_IoDataArray ...............................................21
UFM_Wheel ....................................................... 16
UFM_Jog .............................................................. 6
UFM_WriteUser ................................................. 16
UFM_Loglevel .....................................................20
UFM_WriteValueSources .................................. 17
UFM_Move ........................................................... 6
UFM_WriteVariables .......................................... 17
UFM_MovementParameters ..............................22
UFM_MoveMode ................................................22 V
UFM_OverloadComparisonOperator ..................23 Value Sources .................................................... 28
UFM_ReadMeasuredValues ................................ 7
36
37
PROMESS. For more efficiency.