Chapter 47

Sensors

An automated machine needs to know what’s happening: whether the workpiece is present, whether the door is closed, where the axis is located, and how hot the spindle cartridge is. This information is provided by sensors—the “sense organs” of mechatronics. In this chapter, we’ll look at how the most commonly used sensors in the workshop work, how they connect to a PLC or a CNC controller, how they measure position, speed, force, pressure, and temperature, and how to identify a faulty sensor using a tester.

47.1 Sensors and Transducers

A sensor is a device that detects a physical quantity (a position, a force, a temperature, the presence of an object) and converts it into an electrical signal. The signal is sent to a PLC (Chapter 49) or a numerical control system (Chapter 50), which reads it and decides what to do: start a cycle, stop an axis, or trigger an alarm.

In everyday language, “sensor” and “transducer” are used interchangeably. Strictly speaking, a transducer consists of the sensing element—the part that responds to the physical quantity (such as a coil, a photodiode, or a wire whose resistance changes)—and the signal conditioning circuit, which amplifies, filters, and converts the signal into a standard form: a closing contact, a voltage from 0 to 10 V, a current from 4 to 20 mA, or a series of pulses. The entire sequence, from the physical quantity to the control signal, is called the measurement chain.

physical quantityposition, force,temperatureelementsensorcoil, photodiodesignal conditioningamplifies, filters,convertselectrical signalon/off, 4–20 mA,0–10 V, pulsesPLC or CNCreads the signaland determinessensor or transducerThe sensor converts a physical quantity into an electrical signal that the control system can read.
Figure 47.1 · The measurement chain: the sensing element and the signal conditioning unit together form the transducer.

Digital and Analog Sensors

Sensors are divided into two main categories, based on the signal they produce.

  • Digital (also known as on/off, binary, or threshold): The output has only two states, on or off. They answer a question with yes or no: Are the workpieces there? Is the cylinder fully extended? Is the door closed? These make up the vast majority of sensors in a machine: limit switches, proximity sensors, photoelectric sensors, pressure switches, and thermostats.
  • Analog: The output varies continuously with the measured quantity, within a measurement range. They answer the question “how much?”: how many bar are in the circuit, what is the oil temperature in degrees, how many kilograms does the container weigh? The standard signals are 0–10 V and 4–20 mA; Chapter 46 explains their electrical characteristics.

There is a third category: pulse sensors, such as encoders. Each pulse represents a small position step, and by counting them, a displacement is measured. The signal is digital, but the information is a continuous quantity.

ONOFF0510Object distance (mm)Digital: two states onlyswitches at 5 mm4 mA20 mA0510Measured quantity (0–10 range)analog: infinite values
Figure 47.2 · On the left, a digital sensor: the output triggers when the object reaches 5 mm. On the right, an analog sensor: the current increases in proportion to the object’s size.

47.2 Sensor Characteristics

Each sensor has a technical data sheet. To read it, you need to understand the meaning of a few terms that apply to all types.

  • Measuring range (or operating range): the range of values within which the sensor operates. A pressure transducer rated from 0 to 10 bar, an inductive sensor that detects metal up to 8 mm.
  • Resolution: the smallest change that the sensor can detect. An encoder with 10,000 steps per revolution has a resolution of 0.036°.
  • Repeatability: the degree to which the sensor provides the same response when the measurement is repeated under the same conditions. For a zero sensor, this is the most important quality: it is not necessary to know exactly at what distance it triggers; what matters is that it always triggers at the same point. For proximity sensors, it is usually a few percent of the trigger distance.
  • Precision (or accuracy): how closely the measured value approximates the true value. A sensor can be highly repeatable but not very precise: it makes errors, but always by the same amount, and the error can be corrected through calibration (Chapter 31).
  • Hysteresis: In digital sensors, this is the difference between the point at which the output turns on and the point at which it turns off. It is intentional: without hysteresis, an object resting exactly on the threshold, even with slight vibration, would cause the output to turn on and off continuously (“flickering”).
  • Response time: the time between a change in the measured quantity and a change in the output. For proximity sensors, it is on the order of a millisecond or less; for a temperature probe inside a well, it can be as long as tens of seconds.
  • Switching frequency: For digital sensors, the maximum number of on/off cycles per second, measured in hertz. It counts when the sensor is counting teeth, cams, or fast-moving workpieces.
01234678Distance (mm)ONOFFmoves closermoving awayTurns on at 5.0 mmturns off at 5.5 mmhysteresis 0.5 mm
Figure 47.3 · Hysteresis: As the object approaches, the output turns on at 5.0 mm; as it moves away, it turns off only at 5.5 mm.
Hysteresis and Switching Frequency
soff = son · (1 + H) f = z · n60
son distance at which the output turns on, in mm · soff distance at which it turns off, in mm · H hysteresis as a fraction (10% = 0.10) · f frequency of the objects in front of the sensor, in Hz · z teeth or cams per revolution · n revolutions per minute.
Example 47.1 · Hysteresis and a Vibrating Workpiece

An inductive sensor activates when a cam reaches 5.0 mm; the specified hysteresis is 10%. The workpiece stops 5.2 mm from the face and vibrates by ±0.2 mm. Does the output fluctuate?

extinguishing point: 5.0 · (1 + 0.10) = 5.5 mm
The workpiece oscillates between 5.2 − 0.2 = 5.0 mm and 5.2 + 0.2 = 5.4 mm
If the output light is on (the workpiece has reached at least 5.0 mm), it remains on until the workpiece exceeds 5.5 mm: 5.4 < 5.5
No flickering: the 0.5 mm hysteresis absorbs vibration
Example 47.2 · Switching Frequency

An inductive sensor counts the teeth on a 12-tooth wheel to monitor the revolutions of a shaft. The sensor's data sheet specifies a maximum of 500 Hz. Is that sufficient for up to 1,500 rpm? What about 3,000?

at 1,500 rpm: f = 12 × 1,500 / 60 = 300 Hz < 500 Hz
at 3,000 rpm: f = 12 · 3,000 / 60 = 600 Hz > 500 Hz
It works fine up to 1,500 rpm; at 3,000 rpm, the sensor loses pulses. You need a faster (usually smaller) sensor or a gear with fewer teeth.

47.3 Mechanical Limit Switches

The limit switch (or position microswitch) is the simplest sensor: a switch that opens or closes when a part of the machine presses against it. A cam mounted on the slide pushes a roller or a plunger, and the plunger moves the contacts. It does not require a power supply, is not dependent on the material of the cam, and can handle relatively high currents; however, it has parts that wear out and must make physical contact, so it is slower and less precise than an electronic sensor.

NA and NC Contacts

The contacts of a limit switch (and of any switch or relay) are described in their resting state—that is, when nothing is pressing them.

  • NA, normally open (NO): open when not actuated; closes when pressed. The terminals are numbered 13-14 (or 23-24, 33-34).
  • NC, normally closed (NC): closed when at rest; opens when pressed. The terminals are numbered 11-12 (or 21-22).
slidecammotorcycleNC 11-12closed at restNA 13-14open at restroller andpistonrest position limit switch+24 VNC, normally openpositiverelaysafetysafety0 Vcam, broken wire,slow terminal:in all casesthe current stopsand the axis stops
Figure 47.4 · On the left, a limit switch with one NC contact and one NO contact. On the right, the NC contact used in the safety circuit: any wiring fault stops the machine.

Why does the safety device use an NC contact?

For a safety function (open door, shaft out of travel, emergency stop button), the NC contact is always used; current flows when everything is in order and is interrupted to trigger a stop. This is the principle of the standby current: a broken wire, a disconnected connector, an oxidized terminal, or a power outage all have the same effect as an open contact, causing the machine to stop. With an NO contact, however, the same fault would make it impossible to transmit the stop signal, and no one would notice until the day it was actually needed.

