Chapter 46

Electronics and Digital Logic

Behind every button, sensor, and control on a machine tool lies a bit of electronics: diodes that rectify, transistors that control relays, 24-volt power supplies, signals that travel as voltages or currents, and circuits that operate on 0s and 1s. In this chapter, we’ll start with semiconductor materials and move on to digital logic, analog-to-digital converters, and fieldbuses. Ohm’s and Kirchhoff’s laws are covered in Chapter 44; here, we’ll use them without repeating them.

46.1 Conductors, Insulators, and Semiconductors

A material conducts electricity if there are free charges moving within it. In conductors (copper, aluminum, silver), each atom contributes electrons that move freely throughout the metal: even a small voltage is enough to set them in motion. In insulators (plastic, glass, ceramic, rubber), the electrons remain bound to the atoms, and virtually no current passes. In between are semiconductors: the most commonly used is silicon, which, in its pure form, conducts very little but changes its behavior when a minimal amount of other elements is added.

TypeExamplesApproximate resistivity (Ω·m)Where it is used
Hostcopper, aluminumapproximately 0.000 000 02cables, windings, busbars
Semiconductorsilicon, germaniumfrom 0.001 to a few thousand, depending on the adulterationdiodes, transistors, integrated circuits
InsulationPVC, glass, ceramicmore than 1,000,000,000,000sheaths, supports, insulators

Approximate values, rounded: these are provided solely to illustrate how far apart the three groups are.

Doping: N-type silicon and P-type silicon

Each silicon atom has four electrons with which it bonds to its four neighbors, forming an ordered lattice in which no electrons are free. If you replace some of the atoms with an element that has five bonding electrons (phosphorus, arsenic), four are used for the bonds and the fifth remains free: the silicon becomes an N-type material, because the mobile charges are negative. If, on the other hand, an element with three electrons (boron) is introduced, one bond is missing: that empty spot is called a vacancy and behaves like a positive charge that moves, because a nearby electron fills it and leaves a hole behind. This is P-type silicon. This controlled addition is called doping: just a few foreign atoms per million are enough to significantly alter the conductivity.

YesYesYesYesYesPYesYesYesYesYesYes−N-type silicon (doped with phosphorus)Phosphorus has 5 valence electrons:one remains free (blue dot)SiSiSiYesYesBYesYesYesYesYesYes+P-type silicon (boron-doped)Boron has only 3: one bond is missing,leaving a hole (green circle)
Figure 46.1 · The silicon lattice viewed in plan view: each pair of dashes represents a bond. Phosphorus donates a free electron, while boron leaves a hole.

The PN junction

When a P-region and an N-region in the same crystal are brought into contact, a PN junction is formed. Near the boundary, the free electrons from the N-region fill the holes in the P-region: no mobile charges remain there, and a thin depletion region forms, acting as a barrier. In silicon, a voltage of about 0.6–0.7 V is required to overcome this barrier.

  • Forward bias: the battery’s positive terminal is connected to the P-type region and the negative terminal to the N-type region. The charges are pushed toward the junction, the barrier thins, and once the voltage exceeds 0.6–0.7 V, current flows.
  • Reverse polarization: the positive charge is on N. The charges are pulled away from the boundary, the depleted region expands, and only a very small current flows.
PN+−Direct: thin section, current passes throughdrainage zonePN+−Reverse: wide zone, no current flowswide discharge zone
Figure 46.2 · On the left, forward-biased junction: the depletion region is narrow and current flows. On the right, reverse-biased junction: the region widens and blocks current. Green circles indicate gaps; light blue dots indicate electrons.

46.2 The Diode

A diode is a PN junction enclosed in a package with two terminals: the anode (A, P-side) and the cathode (K, N-side, marked with a band on the body). It allows current to flow from the anode to the cathode and blocks it in the opposite direction: it is the electrical equivalent of the check valve used in pneumatics and hydraulics (Chapters 42 and 43). Just as a valve requires a small amount of pressure on the spring to open, a diode requires a small voltage to begin conducting.

0.7 VVIConduction:the current rises sharplyblockreverse breakdown(tens or hundreds of V)AKA anode, K cathodeThe arrow indicates the directionin which the current flowsdoesdoes not flow
Figure 46.3 · On the left is the symbol. On the right is the characteristic curve: in forward bias, the current remains nearly zero up to about 0.6 V and then rises very steeply; in reverse bias, the diode blocks current up to the breakdown voltage. The two voltage scales are not the same.

The curve in the figure is called the diode characteristic curve. You can read three things from it:

  • the forward voltage (VF): for a silicon diode, approximately 0.6–0.7 V, which is typically rounded to 0.7 V in calculations; for Schottky diodes, it ranges from 0.3 to 0.4 V, while for LEDs, it ranges from 1.8 to 3.5 V;
  • the maximum current direct current, as specified by the manufacturer in the technical data sheet (1 A for the standard 1N4007, 3 A for a 1N5408);
  • the maximum reverse voltage, beyond which the diode breaks down (1000 V for the 1N4007).

When the diode is conducting, the voltage across it is approximately VF, so it heats up: the power loss is equal to the voltage multiplied by the current.

Power dissipated by a conducting diode
P = VF · I
P power in W · VF voltage across the diode when conducting, in V (approximately 0.7 V for silicon) · I current flowing through it, in A
Example 46.1 · The Reverse-Polarity Protection Diode

A diode is connected in series with the 24 V input of a board: if someone reverses the wires, the diode blocks the current and the board won't be damaged. The board draws 3 A. How much power does the diode dissipate, and how much would a 0.4 V Schottky diode dissipate?

silicon: P = 0.7 × 3 = 2.1 W
Schottky: P = 0.4 × 3 = 1.2 W
voltage reaching the board via the silicon diode: 24 − 0.7 = 23.3 V
2.1 W vs. 1.2 W: For high currents, the Schottky diode is the better choice, as it generates nearly half the heat

46.3 Rectifiers and Smoothing Capacitors

The power grid supplies alternating current, but the control electronics require direct current. The first step is to rectify the current: to make it flow in only one direction using one or more diodes.

Half-wave rectifier

A single diode connected in series with the load allows the positive half-waves to pass and blocks the negative ones. The output voltage always has the same polarity but consists of “peaks” separated by pauses as long as the peaks themselves. It’s simple and inexpensive, but it wastes half the wave and is used only for small loads.

~network ortransformerDRIvoltagetdashed line: inputred: output
Figure 46.4 · With a single diode, only the positive half-waves pass through.

Bridge Rectifier (Graetz Bridge)

Four diodes arranged in a diamond pattern allow both half-waves to conduct: in each half-wave, two opposite diodes conduct, and the current in the load always flows in the same direction. The spikes double in frequency, occurring once every 10 ms with a 50 Hz power grid (spike frequency 100 Hz). The current always flows through two diodes, so approximately 2 × 0.7 = 1.4 V is lost at the output. The bridge can be purchased as a single, ready-made component with four pins: two marked “~” and two marked “+” and “−.”

The smoothing capacitor

The humps aren't enough: you need a nearly flat voltage. Connect a electrolytic capacitor large (thousands of microfarads; the capacitor as a component is described in Chapter 44). On the rising edge of each peak, the capacitor charges up to its peak value; when the peak declines, it supplies current to the load while discharging slightly, until the next peak arrives. At the output, a nearly continuous voltage remains with a small undulation (in English ripple) ΔV.

