TwinCAT NC Configuration

1. Add NC axis

Add to the NC axes a "Continuous Axis" for each ProfiDrive, e.g. the NC-Task 1 has to be added if it is not yet there.

TwinCAT NC Configuration 1:

2. Select Axis Type

Select the Axis Type "ProfiDrive MC".

TwinCAT NC Configuration 2:

3. Link NC Axis to ProfiDrive

Link each NC Axis to a ProfiDrive (Double drives have one axis number but two channels, first "A" and second "B").

TwinCAT NC Configuration 3:
TwinCAT NC Configuration 4:
TwinCAT NC Configuration 5:

4. Necessary Encoder Settings

4.1 Encoder Scaling

Setup the NC Scaling Factor to a value that represents the amount of mm that the load moves with one encoder increment (Position feedback over the Profibus). The gearbox and the spindle pitch can be setup in the drive (see Mechanics of SimoComU ProfiDrive Configuration) or be part of the NC encoder scaling factor, but only in one place.

TheNC-Axis Encoder-Scaling-factor can be calculated with the following formula:

Scaling
factor = 1 / (Increments Per Revolution / feedconstant)


Example:

    feedconstant          = 10 mm/rev

    Increments per Revolution = 2097152 INC/rev


Scaling factor = 1 / (2097152[INC/rev] / 10[mm/rev]) =
0.00000476837158203 [mm/INC] 

See chapter "5. NC ProfiDrive Settings" for calculation of increments per revolution.

4.2 Encoder Bit Rejection Filter Mask

The position feedback is smoothed by rejecting (ignoring) the lowest 11bits of the position feedback. The smoothing algorithm uses the "Encoder bit rejection filter mask" with the default value 0x7FFh for that. This is only useful for Encoders with a high number of lines (i.e., 1024, 2048) plus 11 bits of fine resolution.

When using encoders with a low number of lines (i.e., 32) or a smaller fine resolution, this filter mask value must be set to a lower value (i.e., 0). If to many bits are rejected, the NC sees steps in the position feedback. This causes a bigger following error (lag distance) and the axis might vibrate violently, especially in combination with telegram type 5 or 105 (Dynamic Stiffness Control).

4.3 Encoder Reference System

The 611u can report two position feedbacks per encoder, the incremental position value is always reported in Gx_XIST1, the absolute position value is on demand reported in Gx_XIST2. When using an absolute encoder, then the reference system must be set to ABS or ABS_MODULO, otherwise to INC. In case of ABS or ABS_MODULO the NC is requesting the absolute position value from the drive.

With INC the drive resets the position to 0 after powerup regardless of the physically position of the axis. This is a pure incremental behavior. All overflows of the 32bit position feedback (hard increments) are counted and added to the 64bit encoder soft increments.

With ABS the real absolute position (hard increments) is used in the NC and directly extended to 64bits encoder soft increments. The overflow of the hard increments causes a maximum following error of 32bits and is not permitted.

With ABS_MODULO the NC keeps track of the overflows of the 32bit position value (hard increments) and extends it properly to 64bits. Multiple overflows are possible. This mode is similar to the SERCOS position feedback.

Notice

If the NC (TwinCAT System) is stopped it always starts up as if there was no overflow. If the hard increment is between 0x80000000 and 0xFFFFFFFF then the NC takes it as a negative position and sets the overflow counter to -1.

E.g., the "Expert Mode (IQ)" of the System Manager must be activated to see the Encoder Bit Rejection Filter Mask parameter.

TwinCAT NC Configuration 6:

5. NC ProfiDrive Settings

5.1 Using an Encoder

The encoder setup for ProfiDrives is done on the NC axis ProfiDrive tab. When using an encoder, then the radio button "Encoder (P1005)" must be selected. By this selection the multiplier for the encoder lines is automatically preset with 0x0800 (dec. 2048). This factor (fine resolution, P1043) might be different for other drives then the 611u.

