Overview: Why Switch Measuring Systems on an 840D
On the SINUMERIK 840D (and the sl/840D sl/Powerline variants), each NC axis can be configured to accept one or two position-measuring systems. A common second system is the integrated motor encoder (resolver or absolute singleturn/multi-turn encoder such as the Siemens SIMOTICS motor with DRIVE-CLiQ), while the first system is typically a Heidenhain, Renishaw, or Fagor linear glass/steel scale. When an axis develops vibration, position-following error, or contouring deviations, the cleanest diagnostic move is to temporarily run the axis closed-loop on the motor encoder only. If the vibration disappears, the scale (cable, head, scale tape, mounting bracket, or signal conditioner) is implicated. If the vibration persists, the mechanical/spindle drive loop is the prime suspect.
This article covers both legal ways to perform the switchover on the 840D: (1) toggling the PLC interface bits, and (2) editing the affected machine data. It also flags the reference-point, backlash, and safety constraints that often get overlooked on a live machine.
Prerequisites Before the Switchover
-
Know your current encoder configuration. Read the active machine data and write it down so you can restore the original state after the test.
MD30200 $MA_NUM_ENCS = 2 ; 1st = scale, 2nd = motor encoder MD30220 $MA_ENC_FEEDBACK_POLARITY[AX1] = 1.0 MD30240 $MA_ENC_TYPE[1] = 1 ; incremental (typical for linear scale) MD30240 $MA_ENC_TYPE[2] = 0 or 4 ; motor encoder (0=simulated, 4=absolute) MD31000 $MA_ENC_IS_LINEAR[1] = 1 ; axis 1 uses a linear scale MD31000 $MA_ENC_IS_LINEAR[2] = 0 ; axis 1 motor encoder is rotary MD31700 $MA_ENC_DSMS_CTRL[AX1]= 0 ; no dual-encoder special handling - Verify the second measuring system is electrically present. On the 840D, open Commissioning > Drive system > Axes > [Axis] > Measuring system and confirm encoder 2 shows a valid position and OK state. Look for alarm 25000 "Active encoder error" or alarm 25010 "Encoder contamination" on encoder 1; these are typical pre-existing scale issues.
- Check NC/PLC version compatibility. The bit names DBX1.5 and DBX1.6 are stable from SW 4.x onward, but additional safety interlock bits (DBX1.7, DBX2.1) behave differently in 840D sl with SINAMICS S120 versus classic SIMODRIVE 611. Cross-check against the version of the SINUMERIK 840D sl List Manual for your SW release.
- Make a backup of the NC/PLC project. Use Start-up > Series commissioning > Save (HMI Advanced) or export the archive in TIA Portal / SINUMERIK Operate so the original encoder map can be restored in seconds.
- Be ready to deal with the reference point. Encoders 1 and 2 are referenced independently. The motor encoder (encoder 2) usually loses its reference after power-off unless it is an absolute EnDat/DRIVE-CLiQ encoder, whereas the linear scale may be absolute with coded distance marks. Plan for the re-referencing pass described in the Reference Point section below.
Method 1 - Switchover via the PLC Interface (DB31 / DB32 / ...)
The PLC interface for axis N lives in DB (31 + N - 1) (or DB31 for axis 1, DB32 for axis 2, etc., on the classic 840D). The two bits that select the active position measuring system are:
| Address | Bit | Symbol | Meaning |
|---|---|---|---|
| DB31.DBX1.5 | 5 | Position measuring system 1 | 1 = encoder 1 (typically the linear scale) is used for position control |
| DB31.DBX1.6 | 6 | Position measuring system 2 | 1 = encoder 2 (typically the motor encoder) is used for position control |
| DB31.DBX1.7 | 7 | Position measuring system (collective) | Status feedback to the PLC; mirrors the current selection |
| DB31.DBX2.1 | 1 | Referenced / synchronized | 0 = encoder 1 not yet referenced; 1 = referenced |
| DB31.DBX2.2 | 2 | Restored 2 (encoder 2 referenced) | 0 = encoder 2 not yet referenced; 1 = referenced |
Step-by-step: change from scale (encoder 1) to motor encoder (encoder 2)
- Open the project in STEP 7 / TIA Portal with the 840D station online. Go to PLC > Monitor/Modify and open DB31.
- Locate byte 1, bits 5 and 6. By default on a properly configured scale-feedback axis you will see:
DB31.DBX1.5 = 1 ; measuring system 1 selected (scale) DB31.DBX1.6 = 0 ; measuring system 2 not selected - Toggle the selection:
DB31.DBX1.5 = 0 ; measuring system 1 deselected DB31.DBX1.6 = 1 ; measuring system 2 selected (motor encoder) - Watch the controller reaction. The NCK clears the reference-point status for encoder 1 and forces a re-referencing on encoder 2 the next time the axis is enabled. The PLC should see:
DB31.DBX1.7 = 1 ; status: encoder 2 active DB31.DBX2.1 = 0 ; encoder 1 no longer "referenced" DB31.DBX2.2 = 1 ; encoder 2 "referenced" (only if it was referenced before or is absolute) - Run the axis in JOG at low feed override (5 %) and observe the position-following error (SERVO trace) and the mechanical vibration signature. The actual-position value should now update from the motor encoder alone.
What if the PLC "re-writes" the bits every scan?
If the project drives DBX1.5/DBX1.6 from coil/FB outputs that you cannot break online, the Monitor/Modify value will be overwritten on the next PLC cycle. The two legal remedies are:
- Edit the source: add a temporary input (e.g.,
I 0.0= Scale-Test-Mode) that OR-gates into the bits so the diagnostic value is forced by the operator. Recompile and download to the PLC. - Use Method 2 below - changing the machine data - which is driven by the NCK, not the PLC, so the PLC cannot fight it.
Method 2 - Switchover via Machine Data (no PLC change)
If the PLC is locked out or the program is write-protected, the same switchover is achievable from the HMI by editing the relevant axis machine data and powering the NCK down/up (or issuing an NCK reset). The decisive parameters are:
| Machine Data | Effect | Test-mode value (scale → motor encoder) |
|---|---|---|
| $MA_NUM_ENCS (MD30200) | Number of encoders configured for the axis | Leave at 2 |
| $MA_ENC_TYPE[2] (MD30240[2]) | Encoder 2 type (0=simulated, 1=incr., 4=absolute) | Set to match motor encoder |
| $MA_ENC_IS_LINEAR[1] (MD31000[1]) | Treat encoder 1 as linear (affects modulo, leadscrew error comp.) | Set 0 to disable linear scale semantics |
| $MA_ENC_FEEDBACK_POLARITY[2] (MD30220[2]) | Sign of encoder 2 | Verify with reference move; flip if axis runs away |
| $MA_REFP_SET_POS[2] (MD34100[2]) | Reference position for encoder 2 | Set to the desired machine-zero offset for encoder 2 |
Procedure on the HMI
- Operator menu → Commissioning → Machine data → Axis-specific. Filter by axis (e.g., AX1).
- Open MD30200 and confirm NUM_ENCS = 2. If it is 1, the controller does not even know a second encoder exists; you must add it and re-power.
- Open MD31000[1] and set the linear-scale flag to 0. This tells the NCK that the active measurement source is rotary and removes any leadscrew-error compensation table that was tied to the scale.
- Save, then trigger an NCK reset. On reboot the NCK auto-selects encoder 2 if the PLC has not asserted DBX1.5/DBX1.6.
- Re-reference the axis using the standard referencing routine, but select the encoder 2 reference-point cam in the machine data $MA_REFP_CAM_DIR_IS_MINUS, $MA_REFP_CAM_TYP, $MA_REFP_CAM_SHIFT, etc.
Reference Point and "Restored" Bits - The Trap That Bites Most People
On a typical 840D with a Heidenhain LS486 linear scale (incremental, no coded reference marks), the scale is referenced by a hardware cam (proximity switch on the axis) plus a zero pulse on the scale. The motor encoder is usually a singleturn resolver with 1 zero pulse per revolution and needs its own cam - or, if the motor encoder is absolute (EnDat 2.1/2.2, DRIVE-CLiQ), referencing is automatic after power-on.
Decision matrix for the reference procedure
| Scale (encoder 1) type | Motor encoder (encoder 2) type | What you must do after switching to encoder 2 |
|---|---|---|
| Incremental glass/steel scale with reference cam | Incremental resolver (no absolute) | Jog across the cam and let NCK detect zero pulse. DB31.DBX2.2 transitions 0 → 1. |
| Incremental scale with coded distance marks (Heidenhain LSxxxC, LCxxxC) | Incremental resolver | Encoder 2 still needs a zero pulse; the coded-distance feature of the scale is irrelevant on encoder 2. |
| Incremental scale | Absolute singleturn (EnDat 01, DRIVE-CLiQ) | Encoder 2 is automatically referenced after first power-up; DBX2.2 = 1 immediately. No motion required. |
| Absolute linear scale (Heidenhain LCxxx with EnDat) | Any | Encoder 1 is referenced at power-up; encoder 2 must still be referenced separately if you switch. |
If the PLC was written assuming only one cam is present (the cam is on the scale, not on the motor encoder), switching to encoder 2 will leave the axis with DBX2.2 = 0 (not referenced) and most part programs will refuse to start. The remedy is to either:
- Re-run the reference-point routine in JOG (DB31.DBX0.4 = 1, DB31.DBX0.5 = 0/1 depending on direction), or
- Add a referencing FB to the PLC that uses the existing scale cam but flags it as the encoder-2 reference (with $MA_REFP_CAM_IS_NO_ENCODER and a software offset).
Verification - Proving the Switch Took Effect
- Service display on HMI Advanced: Diagnostics → Service display → Axis → Measuring system should now show "Encoder 2" as active. The position value is now derived from the motor encoder alone.
- DB31 status bits: DBX1.7 = 1, DBX2.2 = 1. If DBX2.2 is 0, the axis is referenced on encoder 1 only and you will get alarm 27010 "Axis %1 reference point not set" the moment a part-program is selected.
- Position-following error: with the scale feedback the steady-state following error at 10 % rapid is typically 5-20 µm; with the motor encoder alone it rises to 50-200 µm because the encoder sits behind the ballscrew/ballscrew nut compliance. This is expected and proves the switch is real.
- SERVO trace: trace the actual position value (e.g., ActPos) and a vibration channel (motor speed ripple, drive current). The vibration signature at the mechanical resonant frequency (~80-200 Hz on a typical ballscrew) should be markedly different.
- Reversal error check: with the motor encoder alone, the reversal jump in actual position should NOT have spikes larger than ±0.01 mm. If it does, the encoder direction is wrong (MD30220 polarity) or the encoder resolution ($MA_ENC_RESOL, MD31020) does not match the DRIVE-CLiQ/SIMODRIVE feedback scaling.
Troubleshooting Matrix - What You Will See If Something Is Wrong
| Symptom after switchover | Probable cause | Remedy |
|---|---|---|
| Alarm 25000 "Active encoder error" on encoder 2 | Motor encoder cable / DRIVE-CLiQ link down | Check the DRIVE-CLiQ LEDs on the SMC/SME module; reseat connector; check MD13140 $MD_DRIVE_TELEGRAM_TYPE |
| Alarm 27010 "Reference point not set" | Encoder 2 not referenced | Jog across the cam or treat encoder 2 as absolute (MD30240[2] = 4) |
| Axis runs away at enable | Encoder 2 polarity inverted | Toggle MD30220 $MA_ENC_FEEDBACK_POLARITY[2] sign |
| No PLC effect when toggling DBX1.5/DBX1.6 | PLC program re-writes the bit each scan | Edit FB source or use Method 2 (machine data) |
| Vibration unchanged after switch | Problem is mechanical (ballscrew, bearings, coupling) or in the drive current loop | Capture SERVO trace, inspect mechanical run-out, check drive MD1407/P gain ($MA_SERVO_GAIN_FACTOR) |
| Vibration disappears on encoder 2 but returns on encoder 1 | Scale or scale head is the source | Clean scale, check bracket alignment, replace read head, verify Heidenhain signal conditioner PWT/PWM |
| Following error spike on switchover | Position offset between the two encoders not compensated | Use $MA_ENC_COMP_ENABLE[0/1] and re-equalize with $AA_ENC_COMP_STEP |
| Alarm 21612 "Vdi channel reset because of axis %1" | The NCK rejected the bit change because axis was moving | Stop axis (DBX21.7 = 0), then toggle measuring system |
Related Axis Data Worth Checking While You Are in There
- $MA_SERVO_GAIN_FACTOR (MD32200) and $MA_SERVO_GAIN_FF (MD32610): kV and Kv factor, feedforward. Encoder-2-only systems often need a kV reduction of 10-30 % because the loop is now compliant.
- $MA_BACKLASH[0/1] (MD32450/32452): backlash compensation value. If the scale was at the workpiece end and the motor encoder is at the motor end, the two are physically separated by the ballscrew and the backlash value may need re-measuring.
- $MA_SSC_SLIND_P, $MA_SSC_SLIND_P, $MA_LEADSCREW_PITCH (MD31010/31020/31030): leadscrew error compensation, encoder resolution, screw pitch. Confirm these are still valid when the loop runs on the motor encoder.
- $MA_JOG_AND_POS_JERK_ENABLE (MD32400) and $MA_JOG_JERK (MD32410): jerk limits. Encoder-2-only systems may want softer jerk to keep the drive from oscillating into the ballscrew compliance.
Restoring the Original Configuration
When the diagnostic is finished, restore the scale feedback so production resumes with the original loop integrity:
- In the PLC Monitor/Modify, set DB31.DBX1.5 = 1, DB31.DBX1.6 = 0 (encoder 1 selected again).
- Re-reference encoder 1 if the controller has cleared DBX2.1 (DB31.DBX2.1 = 0). Jog to the cam and let NCK capture the zero pulse.
- Confirm the SERVO trace position matches the previous scale-based position at the same machine coordinate.
- Run a small part program in MDA to confirm following error returns to its baseline value.
- Save the project archive again so the (possibly modified) test values are documented.
Which PLC bits on the 840D switch between the linear scale and the motor encoder?
DB31.DBX1.5 (encoder 1 / scale) and DB31.DBX1.6 (encoder 2 / motor encoder). To run on the motor encoder, set DBX1.5 = 0 and DBX1.6 = 1. The status is reflected in DBX1.7 and the referenced bits in DBX2.1 (encoder 1) / DBX2.2 (encoder 2).
Do I need to change the PLC program to switch measuring systems on a SINUMERIK 840D?
Not always. You can either toggle DBX1.5/DBX1.6 from the PLC monitor (if the project does not overwrite them every scan) or change the axis machine data such as $MA_NUM_ENCS (MD30200), $MA_ENC_TYPE[2] (MD30240), and $MA_ENC_IS_LINEAR[1] (MD31000) to make encoder 2 the active source. If the PLC drives the bits every cycle, you must edit the FB and re-download.
What happens to the reference point when I switch from scale to motor encoder?
Each encoder has its own reference status. The motor encoder (encoder 2) must be re-referenced unless it is an absolute EnDat/DRIVE-CLiQ encoder. If the original PLC only had a cam for the scale, switchover will leave DBX2.2 = 0 and the NCK will issue alarm 27010 until you jog across the encoder-2 reference cam or re-mark encoder 2 as absolute in MD30240[2] = 4.
Can the switchover be done while the axis is moving ("on the fly")?
No. The 840D will reject the bit change with alarm 21612 "VDI channel reset because of axis %1" unless the axis is at standstill, drives are disabled, and no part program is active. Always stop the axis, disable the drive (DB31.DBX21.7 = 0), and then toggle the measuring system.
If the vibration disappears when I run on the motor encoder, what does that tell me?
The scale (cable, read head, glass/steel tape, mounting bracket, or signal conditioner) is the dominant feedback error source. Inspect the head-to-scale gap, clean the scale, check the bracket for thermal growth, and re-validate the Heidenhain PWM/EnDat signal quality on the EXE/EXM module. If the vibration persists on encoder 2, the problem is mechanical (ballscrew, bearings, coupling) or in the drive current loop, not the scale.