+−CR~ΔVoutput voltagedashed line: without Cred: with C
Figure 46.5 · The four-diode bridge with capacitor C and load R. On the right is the output voltage: double humps without the capacitor, nearly flat with the capacitor. ΔV is the ripple.
Peak Voltage, Bridge Output, and Ripple
Vpeak = Veff · √2 Vu ≈ Vpeak − 1,4 V ΔV ≈ Ifr · C
Veff: effective voltage of the transformer's secondary winding, in V (this is the value listed on the nameplate) · Vpeak: maximum value of the wave, in V · Vu: open-circuit voltage across the capacitor, in V (for a half-wave, subtract 0.7 V instead of 1.4 V) · ΔV: ripple, in V · I: load current, in A · fr: frequency of the ripple peaks: 100 Hz with a bridge configuration, 50 Hz with a half-wave configuration · C: capacitance, in F (4700 µF = 0.0047 F)
Example 46.2 · What is the output voltage of an 18-volt transformer?

A transformer has a secondary winding rated at 18 V rms. What is the voltage across the capacitor when it is open-circuited, and when it is connected in series with a single diode?

Vpeak = 18 · 1,4142 = 25,46 V
bridge: Vu = 25.46 − 1.4 = 24.06 V
one half-wave: Vu = 25.46 − 0.7 = 24.76 V
About 24 V with the bridge: an 18 V transformer produces a DC voltage of about 24 V

It's a classic error: anyone who installs a 24-volt transformer to get 24 volts DC will end up with more than 32 volts across the capacitor.

Example 46.3 · How Much Does It Sway, and What Capacitor Is Needed?

The circuit in Example 46.2 supplies a 2 A load using a 4700 µF capacitor. What is the ripple voltage? What capacitance would be needed to reduce the voltage to 2 V?

ΔV = 2100 · 0,0047 = 20,47 = 4,26 V
The voltage fluctuates between 24.06 V and 24.06 − 4.26 = 19.80 V
for ΔV = 2 V: C = Ifr · ΔV = 2100 · 2 = 0.01 F = 10,000 µF
ΔV ≈ 4.3 V with 4,700 µF; for 2 V, a 10,000 µF capacitor is needed

With a half-wave rectifier at fr = 50 Hz, the ripple doubles (8.5 V): this is another reason to use a bridge rectifier.

46.4 Special Diodes: LEDs, Zener Diodes, and Recirculation Diodes

The LED and Its Resistance

An LED (light-emitting diode) is a diode that emits light when it conducts. It is found in button indicator lights, on PLC outputs, on proximity sensors, and in column lamps. Its threshold voltage depends on the color: approximately 1.8–2.2 V for red and yellow, 2–3 V for green, and 3–3.5 V for blue and white (these are approximate values; the exact values are listed in the datasheet). The operating current of an indicator LED is a few milliamps, typically ranging from 2 to 20 mA.

The LED should never be connected directly to the power supply: once the threshold is exceeded, the current rises very rapidly (Figure 46.3) and the LED burns out. A resistor is connected in series to “absorb” the excess voltage and stabilize the current, applying Ohm’s law (Chapter 44) to the resistor alone:

Series Resistance Across the LED
R = V − VLEDI PR = (V − VLED ) · I
R resistance in Ω · V supply voltage in V · VLED LED threshold voltage in V · I desired LED current in A · PR power dissipated by the resistor in W
+24 VR = 2.2 kΩ22 V across itRed LED2 V · 10 mAI0 V+24 VR = 470 ΩZenerUZ = 12 Vload20 mA12 V0 V
Figure 46.6 · On the left, a 24-V LED indicator with its resistor. On the right, a simple voltage regulator: the Zener diode, mounted in reverse, maintains 12 V across the load.
Example 46.4 · 24-V LED Indicator

We want to light up a red LED (VLED = 2 V) with a current of 10 mA, powered by the 24 V from the control panel.

R = 24 − 20,010 = 220,010 = 2200 Ω
PR = 22 · 0,010 = 0,22 W
Power consumed by the LED: 2 × 0.010 = 0.02 W
R = 2.2 kΩ (a standard value that exists), rated for at least 0.5 W

A 0.25 W resistor would operate nearly at its limit and get very hot; you should always choose a rated power that is at least double the calculated value. Also note that almost all of the power (0.22 W out of 0.24 W) is wasted in the resistor: this is why the LEDs in 24-volt industrial indicator lights often contain a small constant-current circuit.

The Zener Diode

A Zener diode is designed to operate in reverse bias, in the breakdown region, without breaking down. In that region, the voltage across it remains nearly constant at the value UZ (there are Zener diodes rated at 3.3, 5.1, 10, 12, 15, 24 V, and many others), even though the current varies considerably. With a resistor in series, it becomes a simple voltage regulator: the resistor absorbs the excess voltage, while the Zener diode keeps the output voltage stable. The symbol is that of a diode with the bar bent into a “Z” shape.

The resistance is calculated so that the load current plus a small minimum current (a few milliamps) flows through the Zener diode, which serves to keep it in the breakdown region:

Zener Diode Stabilizer
R = Vin − UZIL + IZ,min PZ,max = UZ · IR
Vin Input voltage in V · UZ Zener voltage in V · IL load current in A · IZ,min minimum current through the Zener diode in A · IR current through the resistor in A · PZ,max Power across the Zener diode in the worst-case scenario, with the load disconnected, in W
Example 46.5 · Deriving 12 V from 24 V

A small circuit requires 12 V and draws 20 mA. A 12-V Zener diode with a minimum current of 5 mA is used, powered by 24 V.

R = 24 − 120,020 + 0,005 = 120,025 = 480 Ω → the standardized value of 470 Ω is chosen
Current with 470 Ω: IR = 12 / 470 = 0.02553 A = 25.5 mA
In the Zener diode with the load connected: 25.5 − 20 = 5.5 mA (above the minimum ✓)
When the load is disconnected, all the current flows through the Zener diode: PZ = 12 × 0.02553 = 0.306 W
Resistance: PR = 12 × 0.02553 = 0.306 W
R = 470 Ω, 1 W; 12 V Zener diode, at least 0.5 W (preferably 1.3 W)

The Zener stabilizer is suitable for currents of a few milliamps; for higher currents, the integrated regulators described in section 46.6 are used.

The recirculation diode on the coils

The coils of relays, contactors, and solenoid valves are inductors: they store energy in the magnetic field when current flows through them. An inductor resists any change in current: when the contact or transistor controlling it opens, the current would want to stop abruptly, and the coil, to keep the current flowing, generates a very high voltage of the opposite polarity across its terminals. This is the same phenomenon that causes the spark in the spark plugs of an internal combustion engine. That voltage spike—running into the hundreds or thousands of volts—burns out the output transistors, wears down the contacts with sparks, and sends interference throughout the control panel.

The solution is a recirculation diode (also called a free-wheeling diode) connected in parallel with the coil, but in the opposite direction: with the cathode toward the +24 V. When the coil is powered, the diode is in reverse bias and does nothing; when the circuit opens, the current from the coil flows through the diode, loops back, and dies out in a few milliseconds, heating the coil’s resistance. The voltage across the contact does not exceed 24 V plus 0.7 V for the diode.

