Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Overview

TS5800 | TwinCAT Digital Cam Server

Cam controller overview

The TwinCAT Digital Cam Server realises a fast digital cam controller. The cam controller is installed as an additional option with the TwinCAT system and can subsequently be configured in the TwinCAT System Manager. In addition to basic parameterisation the function of the cam controller can be influenced via the PLC. For example, individual cams can be activated or deactivated, or cam switching positions can be modified.

Configuration facilities

The cam controller can be operated in a dedicated fast task with a separate I/O bus, making it independent of slower PLC or NC cycle times. Configuration without separate I/O bus is also possible, if very short cycle times are not required.

  • Encoder source freely selectable (e.g. NC drive)
  • Cycle time depending on encoder source (e.g. 250 µs)

Optional configuration with separate I/O bus

  • Independent fast digital cam server task with cycle times down to 80 µs
  • Beckhoff Lightbus I/O card with connected encoder and cam outputs

Properties

  • up to 320 outputs (cam tracks)
  • up to 180 cams per output
  • up to 2048 cams overall
  • distance cams (switch-on and switch-off position)
  • time cams (switch-on position and switch-on time)
  • brake cams (special function for machine stop)

Note regarding documentation

All variable and parameter names mentioned in this documentation refer to the English language version of the TwinCAT System Manager. For some variables and parameters the System Manager uses different names with a different language setting and will change some of the identifiers when the user selects a different language. In order to ensure unambiguous reference to this documentation it is advisable to set the language to English before creating a new cam controller. The language is irrelevant for the actual function of the cam controller.


Configuration of the cam controller

The TwinCAT Digital Cam Server is installed as an option with the TwinCAT system. Subsequently a configuration group for the cam controller is available in the TwinCAT System Manager. A new cam controller can be inserted by right-clicking on this group.

The newly inserted cam controller contains two tasks: a fast task for cams output on the I/O bus, and a slower task for calculating the cam switching points. It also includes a logical encoder that monitors the position of the cam controller.

The cycle time is set via the Task tab. The cycle time can be set down to the base time of the TwinCAT system (see System configuration).

The cycle time of the fast cam output task (Cam Group 1 in the image) should be chosen such that at maximum rotational speed a maximum permitted angular error is not exceeded.

Example: At 30 rpm (180 °/s) the maximum permitted angular error for the cam output is 0.2 degrees

CycleTime = PositionError / Velocity

Cycle Time = 0.2° / 180°/s = 0.00111 s

A cam controller cycle time of 1 ms is adequate in this case.

A shorter cycle time may cause significant additional CPU load.

The cycle time of the calculation task (CAM Calc Task in the image) has no effect on output precision. Since this task handles complex calculations, the cycle time should be significantly longer (default: 10 ms).

For cycle times below 1 millisecond two configurations are possible. On the one hand the base time of the TwinCAT system (see real-time configuration) can be reduced to below 1 millisecond. Since the cam controller task can be set down to the base time, this cycle time can also be reduced. Optionally a separate timer can be configured for the cam controller task, in order to reduce the CPU load of the overall system. The Fast Clock option is described in the next section.

Further cam controller parameters

On the Global tab cam independent operating parameters of the cam controller are specified.

Cam Output Groups: Initially the required number of cam groups is specified. A cam group contains 32 digital outputs. The cam controller can be extended to 10 groups, i.e. up to 320 digital outputs (cam tracks).

Fast Clock Handler

The cam controller can be operated with a significantly faster cycle time than other system task (NC, PLC, etc.). The required cam controller cycle time may even be below the base time of the system (typically 1 ms). In this case it may be advisable to provide a dedicated clock generator for the cam controller.

Once the Fast Clock Handler was activated, the cam controller operates outside the TwinCAT task scheduler and is therefore independent of the system base time. The base time of the TwinCAT system is then set to 1 ms, and the cycle time of the cam controller can now be set in the real-time configuration via the Fast Tick interval.

Remark:

The Fast Clock option is not limited to Lightbus I/O cards (FC2000, C1220, C1200). If a (now rarely used) C1200 ISA card is used, the associated option in the configuration dialog must be selected, since this card is managed directly by the cam controller. The card also requires the Fast Clock option.

Firmware version V4.18 or higher is required for a C1220 card.

Safety functions

The safety functions are used to monitor the machine or encoder function. Monitoring is activated as soon as the Coupled signal in the process image is activated by the PLC. If the Coupled signal is not active, the control system assumes that the encoder is mechanical decoupled and therefore also switches off the monitoring.

  • Check Encoder: If monitoring is active, the encoder count is monitored for changes. If the value does not change, the cam controller (in the process image) sets the variable EncoderError. The error can be reset by the PLC via the variable ResetEncoderError, also in the process image.
  • Check Shaft: If monitoring is active, the encoder count is monitored for changes, similar to encoder monitoring. This type of monitoring uses a configurable filter time. An error is indicated in the process image through the variable ShaftError. The error can be reset by the PLC via the variable ResetShaftError, also in the process image.
  • Check Rpm: The stroke count monitoring function monitors the encoder speed for deviation from a value that can be configured here. Monitoring can be filtered with a configurable time.
    - Rpm Check Range: Maximum speed deviation
    - Rpm Check Time: Minimum duration of the speed deviation
    In the event of a fault the cam controller set the variable HPMError in the process image. The error can be reset by the PLC via the variable ResetHPMError, also in the process image.


Cam controller encoder configuration

TS5800 | TwinCAT Digital Cam Server

Encoder configuration

The encoder for the cam controller can be read via a dedicated I/O bus that is operated by the cam controller itself. If the velocity of the standard I/O bus is adequate, the encoder data can also be read by an encoder or a drive at this bus.

Encoder types

The cam controller can operate with encoders with different resolution. The encoder types offered in the selection diagram essentially differ in terms of bit width. An encoder that is not listed can therefore be inserted as a User Defined Encoder, after which the encoder mask must be configured to match the actual bit width (see Global dialog).

Encoder at standard I/O bus

The encoder data word is linked with the alternative cam controller encoder input.

  • Alternative Input: Input for linking the hardware encoder count with the cam controller

The outputs of the encoder process image can optionally be linked with the PLC.

  • Encoder Raw Value: Current encoder count
  • Encoder Value Deg: Current encoder position in degrees. The resolution is [1/10°] if the parameter Use Encoder Precision is set to FALSE and [1/1000 °] if set to TRUE.

The encoder parameterisation is specified in the Global dialog.

II/O Box Address: not required in this case.
The II/O Box Address is required if the cam controller has its own II/O-bus (option with C1200, C1220 or FC2000 card). In this particular case the bus is managed by the cam controller, and the address of the output box must be specified.

Zero Offset: Offset for adjusting the 0 degree position of the encoder.

Inverse: Reverses the direction of rotation of the encoder, if the physical count direction does not match the required direction of rotation.

Encoder Input Mask: The encoder value range is determined via this mask. The maximum encoder count is specified as a hexadecimal value. For example, 0x00000FFF is entered for a 12-bit encoder with overrun at a count of 4095.

Disable Position Rounding : Position rounding is used to adjust different encoder resolutions (e.g. 4096 increments) to the cam controller resolution (e.g. 360 degrees in 1-degree steps). Due to the rounding, the actual cam switching point will be within a window around the specified switching position (e.g. 90 degrees +/- 0.5 degrees).

Rounding can be switched off if it is not required.

Use Encoder Precision: The cam controller operates with a resolution of 1 degree, i.e. 360 steps per revolution, as standard. If a higher resolution is required, the cam controller can be operated with the resolution of the encoder. In this case, 65,536 possible switching points per revolution are available for a 16-bit encoder. (The cam switching positions are still specified in degrees.)

Changing this setting will also change the units of process data. The PLC program may be affected!

Warning:

High-resolution encoders (from around 20 bits) have a very large number of possible switching points. In this case the router memory (see real-time settings) should be expanded to a larger value.

Optional: Encoder at dedicated I/O bus

