Electronic Camming – TML Programming Details

In the electronic camming a drive/motor may operate as master or as slave.

When set as master, the drive/motor sends its position via a multi-axis communication channel, like the CAN bus. When set as slave, the drive/motor executes a cam profile function of the master position. The cam profile is defined by a cam table – a set of (X, Y) points, where X is cam table input i.e. the master position and Y is the cam table output i.e. the corresponding slave position.  Between the points the drive/motor performs a linear interpolation.

Master operation

The master operation can be enabled with the TML command SGM followed by an UPD (update) and can be disabled by the TML command RGM followed by an UPD. In both cases, these operations have no effect on the motion executed by the master.

Once at each slow loop sampling time interval, the master sends either its load position APOS (if OSR.15 = 0) or its position reference TPOS (if OSR.15 = 1) to the axis or the group of axes specified in the TML parameter SLAVEID. The SLAVEID contains the axis ID of one slave or the value of a group ID+256 i.e. the group of slaves to which the master should send its data.

Remark: The group ID is an 8-bit unsigned value. Each bit set to 1 represents a group: bit 0 – group 1, bit 1 – group 2, etc. In total there are 8 groups. For example, if the master sends its position to group 3, the group ID = 4 (00000100b) and the SLAVEID is 4+256 = 260.

The master operation can be synchronized with that of the slaves. The synchronization process is performed in two steps. First, the master sends a synchronization message to all axes, including to itself. When this message is received, all the axes read their own internal time. Next, the master sends its internal time to all the slaves, which compare it with their own internal time. If there are differences, the slaves correct slightly their sampling periods in order to keep them synchronized with those of the master. As effect, when synchronization procedure is active, the execution of the control loops on the slaves is synchronized with those of the master within a 10μs time interval. Due to this powerful feature, drifts between master and slave axes are eliminated. The synchronization procedure is activated with the TML command SETSYNC value where value represents the time interval in internal units between the synchronization messages sent by the master. Recommended value is 20ms.

Slave operation

The slaves can get the master position in two ways:

1.Via a communication channel, from a drive/motor set as master
2.Via an external digital reference of type pulse & direction (if ACR.2=1) or quadrature encoder (if ACR.2 = 0). Both options have dedicated inputs. The pulse & direction signals are usually provided by an indexer and must be connected to the pulse & direction inputs of the drive/motor. The quadrature encoder signals are usually provided by an encoder on the master and must be connected to the 2nd encoder inputs.

You can activate the first option with the TML command: EXTREF 0 and the second option with the TML command EXTREF 2. Both become effective at the next UPD command.

The TML parameter MASTERRES provides the master resolution which is needed to compute correctly the master position and speed (i.e. the position increment). MASTERRES is a 32-bit long integer value, expressed in the master position units. If master position is not cyclic (i.e. the resolution is equal with the whole 32-bit range of position), set master resolution to 0x80000001.

When master position is provided via the external digital interface, the slave computes the master position by counting the pulse & direction or quadrature encoder signals. The initial value of the master position is set by default to 0. It may be changed to a different value by writing the desired value in the TML variable APOS2.

Through the TML parameter CAMOFF you can shift the cam profile versus the master position, by setting an offset for each slave. The cam table input is computed as the master position minus the cam offset. For example, if a cam table is defined between angles 100 to 250 degrees, a cam offset of 50 degrees will make the cam table to execute between master angles 150 and 300 degrees.

In slave mode the drive/motor performs a position control. Based on the master position X, it calculates the cam table output Y = f(X). It is not mandatory to define the cam table for 360 degrees of the master. You may also define shorter cam tables, with a start angle Xmin > 0 and an end angle Xmax < 360 degrees. In this case, the cam table output remains unchanged outside the active area of the cam, being computed as follows:

Y = Ymin = f(Xmin), if  0 < X < Xmin
Y = f(X), if  Xmin ≤ X ≤ Xmax
Y = Ymax = f(Xmax), if Xmax < X < 360

The electronic camming can be: relative (if ACR.12 = 0) or absolute (if ACR.12 = 1).

In the relative mode, the output of the cam table is added to the slave actual position. At each slow loop sampling period the slave computes a position increment dY = Y – Yold. This is the difference between the actual cam table output Y and the previous one Yold. The position increment dY is added to the old target position to get a new target position: TPOS = TPOS + dY. The slave detects when the master position rolls over, from 360 degrees to 0 or vice-versa and automatically compensates in dY the difference between Ymax and Ymin. Therefore, in relative mode, you can continuously run the master in one direction and the slaves will execute the cam profile once at each 360 degrees with a glitch free transition when the cam profile is restarted.

