Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

UFM V5 PLC Library

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

UFM-5 PLC Library for TwinCat-3 Platform

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).

In order to be used, the library requires a properly configured field bus


(EtherCAT,Profibus, Profinet, Modbus/TCP) between the NC station and PLC. The
IO data mapped to PLC variables (16 DWORDs in each direction) are assigned to
a station module (UFM_Station) that establishes a link between the individual
functional modules at the user level and the NC station. Here, the interfaces of the
various application modules follow the common Execute-Busy-Done model from
Beckhoff.

Accordingly, the basic means of using the UFM-5 library is as follows:

UfmInData AT%I* : UFM_IoDataArray; // mapped field bus data


UfmOutData AT%I* : UFM_IoDataArray;
ufmStation : UFM_Station;
ufmHome : UFM_Home; // Example with module
// "Homing"
// ...

(* Assignment of IO data to station module


*)
ufmStation
InDataPtr := ADR(UfmInData),
OutDataPtr := ADR(UfmInData),
);

(* Assigns an application module to the station FB


*)
ufmHome(StationPtr := ADR(ufmStation));

// ...

(* Start of homing
*)
ufmHome(Execute := true);

Appendix C contains a code listing of an extended executable demo program.

3
General Use of Function Modules

2 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)

• While a module is active (busy), it must be called in each PLC cycle.

• Some modules (UFM_CycleStart, UFM_Home, UFM_Move) can be aborted,


thus when the Abort input is set to active status, the operation will be aborted and
ERR_ABORTED will appear as an error message. UFM_Jog is properly quit by
resetting both direction inputs. UFM_Wheel is properly quit by setting the
Terminate input. In all other cases, the inputs are ignored after activation.

• 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

Some application modules can be operated in parallel but others cannot. In


general, only one data transfer module (variables etc.) and one control module
(movement, program execution etc.) can access the field bus at any given time.
You can still nonetheless activate several modules simultaneously or successively,
but a module that, after being activated, does not immediately receive access to
the field bus will change to a special waiting status. If the timeout elapses during
this time, execution will be ended and ERR_TIMEOUT_LOCAL will be issued. In
contrast to ERR_TIMEOUT_REMOTE, this error indicates that execution was
blocked by other modules in the UFM library.

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

This function module executes a single step or complete cycle of a previously


selected program.

Inputs Type Default Value Description

ProgramNo UINT 0 If the received value is not equal to 0, the


function module will check whether this
program is actually currently selected. Value
range: 0 - 1023.

SingleStep BOOL FALSE Single-step mode

Abort BOOL FALSE Allows an abort during execution. Must not


be set at the same time as being activated.
After aborting execution, the module issues
an ERR_ABORTED error.

Outputs

OK BOOL Part IO flag set from station

NOK BOOL Part IO flag set from station

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

Parameters UFM_MovementParameters After execution, this contains the current


parameter values of the movement
commands.

5
Parallel Operation

3.3 UFM_Home

This function module executes a homing.

Inputs Type Default Value Description

Abort BOOL FALSE Can be used during execution to abort the


homing procedure. Must not be set at the
same time as being activated. After
aborting execution, the module issues an
ERR_ABORTED error.

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.

The movement parameters should be set prior to each activation (see


UFM_SetMoveParams), since these are reset after executing a movement. To jog,
the movement mode is set automatically to Positioning (compare with
UFM_MoveMode)

Inputs Type Default Value Description

Up BOOL FALSE Movement upwards

Down BOOL FALSE Movement downwards

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.

Inputs Type Default Value Description

Abort BOOL FALSE Can be used during execution to abort the


target positioning. Must not be set at the
same time as being activated. After
aborting execution, the module issues an
ERR_ABORTED error.

6
Parallel Operation

3.6 UFM_ReadMeasuredValues

This function module reads a measurement value.

Inputs Type Default Value Description

Index BYTE 1 Index of measurement value to be read.


Value range: 1 to 16

Outputs

Sample UFM_DataSample Read measurement value

3.7 UFM_ReadMeasuredValuesExt

Lesen von bis zu 16 Messwerten.

Inputs Type Standardwert Beschreibung

FirstIndex BYTE 1 Index of measurement value to be read.


Value range: 1 to 16