There is a second risk: a contact that has carried too much current may stick (micro-weld) and remain closed even when the cam presses it. For this reason, safety limit switches have positive-break contacts (symbol: an arrow inside a circle): the plunger is connected to the NC contact bridge by a rigid element, with no springs in between, and when the cam pushes it, it forces the contacts apart even if they are stuck together. These topics are covered in full in Chapter 51, on machine safety.

Example 47.3 · Where to Place the Overtravel Limit Switch

An axis moves at a rapid feed rate of 24 m/min and brakes with a deceleration of 3 m/s². The control system responds to the limit switch in 10 ms. What is the minimum distance from the mechanical stop at which the overtravel limit switch should be installed?

speed: v = 24 / 60 = 0.4 m/s
Distance traveled while the control system responds: 0.4 × 0.010 = 0.004 m = 4.0 mm
stopping distance: s = v² / (2 · a) = 0.4² / (2 · 3) = 0.16 / 6 = 0.0267 m = 26.7 mm (Chapter 9)
Total: 4.0 + 26.7 = 30.7 mm
At least 31 mm before the joint, plus a margin (in practice, 40–50 mm)

47.4 Inductive and Capacitive Proximity Sensors

Proximity sensors detect an object without touching it. They have no moving parts, are wear-resistant, switch in less than a millisecond, and are enclosed in a sealed housing: they are the most widely used sensors in machine tools.

The Inductive Sensor

Inside the inductive sensor is a coil wound around a ferrite core, powered by an oscillator that creates an alternating magnetic field in front of the sensing surface. When a metallic object enters the field, eddy currents (or Foucault currents; see Chapter 44) are induced in the metal, which draw energy from the oscillator: the runout amplitude decreases, a detection circuit detects this, and the output stage switches. An LED on the housing lights up when the output is active.

cableoscillatordetectoroutputLEDsteel targetCurrent flows through the metaleddy currents that absorbenergy: the runoutdampens and the output switchesSncoil onferritethreaded body M8, M12, M18, M30
Figure 47.5 · Inductive sensor: oscillator, detector, and output stage; the steel target enters the coil’s field.

The inductive sensor detects only metals and ignores plastic, wood, water, oil, and non-metallic chips. It is ideal for monitoring the position of cams, slides, pistons, tools, and spindles.

The intervention distance

The distance at which the sensor switches depends on the size of the coil—that is, the diameter of the body—and on the material of the target. The data sheet specifies the nominal switching distance Sn, measured using a standardized target: a 1-mm-thick square of mild steel with a side equal to the diameter of the sensing face (or three times Sn, if it is larger). Two other parameters defined by the standard for proximity sensors (EN 60947-5-2) are important for the project:

  • the actual distance Sr, that of a single specimen, which can range from 0.9 to 1.1 times Sn;
  • The safe operating distance Sa, between 0 and 0.81 · Sn: within this distance, the sensor operates reliably, regardless of which model is installed and within all permitted voltage and temperature ranges. The target must always be positioned within Sa.
BodyShielded Sn (mm)Unshielded SN (mm)Switching frequency (Hz)
M81,52,5from 1,000 to 3,000
M1224from 800 to 2,000
M1858from 300 to 1,000
M301015from 100 to 500

These are approximate values for standard sensors; models with extended range (up to two or three times these values) are available. Refer to the manufacturer's data sheet for details.

With metals other than steel, the distance decreases because the metal absorbs less energy from the field. Sn is multiplied by a reduction factor:

Target MaterialReduction factor (approximate)
Mild steel (S235)1,00
Austenitic stainless steel0,70
Brass0,45
Aluminum0,40
Copper0,30

Rounded average values: These vary from one manufacturer to another and depending on the thickness of the target. There are sensors known as “factor 1” sensors that detect all metals at the same distance.

Safe operating distance of an inductive sensor
Sa ≤ 0,81 · Sn · km
Sa: Safe working distance, in mm · Sn: Nominal distance from the board (steel target), in mm · km: Material reduction factor (see table above).
Example 47.4 · Brass Target

A screened M18 sensor (Sn = 5 mm) must be aligned with a brass bushing. At what distance should it be mounted?

nominal distance on the brass: 5 × 0.45 = 2.25 mm
safe distance: Sa = 0.81 × 2.25 = 1.82 mm
The sensor must be mounted no more than 1.8 mm from the bushing: with brass, the margin is reduced to less than half
Example 47.5 · Choosing a Sensor for an Aluminum Target

An aluminum bracket passes within 4 mm of the sensor's surface. Which sensor in the table can reliably detect it?

Unshielded M18: 0.81 × 8 × 0.40 = 2.59 mm < 4 mm, no
Shielded M30: 0.81 × 10 × 0.40 = 3.24 mm < 4 mm, no
Unshielded M30: 0.81 × 15 × 0.40 = 4.86 mm ≥ 4 mm, yes
You need an unshielded M30 (or a factor-1 sensor, or move the bracket closer)

The Capacitive Sensor

The capacitive sensor has an electrode as its sensing element, which forms a small capacitor with the surrounding environment (Chapter 44). Any material that enters the field changes the capacitance, with the effect increasing as the material’s dielectric constant rises: water affects it significantly, oil and plastic less so, and air almost not at all. The internal circuit detects this change and switches.

That’s why the capacitive sensor can detect non-metallic materials as well: plastic, wood, glass, cardboard, granules, powders, and especially liquids. It can even detect liquid through the plastic or glass wall of a tank, which has a lower dielectric constant than its contents. A trimmer screw on the back adjusts the sensitivity to ignore the wall and detect only the liquid. However, it is more sensitive to humidity, dirt, and droplets on the surface, and the detection range depends heavily on the material: it must always be adjusted on-site using the actual material.

liquid(water, oil, emulsion)airplastic tank wallmaximum sensordetects air: output OFFminimum sensorDetects liquid: Output ONone adjustment screwon the back sets the sensitivity
Figure 47.6 · Two capacitive sensors monitor the minimum and maximum levels through the plastic wall of the tank.

47.5 Photoelectric Sensors

Photoelectric sensors (photocells) use a beam of light—almost always infrared or red—that is pulse-modulated to prevent interference from ambient light. An emitter (an LED or a small laser) emits the light, and a receiver (a photodiode or a phototransistor) detects it. They detect any object that blocks or reflects the light, at distances much greater than those of proximity sensors. There are three main types.

Barrier

The transmitter and receiver are two separate devices, positioned opposite each other. The object triggers the output when it interrupts the radius. This is the most reliable type with the longest range (up to several tens of meters); it can also detect shiny or thick transparent objects, but requires two units to be mounted, aligned, and wired.

AndRobjectradius of lightno lightemitterreceiverTwo devices facing each other, two cables. Range up to a few dozen meters.
Figure 47.7 · Through-beam photoelectric sensor: The object interrupts the radius between the transmitter and the receiver.

A reflective strip

The transmitter and receiver are housed in the same unit; a reflector (like those on bicycles) is mounted in front of it, which reflects the light back exactly where it came from. The object switches off the output when it blocks the returning light. Only one unit needs to be wired, and the range extends to a few meters. Shiny objects could reflect the light and “fool” the sensor; for this reason, the best models have a polarizing filter, which recognizes light rotated by the reflector and filters out light reflected by a mirror or a sheet of metal.

AndRoutboundreturnreflectiveE and R togetherAn object between the sensor and the reflector blocks the return of the light.
Figure 47.8 · Reflective photoelectric sensor with reflector: the beam travels back and forth along the same path.

Direct reflection on the object

Here, too, the transmitter and receiver are housed in the same device, but without a reflector: the object itself scatters a small amount of light toward the receiver. The output switches when the object is present. It’s the easiest to install, but the range is short (from a few centimeters to about one meter) and depends on the color and finishing: a white object can be detected from much farther away than a matte black one. Models with background suppression measure the angle of the returning light and ignore anything beyond a preset distance, even if it is bright.

AndRobjectbackground:too muchnot enough lightworking distancediffused light reflecting back
Figure 47.9 · Direct reflection: The object scatters light in all directions, and some of it returns to the receiver.