Additionally, the amount of encoder lines must be set up for the calculation of the ProfiDrive Encoder Scaling. The amount of encoder lines is in the drive parameter P1005. The value of parameter P1005 can be looked up on the Drive Online tab and must be entered into the edit box beside "Incs/Rot (P1005):".

The ProfiDrive Velocity Scaling is in the drive parameter P880 and tells the NC about how to scale the velocity setpoint. The value of parameter P880 can be looked up on the Drive Online taband has to be entered into the edit box beside "Speed evaluation (P0880)".

The System Manager currently calculates the output scaling according to the following formula:

Output Scale := 60    /
((P1005 * 0x0800) /
(0x40000000 / P880     ))
[sec/Inc]    := [sec/min]
/ (([Inc/rot])      / (     1 / [rot/min]))

To prove the output scale that the System Manager has calculated, the steps in the chapters 5.1.1 to 5.1.3 should be executed. If this leeds to a different result, then the output scale on the ProfiDrive tab must be overwritten with the manually calculated value. But any change of the parameters in the formula on the ProfiDrive tab forces automatically a new calculation of the output scale with the formula above. A manually entered output scale will be overwritten.

TwinCAT NC Configuration 7:

5.1.1 Calculate increments per revolution

The parameter P979 Encoder Format contains the information needed, to calculate the increments per revolution. To choose the proper sub index, it has to be distinguished between "IM" indirect measurement (on the motor, uses G1) and "DM" direct measurement (on the load, uses G2) and if the NC Reference System is set to "INC" incremental (uses XIST1) or "ABS"/"ABS MODULO" absolute (uses XIST2).

For simplification the following assumption are made:
- Gearbox ratio in the 611u is set 1:1 (P237, P238)
- XIST3 is not used

Depending on these two selections the formular to calculate the increments per revolution looks like one of the following:


Encoder on the motor:

    Incremental Position (G1_XIST1)

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Signal P979:4


    Absolut Position (G1_XIST2)

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Abs P979:5



Encoder on the load:

    Incremental Position (G2_XIST1)

    Increments per revolution = Encoder Resolution P979:13 * 2^
Shift Factor Signal P979:14


    Absolut Position (G2_XIST2)

    Increments per revolution = Encoder Resolution P979:13 * 2^
Shift Factor Abs P979:15



Encoder with 2048 lines on the motor, incremental value, 11bit fine
resolution (P979:4 = 11):

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Signal P979:4

    Increments per revolution = 0x00000800 * 2^11    = 2^11 *
2^11 = 2^22 = 4194304 = 0x00400000

5.1.2 Calculateoutput scaling

The output scaling on the ProfiDrive tab can be calculated in the following way:

Output
Scale = 60[s/min] / (IncPerRev / (0x40000000 /Speed Evaluation P880
[rev/min]))
Example

    Speed Evaluation P880 = 16384 = 0x00004000

    Increments per revolution = 4194304 = 0x00400000 INC/rev

    Output
Scale= 60[s/min] / (0x00400000[INC/rev] /
(0x40000000 / 0x00004000[rev/min]))
    Output Scale=
60[s/min] /  64[INC/min] = 0.9375 [s/INC]

5.1.3 Checkoutput scaling

The test can only be done if the axis can move a short distance with constant velocity.

WARNING

Attention, if the scaling is wrong or the tuning is to aggressive, the axis might take off fast and slam hard into the bumper!

To check the output scale the NC axis has carefully to be moved by the NC with a slow speed, with no proportional gain in the NC (Kv = 0). If the axis can follow the setpoint speed without increasing following error, then the output scaling is set properly.

Example

    Increments per revolution = 4194304 [INC/rev]

    Output Scaling = 0.9375 [s/INC]

    Feed constant = 10mm/rev


    Setpoint speed of 10 mm/s = 1rps  =  60rpm

    NSOLL_B = 0x003C0000 =  3932160


    3932160 / 0.9375 [s/INC] =  4194304 [INC/s] =  1 * 2^22 =
 1rps =  10mm/s