Count BYTE 1 Count of the measurement value to be


read. Range: 1 to 16. Increasing the count
parameter increases the execution time.

Outputs

Samples ARRAY[1..16] OF Read measurement values. Attention: The


UFM_DataSample indexes of the output array are
correspondig to the indexes of the
measurments.

7
Parallel Operation

3.8 UFM_ReadPartId

This function module reads one or more part IDs.

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.

Inputs Type Default Value Description

ReadSegment_1 BOOL Specifies whether the first segment is to


be read or not. - Note: For reasons of
execution speed, segments that are not
required by the PLC will not be read.

ReadSegment_2 BOOL Specifies whether the second segment is


to be read or not.

ReadSegment_3 BOOL Specifies whether the third segment is to


be read or not.

Outputs

Segment_1 STRING First segment that was read

Segment_2 STRING Second segment that was read

Segment_3 STRING Third segment that was read

3.9 UFM_ReadUser

This function module reads the currently logged in user together with his rights.

Type Description

Outputs

UserName STRING User name

UserRights UFM_UserRights Rights of this user

8
Parallel Operation

3.10 UFM_ReadValueSources

This function module reads up to seven value sources. (See Appendix B : Values
Sources)

Inputs Type Default Value Description

FirstIndex BYTE 0 Index of first value source to be read.


Value range: 0 - 255

Count BYTE 1 Number of value sources to be read.


Value range: 1 - 7

Outputs

Data ARRAY[0..6] Data that has been read


OF REAL

3.11 UFM_ReadVariables

This function module reads in up to 7 variables.

Inputs Type Default Value Description

FirstIndex BYTE 1 Index of first variable to be read.


Value range: 1 - 64

Count BYTE 1 Number of variables to be read.


Value range: 1 - 7

Outputs

Data ARRAY[0..6] Data that has been read


OF REAL

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)

Inputs Type Default Value Description


Execute bool false Quittieren eines
quittierungspflichtigen Fehlers

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.

Eingänge Typ Standardwert Beschreibung


FirstIndex BYTE 1 Index of first variable to be read.

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.

Inputs Type Default Value Description

ProgramNo UINT 0 Value range: 0 – 1023.


Valid program numbers range from 1–
1023. By entering 0 as a program number,
any currently selected programs will be
cleared.

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.

Inputs Type Default Value Description

Index BYTE 1 Index of the signal source to be chosen.


Value range: 1 - 3

Source UFM_SignalSource sstForce Type of signal source to be used

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.

Inputs Type Default Value Description

SetLock BOOL TRUE Specifies whether the keyboard lock can


be set or removed.

11
Parallel Operation

3.17 UFM_SetMoveParams

This function module sets the parameters for jogging, handwheel and target
positioning.

To modify parameters, we recommend first getting them using


UFM_GetMoveParams, modifying them as required and setting them using
UFM_SetMoveParams. Note here that parameters must be rewritten prior to each
movement command since, for safety reasons, they are reset after the movement
is executed.

Inputs Type Default Value Description

Parameters UFM_MovementParameters The parameters to be used


for the following movement.

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.

Inputs Type Default Value Description

Value WORD 0 Data to be written

3.19 UFM_GetUserOutputs

Read 16 bits of data written in the user program on the PC side.


Note: The data are also readable via UFM Station.Status. However, it is important
to ensure that the UFM_Station module is also called so that it can update its
status output.

Outputs Type Default Value Description


Value WORD 0 Read data

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:

UfmInData AT%I* : UFM_IoDataArray;


UfmOutData AT%Q* : UFM_IoDataArray;
ufmStation : UFM_Station;
ufmHome : UFM_Home;

// ...

(* Assignment of IO data to station module


*)
ufmStation(
InDataPtr := ADR(UfmInData),
OutDataPtr := ADR(UfmOutData)
);

(* Assigns an application module to the station FB


*)
ufmHome(StationPtr := ADR(ufmStation));

The IO data can naturally only be assigned to a UFM_Station module.

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

Inputs Type Default Description


Value

InDataPtr POINTER TO zero Pointer for the mapped input data


UFM_IoDataArray

OutDataPtr POINTER TO zero Pointer for the mapped output data


UFM_IoDataArray

LogFileName○ T_MaxString (empty) Path name of the log file to be written.