+24 Vcoilrelay or EVdioderecirculationcontact ortransistor24 Vwithout diode: peak ofhundreds of voltswith diode: approximately 24.7 Vopentvoltage across the contact
Figure 46.7 · The diode connected in parallel with the coil, with the cathode connected to the positive terminal. When the circuit is opened, the current flows through the dashed loop, and the voltage across the contact remains at approximately 24.7 V instead of rising to hundreds of volts.
Coil Energy and Time Constant
E = 12 · L · I² τ = LR v = L · ΔIΔt
E: stored energy in J · L: inductance of the coil in H (henry) · I current in A · τ time constant in s: with the diode, the current has practically died out after about 5τ · R coil resistance in Ω · v induced voltage in V when the current changes by ΔI over a time interval of Δt (s)
Example 46.6 · Why the solenoid valve needs a diode

A 24 V, 4 W solenoid coil has an inductance of approximately 0.3 H. Calculate the current, resistance, stored energy, the theoretical voltage if the current were to stop in 1 µs, and the turn-off time with the diode.

I = PV = 424 = 0,1667 A · R = 240,1667 = 144 Ω
E = 0.5 × 0.3 × 0.1667² = 0.00417 J = 4.17 mJ
v = 0,3 · 0,16670,000 001 = 50,000 V (theoretical)
with the diode: τ = 0.3 / 144 = 0.00208 s = 2.08 ms → turns off in approximately 5 × 2.08 = 10.4 ms
Without a diode, the theoretical peak is tens of thousands of volts; with a diode, the current dies out in about 10 ms

In practice, 50,000 V is never reached, because a spark will occur or the transistor will break down first—which is exactly what we want to avoid. The trade-off for using a diode is a slight delay in the release of the relay or valve; where rapid release is required, a Zener diode in series with the diode, a varistor, or a resistor-capacitor circuit is used. Many coils with industrial connectors already have this protection built in (you can tell by the LED in the connector).

46.5 The Transistor as a Switch

A bipolar transistor consists of three layers of doped silicon: N-P-N or P-N-P. The three terminals are called the base (B), collector (C), and emitter (E). In the NPN type, which is the most commonly used, a small current entering the base and exiting the emitter allows a much larger current to flow from the collector to the emitter. The ratio between the two is the current gain hFE (also called β), which for low-power transistors ranges from 50 to a few hundred.

B baseC: CollectorE: EmitterNPN: the arrow points away from the emitter+24 V5 V control(digital output)RBIBK1480 ΩICrecirculationrecirculation
Figure 46.8 · On the left is the symbol for an NPN transistor. On the right is its most common application in a circuit: a 5-V digital output controls, via RB and the transistor, the coil of a 24-V relay protected by a flyback diode.

A transistor can amplify signals, but in automation it is almost always used as a switch, with only two states:

  • off (open): base at 0 V, no base current, no collector current. The load is off;
  • Saturation (off): A current slightly greater than necessary is applied to the base; the transistor conducts the full current demanded by the load, and only 0.1–0.3 V (VCE,sat) remains between the collector and emitter. The load is on, and the transistor generates little heat.

There is a PN junction between the base and the emitter, so when it is conducting, there is a voltage of about 0.7 V (VBE) across its terminals, just like in a diode. The calculation for driving a load is always the same:

NPN Transistor in Saturation
IC = VccRload IB,min = IChFE, min IB = k · IB,min RB = Vin − VBEIB
IC collector current (the load current) in A · Vcc Load voltage in V · Rload Load resistance (of the coil) in Ω · hFE, min Minimum gain from the technical data sheet · k safety factor to ensure saturation, typically ranging from 2 to 10 · RB base resistance in Ω · Vin Control voltage in V · VBE ≈ 0,7 V
Example 46.7 · Controlling a Relay from a 5 V Output

A microcontroller has 5 V outputs that can supply a maximum of 20 mA. It must drive a relay with a 24 V coil and a resistance of 480 Ω. An NPN transistor with a minimum hFE of 100 and a safety factor of k = 5 is used. Calculate the base resistance and the powers involved.

coil current: IC = 24480 = 0.050 A = 50 mA (the 0.2 V voltage of the saturated transistor is neglected: (24 − 0.2) / 480 = 49.6 mA)
minimum base current: IB,min = 0,050100 = 0.0005 A = 0.5 mA
with the safety factor: IB = 5 × 0.5 = 2.5 mA (well below the 20 mA output ✓)
RB = 5 − 0,70,0025 = 4,30,0025 = 1720 Ω → 1.5 kΩ is chosen, as it is the lowest normalized value nearby
Check: IB = 4.3 / 1500 = 2.87 mA, which is 5.7 times the minimum ✓
Power on the transistor: 0.2 × 0.050 = 0.010 W = 10 mW; on the RB: 4.3 × 0.00287 = 12.3 mW
RB = 1.5 kΩ, 0.25 W; low-power transistor (e.g., 100 mA, 40 V), plus the recirculation diode on the coil

Round off RB to the lower value: a lower resistance provides more base current and ensures safer saturation. Rounding up risks leaving the transistor halfway, where it heats up and may burn out.

The MOSFET

A MOSFET is a transistor controlled by voltage rather than current. Its terminals are called the gate (G), drain (D), and source (S). The gate is isolated: under static conditions, it does not draw current; simply applying a voltage above the threshold (usually a few volts—10 V for full conduction in standard models, 4.5 V or less in “logic-level” models) causes the channel between the drain and source to close. When closed, it behaves like a very small resistor, RDS(on), which in power-type models is a few milliohms. This is why MOSFETs are used as switches in the static outputs of PLCs, switching power supplies, and—along with IGBTs—in inverters (Chapter 45). For a MOSFET, the power lost during conduction is P = RDS(on) · I²: with 10 mΩ and 10 A, this amounts to just 1 W.

46.6 The 24-V stabilized power supply

Almost all industrial automation systems (PLCs, sensors, solenoid valves, auxiliary relays, operator panels) operate at 24 V DC: this voltage is low enough to be safe to touch and high enough to travel long distances without being affected by interference. A classic power supply, known as a linear power supply, consists of four blocks:

  • transformer: steps down the 230 V from the power grid and, most importantly, isolates the circuit from the grid (galvanic isolation);
  • rectifier: a diode bridge (paragraph 46.3);
  • filter: the smoothing capacitor;
  • regulator: an integrated circuit containing transistors and a reference voltage, which keeps the output steady at 24 V regardless of the input voltage (as long as it is a few volts higher) and regardless of the load.
Transformerlowers the voltageand isolates from the gridRectifierallows current to flowin one direction onlyFilter (C)smooths out theripplesRegulatorkeeps the outputat 24 V230 V24 Vlowest ACunidirectionalwith rippleclean DC
Figure 46.9 · The four blocks of the linear power supply. Above each block is the waveform of the voltage output from it.

The linear regulator functions as a variable resistor in series: the excess voltage between the input and 24 V is converted into heat. Its efficiency is low, and it requires a heat sink. Today, switching power supplies are almost always installed in control panels: they directly rectify the mains voltage, then a MOSFET turns the current on and off tens of thousands of times per second through a very small transformer, because at high frequencies, very little iron is required. An electronic control circuit determines how long the circuit remains on during each cycle. They are lightweight, compact, accept a wide range of input voltages, and have efficiencies of 90% or higher; however, they are more complex and generate high-frequency noise, which must be filtered out.