5.2 Using a Resolver

The encoder setup for ProfiDrives is done on the NC axis ProfiDrive tab. When using a resolver, then the radio button "Resolver (P1018)" has to be selected. By this selection the multiplier for the encoder lines is automatically preset with 0x0400 (dec. 1024). This factor (fine resolution, P1043) might be different for other drives then the 611u.

Additionally, the amount of pole pairs has to be set up for the calculation of the ProfiDrive Encoder Scaling. The amount of pole pairs is in the drive parameter P1018. The value of parameter P1018 can be looked up on the Drive Online tab and must be entered into the edit box beside "Incs/Rot (P1018):".

The ProfiDrive Velocity Scaling is in the drive parameter P880 and tells the NC about how to scale the velocity setpoint. The value of parameter P880 can be looked up on the Drive Online taband has to be entered into the edit box beside "Speed evaluation (P0880)".

The System Manager currently might calculate the output scaling according to the following wrong formula:

Output Scale := 60    /
((P1018 * 0x0400) /
(0x40000000 / P880     ))
[sec/Inc]    := [sec/min]
/ (([Inc/rot])      / (     1 / [rot/min]))

This automatically calculated output scale, must be overwritten manually. Follow the steps in the chapters 5.2.1 to 5.2.3, then overwrite the output scale on the ProfiDrive tab with the manually calculated value. But any change of the parameters in the formula on the ProfiDrive tab forces automatically a new calculation of the output scale with the formula above. A manually entered output scale will be overwritten.

TwinCAT NC Configuration 8:

5.2.1 Calculate increments per revolution

The parameter P979 Encoder Format contains the information needed, to calculate the increments per revolution. To choose the proper sub index, it has to be distinguished between "IM" indirect measurement (on the motor, uses G1) and "DM" direct measurement (on the load, uses G2) and if the NC Reference System is set to "INC" incremental (uses XIST1) or "ABS"/"ABS MODULO" absolute (uses XIST2).

For simplification the following assumption are made:
- Gearbox ratio in the 611u is set 1:1 (P237, P238)
- XIST3 is not used

Depending on these two selections the formular to calculate the increments per revolution looks like one of the following:


Resolver on the motor:

    Incremental Position (G1_XIST1)

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Signal P979:4


    Absolut Position (G1_XIST2)

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Abs P979:5



Resolver on the load:

    Incremental Position (G2_XIST1)

    Increments per revolution = Encoder Resolution P979:13 * 2^
Shift Factor Signal P979:14


    Absolut Position (G2_XIST2)

    Increments per revolution = Encoder Resolution P979:13 * 2^
Shift Factor Abs P979:15



Example Resolver 12bit (P1011.2 = 0) on the motor, incremental
value, 11bit fine resolution (P979:4 = 11):

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Signal P979:4

    Increments per revolution = 0x00000400 * 2^11    = 2^10 *
2^11 = 2^21 = 2097152 = 0x00200000


Example Resolver 14bit (P1011.2 = 1) on the motor, incremental
value, 11bit fine resolution (P979:4 = 11):

    Increments per revolution = Encoder Resolution P979:3  * 2^
Shift Factor Signal P979:4

    Increments per revolution = 0x00001000 * 2^11    = 2^12 *
2^11 = 2^23 = 8388608 = 0x00800000

5.2.2 Calculateoutput scaling

The output scaling on the ProfiDrive tab can be calculated in the following way:

Output
Scale = 60[s/min] / (IncPerRev / (0x40000000 /Speed Evaluation P880
[rev/min]))
Example

    Speed Evaluation P880 = 16384 = 0x00004000

    Increments per revolution = 8388608 = 0x00800000 INC/rev

    Output
Scale= 60[s/min] / (0x00800000[INC/rev] /
(0x40000000 / 0x00004000[rev/min]))
    Output Scale= 60[s/min] /