(Be sure to check the Windows file
permissions.)

LogNetId T_AmsNetId (leer) AMS NetID of computer where log file is


to be written. Typically, this is the AMS
NetID of the computer where TwinCAT
Runtime is running.

LogLevel BYTE 1 Determines the size of the log file. Value


range LOGLEVEL_TRACE (0) –
LOGLEVEL_ERRORS (3)

Outputs

Status UFM_StationStatus Current status of NC station

StatusValid BOOL Specifies whether the status output is


currently valid. (For instance, it is not
valid if the IO data has not been
assigned yet.)

LoggingError BOOL Specifies whether an error has occurred


while writing the log file.

LoggingErrorId UDINT Type of error while writing the log file.


Reference:
http://infosys.beckhoff.com/index.php?c
ontent=../content/1031/tcplclib_tc2_syst
em/27021598138499979.html&id=

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.

Inputs Type Default Value Description

Terminate BOOL FALSE This is set during execution to quit the


handwheel function.

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.

Inputs Type Default Value Description

PartIdIndex BYTE 1 Specifies which part ID is to be written.


Value range: 1 – 3.

Value STRING (empty) Value of part ID to be written

3.23 UFM_WriteUser

This function module logs in a user (without authentification). As of version 5.11,


this function is available in the UFM PC software.

Inputs Type Default Value Description

UserName STRING(16) (empty) Freely selectable name of the user to


be logged in.

UserRights UFM_UserRights (all rights) Rights of the user

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.

(See Appendix B : Values Sources)

Inputs Type Default Value Description

FirstIndex BYTE 0 Index of first value source to be written.


Value range: 0 - 255

Count BYTE 1 Number of value sources to be written.


Value range: 1 - 7

Data ARRAY [0..6] Contains the data to be written.


OF REAL

3.25 UFM_WriteVariables

This function module writes up to 7 variables

Inputs Type Default Value Description

FirstIndex BYTE 0 Index of first variable to be written. Value


range: 1 - 64

Count BYTE 1 Number of variables to be written. Value


range: 1 - 7

Data ARRAY Contains the variable values to be written.


[0..6] OF
REAL

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

FirstIndex BYTE 1 Index of first variable to be written. Value


range: 1 - 64
Count BYTE 1 Number of variables to be written. Value
range: 1 - 64
Data ARRAY Contains the variable values to be written.
[1..64]
OF Attention: The indexes of the input array
REAL correspond to the indexes of the variables

Import up to 64 varaiables.
Note for the execution speed: each 7 variables can be read internally at the same
time.

Inputs Type Default Value Description


FirstIndex BYTE 1 Index of first variable to be written. Value
range: 1 - 64

Count BYTE 1 Number of variables to be read.

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.

– A rising flank sets the piezo pre amplifier in operate mode,


– A falling flank sets the piezo pre amplifier in Reset mode, except a program
is running, a Homing is done or Jog respectively Handwheel is avtive.
– If the status bit iss et when program end is reached, the Reset mode is not
set by the UFM.

Attention
A boosted drift of the piezo signal might occur if the amplifier is not set to Reset
mode.

The current state can be read by the “UFM_StationStatus.PiezoOperational”

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.

The execution of the module can be done in parallel to other modules.

Inputs Type Default Value Description


Operational BOOL PiezoOp Input

18
Data Types and Constants

4 Data Types and Constants

4.1 UFM_Loglevel (Constants)

This function module determines the extent of the log file to be written. See input
LogLevel of UFM_Station module.

Constants Value Description

UFM_LOGLEVEL_TRACE 0 Log everything. Not recommended for production environments.

UFM_LOGLEVEL_DEBUG 1 Medium extent

UFM_LOGLEVEL_WARNING 2 Only warnings and errors. Recommended for production


S environments.

UFM_LOGLEVEL_ERRORS 3 Only errors

4.2 UFM_AnalogComparisonOperator (ENUM)

This function module specifies the operator to be used for checking the termination of a target positioning.

ancoGreaterOrEqual >=

ancoLessOrEqual <=

4.3 UFM_AnalogTestDirection (ENUM)

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

4.4 UFM_DataSample (STRUCT)

This represents a read measurement value.

Field Data Type Description