The cam controller can be assigned a dedicated I/O bus for the cam controller. This particular configuration operates with a Beckhoff Lightbus and requires an I/O card of type C1200, C1220, or FC2000. This option was developed for very short cycle times down to 80 µs and operates with an encoder and a digital 32-bit I/O box.

In many cases such a configuration is no longer necessary today and can be achieved through the standard configuration as described above. In any case, a fast I/O bus such as EtherCAT is required.


Cam configuration

A cam switches a digital output within a certain angle range during a cam encoder revolution. Several cams can be defined for one output, so that the output signal can be switched several times during a revolution.

Three different cams are available. A distance cam (also referred to as position cam) switches on an output at a certain position and switches it off again at a different position. A time cam switches on an output at a certain position and keeps it active for a certain period. A brake cam has a special function during the braking process.

Right-click on Cam Group 1 to insert a new cam.

A dialog box opens, in which the name and type of the cam can be specified.

  • Distance Cam

  • Time Cam

  • Brake Cam

Distance cams

After a distance cam was inserted the parameters can be configured.

  • Start Position: Angle position during an encoder revolution at which a digital output is switched on.
  • Ending Position: Angle position during an encoder revolution at which the digital output is switched off again.
  • Cam Line: Number of the digital output that is switched by this cam. The outputs are numbered starting from 0.
  • Counter Value: This value defines whether the cam is activated during each revolution or only during each n-th revolution. A value of 0 switches the cam off altogether. For a proper function a minimum value of 1 must therefore be specified.
  • Standard Active: The cam is entered in the standard cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (standard if ReverseMode=0).
  • Reverse Active: The cam is entered in the reverse cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (reverse if ReverseMode=1).
  • Dynamic Enabled: The cam controller calculates a velocity-dependent position correction if this parameter is TRUE. At higher velocities the cam therefore switches earlier. The correction can be configured via Preset Time.
  • Preset Time: Rate time for compensating switching times of an actuator connected to an output (integer value in 100 µs steps). The rate time only takes effect when the dynamic function is switched on (Dynamic Enabled).
  • Hysteresis Enabled: not implemented
  • Increments for Hysteresis: not implemented

Time cams

Time cams cannot be configured together with distance or brake cams on the same output. Depending on the switching time and the velocity, only one time cam should be configured per output track.

  • Start Position: Angle position during an encoder revolution at which a digital output is switched on.
  • Duration: Switch-on time of the cam as integer value in 100 µs steps.
  • Cam Line: Number of the digital output that is switched by this cam. The outputs are numbered starting from 0.
  • Counter Value: This value defines whether the cam is activated during each revolution or only during each n-th revolution. A value of 0 switches the cam off altogether. For a proper function a minimum value of 1 must therefore be specified.
  • Standard Active: The cam is entered in the standard cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (standard if ReverseMode=0).
  • Reverse Active: The cam is entered in the reverse cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (reverse if ReverseMode=1).
  • Dynamic Enabled: The cam controller calculates a velocity-dependent position correction if this parameter is TRUE. At higher velocities the cam therefore switches earlier. The correction can be configured via Preset Time.
  • Preset Time: Rate time for compensating switching times of an actuator connected to an output (integer value in 100 µs steps). The rate time only takes effect when the dynamic function is switched on (Dynamic Enabled).
  • Hysteresis Enabled: not implemented
  • Increments for Hysteresis: not implemented

Brake cams

A brake cam has a special function. The allocated output (Cam Line) is initially active during normal operation, as long as the PLC has set the Break Enabled variable allocated to the output track in the process image. To initiate a braking process, the PLC sets Break Enabled to 0. As a result, the output track is switched off at the parameterised angle position.