Efficiency and Power Loss
η = PuPin Plost = Pin − Pu linear regulator: Plost ≈ (Vin − Vu) · I
η efficiency (absolute value or as a percentage) · Pu power delivered to the load in W · Pin power consumed in W · Vin average voltage at the regulator input in V · Vu output voltage in V · I output current in A
Example 46.8 · Linear or switching?

I need 24 V and 2 A. In a linear power supply with a 24 V transformer, the regulator input receives an average of about 31.5 V (peak 33.9 V, minus 1.4 V for the bridge, minus the ripple). An equivalent switching power supply has an efficiency of 0.9. How much power is lost?

useful power: Pu = 24 × 2 = 48 W
linear: Plost = (31.5 − 24) · 2 = 15 W · η = 24 / 31.5 = 0.76 (not counting the transformer)
switching: Pin = 48 / 0,9 = 53,3 W · Plost = 53,3 − 48 = 5,3 W
15 W lost with the linear regulator versus about 5 W with the switching regulator: one-third of the heat in the panel
Example 46.9 · Selecting the Power Supply for the Control Panel

A 24-V control panel controls 6 4-W solenoid valves, 8 50-mA auxiliary relays, 20 25-mA sensors, a 0.6-A PLC, and a 0.5-A operator panel. A 25% margin is allowed. Which power supply should be chosen?

solenoid valves: 6 · 4 / 24 = 1.0 A
relays: 8 × 0.050 = 0.4 A · sensors: 20 × 0.025 = 0.5 A
Total: 1.0 + 0.4 + 0.5 + 0.6 + 0.5 = 3.0 A (i.e., 3.0 × 24 = 72 W)
with a margin of: 3.0 × 1.25 = 3.75 A
Choose the next larger commercial size: 24 V, 5 A (120 W) switching power supply

The margin accounts for inrush current (the coils and capacitors of the loads draw more current initially) and future additions. It’s also a good idea to distribute the loads across multiple protected circuits, so that a short circuit in one sensor doesn’t shut down the PLC.

46.7 Analog, Digital, and Industrial Signals

A signal is an electrical quantity that carries information. If it can continuously take on all values within a range, it is analog: for example, the voltage of a temperature sensor that rises gradually. If it can assume only two states—on and off—it is digital (or binary): a limit switch, a button, or a proximity sensor. The two states are called 1 and 0, or high and low, true and false.

temperature, pressure...tAnalog: infinite values1024 V24 VtDigital: two states only
Figure 46.10 · The analog signal varies continuously; the digital signal switches only between two levels.

Signs from the workshop

SignalValuesExamplesStrengths and Limitations
24 V Digital1 = approximately 24 V (detected above 15 V) · 0 = approximately 0 V (below 5 V)buttons, limit switches, inductive sensors, relay outputsSimple and robust; the range between 5 and 15 V is invalid, so a small disturbance does not change the state
Analog 0–10 Vfrom 0 V to 10 V, proportional to the measurementpotentiometers, inverter speed referenceEconomical; voltage drops over long cables, and disturbances accumulate; 0 V can mean either “zero reading” or “broken wire”
4–20 mA Analogfrom 4 mA to 20 mA, proportional to the measurementpressure, level, temperature, and flow transmittersThe current is the same throughout the circuit, even with long wires; a broken wire is easy to spot

The 24 V digital thresholds are the most common for PLC inputs (IEC 61131-2 standard, Type 1 inputs); the input data sheet provides the exact values.

Why 4–20 mA and not 0–20 mA?

The signal in current It is not affected by cable resistance: the transmitter regulates the current, and according to Kirchhoff’s law (Chapter 44), in a series circuit the current is the same throughout, even after 100 meters of cable. The “live zero” at 4 mA offers two advantages: the minimum measurement value corresponds to 4 mA rather than zero, so a current of 0 mA indicates a broken wire or a faulty sensor, and not “zero pressure”; furthermore, with those 4 mA, the two-wire transmitter is powered by the same circuit as the signal. By convention (NAMUR NE 43 recommendation), a current below 3.6 mA or above 21 mA is considered a fault.

From Current to Measurement: The Line Through Two Points

The relationship between current and the measured quantity is a straight line passing through two known points: (4 mA; full scale) and (20 mA; full scale). This is the line through two points from Chapter 7 (Section 7.4), with current in place of x and the measured value in place of y:

Conversion of an Analog Signal into a Measurement
y = ymin + x − xminxmax − xmin · (ymax − ymin)
For 4–20 mA: y = ymin + I − 416 · (ymax − ymin) On the contrary: I = 4 + 16 · y − yminymax − ymin
x: signal reading (current I in mA or voltage in V) · xmin, xmax: start and end of the signal range (4 and 20 mA, or 0 and 10 V) · y: measured value · ymin, ymax: start and full scale of the sensor, in its unit
48121620246810012.8 mA → 5.5 bar(20 mA; 10 bar)(4 mA; 0 bar)Faultbelow 3.6 mACurrent I (mA)Pressure p (bar)
Figure 46.11 · The calibration curve for the 0–10 bar pressure sensor with a 4–20 mA output. Below 3.6 mA (red zone), the signal indicates a fault.
Example 46.10 · How many bar is 12.8 mA?

A pressure transmitter has a range of 0–10 bar and a 4–20 mA output. The PLC reads 12.8 mA.

Slope of the line: m = 10 − 020 − 4 = 0.625 bar/mA
p = 0 + (12.8 − 4) · 0.625 = 8.8 · 0.625 = 5.5 bar
p = 5.5 bar
Example 46.11 · From Pressure to Current, and the Broken Wire

Using the same sensor: What current corresponds to 7.5 bar and 3.2 bar? What conclusion should be drawn if the PLC reads 0 mA?

7.5 bar: I = 4 + 16 · 7,510 = 4 + 12 = 16 mA
3.2 bar: I = 4 + 16 × 0.32 = 4 + 5.12 = 9.12 mA
0 mA: The formula would yield (0 − 4) · 0.625 = −2.5 bar, a pressure that is impossible for this sensor
16 mA and 9.12 mA; 0 mA is not a measurement but an alarm: broken wire or sensor not powered

With a 0–10 V sensor, a reading of 0 V would have been indistinguishable from “zero pressure”: for a safety pressure (such as that of the workpiece’s hydraulic clamping system), this is a risk that the 4–20 mA signal eliminates.

46.8 Numbering Systems and Codes

A digital circuit recognizes only 0s and 1s. To represent numbers, it uses the binary system (base 2), which follows the same rules as our decimal system (base 10) but uses only two digits. In the decimal system, each digit is worth ten times the one to its right (ones, tens, hundreds); in the binary system, each digit is worth twice as much: 1, 2, 4, 8, 16, 32, 64, 128, and so on. Each binary digit is called a bit.

  • bit: a binary digit, 0 or 1 (on or off);
  • byte: 8 bits, numbers from 0 to 255;
  • word (word): In 16-bit PLCs, numbers range from 0 to 65,535 (or from −32,768 to +32,767 if one bit is used for the sign); a double word is 32 bits long.

With n bits, you can represent 2n different numbers, ranging from 0 to 2n − 1.

Value of a number in base b
N = ck · bk + ... + c2 · b ² + c1 · b + c0 with n bits: from 0 to 2n − 1
N: value of the number in decimal · c: number of digits, starting from the right with c0 · b: base: 2 (binary), 10 (decimal), 16 (hexadecimal) · n: number of bits