New BOOL New (vs. Old)

Ok BOOL IO (vs. NIO)

Missed BOOL Missed (vs. Captured)

UpperLimitViolated BOOL Upper limit violated

LowerLimitViolated BOOL Lower limit violated

StartPosition REAL Position (Start)

EndPosition REAL Position (End)

UpperLimit REAL Upper limit

Value REAL Force value / analog value

LowerLimit REAL Lower limit

Position REAL Position (capture)

4.5 UFM_IoDataArray (ALIAS)

• This function module assigns a mapped memory range to


UFM_Station
• UFM_IoDataArray : ARRAY[1..16] OF DWORD;

20
Data Types and Constants

4.6 UFM_MovementParameters (STRUCT)

This function module specifies the parameters for the target positioning, jog and
handwheel functions.

Field Data Type Description

Position REAL Target position (not required for handwheel


and jog)

Speed REAL Speed

Overload REAL Overload value

Signal REAL Target signal for analog mode

WheelRatio REAL Handwheel ratio (default: 10)

Acceleration REAL Acceleration

OverloadSignalSource UFM_SignalSource Signal source for overload detection

OverloadComparisonOperator UFM_OverloadComparison Comparison operators used for overload


Operator detection

AnalogSignalSource UFM_SignalSource Signal source for analog mode

Mode UFM_MoveMode Movement mode

AnalogComparisonOperator UFM_AnalogComparison Comparison operators used for analog mode


Operator

AnalogTestDirection UFM_AnalogTestDirection Test direction for analog mode

4.7 UFM_MoveMode (ENUM)

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.

Handwheel: If a parameter has to be changed for handwheel mode


(e.g., sensitivity, speed), UFM_MovementParameters also have to
be written.

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

exception that the positioning commands come from the


handwheel.

4.8 UFM_OverloadComparisonOperator (ENUM)

This function module is used to specify the overload comparison operator.

ocoGreaterOrEqual >= x

ocoLessOrEqual <= x

ocoGreaterOrEqualAbs >= ABS(x)

4.9 UFM_SignalSource (ENUM)

This function module is used to specify a signal source

sstNone (Initial value)

sstPosition Position

sstForce Force

sstStepRuntime Step runtime

sstVirtualInput_1 Virtual input 1

sstVirtualInput_2 Virtual input 2

sstVirtualInput_3 Virtual input 3

sstVirtualInput_4 Virtual input 4

sstSlope Slope

sstSlope_2 Slope 2

sstLiveInput Live input

22
Data Types and Constants

4.10 UFM_StationStatus (STRUCT)

Current status of NC station. This function module is used for the output Status of
UFM_Station.

Field Data type Description

SignalLimitTooEarly BOOL Signal limit too early

SignalLimitNotReached BOOL Signal limit not reached

MeasuredValueNotCaptured BOOL Measured value not captured

MeasuredValueUpperLimitViolated BOOL Upper limit of measured value violated

MeasuredValueLowerLimitViolated BOOL Lower limit of measured value violated

UpperEnvelopeCurveViolated BOOL Curve of upper envelope violated

LowerEnvelopeCurveViolated BOOL Curve of lower envelope violated

CurveMemoryOverrun BOOL Curve memory overrun

TriggerFunctionError BOOL Error in trigger function

NcModuleError BOOL NC module error

NcSetOkManually BOOL NC status set manually to OK

NcSetNokManually BOOL NC status set manually to NOK

SensorOffsetError BOOL Sensor offset error

Overload BOOL Overload

HomingError BOOL Error caused abort during homing

EmergencyOff BOOL Emergency off

StartSignalLost BOOL Start signal lost

NoProgramLoaded BOOL No NC program has been loaded

MaxPositionReached BOOL Maximum position has been reached

NcModuleReset BOOL NC module reset

ConverterTrip BOOL Converter has tripped

AdcOverload BOOL ADC overload

CtNetCouplerError BOOL Promess bus error

23
Data Types and Constants

MotorOverload BOOL Motor overload

SignalSource_1_Value REAL Value of signal source 1

SignalSource_2_Value REAL Value of signal source 2

SignalSource_3_Value REAL Value of signal source 3

UserOutput WORD Output set from PC program for PLC processing.

CurrentProgram WORD Currently selected program