Brake cams cannot be configured together with distance or time cams on the same output. Only one brake cam can be configured for each output track.

  • Brake Position: Angle position during an encoder revolution, at which a digital output is switched off when the brake is deactivated in the PLC (Break Enabled in the process image)
  • Cam Line: Number of the digital output that is switched by this cam. The outputs are numbered starting from 0.
  • Counter Value: This value defines whether the cam is activated during each revolution or only during each n-th revolution. A value of 0 switches the cam off altogether. For a proper function a minimum value of 1 must therefore be specified.
  • Standard Active: The cam is entered in the standard cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (standard if ReverseMode=0).
  • Reverse Active: The cam is entered in the reverse cam table if this parameter is TRUE.
    The cam controller manages two cam tables. Via the variable ReverseMode in the process image the PLC defines whether the standard cam table or the reverse cam table is active (reverse if ReverseMode=1).
  • Dynamic Enabled: The cam controller calculates a velocity-dependent position correction if this parameter is TRUE. At higher velocities the cam therefore switches earlier. The correction can be configured via Preset Time.
  • Preset Time: Rate time for compensating switching times of an actuator connected to an output (integer value in 100 µs steps). The rate time only takes effect when the dynamic function is switched on (Dynamic Enabled).
  • Hysteresis Enabled: not implemented
  • Increments for Hysteresis: not implemented

Position resolution

Cam start and end positions can be specified with a resolution of 1/1000 degree. However, please note that the cam controller internally operates with two possible resolutions and rounds the defined position to the internal resolution. Depending on the encoder configuration (see parameter Use Encoder Precision) the cam controller operates with 360 steps or with the full encoder resolution (encoder increments per revolution)


Process image of the cam controller

In its process image the cam controller provides input and output variables that can be linked with the PLC. Via this interface the PLC can influence the function of the cam controller and monitor the current status.

Input process image

Via the input process image the PLC can influence the function of the cam controller at runtime. On the PLC side these variables are declared as outputs and linked with the input process image of the cam controller in the System Manager.

  • ToolSafe: not implemented
  • ReverseMode: The cam controller manages two cam tables (standard and reverse). For each cam the table in which it becomes active can be parameterised. Via the variable ReverseMode the PLC can specify which of the two cam tables is used.
  • Coupled: The Coupled signal must be set to TRUE by the PLC in order to activate the monitoring functions of the cam controller. It indicates that the encoder is mechanically coupled and that the monitoring functions are therefore active.
    The calculation of Actual HPM starts as soon as Coupled is set to TRUE. Actual HPM will be initialised with HPM Preset while Coupled is set to FALSE.
  • HPM Preset: Set speed value at constant encoder speed after start-up. This value is mainly required for calculating the time cams and must be set by the PLC before start-up.
    The unit of HPM Preset is [1/min] if the Use Encoder precision encoder parameter is set to FALSE. When high precision is enabled, the unit changes to [1/1000 min]
  • HPM Difference: Maximum speed deviation [rpm] from the set value HPM Preset. A deviation leads to recalculation of the cam table. A value of 0 avoids any automatic recalculation of cams.
  • Reset I/O Errors: Via this variable the PLC can reset an I/O error indicated by the cam controller. To this end a value of 1 is written to the variable and reset to 0 during the next cycle.
  • Reset Encoder Error: Via this variable the PLC can reset an encoder error indicated by the cam controller. To this end a value of 1 is written to the variable and reset to 0 during the next cycle.
  • Reset Shaft Error: Via this variable the PLC can reset a shaft failure (Shaft Error) indicated by the cam controller. To this end a value of 1 is written to the variable and reset to 0 during the next cycle.
  • Reset HPM Error: Via this variable the PLC can reset an HPM error indicated by the cam controller. To this end a value of 1 is written to the variable and reset to 0 during the next cycle.
  • Enable Counters: Via bits 0..4 of the data word one of the five counters is activated (see output process image).
  • Preset Counter 1: Initial value for counter 1.
  • Preset Counter 2: Initial value for counter 2.
  • Preset Counter 3: Initial value for counter 3.
  • Preset Counter 4: Initial value for counter 4.
  • Preset Counter 5: Initial value for counter 5.
  • Max val counter 1: Maximum value for counter 1. After this value the counter changes to 0.
  • Max val counter 2: Maximum value for counter 2. After this value the counter changes to 0.
  • Max val counter 3: Maximum value for counter 3. After this value the counter changes to 0.
  • Max val counter 4: Maximum value for counter 4. After this value the counter changes to 0.
  • Max val counter 5: Maximum value for counter 5. After this value the counter changes to 0.
  • Brake Enabled: Brake enable. The data word is resolved into 32 individual variables for the first 32 output tracks. The variables activate brake enable for output tracks 0 to 31. Brake enable is used in conjunction with brake cams.
    If more than 32 outputs were configured, additional data words (Brake Enabled 1..9) are used.
  • PLC AND Mask: Via the AND mask the PLC can deactivate individual output tracks. A track can only become active, if the associated bit (0..31) has the value 1, otherwise the output is permanently inactive.
    The output tracks can be activated through a PLC program, once the cam encoder has reached its constant speed (HPMpreset). During the start-up or braking phase the PLC program should set the mask to 0, thereby deactivating the output tracks.
    The AND mask has priority over the OR mask. If more than 32 outputs were configured, additional data words (PLC AND Mask 1..9) are used.
  • PLC OR Mask: Via the OR mask the PLC can explicitly activate individual output tracks. A track becomes permanently active, if the associated bit (0..31) has the value 1.
    The AND mask has priority over the OR mask. If more than 32 outputs were configured, additional data words (PLC OR Mask 1..9) are used.