Photocells often have a light-on/dark-on selector (output active when light is received or when light is absent), which acts as a choice between NO and NC. The main enemies of photoelectric sensors are emulsion mist, dust on the lenses, and vibrations that misalign the beam; they should be cleaned and checked regularly.

Example 47.6 · Counting Workpieces on a Conveyor Belt

Workpieces 15 mm long, spaced 10 mm apart, pass along a conveyor belt moving at 1.2 m/s. A photoelectric sensor with a response time of 0.5 ms counts them. The PLC has a cycle time of 10 ms. Will this work?

Time taken for the workpiece to cover the radius: 0.015 / 1.2 = 0.0125 s = 12.5 ms
Time during which the radius is free between two workpieces: 0.010 / 1.2 = 0.00833 s = 8.3 ms
frequency: 1 / (0.0125 + 0.00833) = 48 Hz, or 2,880 workpieces per minute
The photoelectric sensor (0.5 ms) is more than fast enough; however, the PLC reads the input every 10 ms, which is longer than the 8.3 ms gap between two workpieces.
The PLC may fail to detect the gap and count two workpieces as one; a fast input (counter) is needed, or the workpieces need to be spaced farther apart.

47.6 Magnetic and Reed Sensors on Cylinders

Magnetic sensors switch when a magnetic field is present, usually that of a permanent magnet. They are most commonly used on pneumatic cylinders (Chapter 42): the piston has a magnetic ring, and the sensors are mounted on the outside of the cylinder barrel, in the designated grooves, without drilling into the cylinder. The cylinder barrel is made of aluminum or stainless steel, which do not shield the magnetic field. A sensor near the bottom indicates “cylinder retracted,” while one near the head indicates “cylinder extended”; in pneumatic notation, they are often designated a0 and a1 for cylinder A.

N Sa0Backa1forwardPiston with magnetic ringrodmagnet fieldreed: two blades in a glass ampoule
Figure 47.10 · Cylinder with a magnetic piston and two sensors in the jacket groove. At the bottom, the bulb of a reed sensor.

There are two types.

  • Reed switch: two strips of ferromagnetic material enclosed in a glass tube filled with an inert gas. The magnetic field magnetizes them and causes them to touch: this is true contact, which requires no power supply and works even with alternating current. It is inexpensive, but it has moving parts, bounces when closing, and is susceptible to strong currents and vibrations.
  • Electronic (Hall-effect or magnetoresistive): They have no moving parts, switch faster, and last longer. They are connected using three wires, just like proximity sensors (paragraph 47.8).

The sensor switches over a zone of a few millimeters (from 5 to 15 mm, depending on the magnet and the sensor), not at a specific point. For a limit switch, this isn’t a problem: the piston reaches the end of its travel and stops there. For a sensor positioned midway through the travel—which the piston passes through without stopping—the signal is brief, and the PLC might not detect it.

Example 47.7 · The Mid-Travel Sensor

A mid-stroke magnetic sensor has a sensing range of 10 mm. The PLC has a cycle time of 10 ms. How long does the signal last if the piston travels at 0.5 m/s? And at 1.5 m/s?

at 0.5 m/s: t = 10 mm / 0.5 m/s = 10 / 500 s = 0.020 s = 20 ms
at 1.5 m/s: t = 10 / 1500 s = 0.0067 s = 6.7 ms
At 0.5 m/s, the signal lasts for two PLC cycles and can be read; at 1.5 m/s, it lasts less than one cycle and may be lost

47.7 Ultrasonic Sensors

The sensor at ultrasound It works like an echo in the mountains, or like a bat's sonar. A piezoelectric transducer sends out a short sound pulse at a frequency too high for the human ear (from about 40 to 400 kHz), then listens for theecho that is reflected back from the object. The time between the pulse and the echo, known as flight time, is proportional to the distance. The sound travels back and forth, so the distance is half the total distance traveled.

sensorliquid surfacepulseechod1234560Time (ms)t = 4.2 ms (round trip)
Figure 47.11 · The sensor sends a pulse; the echo returns after a flight time of t.
Distance vs. Flight Time
d = v · t2 v ≈ 331,3 + 0,606 · T
d: distance to the object, in m · v: speed of sound in air, in m/s (343 m/s at 20 °C) · t: flight time (round trip), in s · T: air temperature, in °C.

The ultrasonic sensor can detect almost anything: liquids, granules, clear glass, and objects of any color. It is widely used to measure liquid levels in tanks and hoppers and to measure distances of up to a few meters. However, it has a blind spot in front of its sensor face (a few centimeters), where it cannot detect anything because it is still emitting sound; it struggles with very steep surfaces, which reflect the echo elsewhere, and soft materials like foam, which absorb it. And since the speed of sound depends on temperature, high-quality models have a sensor that compensates for this.

Example 47.8 · Level in a Tank

An ultrasonic sensor is mounted 1.50 m above the bottom of an emulsion tank and measures a time-of-flight of 4.2 ms at 20 °C. How much emulsion is there?

distance from the surface: d = 343 · 0.0042 / 2 = 0.720 m
level: 1.50 − 0.720 = 0.780 m
The emulsion is 78 cm tall
Example 47.9 · The Effect of Temperature

The same sensor, without compensation, always calculates a value of 343 m/s. In the summer, the air in the tank is 35 °C, and the flight time is still 4.2 ms. How much of an error is there?

true speed: v = 331.3 + 0.606 × 35 = 352.5 m/s
actual distance: 352.5 × 0.0042 / 2 = 0.740 m; calculated distance: 0.720 m
error: 0.740 − 0.720 = 0.020 m = 20 mm, approximately 2.7%
The measured level is 2 cm higher than the actual level: temperature compensation is needed for accurate measurements

47.8 The Connection: PNP, NPN, and Two-Wire

Electronic sensors (inductive, capacitive, photoelectric, and electromagnetic) require a power supply, almost always 24 V DC (Chapter 46). The most common type has three wires, with colors specified by the standard:

ColorAcronymFunction
BrownBNpositive power supply, +24 V
BlueBUnegative power supply, 0 V
BlackBKoutput (usually NA)
WhiteWHsecond output, if any (usually NC or complementary)

In M12 and M8 screw-type connectors—the most commonly used types—the contacts are numbered as follows: 1 brown, 2 white, 3 blue, 4 black.

PNP Output and NPN Output

The sensor's output is a transistor that functions as an electronic switch (Chapter 46). The difference between the two types lies in which side this switch is on.

  • PNP: The transistor connects the black wire to the +24 V. The load (the PLC input, a relay) is connected between the black wire and 0 V. When the sensor is active, there is 24 V on the black wire: this is referred to as positive logic, and the sensor “supplies” current to the load (in English source).
  • NPN: The transistor connects the black wire to the 0 V. The voltage ranges from +24 V to ground. When the sensor is active, ground drops to 0 V: this is referred to as negation, and the sensor “absorbs” the load current (sink).
Brown BN +24 VBU blue 0 VPNP sensorcircuitBN brown +24 VBU blue 0 VNPN sensorcircuitBK blackInputPLCWhen ON, the black wire goes to +24 V: positive logicBlack BKInputPLCWhen ON, black goes to 0 V: negative logic
Figure 47.12 · On the left is a PNP sensor: the switch is connected to +24 V, and the load is connected to 0 V. On the right is an NPN sensor: the load is connected to +24 V, and the switch is connected to 0 V. The red arrow indicates the current flow when the output is active.

A PNP sensor must be connected to a PLC input designed to receive 24 V (known as a sink input, or “PNP”); an NPN sensor must be connected to an input that is activated when brought to 0 V. Mixing them up won’t cause any damage, but the signal won’t be transmitted. In Europe, PNP is almost always used: with positive logic, an output wire touching the machine’s ground (which is connected to 0 V and earth) sets the input to zero—that is, to “inactive”—which is the safest state; and “24 V = 1” is more intuitive to check with a multimeter. NPN remains common on machines and controls of Asian and American origins: always check the part number before replacing a sensor.

