Sample programs (from V3.0)

Structure of the application

The application is largely made up of PLCopen function blocks. A selection of function blocks is available, which are equipped with an interface defined by the PLCopen. A number of examples are described below, which provide a good basis for project configuration.

Each example contains the project file, the required axis parameter files and a scope configuration. The axis parameter files must be stored in a folder on the target system. The file path must be adjusted in the global constant "cnst_ParamFilePath" of the project file.

Example 1: Single axis

For TC2: TcPlcMcEx_1.zip

For TC3: TC3_TcPlcMcEx_1.zip

The MC_AxUtiStandardInit_BkPlcMc function block loads the parameters and monitors the pointer addresses. After the data has been loaded successfully, "bParamsEnable" becomes TRUE and the actual axis blocks are called.

MC_AxStandardBody_BkPlcMc internally calls the required function blocks such as MC_AxRtEncoder_BkPlcMc, MC_AxRuntime_BkPlcMc, MC_AxRtFinish_BkPlcMc and MC_AxRtDrive_BkPlcMc. However, if a filter, a pressure regulator, a characteristic curve measurement or similar is required, the individual components must be called instead of MC_AxStandardBody_BkPlcMc.
By using a MC_AxAdsCommServer_BkPlcMc function block the axis can be commanded via the PlcMcManager. The MC_AxParamDelayedSave_BkPlcMc function block saves changes made by the PlcMcManager after a given time (here 10 s).
Via the PlcMcManager you can log onto the target system and actively move the axis.

Example 2: Multi-axis application

For TC2: TcPlcMcEx_2.zip

For TC3: TC3_TcPlcMcEx_2.zip

The example illustrates a configuration with arrays of function blocks and structures. The range of functions corresponds to example 1.

Example 3: Pressure-controlled braking

For TC2: TcPlcMcEx_3.zip

For TC3: TC3_TcPlcMcEx_3.zip

The example shows how the pressure regulator MC_AxCtrlSlowDownOnPressure_BkPlcMc throttles the feed rate of an axis depending on the pressure. In this example, the controller becomes active when the actual pressure exceeds the set pressure. Since the result is transferred via an application code to "fLagCtrlOutput", the controller must be called after the setpoint generator. Otherwise, fLagCtrlOutput would be overwritten by the position controller in MC_AxRuntime_BkPlcMc.
If a command is started in the PlcMcManager with a velocity of 100 mm/s and a position of 500 mm, for example, the scope shows that the pressure increases continuously with increasing position. At a position of 400 mm, the system has reached the set pressure of 50 bar and stops.

Example 5: Move function blocks

For TC2: TcPlcMcEx_5.zip

For TC3: TC3_TcPlcMcEx_5.zip

In this example, various function blocks are used for motion control. If the variable bStart becomes TRUE, the state machine starts the axis with MC_MoveAbsolute_BkPlcMc to the position 500 mm. When the axis has reached the target and the target window conditions are met (in PosRang, in TargetRange for TargetFilterTime and in BrakeDistance), a MC_MoveVelocity_BkPlcMc automatically starts with a velocity of 400 mm/s. This velocity remains active for 5 seconds and is then terminated with MC_Stop_BkPlcMc, so that the axis comes to a standstill. This is followed by a relative movement of 100 mm with MC_MoveRelative_BkPlcMc and a move to position 0.0 mm. Different acceleration and deceleration ramps are used in the different motion profiles.

Example 6: Time ramp generator

For TC2: TcPlcMcEx_6.zip

For TC3: TC3_TcPlcMcEx_6.zip

An axis without encoder cannot be controlled via the standard setpoint generator. For this type of axis, iTcMc_ProfileTimeRamp provides an alternative setpoint generator. If the variable "bUp" or "bDown" is TRUE in the global variables, the axis moves at the specified velocity (here 500 mm/s) to the first limit switch (DigCamP – for positive/ DigCamM – for negative) and then slows down to the corresponding creep velocity. After reaching DigCamPP – for positive/ DigCamMM – for negative the output is deleted.

Example 7: Override and function generator

For TC2: TcPlcMcEx_7.zip

For TC3: TC3_TcPlcMcEx_7.zip

Demonstration of the function block MC_SetOverride_BkPlcMc. Global variables (bOverrideSinusoidal, fOverrideCycleTime, fOverrideMinValue, fOverrideMaxValue) can be used to specify the sequence, the period and the limitations of a signal generator, which modifies the override. Function blocks of type MC_FunctionGeneratorFD_BkPlcMc, MC_FunctionGeneratorTB_BkPlcMc and MC_FunctionGeneratorSetFrq_BkPlcMc are used for generating the override.

Example 8: Digital cam controller

For TC2: TcPlcMcEx_8.zip