From Decimal to Binary: Division by 2

Divide the number by 2 and write down the remainder (0 or 1); divide the quotient by 2 and write down the new remainder, and so on until the quotient is zero. The binary number is read with the remainders from bottom to top.

Example 46.12 · The number 45 in binary
45 : 2 = 22, with a remainder of 1
22 ÷ 2 = 11, remainder 0
11 ÷ 2 = 5, with a remainder of 1
5 : 2 = 2, with a remainder of 1
2 : 2 = 1, remainder 0
1 : 2 = 0, remainder 1
Read from the bottom: 101101
check: 32 + 8 + 4 + 1 = 45 ✓
45 = 101101 in binary (in one byte: 0010 1101)

Hexadecimal

Long binary numbers are hard to read. So we use hexadecimal (base 16), which has sixteen digits: 0 through 9, followed by A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15. The trick is that four bits correspond exactly to one hexadecimal digit: to convert from binary to hexadecimal, simply divide the number into groups of four bits starting from the right. A byte is written using two hexadecimal digits (from 00 to FF), and a word using four. To avoid confusion, hexadecimal numbers are written with a prefix: 16#D6 in PLCs according to IEC 61131-3, 0xD6 in programming languages, and D6h in many manuals.

Example 46.13 · From Binary to Decimal and Hexadecimal

A PLC displays the byte 11010110. What is its value in decimal and hexadecimal?

Weights from left to right: 128 · 64 · 32 · 16 · 8 · 4 · 2 · 1
decimal: 128 + 64 + 16 + 4 + 2 = 214
groups of four: 1101 | 0110 → 1101 = 8 + 4 + 1 = 13 = D · 0110 = 4 + 2 = 6
11010110 = 214 = 16#D6
Example 46.14 · From Hexadecimal to Decimal and Binary

An alarm code for a drive is 16#3F8. What is its value in decimal and binary?

decimal: 3 · 16² + F · 16 + 8 = 3 · 256 + 15 · 16 + 8 = 768 + 240 + 8 = 1016
binary, digit by digit: 3 = 0011 · F = 1111 · 8 = 1000
16#3F8 = 1016 = 0011 1111 1000

The BCD Code

In BCD (binary-coded decimal), each decimal digit is represented by four bits. The number 59 is not written as 111011 but as 0101 1001: “5” and “9.” A few combinations are wasted (1010 through 1111 are not used), but the conversion for digit displays and numerical switches (the old-style “contraves” with wheels) is immediate.

Gray Code and Absolute Encoders

A absolute encoder (Chapter 47) reads the position of a shaft from a disk with multiple concentric tracks, one per bit, read by an equal number of optical sensors. If the tracks were written in pure binary, when moving, for example, from 3 (011) to 4 (100), they would have to change three bits at the same time. But the sensors are never perfectly aligned: for a moment, one changes before the others, and the encoder reads incorrect values such as 111 (7) or 000 (0)—that is, a position jump that doesn't exist. The Gray Code It is designed so that between two adjacent numbers, there is a change a single bit: In the worst-case scenario, you'll see either the previous or the next position, but never one that's far away.

To convert from binary to Gray code: the most significant bit remains unchanged; each subsequent bit is 1 if the corresponding binary bit and the bit to its left are different, and 0 if they are the same (this is the XOR operation described in paragraph 46.9).

00001001201030114100510161107111Binary codeBetween 3 and 4, three bits change00001001201130104110511161017100Gray codeBetween 3 and 4, only one bit changesb2b1b0
Figure 46.12 · The three tracks of an eight-position encoder, laid out in a plane (dark = 1). In the binary representation, all three bits change between positions 3 and 4; in the Gray code representation, only one bit changes.
DecimalTrackHexadecimalBCDGray
0000000000 00000000
1000110000 00010001
2001020000 00100011
3001130000 00110010
4010040000 01000110
5010150000 01010111
6011060000 01100101
7011170000 01110100
8100080000 10001100
9100190000 10011101
101010A0001 00001111
111011B0001 00011110
121100C0001 00101010
131101D0001 00111011
141110E0001 01001001
151111F0001 01011000
Example 46.15 · BCD and Gray

Write 59 in BCD and compare it to the binary representation; then write 5 (101) in Gray code.

BCD: 5 = 0101, 9 = 1001 → 0101 1001
binary: 59 = 32 + 16 + 8 + 2 + 1 = 111011
Gray code 101: first bit 1 · 1 and 0 are different → 1 · 0 and 1 are different → 1
59 = 0101 1001 in BCD (111011 in binary); 5 = 111 in Gray

46.9 Logic Gates and Boolean Algebra

Digital circuits are built using logic gates: small circuits (made of transistors) with one or more inputs and one output, each of which performs a logical operation. Their behavior is described by a truth table, which lists the output for all combinations of inputs: with n inputs, there are 2n rows.

  • AND (logic product, “AND”): The output is 1 only if all inputs are 1. It is like two switches connected in series.
  • OR (logical OR, “OR”): The output is 1 if at least one input is 1. Two switches connected in parallel.
  • NOT (negation): The output is the opposite of the input. It is written with a bar above it: Ā, pronounced “A negated.”
  • NAND and NOR: an AND and an OR followed by a NOT. The dot on the output indicates negation.
  • XOR (exclusive OR): The output is 1 if the inputs are different. It is used to compare two bits.
ABYANDY = A · BIEC: &ABYORY = A + BIEC: ≥1AYNOTY = ĀIEC: 1ABYNANDY = (A · B) negatedIEC: &, inverted outputABYNORY = (A + B) negatedIEC: ≥1, inverted outputABYXORY = A ⊕ BIEC: = 1
Figure 46.13 · The symbols for the six ports in their most common form (the American standard). In IEC standards, a rectangle is drawn with the symbol listed below each port inside it.
ABAND A · BOR A + BNOTE ĀNANDNORXOR A ⊕ B
00001110
01011101
10010101
11110000

NAND and NOR gates are called universal gates: all other gates can be built using only NAND gates (or only NOR gates). The first integrated circuits were manufactured in this way.

Boolean Algebra

Logical operations follow precise rules, which are set forth in Boolean algebra. Variables can only take the values 0 or 1; the product “·” is the AND operator, the sum “+” is the OR operator, and the vertical bar is the NOT operator. Many rules are similar to those of standard algebra (Chapter 1), while others are not: for example, A + A = A, and A + 1 = 1.

PropertiesWith the ORWith the AND
Neutral elementA + 0 = AA · 1 = A
An element that absorbs everythingA + 1 = 1A · 0 = 0
IdempotenceA + A = AA · A = A
AccessoryA + Ā = 1A · Ā = 0
CommutativeA + B = B + AA · B = B · A
Association(A + B) + C = A + (B + C)(A · B) · C = A · (B · C)
DistributionA + B · C = (A + B) · (A + C)A · (B + C) = A · B + A · C
AbsorptionA + A · B = AA · (A + B) = A
Negation AbsorptionA + Ā · B = A + BA · (Ā + B) = A · B
Double NegationIf you say "no" twice, you go back to A

The two most useful rules are De Morgan's theorems: the negation of a product is the sum of the negations, and the negation of a sum is the product of the negations. In practice: a NAND gate is equivalent to an OR gate with the inputs negated, and a NOR gate is equivalent to an AND gate with the inputs negated.