Example 47.10 · A Relay on the PNP Output

I want to directly control a 24 V, 1.2 W relay using a PNP sensor. The sensor's output can handle a maximum of 200 mA. Is that okay?

Relay current: I = P / U = 1.2 / 24 = 0.050 A = 50 mA (Chapter 44)
50 mA < 200 mA
All right. A feedback diode (Chapter 46) is installed on the relay coil anyway to protect the transistor when the circuit is turned off.

Two-wire sensors

The two-wire sensor is connected in series with the load, just like a switch: one wire goes to +24 V, and the other to the PLC input. It’s quick to wire and makes it easy to replace an old limit switch, but there’s a catch. The sensor must be powered by the load itself, so:

  • When it is turned off, it allows a small residual current to flow (approximately 0.5 to 1.5 mA), which it needs to stay lit inside;
  • When it is turned on, there is a voltage drop of a few volts (3 to 6 V), and the load receives less than 24 V.
+24 Vsensortwo-wireinputPLC0 VThe same current flows through bothON3–6 V dropOFFresidual current0.5–1.5 mAmust read OFFeven with theresidual current
Figure 47.13 · The two-wire sensor is connected in series with the load: when off, it allows the residual current to flow; when on, it maintains a small voltage.

According to the relevant standard (EN 61131-2), the 24 V inputs of PLCs reliably read “1” above 15 V and “0” below 5 V; in between, the value is uncertain. The standards specify different types of inputs: Type 2 and Type 3 inputs are designed to accept the residual current from two-wire sensors.

Two-wire sensor at the PLC input
UOFF = Ir · Ri UON = Ualim − Ud
UOFF: Voltage across the input with the sensor off, in V · Ir: Residual current, in A · Ri: PLC input resistance, in Ω · UON: Voltage across the input with the sensor on · Ualim: Supply voltage (24 V) · Ud: Voltage drop across the sensor.
Example 47.11 · A two-wire sensor that does not turn off

A two-wire sensor has a quiescent current of 1.0 mA and a voltage drop of 5 V. It is connected to two different PLCs: one with 3.3 kΩ inputs, the other with 7 kΩ inputs. What reading does each one get?

Sensor on: UON = 24 − 5 = 19 V > 15 V; both read “1”
Sensor off, first PLC: UOFF = 0.001 × 3300 = 3.3 V < 5 V, reads “0”
Sensor off; according to the PLC: UOFF = 0.001 × 7,000 = 7 V, in the uncertain range between 5 and 15 V
With the second PLC, the input can remain “on” even without a load: either a resistor is connected in parallel with the input to lower the voltage, or a three-wire sensor is used

NA and NC Outputs

Electronic sensors also have NO (normally open—active when an object is present) or NC (normally closed—active when an object is not present) outputs. Some have both, on the black and white terminals (complementary outputs), while others are programmable. For a check such as “workpiece present,” NO is usually chosen; for a check such as “no obstacle” or “level not too low,” where a broken wire must trigger an alarm, the NC output is chosen, following the same reasoning as in paragraph 47.3. Today, many sensors also have an IO-Link interface: over the same three-wire cable, in addition to the on/off signal, they send the measured distance, internal temperature, and diagnostic data to the PLC, and they can be configured remotely.

🛡️
Safety sensors. A standard sensor—even an NC sensor—is not enough to protect people: a transistor can short-circuit and remain on. For doors, light barriers, and safety mats, the following are used: safety sensors Certified devices: switches with double positive-break contacts, magnetic sensors, or encoded RFID tags (which cannot be fooled by just any magnet), safety light curtains, and laser scanners. They have two channels that monitor each other and must be connected to a relay or a safety PLC. Chapter 51 discusses this in detail.

47.9 The Incremental Encoder and Speed Measurement

To measure a position continuously, as a numerical control system does with its axes, on/off sensors are not enough: encoders are needed. A rotary encoder is mounted on the shaft of a motor or a lead screw and measures the angle of rotation; from this, the control system determines the position of the slide.

How It's Made

The optical incremental encoder has a disc made of glass or metal with a ring of slits (or opaque and transparent lines) spaced at regular intervals. On one side, an LED illuminates the disc; on the other, some photodetectors receive light through a mask fixed at the same pitch. As the disc rotates, the light passes through and is interrupted: each slit produces a pulse. The number of slits, that is, the number of pulses per revolution (PPR, pulses per revolution), you can choose from a few hundred to a few thousand: typical values are 1000, 1024, 2048, 2500, and 5000.

ABZslots with a constant pitch and a single zero markLEDdiscmaskphotodetectorsA, B, Zshaft
Figure 47.14 · Incremental encoder: on the left, the disk with the A and B markings and the zero mark Z; on the right, a side view.

Channels A, B, and Z

  • A and B: two readings on the same crown, offset by a quarter of a step. They produce two identical square waves, out of phase by 90° (they are said to be in quadrature). The order in which they change indicates the direction of rotation: if A rises when B is low, the shaft rotates in one direction; if A rises when B is high, it rotates in the other.
  • Z (or zero channel, or reference mark): a single slot on an internal ring that produces one pulse per revolution. It is used for zero search (paragraph 47.13) and to synchronize the spindle during threading.

In machine tools, signals are transmitted in differential form: for each channel, there is also a negated signal (A and /A, B and /B, Z and /Z) on a twisted-pair cable. The receiver monitors the difference between the two wires, and any noise that is present on both wires equally cancels itself out.

ABZ1/4 of a period (90°)1234four edges per period: count ×4one Z pulse per revolution
Figure 47.15 · Signals A and B, which are out of phase by a quarter of a period, and pulse Z. By counting the rising and falling edges of both channels, there are four counts per slot.

Resolution and Multiplication by Four

The control counter doesn't just count the pulses from A: it counts on all fronts, up and down, A and B. At any given time, there are four edges, so an encoder with 2,500 pulses per revolution produces 10,000 counts per revolution. It is the multiplying by four (×4). If the encoder is mounted on the motor of a recirculating ball screw (Chapter 40), the linear resolution of the axis is the screw pitch divided by the number of counts per revolution.

Resolution of the incremental encoder
Nc = 4 · N rang = 360°4 · N rlin = P4 · N
N pulses per encoder revolution · Nc counts per revolution with a ×4 multiplier · rang angular resolution, in degrees · rlin linear resolution of the axis, in mm · P lead of the lead screw, in mm (encoder connected directly to the lead screw or to the motor via a coupling).
Example 47.12 · Resolving an axis

A motor with an encoder that produces 2,500 pulses per revolution directly drives a ball screw with a 10-mm pitch. What is the resolution of the axis? And what about a motor with a 1,024-pulse encoder and a ball screw with a 5-mm pitch?

counts per round: 4 × 2,500 = 10,000
rlin = 10 / 10,000 = 0.001 mm = 1 µm; rang = 360 / 10,000 = 0.036°
Second case: 4 × 1024 = 4096 counts; rlin = 5 / 4096 = 0.00122 mm
1 µm in the first case, 1.22 µm in the second. Resolution is not the same as precision: the errors of the lead screw remain (paragraph 47.10)
Example 47.13 · From Count to Position

Using the axis from the previous example (10,000 counts per revolution, 10 mm pitch), after resetting to zero, the counter has counted 186,000 counts forward and 6,000 counts backward. Where is the slide?

net total: 186,000 − 6,000 = 180,000
screw revolutions: 180,000 / 10,000 = 18 revolutions
position: 18 × 10 = 180 mm from zero
The slide is set to 180 mm. If the machine is turned off, the count is lost: this is why the encoder is called an incremental encoder, and a zero search is required when the machine is turned on.

Measuring Speed

Rotational speed is measured in two ways.

  • Tachometer generator: a small permanent-magnet DC generator mounted on the shaft. It produces a voltage proportional to the speed—for example, 20 V per 1,000 rpm—and the polarity of the voltage indicates the direction of rotation. It was the speed sensor used in older DC drives; today it is found only on older machines.
  • From the encoder: the controller counts how many pulses arrive within a certain time, that is, it measures their frequency. A single encoder is thus used for both position and speed, and this is the solution used in all modern servo drives (Chapter 48).