ReferenceRequest BOOL Station indicates that a homing request was


received

ReadyToStart BOOL Program is ready to start (Quit & DB_Healthy)

CurveDataReady BOOL Curve data for UDP library ready to collect

PiezoOperational BOOL OP_PIEZO state bit. When set, the piezo


preamplifier is in Operate state.

PiezoOperationalState BOOL Current state of the piezo output set by the function
UFM_SetPiezoState. (Can be used for diagnostic
purpose)

PC_LIFE BOOL UFM Software loaded

4.11 UFM_UserRights (STRUCT)

This function module defines the permission levels for a logged in user of UFM-5.

Field Data Type Description

RIGHT_ADMIN BIT Administration

RIGHT_PRG_EDIT BIT Edit the program

RIGHT_STEP_EDIT BIT Edit the program step

RIGHT_PRG_LOAD BIT Load the program

RIGHT_MOVE BIT Movement

RIGHT_CONFIG BIT Configuration

24
Appendix

5 Appendix

5.1 Appendix A – Error List

Error Value Description

ERR_NO_ERROR 0 No error.

ERR_STATION_UNASSIGNED 1 Attempt to activate an application module without prior


assignment to a station FB

ERR_STATION_CHANGED_WHILE_BUSY 2 Re-assignment of a station to an application module while


this one is active.

ERR_IO_DATA_UNASSIGNED 3 Attempt to activate an application module assigned to a


station whose IO data range has not yet been assigned.

ERR_IO_DATA_CHANGED_WHILE_BUSY 4 The IO data range of the assigned station was changed while
the application module was active.

ERR_ABSTRACT_INSTANCE 5 Attempt to instantiate UFM_AbstractUseCase.

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)

ERR_INVALID_FIRSTINDEX 8 An invalid value was assigned to the Index or FirstIndex input


of an application module. Check the value using the
documentation of the relevant application module.

ERR_INVALID_COUNT 9 The Count input of an application module was assigned to an


invalid value. Check the value using the documentation of
the relevant application module.

ERR_INVALID_PARTIDINDEX 10 An invalid value was assigned to the PartIdIndex input in an


instance of UFM_WritePartId. Valid values are are 1 to 3.

ERR_PARTID_TOO_LONG 11 The character string assigned to the Value input of


UFM_WritePartId is too long. The string can have 20
characters for PartIdIndex <= 2 or 80 characters for
PartIdIndex = 3.

ERR_READ_AT_LEAST_ONE_ID_SEGMENT 12 At least one of the inputs ReadSegment_n from


UFM_ReadPartId must be TRUE.

ERR_HOMING_ERROR 13 The NC station has signalized that it has aborted while


homing. Be sure to check the status of the station module for
more information on the cause of error.

ERR_ILLEGAL_PRG_NO 14 The value of the ProgramNo input from UFM_SelectProgram


or UFM_CycleStart is larger than 1023. Valid program
numbers are 1-1023. For UFM_CycleStart, the value 0
means "Do not validate program number", for
UFM_SelectProgram it means "Unload".

25
Appendix

ERR_PRG_NOT_LOADABLE 15 The chosen program could not be loaded.

ERR_WRONG_PRG_LOADED 16 The program number transferred to UFM_CycleStart does


not correspond to the number of the currently loaded
program. (To switch of the check, transfer program number
0.)

ERR_REF_REQ 17 The NC station has unexpectedly received a homing request


and this is effectively equivalent to aborting the operation due
to an error. 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_ABORT_AT_START 18 An abortable application module was activated while its Abort


input was already set to TRUE.

ERR_INVALID_JOG_INPUTS 19 Both direction inputs (Up, Down) of an UFM_Jog module


were set to TRUE.

ERR_ABORTED 20 An abortable application module was aborted through


application code that set the Abort input to TRUE.

ERR_INVALID_SIGNAL_SRC_INDEX 21 The Index input of an UFM_SelectSignalSource module was


not between 1 and 3.

ERR_INVALID_SIGNAL_SRC 22 An invalid value was transferred to a parameter of type


UFM_SignalSource and possibly within a value of type
UFM_MovementParameters

ERR_INVALID_OVERLOADCOMPOP 23 An invalid value was transferred to a parameter of type