Output process image

  • Actual HPM: Current speed of the cam encoder.
    The unit of Actual HPM is [1/min] if the Use Encoder precision encoder parameter is set to FALSE. When high precision is enabled, the unit changes to [1/1000 min]
    The calculation of Actual HPM starts as soon as Coupled is set to TRUE. Actual HPM will be initialised with HPM Preset while Coupled is set to FALSE.
  • Cams in use: not implemented
  • I/O Errors: This variable is set if the cam controller detects an I/O error.
  • Encoder Error: This variable is set if the cam controller detects an encoder count error. (The encoder value does not change)
  • HPM Error: This variable is set if the cam controller detects an encoder speed deviation.
  • Timeout Rec. 1: Only for special configuration with dedicated Lightbus I/O card. In this case a diagnostic value relating to the card is indicated.
  • Timeout Rec. 2: Only for special configuration with dedicated Lightbus I/O card. In this case a diagnostic value relating to the card is indicated.
  • Counter 1: Count of counter 1. The value is initialised with an initial value specified by the PLC and incremented with each encoder revolution as long as the associated bit of the Enable Counters variable in the input process image is 1.
  • Counter 2: Count of counter 2.
  • Counter 3: Count of counter 3.
  • Counter 4: Count of counter 4.
  • Counter 5: Count of counter 5.
  • Counter ready: The data word is broken down into individual bits. Bits 0 to 4 indicate that the maximum value for counter 1 to 5 was reached.
  • Cam Inputs: Only for special configuration with dedicated Lightbus I/O card. In this case the digital inputs of the connected digital I/O box are indicated here.
  • Cam Output: Current status of the output tracks. The data word is broken down into 32 individual bits that can be linked with the connected digital outputs.
    If more than 32 outputs were configured, additional data words (Cam Output 1..9) are used.


PLC programming of the cam controller

TS5800 | TwinCAT Digital Cam Server

Programming of the cam controller through the PLC

In order to ensure the function of the cam controller, the PLC program must enable the cam controller and individual output tracks. Errors must be monitored and reset if necessary. Optionally, cam parameters (such as switching positions) can also be modified through the PLC program. A PLC library is available for this purpose.

Click here to save the library

Definition of variables for the process image

Input and output variables of the same type are created in the program in order to make the process image of the cam controller available for the PLC program.