Revolutions per Pulse Frequency
n = 60 · fN vf = n · P
n revolutions per minute · f pulse frequency of a channel (A), in Hz · N pulses per revolution · vf slide speed, in mm/min · P lead of the screw, in mm.
Example 47.14 · Speed from the encoder and the generator

On channel A of a 2,500-pulse-per-revolution encoder mounted on a 10-mm-pitch screw, a frequency of 62.5 kHz is measured. What is the motor’s speed, and what is the speed of the slide? On another machine, a tachometer generator that produces 20 V per 1,000 rpm outputs 31 V: what is its speed?

n = 60 × 62,500 / 2,500 = 1,500 rpm
vf = 1,500 × 10 = 15,000 mm/min = 15 m/min
dynamo: n = 31 / 20 × 1000 = 1,550 rpm
Motor at 1,500 rpm, carriage at 15 m/min; the second machine runs at 1,550 rpm

47.10 Absolute Encoders, Optical Encoders, and Resolvers

The Absolute Encoder

The incremental encoder only knows how far it has moved since the last time. The absolute encoder, on the other hand, knows its exact position at any given moment, even right after it is turned on. The disk does not have a single ring of slits, but rather many concentric tracks, one for each bit: a file of photodetectors reads them all at once, and each angular position has a different code. With n tracks, 2n positions can be distinguished per revolution.

The tracks do not follow standard binary code but rather Gray code, in which only one bit changes between one position and the next (Chapter 46): if the bit readings are not perfectly simultaneous, the error remains within one step at most, rather than jumping to a distant value.

reading4 tracks = 2⁴ = 16 positions per revolutionThe red line reads all four tracks together:0 1 1 1 = sector 5 of 16 (Gray code)Each sector has a different code: when powered onthe encoder immediately knows its position; there is no zeroOnly one bit changes between one sector and the next(Gray code, Chapter 46)Real models have 12 to 23 bits per revolution
Figure 47.16 · Four-track absolute encoder: the inner track is the most significant bit. The reading yields the Gray code for the sector.
  • A single-turn encoder knows its position within a single turn, but it does not know how many turns it has made.
  • The multiturn encoder also counts revolutions: either using a series of discs connected by reduction gears, or with an electronic counter powered by a battery. On an axis with a lead screw, it knows the slide’s position throughout its entire travel: when powered on, the machine is immediately ready, with no need for zeroing.

Modern absolute encoders do not transmit bits over multiple files, but rather via a digital serial connection (using protocols such as EnDat, BiSS, SSI, or those specific to control manufacturers): two or four files carry position, revolutions, and diagnostic data.

Example 47.15 · A multiturn absolute encoder

An encoder has 13 bits per revolution and a 12-bit revolution count. How many positions does it distinguish in one revolution, what is its angular resolution, and what travel distance does it cover on a screw with a 10-mm pitch?

positions per revolution: 213 = 8,192; resolution: 360° / 8,192 = 0.0439°
Number of revolutions: 212 = 4,096
travel: 4096 × 10 mm = 40,960 mm = 40.96 m
8,192 positions per revolution (0.044°); the travel distance, nearly 41 m, is much longer than that of any machine tool axis

The optical ruler: direct measurement of the slide

The encoder on the motor measures the position by indirect: Count the number of turns of the screw and multiply it by the pitch, assuming that the screw is perfect and that the slide follows the lead screw without any clearances. But the screw has errors of step (a few micrometers on each segment), a little clearance or elastic deformation in the spiral and the supports, and above all, it It stretches as it heats up, because the rolling balls generate heat. The encoder doesn't detect any of this.

The optical line (or linear scale) is a glass or steel ruler with an engraved grid, secured to the base along its entire travel; a sensor mounted on the slide reads it using the same principle as an encoder (quadrature signals, paragraph 37.1). It measures the position really the sled, in such a way that direct: Errors in the lead screw are not included in the measurement, because the control system adjusts the motor until the line indicates that the slide has reached its destination. It is said that the axis operates at closed loop on the line. Scales are incremental (with reference marks, often spaced at a standardized distance to locate the zero point within a few millimeters) and absolute types.

basemotorencoderslideball screwprint headoptical scale attached to the baseThe encoder counts the screw's revolutions; the scale measures the slide's actual position.pitch errors, clearance errors, andscrew expansion
Figure 47.17 · The encoder on the motor measures the rotations of the lead screw; the optical scale measures the position of the slide relative to the base.
Thermal expansion of the screw
ΔL = α · L · ΔT
ΔL elongation, in mm · α coefficient of linear expansion (steel: approximately 11.5 × 10−6 /°C) · L length of the screw section, in mm · ΔT temperature increase, in °C.
Example 47.16 · Why the optical line is more accurate

During a day of heavy use, the 800-mm section of lead screw used by an axis heats up from 20 °C to 32 °C. By how much will the end-of-travel dimension be off if the axis is measured only using the encoder on the motor?

ΔL = 11,5 · 10−6 · 800 · 12 = 0.110 mm
The extended screw moves the lead screw farther than the number of revolutions counted by the encoder would indicate
An error of about 0.11 mm—enormous for a tolerance of a few hundredths. With the optical ruler, the error disappears (only the expansion of the workpiece and the ruler itself remains, which is much smaller).

Without a ruler, modern controls mitigate the problem through pitch error compensation (a correction table measured with an interferometer; see Chapter 37) and through preloaded or internally cooled screws; but only the scale bar detects effects that change from hour to hour.

The Resolver

The resolver is an angle transducer with no onboard electronics: it is a small rotating transformer. The rotor is powered by an alternating voltage, and two fixed windings, spaced 90° apart, pick up two voltages that vary like the sine and cosine of the angle; based on their ratio, the drive calculates the position within the revolution. It is less precise than a good optical encoder, but extremely robust against temperature, vibrations, shocks, and dirt; for this reason, it is found on many brushless servomotors and in harsh environments.

47.11 Force, Weight, and Pressure

The strain gauge

L'strain gauge (strain gauge) is a grid of very thin metal wire or foil, bonded to an insulating substrate, which is in turn bonded to the workpiece being measured. When the workpiece deforms, the grid stretches or shortens along with it, and its resistance changes in proportion to the deformation ε (Chapter 10). The ratio of the relative change in resistance to the deformation is called calibration factor k, which is approximately 2 for metal strain gauges.

Strain gauge
ΔRR = k · ε
ΔR change in resistance, in Ω · R open-circuit resistance (120, 350, or 1000 Ω) · k calibration factor (approximately 2) · ε strain, dimensionless (often in µm/m: 500 µm/m = 0.0005).

The variations are extremely small—fractions of an ohm—and a Wheatstone bridge is used to measure them: four resistors arranged in a diamond pattern, powered between two opposite vertices, with the output taken between the other two. At rest, the bridge is balanced and the output is zero; as soon as one resistor changes, a voltage of a few millivolts appears. By using four active strain gauges—two that stretch and two that contract—the signal is amplified, and the effects of temperature cancel each other out.

The load cell

A load cell is a steel or aluminum block, shaped to deform in a precise and repeatable manner, with four strain gauges already bonded and calibrated in a bridge configuration. It is used for weighing (scales, dispensers, hoppers) and for measuring compression, tensile, and clamping forces. The data sheet specifies its sensitivity in mV/V: a typical value is 2 mV/V, meaning 2 mV of full-scale output for every volt of supply voltage.

FR1 and R3: they get longerR2 and R4: shortenstrain gauges glued to the beamR2R3R4R1U+ power supply (e.g., 10 V)0 Voutputin mV
Figure 47.18 · On the left, a bending load cell: the force stretches the strain gauges at the top and shortens those at the bottom. On the right, the four strain gauges connected in a bridge configuration.
Load Cell Output
Ufs = S · Ua m = mfs · UUfs
Ufs full-scale output, in mV · S sensitivity, in mV/V · Ua bridge supply voltage, in V · m measured load · mfs full-scale load (same unit) · U Read output, in mV.
Example 47.17 · Strain Gauge and Load Cell