De Morgan's Theorems
A · B = A + B A + B = A · B
A, B are logical variables (0 or 1) · the long bar negates the entire expression below it · these rules also apply when there are three or more variables

An example from the workshop: “The machine stops if not "It's true that both the pressure and the lubrication are fine" is equivalent to "the machine stops if there is no pressure" or "There's a lack of lubrication." That's what De Morgan said.

Example 46.16 · Simplify an expression

From an old diagram, we get Y = A · B + A · B + A · B. Can this be done with fewer gates?

I factor out A from the first two terms: Y = A · (B + B) + A · B
complement, B + B = 1: Y = A · 1 + A · B = A + A · B
Negation absorption: Y = A + B
Checking against the table: A = 0, B = 0 → 0 + 0 + 0 = 0; A = 0, B = 1 → 0 + 0 + 1 = 1; A = 1, B = 0 → 0 + 1 + 0 = 1; A = 1, B = 1 → 1 + 0 + 0 = 1: this is indeed the truth table for OR ✓
Y = A + B: three AND gates, two NOT gates, and a three-input OR gate become a single OR gate

46.10 From the truth table to the circuit

The method for designing a logic circuit is always the same:

  • You write out in words what the machine is supposed to do and give each input and output a name;
  • Fill in the truth table with all possible combinations of the inputs;
  • For each row where the output is 1, write the product (AND) of the inputs, negating those that are 0; then sum (OR) all these products;
  • You can simplify it using Boolean algebra and draw the circuit with logic gates, or write the PLC program (Chapter 49).
Example 46.17 · The press with a two-hand control

A press should only lower if the safety door is closed and the operator presses both buttons with both hands, or if the maintenance mode key is inserted. Inputs: P = door closed, S1 = left button, S2 = right button, K = key inserted (1 = true). Output: Y = descent.

PS1S2KY
00000
00100
01000
01100
10000
10100
11000
11101
anyanyany11
When K = 0, the output is 1 in a single row: P = 1, S1 = 1, S2 = 1 → term P · S1 · S2
When K = 1, the output is always 1 (eight rows) → upon summation, their eight products reduce to K
Y = P · S1 · S2 + K
A three-input AND gate and a two-input OR gate (Figure 46.14)
P: Door ClosedS1 left handS2 right-hand side&K: maintenance key≥1Y downward movementof the pressP · S1 · S2Y = P · S1 · S2 + K
Figure 46.14 · The press circuit: door, left hand, and right hand in an AND gate; the result in an OR gate with the maintenance switch.
⚠️
Logic, yes; safety, no. This example is meant to teach logic. On a real press, the two-hand control must also require that the buttons be pressed almost simultaneously (within half a second) and released before a new cycle begins, and maintenance mode never allows the press to descend at full speed: the safety functions are implemented using certified safety relays and PLCs, as shown in Chapter 51, not with just any logic gates.

46.11 Sequential Circuits: Memories, Counters, and Timers

In the circuits we've seen so far (called combinational circuits), the output depends only on the current inputs. Many functions, however, require memory: a motor started with a button must remain running even after the button is released. Circuits in which the output also depends on past events are called sequential circuits.

The SR Flip-Flop

The simplest memory is the SR flip-flop (or SR latch), made with two NOR gates, each of which receives the output of the other. The S (set) input sets the Q output to 1; the R (reset) input sets it to 0; when both S and R are 0, Q remains as it was: it is a single bit of memory. The combination of S = 1 and R = 1 is not allowed, because it would set both outputs to 0, and the final state would depend on which input returns to 0 last.

RSQQtwo NOR gatesEach receives the output of the otherS OnR stopQ motorQ remains at 1 without St
Figure 46.15 · On the left is the SR flip-flop. On the right is its behavior over time: a pulse on S sets Q, which remains set until a pulse on R resets it.
SRQ nextMeaning
00Q firstmemory: nothing changes
101set: turns on
010reset: turns off
11prohibitedIn PLCs, you choose which one wins (set or reset takes priority)

This is the same self-holding function found in relay circuits: the start button energizes the contactor; a contact on the contactor itself closes in parallel with the button and keeps it energized; the stop button, which is normally closed, breaks the circuit. In logic terms: Q = (RUN + Q) · STOP. In this configuration, the stop command takes precedence over the run command, which is the correct choice for safety. In PLCs (Chapter 49), self-holding is implemented as follows in contact-based language, or using the SET and RESET instructions, or with the SR and RS blocks defined in the IEC 61131-3 standard.

Counters and Timers

By filing several flip-flops together, you get a log (a multi-bit memory unit, such as a byte) and a counter: With each input pulse, the stored binary number increases by one (0000, 0001, 0010, 0011...). A counter with n The bit counts up to 2n − 1, and then it starts over from zero. A timer A digital counter is a device that counts the pulses from an internal clock (the clock) with a known frequency: when the count reaches the set value, the desired time has elapsed. This is how PLC timers and counters, machine piece counters, and dwell times—such as G04 in numerical control—work.

Digital Timer and Counter
t = Nfclock Nmax = 2n − 1
t time in s · N number of pulses counted · fclock clock frequency in Hz (pulses per second) · Nmax maximum reading of a meter at n bit
Example 46.18 · Timers and Counters

A timer counts the pulses of a 1-kHz clock. What value should be set for a delay of 2.5 s? What is the maximum count of a 16-bit counter using the same clock? And what is the maximum count of a 16-bit signed counter?

N = t · fclock = 2.5 · 1000 = 2500 pulses
16-bit unsigned: Nmax = 216 − 1 = 65,535 → tmax = 65,535 / 1,000 = 65.5 s
16-bit signed: one bit is used for the sign, leaving 15 bits → 2¹⁵ − 1 = 32,767 workpieces
Preset 2500; maximum 65.5 s; piece counter up to 32,767 (to count higher numbers, a 32-bit double word is used)

46.12 Analog-to-Digital Conversion

PLCs and numerical control systems work with numbers, but analog sensors provide voltages and currents. The analog-to-digital converter (ADC) acts as a bridge: at regular intervals champion the signal—that is, it reads its value at that instant—and it quantize, that is, it converts it to the nearest integer it can represent. A converter that n bit divides the input field into 2n steps: the width of a step is called resolution (or LSB, the least significant bit). A change smaller than one step is not visible.

000001010011100101110111Tscodetblue: true signalred: values read from the converter
Figure 46.16 · A 3-bit converter (with eight levels, to make them visible): at each interval Ts, it reads the signal and rounds it down to the next lower step. With 12 bits, there are 4,096 steps, and the scale becomes extremely fine.
Resolution and Code of an A/D Converter
q = field2n N = x − xminq (whole part)
q resolution (step width) in the signal unit · range = xmax − xmin, for example 10 V or 16 mA · n number of bits · N integer output by the converter, from 0 to 2n − 1 · x input signal. Some texts divide by 2n − 1: the difference is negligible
Example 46.19 · 12-bit converter for 0–10 V and 4–20 mA

An analog input card has a 12-bit converter. Calculate the resolution for 0–10 V and 4–20 mA, the code corresponding to 6.2 V, and the resolution in bar for the 0–10 bar sensor in Example 46.10.