VAR_GLOBAL
        (* Digital Cam Server Input Process Image - PLC --> DigitalCamServer *)
        ReverseMode     AT %Q* : UDINT;
        Coupled                 AT %Q* : UDINT;
        HPMPreset       AT %Q* : UDINT;
        HPMDifference   AT %Q* : UDINT;
        ResetIOErrors   AT %Q* : UDINT;
        ResetEncoderError       AT %Q* : UDINT;
        ResetShaftError         AT %Q* : UDINT;
        ResetHPMError   AT %Q* : UDINT;
        BrakeEnabled    AT %Q* : DWORD;
        PlcAndMask      AT %Q* : DWORD;
        PlcOrMask       AT %Q* : DWORD;

        (* Digital Cam Server Output Process Image - DigitalCamServer --> PLC *)
        ActualHPM       AT %I* : UDINT;
        IOerrors                AT %I* : UDINT;
        EncoderError    AT %I* : UDINT;
        ShaftError      AT %I* : UDINT;
        HPMError                AT %I* : UDINT;
        CamInputs       AT %I* : DWORD;
        CamOutput       AT %I* : DWORD;
END_VAR

The process image described here corresponds to a configuration with one output group, i.e. 32 digital outputs. If more than one output group (up to 10) is created, is the process image is extended, involving additional variables. In this case the variables BrakeEnabled, PlcAndMask, PlcOrMask and CamOutput apprehensive be created as an ARRAY.

Once the PLC program is compiled and imported into the TwinCAT System Manager, these variables can be linked with the associated process image variables of the digital cam controller. The PLC program then has access to the content of these variables.

Programming of the cam controller via the process image

In order to activate the cam controller, several steps are required within the PLC program as a minimum:

  1. The required set speed of the cam controller is entered in variable HPMpresest (rpm). This speed serves as the basis for the cam calculation and for monitoring functions and should match the actual speed of the cam encoder.
    The unit of HPM Preset is [1/min] if the Use Encoder precision encoder parameter is set to FALSE. When high precision is enabled, the unit changes to [1/1000 min]
  2. The maximum speed deviation is entered in variable HPMdifference (e.g. 1 rpm). This value is required for monitoring functions and for recalculating the cam switching points.
  3. Output tracks must be activated via variable PlcAndMask as soon as the cam encoder has reached its constant speed. In the simplest case the variable PlcAndMask is set to value 16#FFFFFFF in order to enable all 32 output tracks for the cam controller. (A configuration with more than one output group can have up to 10 PlcAndMask variables (ARRAY), through which up to 320 outputs can be activated.)
  4. If brake cams are used, the associated output tracks are activated by setting the associated bits of the BreakEnabled variables (similar to the PlcAndMask).
  5. As soon as the encoder has reached its constant set speed, the variable Coupled is set to 1, thus enabling monitoring of the cam controller.

PLC library TcDigitalCamServer.lib

The PLC library TcDigitalCamServer.lib contains function blocks for configuring the cam controller through the PLC.

Click here to save the library

Reading and writing of the encoder configuration

Encoder parameters can be read or written with an associated function block. In order to change individual parameter, such as the encoder offset, the encoder dataset should initially be read and written back after a value was changed. Writing cam data causes the recalculation of the digital cam.

The parameter data structure is defined in the library.

TYPE ST_DigitalCamEncoder :
STRUCT
        EncoderID       : UDINT;        (* unique ID of the cam encoder *)
        EncoderType     : UDINT;        (* type of the cam encoder *)
        EncoderName     : STRING(79);
        EncoderRevDir   : UDINT;        (* encoder uses inverted counting direction when TRUE *)
        EncoderBoxAddr  : UDINT;
        EncoderZeroOffset       : UDINT;        (* zero offset of the encoder position in steps of [1/1000 degrees] *)
        EncoderMask     : DWORD; (* encoder bit mask defines the maximum counter value passed to the control system *)
END_STRUCT
END_TYPE

Reading and writing of cam parameters

The parameter dataset for each cam can be read and written. Here too, the complete cam dataset should be read before changing a parameter, such as the switching position, and written back again after the change.

.

The resolution of the position parameters in the data structure below depends on the parameterized encoder resolution. If the Use Encoder Precision parameter in the encoder configuration is set, all position data is defined as [1/1000 degrees]; otherwise as [1 degrees].

The parameter data structure is defined in the library.