UFM_OverloadComparisonOperator and possibly within a
value of type UFM_MovementParameters

ERR_INVALID_MOVEMODE 24 An invalid value was transferred to a parameter of type


UFM_MoveMode and possibly within a value of type
UFM_MovementParameters.

ERR_INVALID_ANALOGCOMPOP 25 An invalid value was transferred to a parameter of type


UFM_AnalogComparisonOperator and possibly within a
value of type UFM_MovementParameters.

ERR_INVALID_ANALOGCOMPARISONDIR 26 An invalid value was transferred to a parameter of type


UFM_AnalogTestDirection and possibly within a value of
type UFM_MovementParameters.

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.

ERR_INVALID_COUNT_FOR_FIRSTINDEX 29 The FirstIndex and Count inputs of an application module


together result in a violation of the valid index range. Please
refer to the documentation on the inputs of the relevant
application module.

26
Appendix

5.2 Appendix B : Value Sources

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

Home Position/ Zero Point

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

5.3 Appendix C – Demo Program

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;

(* Error signaled by UFM library


*)
ufmError : UDINT := ERR_NO_ERROR;
(* State of this demo program
*)
state : BYTE := 0;
(* Various (sample data, fake inputs etc.)
*)
abortButtonPressed : BOOL := FALSE;
currentPartIdSegment : BYTE := 1;
partIdSegments : ARRAY[1..3] OF STRING :=
'ABCD',
'01234567890123456789',
'01234567890123456789ABCDEF'
;
testWriteData : ARRAY [0..6] OF REAL := 0, 1, 2, 3.14, 4, 5, 6;
actualValue : REAL;
END_VAR

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

(* Selecting the user program


*)
2 : ufmSelectProgram();
IF ufmSelectProgram.Error THEN
ufmError := ufmSelectProgram.ErrorId;
ELSIF ufmSelectProgram.Done THEN
(*
Start writing all three segments of the part id in
a loop
*)
ufmWritePartId(
Execute := TRUE, PartIdIndex := currentPartIdSegment,
Value := partIdSegments[currentPartIdSegment]
);
state := 3;
END_IF
(* Writing the part id segments
*)
3 : ufmWritePartId();
IF ufmWritePartId.Error THEN
ufmError := ufmWritePartId.ErrorId;
ELSIF ufmWritePartId.Done THEN
(*
All three parts written?
*)
IF currentPartIdSegment >= 3 THEN
(*
Start writing seven contiguous variables
from index 3
*)
ufmWriteVars(
Execute := TRUE, FirstIndex := 3,
Count := 7, Data := testWriteData
);
state := 4;
ELSE
(* Write next segment
*)
currentPartIdSegment := currentPartIdSegment + 1;
ufmWritePartId(Execute := FALSE);
ufmWritePartId(
Execute := TRUE,
PartIdIndex := currentPartIdSegment,
Value := partIdSegments[currentPartIdSegment]
);
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

(* POUs that possibly involve axis movements may be aborted with


the 'Abort' input. In this case the POUs will terminate with
ErrorId == ERR_ABORTED
*)
6 : ufmCycleStart(Abort := abortButtonPressed);
IF ufmCycleStart.Error THEN
ufmError := ufmCycleStart.ErrorId;
ELSIF ufmCycleStart.Done THEN
(*
Start reading a mesaured value
*)
ufmReadMeasuredValues(Execute := TRUE, Index := 1);
state := 7;
END_IF

(* Reading the measured value


*)
7 : ufmReadMeasuredValues();
IF ufmReadMeasuredValues.Error THEN
ufmError := ufmReadMeasuredValues.ErrorId;
ELSIF ufmReadMeasuredValues.Done THEN
(*
Access data sample properties via the 'Sample' output
*)
IF ufmReadMeasuredValues.Sample.UpperLimitViolated THEN
; (* ... *)
ELSE
actualValue := ufmReadMeasuredValues.Sample.Value;
(* ... *)
END_IF
state := 100;

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.

PROMESS Gesellschaft für


Montage- und Prüfsysteme mbH

Nunsdorfer Ring 29 | D-12277 Berlin


Fon +49 (0)30 / 62 88 72 - 0
Fax +49 (0)30 / 62 88 72 - 59
promess@promessmontage.de

You might also like