For TC3: TC3_TcPlcMcEx_8.zip

The example shows how to control digital cams through an axis and MC_DigitalCamSwitch_BkPlcMc. In the example two cams are activated in TRACK_REF_BkPlcMc (maximum 32). The first cam is activated under three different conditions:
1. from position -1000 mm to 1000 mm and positive direction
2. from position 2000 mm to 3000 mm and positive direction
3. from position 3000 mm to 2500 mm and negative direction
The second cam has only one condition:
1. to be active in positive and negative direction for a time of 1.35 s from position 3000 mm.
In addition to the switching conditions, a cam can also have a switch-on and switch-off delay. For cam 1, the switch-on delay is set to 0.125 s and the switch-off delay is set to 0.250 s. The conditions for switching a cam are specified in CAMSWITCH_REF_BkPlcMc. The output of a cam is specified in OUTPUT_REF_BkPlcMc.
The axis must be commanded via the PlcMcManger (position greater than 3000 mm).

Example 9: Joystick

For TC2: TcPlcMcEx_9.zip

For TC3: TC3_TcPlcMcEx_9.zip

The example demonstrates the use of the function block MC_MoveJoySticked_BkPlcMc. With this function block, the axis is moved in an endless motion at a velocity specified by JoyStick. Joystick is a normalized value between +/-1.0, which, multiplied by the commanded velocity, results in the set velocity.

Example 10: Identification and linearization

For TC2: TcPlcMcEx_10.zip

For TC3: TC3_TcPlcMcEx_10.zip

The example describes the automatic characteristic curve measurement with MC_AxUtiAutoIdent_BkPlcMc and the use of the characteristic curve with MC_AxRtFinishLinear_BkPlcMc. The settings for the automatic characteristic curve measurement are accessible in the PlcMcManger under the LinDef tab and can be found in the structure ST_TcMcAutoIdent.
In the example, you can choose between three different valve simulations using the global variable nTest. A suitable .dat file is loaded according to the selected simulation. The parameters for the characteristic curve measurement are preset in the .dat file as required. Caution: If nTest is switched while the PLC is running, the PlcMcManager must be reconnected. The following scenarios can be selected via nTest:

  1. Only the overlap and velocity ratio is missing
  2. A zero overlap characteristic curve with bend is missing
  3. A characteristic curve with overlap is missing

The variable "bStartAuto" can be used to start MC_AxUtiAutoIdent_BkPlcMc. During the measurement the function block returns Busy, and the already measured characteristic curve is displayed on the LinTab tab.
If the measurement was successful, the characteristic curve can be used by the function block MC_AxRtFinishLinear_BkPlcMc. The characteristic curve is automatically saved and loaded in the .dat file of the axis. The function block MC_AxTableToAsciFile_BkPlcMc is available for exporting the characteristic curve in an ASCII-readable format.

Example 11: Stop function blocks

For TC2: TcPlcMcEx_11.zip

For TC3: TC3_TcPlcMcEx_11.zip

The different ways of stopping an axis are compared here. The example can be started by setting the variable bStart to TRUE.

MC_Stop_BkPlcMc: Executes a stop with preset deceleration parameters. The axis reports ready when the calculated target including target tolerances (in PosRange, in TargetRange for target filter time and in BrakeDistance) has been reached.

MC_EmergencyStop_BkPlcMc: Brakes with preset ramp to standstill.

MC_ImediateStop_BkPlcMc: Sets the set value to zero without ramp.

Example 12: Buffering and blending

For TC2: TcPlcMcEx_12.zip

For TC3: TC3_TcPlcMcEx_12.zip

The basic procedure for buffered movements is explained in FAQ 20. To start the example, the variable bStart must become TRUE. The Scope View shows that there are six movements, which are processed in coupled mode.

Example 13: Filter

For TC2: TcPlcMcEx_13.zip

For TC3: TC3_TcPlcMcEx_13.zip

The example shows the behavior of several filter types and what to consider when using filters.
If all signals with the name "Noisy" are switched off in Scope View, the original signal and the filtered signals can be seen with corresponding offsets. The shape of the signal is retained. The more a signal is filtered, the stronger the phase shift between the original and filtered signal. This phase shift has a direct influence on the controllability of axes and other sections.
If the noisy signals are made visible in the Scope, it can be seen that the noise portion in the signal is considerably lower both through a MC_AxUtiSlidingAverage_BkPlcMc and after a MC_AxUtiPT1_BkPlcMc.

Example 14: Function generator

For TC2: TcPlcMcEx_14.zip

For TC3: TC3_TcPlcMcEx_14.zip

In some applications, a setpoint generator is required to generate sinusoidal, trapezoidal or sawtooth signals. For example, the signals generated with MC_FunctionGeneratorTB_BkPlcMc and MC_FunctionGeneratorFD_BkPlcMc can be transferred to an axis via MC_AxRtSetExtGenValues_BkPlcMc.