TYPE ST_DigitalCamStruct :
STRUCT
        CamID                   : UDINT; (* unique cam ID from 1 to 2048 *)
        CamType                         : UDINT; (* type E_DigitalCamType: 1=distance cam, 2=time cam, 3=brake cam *)
        CamLine                         : UDINT; (* number of cam output 0 to 319 that is cam is active on *)
        PresetTime              : UDINT; (* preset time in steps of [1/10 ms] *)
        Counter                         : UDINT; (* activation counter: 0=inactive, 1=every cycle, 2=every 2nd cycle, etc. *)
        HysteresisInc           : UDINT; (* not supported *)
        StandardActive          : UDINT; (* this cam is active when the standard cam table is activated by the PLC *)
        ReverseActive           : UDINT; (* this cam is active when the reverse cam table is activated by the PLC *)
        DynamicEnabled          : UDINT; (* preset time is used when TRUE *)
        HysteresisEnabled               : UDINT; (* not supported *)
        StartPosition           : UDINT; (* start position of the cam in steps of [1/1000 or 1 degrees] *)
        EndPositionOrDuration   : UDINT; (* end position of distance cams in steps of [1/1000 or 1 degrees]
                                           or duration of time cams in steps of [1 ms] *)
END_STRUCT
END_TYPE

The CamType can be assigned the following values:

TYPE E_DigitalCamType :
(
        CAMTYPE_NONE,   (* undefined cam type *)
        CAMTYPE_DISTANCE,
        CAMTYPE_TIME,
        CAMTYPE_BREAK
);
END_TYPE

Creating and deleting cams

Cams are generally configured in the TwinCAT System Manager. The PLC program should then only change the cam parameterisation. In some cases it may be necessary to create new cams or delete cams through the PLC program. The parameter data structure used here matches the structure during reading and writing of the cam data.

Recalculation of the cam table

The digital cam controller converts all cam parameters within a cam table for fast output. This cam table is calculated for a certain, user-specified velocity and only calculated in the event of deviations from this velocity. Via the function block DCS_CalcCamData the user can specifically initiate recalculation of the cam table and therefore ensure the calculation for a certain velocity level.

Output signals of the function blocks

All function blocks described in this documentation are triggered by a rising edge at the Execute input. The Busy output changes to TRUE to indicate that the execution of the function is in progress. The process is completed when Busy changes back to FALSE. At the same time the Done output indicates that the function was completed successfully. Otherwise the Error output becomes TRUE to indicate an error with the associated error number in ErrorID. Busy, Done and Error are exclusive, only one of the signals can be TRUE at any one time.


Cam controller diagnostics

The cam controller calculates a cam table from all configured cams. The cam table can be displayed via the online dialog of the cam controller for diagnostic purposes.

Diagnostic displays in the online dialog

The upper part of the dialog box shows the current position of the cam encoder in degrees and the current encoder velocity in [rpm]. Several 32-bit binary values are shown below, which can be interpreted as follows. For a single output group with 32 tracks each bit corresponds to a digital output. The bit with the lowest value on the right is assigned to output 0, the bit with the highest value is assigned to output 31. If more than one output group was configured, the group number can be set via the Output Group (Outp. Grp.) dialog box. Groups of 32 outputs can therefore be considered separately. The displayed data have the following meaning:

Cam Tab. Val: Current cam table row corresponding to the displayed angle.

Counter AND: Cams can be activated during each revolution or only during each n-th revolution. The counter mask indicates that an output can become active at the displayed angle.

PLC OR: Current OR mask determined by the PLC (PlcOrMask).

PLC AND: Current AND mask determined by the PLC certain (PlcAndMask).

Cam Output: Currently issued dataset for 32 output tracks. The output is generated through linking of the cam table with the described masks.

Cam Table: Complete cam table with one row for each of 32 outputs for each resolved angle position (second column on the right next to the 32-bit value). The table has 360 entries, depending on the parameterised resolution, or it contains the number of rows that matches the encoder resolution (e.g. 4096). The cam table contains the raw data calculated from all cams for the cam track output. The calculation is based on the set velocity HPM Preset.

Warning:

Unlike the other values described here, the Cam Table field is not updated automatically, but only through manual pressing of the Upload button. The cam table may change after velocity changes.