steps: 212 = 4096, codes from 0 to 4095
0–10 V: q = 10 / 4096 = 0.002 441 V = 2.44 mV
6.2 V code: N = 6.2 / 0.002 441 = 2539.5 → 2539 (which, when converted back, gives 2539 × 0.002 441 = 6.199 V)
4–20 mA: q = 16 / 4096 = 0.003 906 mA = 3.91 µA
For the 0–10 bar sensor: q = 10 bar / 4096 = 0.002 44 bar = 2.4 mbar
2.44 mV on a 0–10 V scale, 3.9 µA on a 4–20 mA scale, or 2.4 millibars of pressure

In practice, many PLCs do not use the 0–4095 range directly but instead use their own scale: for example, some cards use a range from 0 to 27,648 for the entire nominal range and reserve the numbers above that to indicate an out-of-range condition. Conversion to technical units is always performed using the straight line through two points described in paragraph 46.7.

How often to sample

The converter detects the signal only at the sample instants: whatever happens in between is lost. The theoretical rule (the sampling theorem, or Nyquist-Shannon theorem) states that you must sample at least twice the highest frequency contained in the signal; in practice, to clearly see the waveform, you sample 5 to 10 times faster. A temperature that changes over tens of seconds can be read a few times per second; a motor’s current or the position of an axis must be read thousands of times per second, which is why drives have their own converters, much faster than the PLC’s cycle time.

The digital-to-analog converter (DAC) performs the reverse process: it converts a number into a voltage or current—for example, the 0–10 V speed reference that the PLC sends to a drive.

46.13 Microcontrollers, Fieldbuses, and Communication

From the circuit to the program

To create a complex function using logic gates, you would need thousands of them, and changing the function would mean rebuilding the circuit. The microprocessor solves this problem: it is a single integrated circuit that contains a processing unit capable of executing, one after another, simple instructions (add, compare, jump, read, write) retrieved from memory. By changing the instructions—that is, the program—the same circuit performs different tasks. The microcontroller also integrates program and data memory, digital inputs and outputs, A/D converters, timers, and communication ports into the same chip: it is a complete mini-computer on a chip, and can be found inside smart sensors, actuators, panels, and household appliances. PLCs (Chapter 49) and numerical control systems (Chapter 50) are, essentially, industrial computers of this type—robust and equipped with inputs and outputs suited for factory environments. The rate at which they execute instructions is determined by the clock, which today ranges from tens of megahertz to a few gigahertz.

Serial Communication

To communicate with each other, devices exchange bytes one after another over a few files: this is serial communication. In asynchronous serial communication, each byte is transmitted as a character that begins with a start bit and ends with at least one stop bit: in the most common format, “8N1,” there are 10 bits per byte. The speed is measured in bits per second (baud): 9,600, 19,200, 115,200.

Serial Transmission Time
t = Nbyte · bbaud
t time in s · Nbyte number of bytes to be transmitted · b bits per character (10 with 8N1: start, 8 data, stop) · baud rate in bits/s
Example 46.20 · How long does it take for a message to arrive?

A control unit sends a 100-byte message to another device over a 9,600-baud, 8N1 serial connection. How long does it take? And at 115,200 baud?

one byte: 10 / 9600 = 0.001 042 s = 1.04 ms
100 bytes: 100 × 10 / 9600 = 0.104 s = 104 ms
at 115,200 baud: 1,000 / 115,200 = 0.00868 s = 8.7 ms
104 ms at 9,600 baud, 8.7 ms at 115,200 baud

One-tenth of a percent-byte is nothing when loading a program, but it's too much to close the position loop of an axis, which updates every millisecond or less: that's why the drives use much faster buses.

  • RS-232: the classic serial interface, point-to-point (from one device to another), with voltages referenced to ground. It has a range of about 15 meters. For decades, this was the port used to load programs into numerical control systems, and it can still be found on older machines.
  • RS-485: uses a pair of twisted wires and transmits differentially: it measures the voltage difference between the two wires, not the voltage relative to ground. Any noise that enters both wires equally cancels itself out. It has a range of over 1,000 m and can connect up to 32 devices on the same line, with a termination resistor (usually 120 Ω) at both ends. Protocols such as Modbus RTU and Profibus DP run over RS-485.
  • Industrial Ethernet: the same technology as office networks, but with rugged cables and connectors and protocols suited for real-time applications. The most widely used are Profinet (developed by Siemens and widely used in Europe with PLCs), EtherCAT (in which the message passes through all devices in sequence, and each one reads and writes its portion on the fly, with cycle times under a millisecond—ideal for motion control), EtherNet/IP, and Modbus TCP.
AB120 Ω120 ΩPLCMasterInverterNode 1DriveNode 2Remote I/ONode 3A and BOne file goes up when the other goes down:only the difference A − B matters
Figure 46.17 · An RS-485 fieldbus: all devices are connected in parallel on the same pair of wires, A and B, with terminating resistors at both ends. Below is the differential signal.

A fieldbus replaces hundreds of wires: instead of connecting each sensor and valve to the PLC with its own cable, input and output modules are placed near the machine and connected via a single communication cable. The numerical control communicates with its drives in the same way (Chapter 48).

46.14 Electromagnetic Interference and Best Practices

An electrical panel contains both cables carrying hundreds of volts and tens of amperes that switch within a few microseconds (motors, inverters, contactors) and signal cables carrying a few milliamps or a few millivolts (analog sensors, encoders). Rapidly changing currents and voltages generate electric and magnetic fields that induce interference in nearby cables: this is the problem of electromagnetic compatibility (EMC). Typical symptoms include fluctuating analog readings, encoders losing pulses, fieldbuses going into errors, and inputs tripping on their own.

powermotors, inverters, 400 Vsignals24 V, encoders, 4–20 mAseparate channelsif they cross: at 90°ground bar (PE)shielded cable(dashed braid)cable tie: braidgrounded all the way around
Figure 46.18 · The three main rules: separate cable trays for power and signals; right-angle crossings; and cable shielding grounded with a cable tie wrapped tightly around it.
  • Separate power and signal lines: use separate conduits, or a metal conduit with a separator; the distances recommended by inverter manufacturers are approximately 20–30 cm for long parallel runs. Where cables must cross, they should cross at right angles to minimize crosstalk.
  • Shielded cables for encoders, analog signals, fieldbuses, and inverter motor cables. The shield (the metal braid) must be connected to ground with a wide contact all around the cable (using cable ties or metal cable glands), and not with a long wire tail, which is virtually useless at high frequencies. For inverter power cables, the shield is grounded at both ends; for some slow analog signals, manufacturers specify grounding on only one side—follow their documentation.
  • Twisted pairs: The two wires of a signal (transmit and receive) are twisted together to pick up equal and opposite noise, which cancels each other out. This is the same principle as RS-485.
  • Star-shaped grounding and metal base plates: all ground connections must be connected to a common point or to an unpainted galvanized plate, using short, wide connections. The protective earth (PE) remains mandatory for personal safety (Chapter 44).
  • Eliminate interference at the source: use recirculation diodes on DC coils (section 46.4), RC circuits or varistors on AC coils, line filters, and short cables between the inverter and the motor.
  • Prefer robust signals: 4–20 mA instead of 0–10 V over long distances, encoders with differential outputs, and fieldbuses instead of multiple analog signals.