128[INC/min] = 0.46875 [s/INC]


Example

    Speed Evaluation P880 = 16384 = 0x00004000

    Increments per revolution = 4194304 = 0x00400000 INC/rev

    Output
Scale= 60[s/min] / (0x00400000[INC/rev] /
(0x40000000 / 0x00004000[rev/min]))
    Output Scale= 60[s/min] / 
64[INC/min] = 0.9375 [s/INC]

5.2.3 Checkoutput scaling

The test can only be done if the axis can move a short distance with constant velocity. Attention, if the scaling is wrong or the tuning is to aggressive, the axis might take off fast and slam hard into the bumper!

TwinCAT NC Configuration 9:

To check the output scale the NC axis has carefully to be moved by the NC with a slow speed, with no proportional gain in the NC (Kv = 0). If the axis can follow the setpoint speed without increasing following error, then the output scaling is set properly.

Example

    Increments per revolution = 2097152 [INC/rev]

    Output Scaling = 1.875 [s/INC]

    Feed constant = 10mm/rev


    Setpoint speed of 10 mm/s = 1rps  =  60rpm

    NSOLL_B = 0x003C0000 =  3932160


    3932160 / 1.875 [s/INC] =  2097252 [INC/s] =  1 * 2^21 =
1rps  =  10mm/s
Example

    Increments per revolution = 8388608 [INC/rev]

    Output Scaling = 0.46875 [s/INC]

    Feed constant = 10mm/rev


    Setpoint speed of 10 mm/s = 1rps  =  60rpm

    NSOLL_B = 0x003C0000 =  3932160


    3932160 / 0.46875 [s/INC] =  8388608 [INC/s] =  1 * 2^23 =
 1rps =  10mm/s

6. Telegram Types 3, 5 (DSC) and 0 (Configurable)

6.1 Position Loop in the NC (Telegram 3 or 102)

The position loop gain is setup as Controller Kv-Factor on the NC axis online tab. For a closed position loop this parameter must be bigger than 0.

TwinCAT NC Configuration 10:

6.2 Position Loop in the Drive (Telegram 5 or 105 with Dynamic Stiffness Control)

In Telegram 5 or 105 there are the following error (position lag) and a position gain setpoint value parts of the setpoint telegram. The Dynamic Stiffness Control of the ProfiDrive uses those parameters to minimize the position error and to close the position loop in the drive.

If the ProfiDrive Position Gain (KPC) is set to 0 then the DSC mode is switched off. If the ProfiDrive Position Gain (KPC) is bigger than the DSC mode is switched on. The KPC must be setup carefully because if the gain is too big, then the axis can start to vibrate violently. This could harm the operator or destroy the attached hardware.

To get a stiffer position control and a better positioning this KPC must be increased.

If the secondary encoder on the load is used (G2_XISTx) then the scaling factor for the following error Xerr must be setup properly since the drive internally has to convert the NC position to an internal scaling. If the primary encoder is used (on the motor shaft) then the scaling factor for the following error Xerr must be 1.

TwinCAT NC Configuration 11:

The NC runs open loop. The Controller Kv-Factor on the NC axis online tab can be set to 0. The position control is done in the drive.

TwinCAT NC Configuration 12:

6.3 Configurable Telegram 0

The telegram 0 should only be used to extend the standard telegrams 3 or 5 with additional cyclic data. In this case see for information in the chapters 6.1 (Telegram 3) or 6.2 (Telegram 5) above.

Information about setting up the configurable telegram in TwinCAT is in chapter "5. Configurable Telegram" of TwinCAT ProfiDrive Configuration.

Information about setting up the configurable telegram in SimoComU is in chapter "Telegram Type 0" in SimoComU ProfiDrive Configuration.

The Profibus telegram has to be setup in TwinCAT and SimoComU to the same content. The Profibus equidistant time has to be recalculated after all changes to the telegram, see TwinCAT Profibus Master Configuration.