A 350 Ω strain gauge with k = 2 undergoes a strain of 500 µm/m: by how much does its resistance change? A 500 kg load cell, with a sensitivity of 2 mV/V and powered by 10 V, reads 7.4 mV: how much does the load weigh?

ΔR = k · ε · R = 2 · 0,0005 · 350 = 0,35 Ω
Full-scale output of the cell: 2 × 10 = 20 mV
load: 500 · 7.4 / 20 = 185 kg
0.35 Ω out of 350 (one-thousandth); the load weighs 185 kg

Pressure: Pressure Switches and Transducers

The pressure switch is a digital pressure sensor: a diaphragm or piston, pushed by pressure against an adjustable spring, triggers a contact when the set threshold is exceeded. It has a hysteresis (the “differential”) between the activation point and the return point. On machine tools, it monitors the compressed air supply, the hydraulic oil in the chuck, and the centralized lubrication system.

The pressure transducer, on the other hand, outputs an analog signal proportional to the pressure. Inside, it contains a diaphragm with strain gauges or a piezoresistive element, along with electronics that convert the signal to 0–10 V or, more commonly, to 4–20 mA. The current is not affected by the resistance of long cables, and the “live” zero at 4 mA makes it possible to distinguish a broken wire (0 mA) from zero pressure (4 mA), as explained in Chapter 46. The relationship between current and pressure is a straight line through two points (Chapter 7).

Conversion of a 4–20 mA Signal
I = 4 + 16 · x − xminxmax − xmin x = xmin + (xmax − xmin) · I − 416
The current, in mA · × measured quantity (bar, °C, mm ...) · × min value corresponding to 4 mA · × max value corresponding to 20 mA. For 0–10 V, simply replace 4 and 16 with 0 and 10.
0246810481216206 bar → 13.6 mA10 bar = 20 mA0 bar = 4 mAbelow 3.6 mA: broken wire or faultCurrent (mA)Pressure (bar)
Figure 47.19 · Transducer ranging from 0 to 10 bar with a 4–20 mA output: 6 bar corresponds to 13.6 mA. A signal below 3.6 mA indicates a fault.
Example 47.18 · Reading a 4–20 mA Transducer

A transducer rated from 0 to 10 bar outputs 13.6 mA. What is the pressure? What current will it output at 2.5 bar? What does a reading of 0.2 mA mean?

slope: 16 mA / 10 bar = 1.6 mA per bar
p = 0 + 10 · (13.6 − 4) / 16 = 10 · 9.6 / 16 = 6 bar
at 2.5 bar: I = 4 + 16 · 2.5 / 10 = 4 + 4 = 8 mA
0.2 mA is below the 4 mA zero point: this is not negative pressure; it indicates a broken wire or a faulty transducer
6 bar; 8 mA; 0.2 mA = fault, to be reported as an alarm

47.12 Temperature and Other Quantities

Thermocouples

A thermocouple consists of two wires made of different metals that are soldered together at one end (the hot junction). If the tip is hotter than the other end (the cold junction, at the instrument’s terminals), a small voltage is generated between the two wires, amounting to a few tens of microvolts per degree (Seebeck effect). The thermocouple therefore measures a temperature difference: the instrument also measures the temperature of the cold junction and adds it (cold junction compensation). It is connected using compensation cables of the same type, never with ordinary copper wires.

TypeMetalsScope of Use (for reference only)Average sensitivity (approximate)
Knickel-chromium / nickel-aluminumfrom −200 to 1200 °Cabout 41 µV/°C
Jiron / copper-nickel (constantan)from −40 to 750 °Cabout 52 µV/°C

Thermocouples are rugged, inexpensive, fast, and can reach extremely high temperatures (heat treatment furnaces, molds, injection molding machine nozzles), but they are not very accurate: a couple of degrees at best. The voltage does not increase in a perfectly linear manner, and instruments use standard tables; for a manual calculation, you can use the average sensitivity.

Example 47.19 · A K-type thermocouple in an oven

A reading of 15.6 mV is measured at the terminals of a K-type thermocouple; the cold junction is at 20 °C. What is the temperature inside the oven, assuming average sensitivity?

temperature difference: 15.6 mV / 0.041 mV/°C = 380 °C
temperature of the hot joint: 380 + 20 = 400 °C
About 400 °C (without compensation, the reading would be 380 °C, 20 degrees lower)

PT100 Resistance Temperature Detectors

The heat resistance takes advantage of the increase in a metal's resistance as the temperature rises. The most commonly used is the PT100: a platinum wire or film that has a resistance of exactly 100 Ω at 0 °C and increases by approximately 0.385% per degree. Within the range of 0 to 100 °C, the relationship is practically a straight line. It is much more accurate and stable than a thermocouple (Class A has an error of less than 0.15 °C at 0 °C), but it is slower and has a maximum operating range of a few hundred degrees. There is also the PT1000, which has a resistance of 1000 Ω at 0 °C.

PT100 Resistance Thermometer (linear response)
R ≈ 100 · (1 + 0,00385 · T) T ≈ R / 100 − 10,00385
R = resistance, in Ω; T = temperature, in °C; 0.00385 = average platinum coefficient between 0 and 100 °C, in 1/°C. Outside this range, the instruments use the complete formula specified in the standard.

When connected with only two wires, the PT100 also measures the resistance of the cables, which leads to errors; for this reason, it is connected using three wires (the instrument measures and compensates for the cable resistance) or four wires for laboratory measurements. Often, a small converter at the tip of the probe converts the signal to 4–20 mA.

Example 47.20 · A PT100 in the spindle

What is the resistance of a PT100 at 60 °C? If the instrument reads 119.25 Ω, what is the temperature? And by how much would a two-wire PT100 with a total cable resistance of 1 Ω be off?

R = 100 · (1 + 0,00385 · 60) = 100 · 1,231 = 123,1 Ω
T = (119,25 / 100 − 1) / 0,00385 = 0,1925 / 0,00385 = 50 °C
The PT100 varies by 100 × 0.00385 = 0.385 Ω per degree; 1 Ω of cable corresponds to 1 / 0.385 = 2.6 °C
123.1 Ω; 50 °C; a two-wire connection would read 2.6 °C higher

NTC Thermistors

The NTC thermistor (negative temperature coefficient) is a semiconductor whose resistance cala significantly, and in a highly nonlinear manner, as the temperature rises. It is small, inexpensive, and extremely sensitive, but has a limited range: it is used to protect motor windings, electronic components, and batteries, and as a thermostat. Motors also contain PTCs (whose resistance rises abruptly at a certain threshold, making them ideal for on/off protection) and KTY-type silicon sensors.

05010010012014060 °C: 123.1 ΩPT100: nearly a straight lineR (Ω)temperature (°C)05010010203025 °C: 10 kΩNTC: drops rapidlyR (kΩ)temperature (°C)
Figure 47.20 · On the left, the PT100, which is nearly linear. On the right, a 10 kΩ NTC at 25 °C (illustrative curve): between 0 and 100 °C, the resistance changes from approximately 34 kΩ to less than 1 kΩ.

Level, Flow Rate, and Vibrations

  • Level: In addition to the capacitive and ultrasonic sensors already discussed, float switches with reed contacts (the most common type used in oil and coolant tanks of machine tools) and hydrostatic pressure transducers at the bottom are used: pressure is given by p = ρ · g · h, so 78 cm of water corresponds to approximately 7,650 Pa.
  • Flow rate: Turbine flow meters have a propeller that rotates with the fluid and sends a pulse each time a blade passes; electromagnetic and ultrasonic flow meters have no moving parts. A flow switch is the on/off version: it simply indicates whether the fluid is flowing, and it is the sensor that controls the cooling water for the spindles and lasers.
  • Vibrations: Piezoelectric accelerometers measure acceleration (in m/s² or in multiples of g). Mounted on the spindle head, they allow for monitoring the bearings (a failing bearing vibrates more at characteristic frequencies), detecting cutting vibrations, and detecting a collision in just a few milliseconds.