When electronic camming is activated in relative mode, the slave initializes Yold with the first cam output computed: Yold = Y = f(X). The slave will keep its position until the master starts to move and then it will execute the remaining part of the cam. For example if the master moves from X to Xmax, the slave moves with Ymax – Y.

In the absolute mode, the output of the cam table Y is the target position to reach: TPOS = Y.

Remark: The absolute mode must be used with great care because it may generate abrupt variations on the slave target position if:

Slave position is different from Y at entry in the camming modef
Master rolls over and Ymax ≠ Ymin

In the absolute mode, you can introduce a maximum speed limit to protect against accidental sudden changes of the positions to reach. The feature is activated by setting UPGRADE.2=1 and the maximum speed value in CSPD.

Remark: When the slave can’t reach the target position corresponding to the cam profile due to the speed limitation, SRH.14 = 1. The same bit is reset to zero when the slave returns to normal operation following the cam profile with a speed below the maximum limit. The bit has no significance in other motion modes.

One way to avoid abrupt variations at activation of absolute mode is to move the slave(s) in the position corresponding to the master actual value, before enabling the camming slave mode. This approach requires finding the cam table output before entering in the camming mode. You can get this information in the following way:

1.Set the slave(s) in trapezoidal position profile mode, for example to keep its actual position
2.Set TML parameter GEAR (also used as gear ratio in electronic gearing) at 0.
3.Introduce an wait of 1ms (more exactly one slow-loop sampling period)
4.Read the cam table output for the actual master position from TML variable EREF

Remark: Before executing point 2, make sure that the cam table is present in the RAM memory and CAMSTART is initialized accordingly (see below for details).

The cam tables are arrays of X, Y points, where X is the cam input i.e. the master position and Y is the cam output i.e. the slave position. The X points are expressed in the master internal position units, while the Y points are expressed in the slave internal position units. Both X and Y points 32-bit long integer values. The X points must be positive (including 0) and equally spaced at: 1, 2, 4, 8, 16, 32, 64 or 128 i.e. having the interpolation step a power of 2 between 0 and 7. The maximum number of points for one cam table is 8192.

As cam table X points are equally spaced, they are completely defined by two data: the Master start value or the first X point and the Interpolation step providing the distance between the X points. This offers the possibility to minimize the cam size, which is saved in the drive/motor in the following format:

1st word (1 word = 16-bit data):
Bits 15-13 – the power of 2 of the interpolation step. For example, if these bits have the binary value 010 (2), the interpolation step is 2 = 4, hence the master X values are spaced from 4 to 4: 0, 4, 8, 12, etc.
Bits 12-0 – the length -1 of the table. The length represents the number of points
2nd and 3rd words: the Master start value (long), expressed in master position units. 2nd word contains the low part, 3rd word the high part
4th and 5th words: Reserved. Must be set to 0
Next pairs of 2 words: the slave Y positions (long), expressed in position units. The 1st word from the pair contains the low part and the 2nd word from the pair the high part
Last word: the cam table checksum, representing the sum modulo 65536 of all the cam table data except the checksum word itself

Before enabling electronic camming slave mode, the cam table must be downloaded into the drive/motor RAM memory and the TML variable CAMSTART must be set with the value of the cam start address. It is possible to download more than one cam table in the drive/motor RAM memory and through CAMSTART to select which one to use at one moment.

Typically, the cam tables are first downloaded into the EEPROM memory of the drive, together with the rest of the TML program. Then using the TML command (included in the TML program):

INITCAM LoadAddress, RunAddress

the cam tables are copied from the EEPROM memory into the drive/motor RAM memory. The LoadAddress is the EEPROM memory address where the cam table was loaded and RunAddress is the RAM memory address where to copy the cam table. After the execution of this command the TML variable CAMSTART takes the value of the RunAddress.

Remarks:

Motion programming tool EasyMotion Studio automatically computes the start addresses in RAM and EEPROM of the selected cam tables and for each cam generates an INITCAM command.  The INITCAM commands are included in the TML application before ENDINIT. Therefore when this command is executed, all the selected cams are already copied from the EEPROM into the RAM.      
During electronic camming slave mode, only one cam table can be active at time

You can compress/extend the cam table input. Specify through TML parameter CAMX, an input correction factor by which the cam table input is multiplied. For example, an input correction factor of 2, combined with a cam offset of 180 degrees, will make possible to execute a cam table defined for 360 degrees of the master in the last 180 degrees.

You can also compress/extend the cam table output. Specify through the TML parameter CAMY, an output correction factor by which the cam table output is multiplied. This feature addresses the applications where the slaves must execute different position commands at each master cycle, all having the same profile defined through a cam table. In this case, the drive/motor is programmed with a unique normalized cam profile and the cam table output is multiplied with the relative position command updated at each master cycle.

See also:

Electronic Camming – Related TML Instructions and Data

TML Description