🔧
The intermittent fault. When an analog input “fluctuates” only while the spindle speed is high, the culprit is almost always a problem with the inverter: before replacing the sensor, check the cable route, the continuity of the shield, and the ground clamp connection.

46.15 The Formulas in This Chapter

What Are You Looking For?FormulaUnits
Power Lost in a DiodeP = VF · I (VF ≈ 0,7 V)W
Peak voltageVpeak = Veff · √2V
The bridge came up empty-handedVu ≈ Vpeak − 1.4V
Capacitor-Induced RippleΔV ≈ I / (fr · C), where fr = 100 Hz with the bridgeV
Series Resistance Across the LEDR = (V − VLED) / IΩ
Zener Stabilizer ResistanceR = (Vin − UZ) / (IL + IZ,min)Ω
Energy in a coilE = ½ · L · I²J
Coil time constantτ = L / Rs
Minimum base currentIB,min = IC / hFE,minA
Basic ResistanceRB = (Vin − 0.7) / (k · IB,min)Ω
Efficiency of a Power Supplyη = Pu / Pinpure number
4–20 mA measurement signaly = ymin + (I − 4) / 16 · (ymax − ymin)unit of measurement
4–20 mA current measurementI = 4 + 16 · (y − ymin) / (ymax − ymin)mA
n-bit numbersfrom 0 to 2n − 1pure number
Digital Timert = N / fclocks
Resolution of an A/D converterq = field / 2nsignal unit
Serial Transmission Timet = Nbyte · 10 / baud (8N1)s
De MorganA · B = A + B · A + B = A · Blogic

46.16 Exercises

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

Exercise 1. A red LED (VLED = 1.8 V) must operate at 15 mA from a 12 V power supply. Calculate the series resistance and the power dissipated.
Solution

R = (12 − 1.8) / 0.015 = 10.2 / 0.015 = 680 Ω (normalized value). PR = 10.2 × 0.015 = 0.153 W: a 0.5 W resistor is chosen (0.25 W would be too close to the limit).

Exercise 2. Convert the binary number 10110011 to decimal and hexadecimal.
Solution

128 + 32 + 16 + 2 + 1 = 179. Groups of four: 1011 = 11 = B, 0011 = 3, so 16#B3.

Exercise 3. Convert the decimal number 200 to binary and hexadecimal.
Solution

200 : 2 = 100 r 0; 100 : 2 = 50 r 0; 50 : 2 = 25 r 0; 25 : 2 = 12 r 1; 12 : 2 = 6 r 0; 6 : 2 = 3 r 0; 3 : 2 = 1 r 1; 1 : 2 = 0 r 1. From the bottom: 11001000. Check: 128 + 64 + 8 = 200. Groups: 1100 = C, 1000 = 8, so 16#C8.

Exercise 4. Convert 16#1A7 to decimal and binary.
Solution

1 · 256 + 10 · 16 + 7 = 256 + 160 + 7 = 423. In binary, digit by digit: 0001 1010 0111, or 110100111.

Exercise 5. A temperature transmitter has a range of 0–150 °C and an output of 4–20 mA. What temperature corresponds to 10 mA? What does a reading of 3.0 mA mean?
Solution

T = 0 + (10 − 4) / 16 · 150 = 6 / 16 · 150 = 56.25 °C. 3.0 mA is below the threshold of 3.6 mA: this is not a measurement but a fault (broken wire, disconnected or broken sensor).

Exercise 6. A distance sensor has a range of 0–250 mm and an output of 0–10 V. The PLC reads 3.6 V. How far away is the workpiece?
Solution

d = 0 + (3.6 − 0) / 10 × 250 = 0.36 × 250 = 90 mm.

Exercise 7. Fill in the truth table for Y = (A + B) · C. In how many rows is the output 1?
Solution

When C = 1, the output is always 0. When C = 0, the output is A + B. Rows (A B C → Y): 000 → 0; 001 → 0; 010 → 1; 011 → 0; 100 → 1; 101 → 0; 110 → 1; 111 → 0. The output is 1 in three lines.

Exercise 8. Simplify Y = A · B · C + A · B · C + A · B.
Solution

A · B · C + A · B · C = A · B · (C + C) = A · B. Then A · B + A · B = A · (B + B) = A. Therefore, Y = A: the other variables do not matter.

Exercise 9. An alarm must sound if the two conditions “oil level” (L) and “clean filter” (F) are not both true. Write the expression and transform it using De Morgan’s laws. Which gate is sufficient?
Solution

Y = L · F = L + F: The alarm sounds if there is no oil or if the filter is dirty. A single NAND gate with inputs L and F is sufficient.

Exercise 10. A 24 V output must drive, via an NPN transistor with a minimum hFE of 80, a relay with a 24 V, 60 mA coil. Given a safety factor of 5, calculate the base resistance.
Solution

IB,min = 0.060 / 80 = 0.75 mA; IB = 5 × 0.75 = 3.75 mA; RB = (24 − 0.7) / 0.00375 = 23.3 / 0.00375 = 6213 Ω. We choose the lower standardized value, 5.6 kΩ: IB = 23.3 / 5600 = 4.16 mA. Power dissipated across the resistor: 23.3 × 0.00416 = 0.097 W, so 0.25 W. Don’t forget the feedback diode on the coil.

Exercise 11. A 10-bit converter reads a 0–10 V signal. What is the resolution? What code does it produce when the input is 3 V?
Solution

210 = 1024 steps; q = 10 / 1024 = 0.009 766 V = 9.77 mV. N = 3 / 0.009 766 = 307.2, so the code is 307.

Exercise 12. A bridge rectifier supplies a 0.5 A load through a 2200 µF capacitor. What is the ripple?
Solution

ΔV = 0.5 / (100 × 0.0022) = 0.5 / 0.22 = 2.27 V.

Exercise 13. Write 47 in BCD. What decimal number does the BCD number 1001 0011 represent?
Solution

4 = 0100, 7 = 0111, so 0100 0111. The BCD value 1001 0011 is 9 and 3, or 93 (in pure binary, the same byte would be 147: be careful not to confuse the two codes).

Exercise 14. Write the numbers 6 and 7 in 3-bit Gray code. How many bits change when going from 6 to 7 in Gray code? And when going from 7 to 0 (the encoder has completed one full cycle)?
Solution

6 = 110 in binary → Gray 101; 7 = 111 → Gray 100. From 101 to 100, one bit changes. From 7 (100) to 0 (000), only one bit changes again: the Gray code is “cyclic,” meaning that even the transition from the last number to the first changes by one bit. In binary, going from 111 to 000 would change three bits.

Exercise 15. How long does it take to transmit 50 bytes over an RS-485 serial connection at 19,200 baud, 8N1?
Solution

t = 50 · 10 / 19,200 = 500 / 19,200 = 0.026 s = 26 ms.

Exercise 16. You want to obtain 5.1 V from 24 V using a Zener diode, for a 10 mA load and a minimum current through the Zener diode of 5 mA. Calculate the resistance and power across the Zener diode with no load.
Solution

R = (24 − 5.1) / (0.010 + 0.005) = 18.9 / 0.015 = 1260 Ω; we choose 1.2 kΩ. Current: 18.9 / 1200 = 15.75 mA. With the load disconnected, PZ = 5.1 × 0.01575 = 0.080 W; across the resistor, 18.9 × 0.01575 = 0.298 W, so a resistor rated for at least 0.5 W (preferably 1 W) is required.