Example 15: Pressure regulator

For TC2: TcPlcMcEx_15.zip

For TC3: TC3_TcPlcMcEx_15.zip

The example shows the reading and scaling of an actual pressure value in the application. A pressure control for an axis with MC_AxCtrlPressure_BkPlcMc is demonstrated.
The application first moves to a position at which a pressure increase is expected via a fast movement. The movement continues at a slower velocity and the controller is activated when the set pressure has been reached.

Example 16: Distributed axis references

For TC2: TcPlcMcEx_16.zip

For TC3: TC3_TcPlcMcEx_16.zip

The example shows the use of a list of POINTER TO Axis_Ref_BkPlcMc. The use of MC_AxAdsPtrArrCommServer_BkPlcMc instead of MC_AxAdsCommServer_BkPlcMc makes it possible to distribute the axis references.

The list must be updated in each cycle. This update must be carried out before calling MC_AxAdsPtrArrCommServer_BkPlcMc.

Sample 17: External setpoint generation

For TC2: TcPlcMcEx_17.zip

For TC3: TC3_TcPlcMcEx_17.zip

The simple sample shows the basic use of a function block of the type MC_AxRtSetGenValues.

Example 18: Locking PlcMcManager

For TC2: TcPlcMcEx_18.zip

For TC3: TC3_TcPlcMcEx_18.zip

It may be necessary to disable PlcMcManager commands such as Jog, MoveAbs or Stop. This can be done in the PLC with MC_AxRtCommandsLocked_BkPlcMc.

Sample 19: External setpoint generation

For TC2: TcPlcMcEx_19.zip

For TC3: TC3_TcPlcMcEx_19.zip

Here, a larger project demonstrates the possibilities of the external setpoint generator.

Example 100: Electronic gearing

For TC2: TcPlcMcEx_100.zip

For TC3: TC3_TcPlcMcEx_100.zip

The example shows how two slave axes can be coupled by an electronic gearing via a master axis (axis 3). The coupling is created and released by MC_GearIn_BkPlcMc and MC_GearOut_BkPlcMc.
It must be ensured that the dynamic parameters of the master and slave are compatible with each other, otherwise the slave cannot follow the master.
To establish the coupling, the master and slave must be in idle state. The coupling can be released during the motion. The master axis moves to the target and the slave axis is stopped when the coupling is released.

Example 101: Electronic cam plate

For TC2: TcPlcMcEx_101.zip

For TC3: TC3_TcPlcMcEx_101.zip

Axes 1 and 2 are coupled to virtual axis 3 via a cam plate. In this example, the coupling parameters for axis 1 are stored in the text file TcPlcMcEx_101_2.txt. For axis 2, the coupling parameters are calculated in function block "FB_CalculateCamTable2". MC_CamTableSelect_BkPlcMc is used to specify the master and slave axis and the cam table. In function block MC_CamIn_BkPlcMc the coupling is generated and the set values for the slave are calculated. If the master axis is moved via the PlcMcManager, the slave axis follows the corresponding cam plate. The coupling is canceled with MC_CamOut_BkPlcMc.

Example 103: Flying gear coupling

For TC2: TcPlcMcEx_103.zip

For TC3: TC3_TcPlcMcEx_103.zip

Demonstration of an activated flying gear coupling with function blocks MC_GearInPos_BkPlcMc and MC_GearOut_BkPlcMc.

Example 104: Synchronization control

For TC2: TcPlcMcEx_104.zip

For TC3: TC3_TcPlcMcEx_104.zip

Demonstration of a synchronization control for a two-axis gantry using a virtual master. Synchronization control is always used where two or more axes have to be controlled in a balanced manner. A virtual master axis is used for generating the set values. The set values are distributed to the slave axes, which add their local position controller. For example, the current position of the virtual master axis is calculated as an average value over the slave axes.
In order to ensure smooth commissioning, it is essential that certain parameters are kept the same. This applies in some cases within the group of slave axes, partly also for the master axis. In "FB_Parameter" this is forced by cyclic copying.

Example 105: Linearization for synchronization control

For TC2: TcPlcMcEx_105.zip

For TC3: TC3_TcPlcMcEx_105.zip

This example demonstrates the characteristic curve determination for a two-axis gantry (see also example 104) with the function blocks MC_AxUtiAutoIdent_BkPlcMc and MC_AxUtiAutoIdentSlave_BkPlcMc.

Sample 106: Flying coupling

For TC2: TcPlcMc_106.zip

For TC3: TC3_TcPlcMcEx_106.zip

Some of the possibilities offered by the flying coupling and uncoupling of an electronic gear unit are illustrated here.