Example 47.21 · A turbine flowmeter

The flow meter in a spindle's cooling circuit registers 450 pulses per liter; the PLC measures 150 Hz. What is the flow rate?

liters per second: 150 / 450 = 0.333 l/s
liters per minute: 0.333 × 60 = 20 L/min
20 l/min; if the flow rate falls below the set threshold, the PLC stops the spindle

47.13 Sensors in CNC Machine Tools

A CNC lathe or machining center has dozens of sensors. Here are the most important ones and what they do.

  • Encoders and optical scales for the axes and spindle (sections 47.9 and 47.10): They provide the controller with position and speed information and are the heart of the control loop (chapter 48).
  • Over-travel limit switches: At each end of every axis, beyond the usable travel range, an NC-contact limit switch (or a safety sensor) that cuts power to the drives if the axis moves beyond that point. After zero search, the controller also uses software limits, which stop the axis before it reaches the limit switch; the limit switch remains the last line of defense before mechanical stop (example 47.3).
  • Machine zero sensor: a limit switch or an inductive sensor, with its cam, used to find the zero point (below).
  • Workpiece and tool measurement probes (section 37.9): The workpiece probe is mounted in the spindle like a tool and transmits contact information to the control via infrared or radio; the control system, using a probing movement (on Fanuc G31 machines, the “jump” command), records the position of the axes at the moment of contact. The tool measuring device, whether contact-type or laser-based, measures the length and radius of the tools and detects tool breakage.
  • Door sensors: safety switches, often with a locking mechanism (electric lock), that keep the door closed as long as the spindle is rotating and prevent it from starting when the door is open.
  • Pressure switches: compressed air supply (if the pressure drops below 5–6 bar, the machine triggers an alarm); hydraulic oil for the chuck and tailstock (if the clamping pressure drops, the spindle stops before the workpiece flies off); centralized lubrication of the guides (if the pressure does not rise within the expected time during each pump cycle, the control system signals a broken hose or an empty reservoir).
  • Temperature Sensors: thermostats, PT100, PTC, or KTY sensors in the spindle motor and axis windings, in the cartridge bearings, in the hydraulic unit oil, and in the electrical cabinet. Some control systems use these temperatures to compensate for thermal expansion of the car.
  • Level and flow switches: lubricating oil, hydraulic oil, coolant, water from the spindle cooling unit.
  • Tool and spindle change: inductive sensors that indicate whether the tool is clamped or released in the spindle, the location of the tool magazine, and whether the exchange arm is in position; on the lathe, whether the turret is locked and what position it is in.

The Quest for Zero

With incremental encoders, when the system powers on, the controller does not know the position of the axes: a zero search must be performed (known in technical jargon as “zeroing” or “homing”; on Fanuc systems, this is done by returning to the reference point with G28 or the ZRN key). The most common method combines a zero sensor with the encoder’s Z channel:

  • The axis moves quickly in the specified direction until the cam presses against the zero sensor;
  • slow down and continue at a low speed until the cam releases the sensor;
  • It stops at the first Z pulse from the encoder (or the line) that arrives after the button is released: that is the machine zero position.

The cam alone would not be enough: the sensor has a repeatability of a few hundredths, which also varies with temperature and speed. The Z pulse, on the other hand, always occurs at the same point in the rotation, with the precision of the encoder. The cam is only used to select which Z pulse to use from among the many—one per revolution. For this reason, the cam must be adjusted so that the release does not occur too close to a Z pulse: if it happened right there, a small variation would cause the system to select one pulse one time and the next pulse the next time, and the zero point would shift by an entire lead screw pitch. With absolute encoders, this search is unnecessary: the zero is set only once, during installation.

machine zerospeedrapid approach toward the camthen slow until the first Zsearch directioncamsensor pressedZ pulsesfirst Z afterrelease
Figure 47.21 · Zero search: rapid approach, deceleration over the cam, and stop at the first Z pulse after the cam has released the sensor.
Example 47.22 · How long does the final phase of the research last?

One axis has a 10-mm-pitch lead screw with an encoder mounted directly on the motor. After the cam is released, the axis moves toward the Z pulse at 100 mm/min. What is the maximum duration of this final phase?

The Z pulse occurs once per revolution, that is, every 10 mm of travel
In the worst-case scenario, the axis travels nearly 10 mm: t = 10 / 100 = 0.1 min = 6 s
At most 6 seconds. If the cam is adjusted properly, the release occurs halfway between two pulses, and the phase lasts about 3 seconds.

47.14 Selection, Installation, and Troubleshooting

Choose the sensor

What Should I See?Suitable sensor
A metal cam or slide, just a few millimeters longinductive
Piston Position in a Pneumatic Cylindermagnetic (reed or electronic)
Plastic, wood, cardboard, liquid through a wallcapacitive
Any objects, even those far awayphotoelectric (the safest barrier)
Levels of liquids and granules, transparent objectsultrasound
High-force position, safety, no power supplymechanical limit switch
Continuous Position and Velocity of an Axisencoder, optical scale
Pressure: threshold or valuepressure switch or 4–20 mA transducer
Temperature: high or precisethermocouple or PT100

Shielded and Unshielded

Inductive and capacitive sensors are classified into shielded (or “built-in,” in English flush) e unshielded (non-flush). On the screen, a metal ring around the coil concentrates the field in front of the face: the sensor can be mounted flush of a steel plate without the plate triggering it, but the operating distance is shorter. The unscreened version has a wider range and a greater distance (see the table in paragraph 47.4), but the head must protrude and a free zone made of metal.

Two sensors that are too close together interfere with each other: the fields of the two oscillators add up, causing the sensors to trigger randomly. As a general rule, leave at least twice the diameter between the axes of two adjacent sensors for screened sensors and three times the diameter for unscreened ones; two sensors facing each other must be kept even farther apart. If space is limited, there are models with different runout frequencies that can be mounted alternately. These are approximate values: refer to the manufacturer’s catalog for specifications.

axes ≥ 2·dshieldedface flush with the metalnarrow field, smaller Sn distanceaxes ≥ 3·dunshieldedfree zonewide field, larger Sn, distant metal
Figure 47.22 · Screened sensors mounted flush with the plate and unscreened sensors with a protruding head and a clear zone around them; d is the diameter of the body.

Protection, Wiring, and Interference

  • IP Protection Rating: The first digit indicates protection against solids (6 = dust-tight), and the second indicates protection against water (7 = temporary immersion, 8 = continuous immersion, 9K = high-pressure, high-temperature jets). Inside a machine tool covered in emulsion, a rating of at least IP67 is required; near the coolant jet, IP68 or IP69K is required, with a stainless steel housing.
  • Installation: Secure the sensor with the two nuts without tightening them too much (the plastic housing will break). Protect it from impacts with chips and from direct contact with the target, which must pass in front of the sensor face and never hit it. A sensor that also acts as a stop will not last long.
  • Cables: With an M12 or M8 connector, the sensor can be replaced in one minute; the cable must be secured without sharp bends, and if it moves along the axis, it must be suitable for cable chains (PUR cable for flexible installation).
  • Interference: Sensor cables—especially those for encoders and analog signals—must be kept away from the power cables of motors and inverters (Chapter 45), which generate significant interference. Separate cable trays should be used, along with shielded cables with the braid grounded (usually on the control panel side, all the way around using a cable gland or a metal clamp) and differential connections for the encoders.

Troubleshooting