Operation

TS5800 | TwinCAT Digital Cam Server

Cam controller function

For a better understanding of the cam controller function it is important to know how the configured cams are optimised for fast processing. The cam controller converts the cam information of all cams into a cam table. This cam table contains the status of all outputs at a certain angle of rotation. The advantage of this approach is very fast cam output, since switching of the cam tracks is separated from the complex cam calculation including dead time compensation. The cam table is thus calculated correctly for a predetermined set speed. The system will adapt to varying velocities, although the exact switching points can only be guaranteed for continuous speed.

Cam tables

The cam controller creates an internal cam table with a fixed number of rows. The number of rows is determined by the configured resolution. The table thus either consists of 360 rows, or the number matches the number of encoder increments (e.g. 4096). In the second case the angle allocated to a row is calculated as

angle = row number / number of encoder increments * 360°

e.g. angle for row no. 1000: 1000 / 4096 * 360° = 87.891°

Each table row contains the status of all cam tracks (digital outputs) for the associated encoder angle. The status is a result of all configured cams, i.e. switching points, switching times, and dead times.

The cam table is initially executed once on system start-up and subsequently recalculated under certain conditions, such as after a significant change in velocity. A recalculation always takes place at 0 degrees, in order to ensure that the cam output within an encoder revolution is consistent.

The cam controller manages two switchable cam tables (variable Reverse Mode). Each cam can be configured for one or both tables (parameter Standard Active or Reverse Active). Switching between the two tables is initiated by the PLC.

Mapping of a distance cam in the cam table

A distance cam is defined between a switch-on position and a switch-off position. In the cam table 1 is entered in all table rows between these two positions. All other table rows remain at 0, if no further cams contact the same cam track.

Mapping of a time cam in the cam table

A time cam is defined from a switch-on position with a certain switch-on time. In the cam table all table rows from the switch-on position up to a position that is greater by 1 degree are set to 1. All other entries are 0. Although the time cam (like a distance cam) is entered in the cam table with a switching angle with a width of 1 degree, the switch-off position is irrelevant. The cam output is in fact time-based: The cam output is initially switched on at the switch-on position. A timer then starts running in the cam controller that switches the output off after the defined switching time.

Mapping of a brake cam in the cam table

A brake cam is defined with a certain brake position. In the cam table all table rows from the brake position up to a position that is greater by 1 degree are set to 0. All other entries are 1. Although the brake cam (like a distance cam) is entered in the cam table with a switching angle with a width of 359 degree, the switch-on position is irrelevant. The cam output is a special function that keeps the output switched on as long as the PLC has set brake enable to 1. When brake enable is cancelled by the PLC, the output track is switched off at the defined brake position and remains switched off.

Recalculation of the cam tables

The cam table calculation is based on set velocity of the cam controller (HPM Preset [rpm]) specified by the user (PLC). As long as the Coupled flag is not set by the PLC, the cam table is calculated based on this velocity.

The user also specifies a velocity tolerance (HPM Difference [rpm]). The cam controller monitors deviations from the set velocity when the Coupled flag was set by the PLC. The table is recalculated if the current speed deviates by more than the difference value from last velocity with which the cam table was calculated. If HPM Difference is specified as 0, the table is not recalculated.

For velocity fluctuations within the range +/- HPM Difference the cam table is not immediately recalculated. HPM Preset should correspond to the mean expected speed, and HPM Difference should be set such that small expected velocity fluctuations do not lead to recalculation of the cam table. Deviations within the range +/- HPM Difference are integrated over time, so that a small mean deviation eventually also leads to recalculation of the cam table and adaptation to the mean velocity.

Individual cam parameters, e.g. the switching positions, can be changed through the PLC program. After a change the cam table is updated without being fully recalculated.

Optionally, recalculation of the cam table can be initiated by the PLC program via a function block. For example, it may be sensible to initiate recalculation after a velocity change, as soon as the new continuous velocity level is reached.

In order to ensure consistency of the cam switching points, a newly calculated cam table only becomes active at the next encoder zero transition after the calculation is completed.