When a machine stops with an alarm such as “cylinder not in position” or “workpiece missing,” in most cases the problem is caused by a sensor, a cable, or a connector. Let’s proceed step by step.

  • Check the LEDs: Many sensors have a green LED (power on) and a yellow LED (output active). A flashing LED often indicates a short circuit at the output or a target at the distance limit. The PLC inputs also have an LED for each channel, and the status of the inputs can be viewed on the control’s diagnostics page.
  • Test the sensor: Hold a metal object close to it (for an inductive sensor) or your hand (for a capacitive sensor or a photoelectric sensor) and see if the yellow LED changes.
  • Using a multimeter set to DC voltage, with the machine turned on and in a safe condition: there should be approximately 24 V between brown and blue (if there isn’t, the fault is in the power supply or the cable); between black and blue, for a PNP sensor, approximately 24 V when the object is present and approximately 0 V when it is not. For an NPN sensor, measure between black and brown. Then repeat the measurement at the PLC’s input terminal: if there is a signal at the sensor but not at the input, the fault is in the cable or the connector.
  • Check the mechanical components: a sensor displaced by an impact, a loose cam, a layer of chips on the surface, or a cylinder that does not reach the bottom due to low pressure can all produce the same symptoms as a faulty sensor.
Example 47.23 · A Diagnostic Case

The control system indicates “chuck not closed,” but the operator sees the jaws closed around the workpiece. The sensor is a PNP inductive sensor. The sensor’s yellow LED is on, and the PLC input LED is off. With the multimeter: 23.8 V between brown and blue, 23.2 V between black and blue on the sensor, 0 V between the input terminal and the 0 V reference in the control panel.

Power supply present (23.8 V) and active output to the sensor (23.2 V): the sensor is working and detects the cam
No signal is reaching the panel (0 V): the black wire is broken between the sensor and the PLC
Check the M12 connector near the spindle and the cable in the cable chain; the sensor does not need to be replaced
🖥️
Try it out in CNC Code. In the simulator, you can see the home search, overtravel limits, and software limits in action: try moving an axis beyond its travel range or running a program without homing first, and see how the controller reacts.

47.15 The Formulas in This Chapter

WhatFormulaUnits
Shut-off point with hysteresissoff = son · (1 + H)mm
Frequency of objects in front of the sensorf = z · n / 60Hz
Braking distance (where to place the limit switch)s = v² / (2 · a)m
Safe working distance (inductive)Sa ≤ 0,81 · Sn · kmmm
Distance Based on Flight Time (Ultrasound)d = v · t / 2m
Speed of sound in airv ≈ 331,3 + 0,606 · Tm/s
Two-wire sensor offUOFF = Ir · RiV
Encoder resolution (×4)rang = 360° / (4 · N) · rlin = P / (4 · N)° · mm
Revolutions per Pulse Frequencyn = 60 · f / Nrevolutions per minute
Positions of an absolute encoder2n (n bits)-
Thermal expansion of the screwΔL = α · L · ΔTmm
Strain gaugeΔR / R = k · ε-
Load cellUfs = S · Ua · m = mfs · U / UfsmV · kg
4–20 mA Signalx = xmin + (xmax − xmin) · (I − 4) / 16-
PT100R ≈ 100 · (1 + 0,00385 · T)Ω
Thermocouple (medium sensitivity)T ≈ U / s + Tgf°C

47.16 Exercises

Try to solve them on your own, using a calculator, before looking at the solution.

Exercise 1. A sensor turns on at 3.2 mm and has a hysteresis of 12%. At what distance does it turn off?
Solution

soff = 3.2 × 1.12 = 3.58 mm.

Exercise 2. A 24-tooth gear rotates at 1,200 rpm in front of an inductive sensor with a maximum frequency of 1,000 Hz. Can the sensor count the teeth?
Solution

f = 24 × 1200 / 60 = 480 Hz, less than 1000 Hz: yes, by a wide margin.

Exercise 3. An unscreened M12 sensor (Sn = 4 mm) must detect an aluminum cam. At what distance should it be mounted? And what about a shielded M18 sensor (Sn = 5 mm) for a stainless steel target?
Solution

Aluminum: 4 × 0.40 = 1.6 mm; Sa = 0.81 × 1.6 = 1.30 mm. Stainless steel: 5 × 0.70 = 3.5 mm; Sa = 0.81 × 3.5 = 2.84 mm.

Exercise 4. An axis moves at a rapid feed rate of 30 m/min and decelerates at 4 m/s²; the control system responds in 8 ms. How much space is needed between the overtravel limit switch and the mechanical stop, without any margin?
Solution

v = 0.5 m/s. Reaction: 0.5 × 0.008 = 4 mm. Braking distance: 0.5² / (2 × 4) = 0.03125 m = 31.25 mm. Total: 35.25 mm, so practically 45–50 mm with the margin.

Exercise 5. An ultrasonic sensor measures a time of flight of 7 ms in air at 20 °C. How far away is the object?
Solution

d = 343 · 0,007 / 2 = 1,20 m.

Exercise 6. Explain why a safety limit switch is connected to the NC contact and what “positive opening” means.
Solution

With the NC, current flows when everything is in order: a broken wire, a disconnected connector, or a loss of power interrupts the current just as opening the contact does, and the machine stops. With an NA, the same fault would prevent the stop signal from being sent without anyone noticing. Positive opening: the plunger opens the NC contacts via a rigid connection, without springs, even if the contacts have become stuck together.

Exercise 7. Using the tester, on a three-wire sensor with the object in front of it, you measure 24 V between brown and blue and 0 V between black and blue, while between black and brown you measure 24 V. The yellow LED is on. What kind of sensor is this? Will it work with a PLC input that requires a 24 V signal?
Solution

When the output is active, the black wire goes to 0 V: it is an NPN sensor, and it works. With an input that requires 24 V (an input for PNP sensors), the signal does not get through: you need to replace it with a PNP sensor (or use an input suitable for NPN).

Exercise 8. An encoder producing 5,000 pulses per revolution is mounted on a screw with a pitch of 16 mm. What is the resolution of the axis with a ×4 multiplication factor?
Solution

4 · 5,000 = 20,000 counts per revolution; rlin = 16 / 20,000 = 0.0008 mm = 0.8 µm.

Exercise 9. A frequency of 40 kHz is measured on channel A of an encoder with 1,024 pulses per revolution. At what speed is the shaft rotating?
Solution

n = 60 × 40,000 / 1,024 = 2,343.75 rpm, approximately 2,344 rpm.

Exercise 10. An absolute encoder has 17 bits per revolution. How many positions can it distinguish, and what is its angular resolution in degrees and arcseconds?
Solution

217 = 131,072 positions; 360 / 131,072 = 0.00275°; in seconds: 0.00275 × 3,600 = 9.9″.

Exercise 11. A 1,200-mm section of a lead screw heats up by 6 °C. How much does it expand? Does the encoder on the motor detect this? Does the optical encoder detect this?
Solution

ΔL = 11.5 × 10−6 · 1200 · 6 = 0.083 mm. The encoder on the motor counts the revolutions but doesn't detect it; the optical scale measures the slide and does detect it, so the controller corrects for it.

Exercise 12. A pressure transducer with a range of 0 to 16 bar and a 4–20 mA output reads 9.0 mA: What is the pressure? What current will it output at 12 bar?
Solution

p = 16 · (9.0 − 4) / 16 = 5 bar. At 12 bar: I = 4 + 16 · 12 / 16 = 16 mA.

Exercise 13. What is the resistance of a PT100 at 150 °C, assuming a linear relationship? What temperature corresponds to 115.4 Ω?
Solution

R = 100 · (1 + 0.00385 · 150) = 157.75 Ω (the complete formula in the standard would yield 157.33 Ω: at 150 °C, the linear law begins to deviate). T = (115.4 / 100 − 1) / 0.00385 = 0.154 / 0.00385 = 40 °C.

Exercise 14. A 1000 kg load cell has a sensitivity of 2 mV/V and is powered by a 5 V supply. What is the full-scale output? What load corresponds to 3.6 mV?
Solution

Ufs = 2 × 5 = 10 mV; m = 1000 × 3.6 / 10 = 360 kg.