Practical circuits for switching on sensors. Analog sensors: application, ways of connecting to the controller Connecting sensors with different power levels

Fundamentals of 4..20 mA current loop operation

Since the 1950s, the current loop has been used to transmit data from measuring transducers for monitoring and control purposes. With a low cost of implementation, high noise immunity and the ability to transmit signals over long distances, the current loop turned out to be especially convenient for working in industrial conditions. This material is devoted to the description of the basic principles of the current loop, the basics of design, setting.

Using current to transfer data from the inverter

Industrial sensors often use a current signal to transmit data, unlike most other transducers, such as thermocouples or strain gauges, which use a signal voltage. Despite the fact that converters using voltage as a parameter of information transfer are actually effectively used in many industrial tasks, there are a number of applications where the use of current characteristics is preferable. A significant disadvantage when using voltage for signal transmission in industrial conditions is the weakening of the signal during its transmission over long distances due to the presence of resistance of wire communication lines. You can, of course, use the high input impedance of the devices to avoid signal loss. However, such devices will be very sensitive to noise generated by nearby motors, drive belts or broadcast transmitters.

According to the first Kirchhoff's law, the sum of currents flowing into a node is equal to the sum of currents flowing out of a node.
In theory, the current flowing at the beginning of the circuit should reach its end in full,
as shown in Figure 1. 1.

Fig. 1. In accordance with the first Kirchhoff's law, the current at the beginning of the circuit is equal to the current at its end.

This is the basic principle on which the measuring loop works. Measuring the current anywhere in the current loop (measuring loop) gives the same result. By using low impedance current signals and data acquisition receivers, industrial applications can benefit greatly from improved noise immunity and increased link length.

Current loop components
The main components of the current loop include a DC power supply, a primary transducer, a data acquisition device, and wires connecting them in a row, as shown in Figure 2.

Fig. 2. Functional diagram of the current loop.

A DC power supply provides power to the system. The transmitter regulates the current in the wires in the range of 4 to 20 mA, where 4 mA represents a live zero and 20 mA represents the maximum signal.
0 mA (no current) means an open circuit. The data collector measures the value of the regulated current. An effective and accurate method of measuring current is to install a precision resistor-shunt at the input of the measuring amplifier of the data acquisition device (in Fig. 2) to convert the current into a measurement voltage in order to ultimately obtain a result that unambiguously reflects the signal at the output of the converter.

To help you better understand the principle of the current loop, consider, for example, the design of a system with a converter, which has the following specifications:

The transducer is used to measure pressure
Transmitter located 2000 feet from the measuring device
The current measured by the data collector provides the operator with information on the amount of pressure applied to the transmitter.

Let's start with the selection of a suitable converter.

Current system design

Converter selection

The first step in designing a current system is choosing a converter. Regardless of the type of measured value (flow, pressure, temperature, etc.), an important factor in choosing a transmitter is its operating voltage. Only the connection of the power supply to the transducer makes it possible to regulate the amount of current in the communication line. The voltage value of the power supply must be within acceptable limits: more than the minimum required, less than the maximum value, which can lead to damage to the inverter.

For the current system shown in the example, the selected transducer measures pressure and has an operating voltage of 12 to 30 V. When the transducer is selected, it is necessary to correctly measure the current signal to provide an accurate representation of the pressure applied to the transmitter.

Selecting a Data Acquisition Device for Current Measurement

An important aspect to pay attention to when building a current system is to prevent the appearance of a current loop in the ground circuit. A common technique in such cases is isolation. By using insulation, you can avoid the influence of the ground loop, the occurrence of which is explained in Fig. 3.

Fig. 3. Ground loop

Ground loops are formed when two terminals are connected in a circuit at different potential locations. This difference leads to the appearance of additional current in the communication line, which can lead to errors in measurements.
Acquisition isolation refers to the electrical separation of the ground of the signal source from the ground of the input amplifier of the measuring device, as shown in Figure 4.

Since no current can flow through the isolation barrier, the ground points of the amplifier and the signal source are at the same potential. This eliminates the possibility of inadvertently creating a ground loop.

Fig. 4. Common-mode voltage and signal voltage in an isolated circuit

Isolation also prevents damage to the data collector in the presence of high common-mode voltages. Common mode is a voltage of the same polarity that is present at both inputs of an instrumentation amplifier. For example, in Fig. 4. both the positive (+) and negative (-) amplifier inputs have +14 V common-mode voltage. Many data collectors have a maximum input range of ± 10 V. If the data collector is not isolated and the common-mode voltage is outside the maximum input range, you could damage the device. Although the normal (signal) voltage at the amplifier input in Figure 4 is only +2 V, adding +14 V can result in +16 V
(The signal voltage is the voltage between the "+" and "-" of the amplifier, the operating voltage is the sum of the normal and common-mode voltages), which represents a dangerous voltage level for collectors with lower operating voltages.

With isolation, the amplifier's common point is electrically separated from the ground reference. In the circuit in Figure 4, the potential at the common point of the amplifier is "raised" to a level of +14 V. This technique leads to the fact that the value of the input voltage drops from 16 to 2 V. Now data collection, the device is no longer at risk of overvoltage damage. (Note that insulators have the maximum common-mode voltage they can reject.)

Once the data collector is isolated and protected, the final step in completing the current loop is to select an appropriate power supply.

Power supply selection

Determine which power supply the best way meets your requirements quite simply. When working in a current loop, the power supply must deliver a voltage equal to or greater than the sum of the voltage drops across all elements of the system.

The data collector in our example uses a precision shunt to measure the current.
It is necessary to calculate the voltage drop across this resistor. A typical shunt resistor has a resistance of 249 Ω. Basic calculations for a current range in the current loop of 4 .. 20 mA
show the following:

I * R = U
0.004A * 249Ω = 0.996 V
0.02A * 249Ω = 4.98 V

With a shunt with a resistance of 249 Ω, we can remove a voltage in the range from 1 to 5 V by linking the voltage at the input of the data collector with the value of the output signal of the pressure transducer.
As mentioned, the pressure transducer requires a minimum operating voltage of 12 V with a maximum of 30 V. Adding the voltage drop across the precision shunt resistor to the operating voltage of the transducer gives the following:

12V + 5V = 17V

At first glance, a voltage of 17V is enough. However, it is necessary to take into account the additional load on the power supply, which is created by wires that have electrical resistance.
In cases where the sensor is far from measuring instruments, you must take the resistance factor of the wires into account when calculating the current loop. Copper wires have a DC resistance that is directly proportional to their length. With the pressure transducer in this example, you need to factor in the 2000 feet of link length when determining the operating voltage of the power supply. Linear resistance of solid copper cable 2.62 Ω / 100 ft. Taking this resistance into account gives the following:

The resistance of one core 2,000 feet long is 2,000 * 2.62 / 100 = 52.4 m.
The voltage drop across one core will be 0.02 * 52.4 = 1.048 V.
To complete the circuit, two wires are needed, then the length of the communication line is doubled, and
the total voltage drop will be 2.096 V. This results in about 2.1 V due to the 2,000 feet distance from the transmitter to the downstream. Summing up the voltage drops across all circuit elements, we get:
2.096V + 12V + 5V = 19.096V

If you used 17 V to power this circuit, then the voltage supplied to the pressure transducer will be below the minimum operating voltage due to the drop across the lead resistance and the shunt resistor. Choosing a typical 24V power supply will satisfy the power requirements of the converter. Additionally, there is a voltage reserve in order to place the pressure sensor at a greater distance.

With the selection of the right transducer, acquisition device, cable lengths, and power supply, the design of the simple current loop is complete. For more complex applications, you can include additional measurement channels in the system.

Connecting the current sensor to the microcontroller

Having familiarized ourselves with the basics of the theory, we can move on to the issue of reading, transforming and visualizing data. In other words, we will design a simple DC meter.

The analog output of the sensor is connected to one of the ADC channels of the microcontroller. All necessary transformations and calculations are implemented in the microcontroller program. A 2-line character LCD is used to display data.

Experimental circuit

For experiments with a current sensor, it is necessary to assemble a structure according to the diagram shown in Figure 8. For this, the author used a breadboard and a module based on a microcontroller (Figure 9).

The ACS712-05B current sensor module can be purchased ready-made (it is sold very inexpensively on eBay), or you can make your own. The capacitance of the filter capacitor is chosen equal to 1 nF; a blocking capacitor of 0.1 μF is installed on the power supply. An LED with a damping resistor is soldered to indicate that the power is on. The power supply and output signal of the sensor are connected to a connector on one side of the module board, a 2-pin connector for measuring the flowing current is located on the opposite side.

For experiments on current measurement, we connect an adjustable constant voltage source to the current measuring terminals of the sensor through a series resistor 2.7 Ohm / 2 W. The sensor output is connected to the RA0 / AN0 port (pin 17) of the microcontroller. A two-line character LCD is connected to port B of the microcontroller and operates in 4-bit mode.

The microcontroller is powered by +5 V, the same voltage is used as a reference for the ADC. The necessary calculations and transformations are implemented in the microcontroller program.

The mathematical expressions used in the conversion process are shown below.

Current sensor sensitivity Sens = 0.185 V / A. With Vcc = 5 V supply and Vref = 5 V reference, the calculated ratios are as follows:

ADC output code

Hence

As a result, the formula for calculating the current is as follows:

Important note. The above relationships are based on the assumption that the ADC supply voltage and reference voltage are 5 V. However, the latter expression, which relates the current I to the ADC Count output code, remains in effect even with fluctuations in the supply voltage. This was discussed in the theoretical part of the description.

The last expression shows that the current resolution of the sensor is 26.4 mA, which corresponds to 513 ADC counts, which is one count higher than the expected result. Thus, we can conclude that this implementation does not allow measuring small currents. To increase the resolution and increase the sensitivity when measuring low currents, the use of an operational amplifier is required. An example of such a circuit is shown in Figure 10.

Microcontroller program

The program of the PIC16F1847 microcontroller is written in C and compiled in the mikroC Pro environment (mikroElektronika). The measurement results are displayed on a two-line LCD display with an accuracy of two decimal places.

Output

At zero input current, the output voltage of the ACS712 should ideally be strictly Vcc / 2, i.e. the number 512 should be read from the ADC. A drift of the sensor output voltage by 4.9 mV causes a shift in the conversion result by 1 least significant bit of the ADC (Figure 11). (For Vref = 5.0 V, the resolution of a 10-bit ADC will be 5/1024 = 4.9 mV), which corresponds to 26 mA of input current. Note that in order to reduce the influence of fluctuations, it is desirable to make several measurements and then average their results.

If the output voltage of the regulated power supply is set to 1 V, through
the resistor should have a current of about 370 mA. The measured value of the current in the experiment is 390 mA, which exceeds the correct result by one unit of the least significant bit of the ADC (Figure 12).

Figure 12.

At a voltage of 2 V, the indicator will show 760 mA.

This concludes our discussion of the ACS712 current sensor. However, we have not touched on one more issue. How to measure alternating current with this sensor? Note that the sensor provides an instantaneous response corresponding to the current flowing through the test leads. If current flows in the positive direction (from pins 1 and 2 to pins 3 and 4), the sensor's sensitivity is positive and the output voltage is greater than Vcc / 2. If the current changes direction, the sensitivity will be negative and the sensor's output voltage will drop below Vcc / 2. This means that when measuring an AC signal, the microcontroller's ADC must sample fast enough to be able to calculate the rms current.

Downloads

The source code of the microcontroller program and the file for the firmware -

Here I separately brought up such an important practical issue as the connection of inductive sensors with a transistor output, which are ubiquitous in modern industrial equipment. In addition, actual instructions for the sensors and links to examples are provided.

The principle of activation (operation) of sensors in this case can be any - inductive (approximation), optical (photoelectric), etc.

In the first part, the possible options for sensor outputs were described. There should be no problems with connecting sensors with contacts (relay output). And in terms of transistor and connection to the controller, it's not so simple.

Connection diagrams for PNP and NPN sensors

The difference between PNP and NPN sensors is that they switch different poles of the power supply. PNP (from the word “Positive”) commutes the positive output of the power supply, NPN - negative.

Below, for an example, the connection diagrams for sensors with a transistor output are given. Load - as a rule, this is the input of the controller.

Sensor. Load (Load) is permanently connected to “minus” (0V), supply of discrete “1” (+ V) is switched by a transistor. NO or NC sensor - depends on the control circuit (Main circuit)

Sensor. Load (Load) is permanently connected to “plus” (+ V). Here the active level (discrete “1”) at the sensor output is low (0V), while the load is supplied with power through the open transistor.

I urge everyone not to get confused, the work of these schemes will be detailed below.

The diagrams below show the same in principle. The emphasis is on the differences in PNP and NPN output circuits.

Connection diagrams for NPN and PNP sensor outputs

The left figure shows a sensor with an output transistor NPN... The common wire is switched, which in this case is the negative wire of the power supply.

Right - transistor case PNP at the exit. This case is the most frequent, since in modern electronics it is customary to make the negative wire of the power supply common, and activate the inputs of controllers and other recording devices with a positive potential.

How to check an inductive sensor?

To do this, you need to supply power to it, that is, connect it to the circuit. Then - activate (initiate) it. The indicator will light up when activated. But the indication does not guarantee correct work inductive sensor. You need to connect the load and measure the voltage across it to be 100% sure.

Replacing sensors

As I already wrote, there are basically 4 types of sensors with a transistor output, which are subdivided according to internal structure and the connection diagram:

  • PNP NO
  • PNP NC
  • NPN NO
  • NPN NC

All these types of sensors can be replaced with each other, i.e. they are interchangeable.

This is done in the following ways:

  • Alteration of the initiation device - the design is mechanically changed.
  • Changing the existing sensor switching circuit.
  • Switching the type of sensor output (if there are such switches on the sensor body).
  • Reprogramming a program - changing the active level this entrance, changing the program algorithm.

Below is an example of how you can replace a PNP sensor with an NPN one by changing the wiring diagram:

PNP-NPN interchangeability schemes. On the left is the original circuit, on the right is the reworked one.

Understanding the operation of these circuits will help to understand the fact that the transistor is a key element that can be represented by ordinary relay contacts (examples are below, in the notation).

So, the diagram is on the left. Suppose the sensor type is NO. Then (regardless of the type of transistor at the output), when the sensor is not active, its output “contacts” are open, and no current flows through them. When the sensor is active, the contacts are closed, with all the ensuing consequences. More precisely, with a current flowing through these contacts)). The flowing current creates a voltage drop across the load.

The internal load is shown with a dotted line for a reason. This resistor exists, but its presence does not guarantee stable operation of the sensor, the sensor must be connected to the controller input or other load. The resistance of this input is the main load.

If there is no internal load in the sensor, and the collector is "in the air", then this is called an "open collector circuit". This circuit ONLY works with a connected load.

So, in a circuit with a PNP output, upon activation, the voltage (+ V) through the open transistor is fed to the controller input, and it is activated. How do you do the same with NPN?

There are situations when desired sensor not at hand, but the machine should work "right now".

We look at the changes in the diagram on the right. First of all, the operating mode of the output transistor of the sensor is provided. For this, an additional resistor is added to the circuit, its resistance is usually about 5.1 - 10 kOhm. Now, when the sensor is not active, through an additional resistor voltage (+ V) is supplied to the controller input, and the controller input is activated. When the sensor is active, there is a discrete “0” at the controller input, since the controller input is shunted by an open NPN transistor, and almost all the current of the additional resistor passes through this transistor.

In this case, there is a rephasing of the sensor. But the sensor works in the mode, and the controller receives information. In most cases, this is sufficient. For example, in the pulse counting mode - a tachometer, or the number of blanks.

Yes, not quite what we wanted, and the interchangeability schemes of npn and pnp sensors are not always acceptable.

How to achieve full functionality? Method 1 - mechanically move or remake the metal plate (activator). Or the light gap in the case of an optical sensor. Method 2 - reprogram the controller input so that discrete “0” is the active state of the controller, and “1” is passive. If you have a laptop at hand, then the second method is faster and easier.

Proximity sensor symbol

On schematic diagrams inductive sensors (proximity sensors) are designated differently. But the main thing is that there is a square rotated by 45 ° and two vertical lines in it. As in the diagrams below.

NO NC sensors. Schematic diagrams.

The top diagram shows a normally open (NO) contact (conventionally designated a PNP transistor). The second circuit is normally closed and the third circuit is both contacts in the same housing.

Color coding of sensor leads

There is a standard system for labeling sensors. All manufacturers currently adhere to it.

However, it is useful to make sure that the connection is correct before installation by referring to the connection manual (instructions). In addition, as a rule, the colors of the wires are indicated on the sensor itself, if its size allows.

This is the marking.

  • Blue (Blue) - Minus power
  • Brown - Plus
  • Black - Exit
  • White - the second output, or control input, you need to look at the instructions.

Inductive sensor designation system

The sensor type is designated by an alphanumeric code in which the main parameters of the sensor are encrypted. Below is the labeling system for popular Autonics sensors.

Download instructions and manuals for some types of inductive sensors: I meet in my work.

Thank you all for your attention, I am waiting for questions on connecting sensors in the comments!

The most widely used sensors in the field of industrial automation with a unified current output 4-20, 0-50 or 0-20 mA can have various schemes connections to secondary devices. Modern sensors with low power consumption and a current output of 4-20 mA are most often connected in a two-wire circuit. That is, only one cable with two cores is connected to such a sensor, through which this sensor is powered, and transmission is carried out along the same two cores.

Typically, sensors with 4-20 mA output and two-wire connection have a passive output and require an external power supply to operate. This power supply can be built directly into the secondary device (at its input) and when the sensor is connected to such a device, a current immediately appears in the signal circuit. Devices that have a power supply for the sensor built into the input are said to be devices with an active input.

Most modern secondary instruments and controllers have built-in power supplies for working with sensors with passive outputs.

If the secondary device has a passive input - in fact, just a resistor from which the measuring circuit of the device "reads" the voltage drop proportional to the current flowing in the circuit, then an additional sensor is needed for the sensor to work. In this case, the external power supply unit is connected in series with the sensor and the secondary device to break the current loop.

Secondary devices are usually designed and manufactured in such a way that both two-wire 4-20 mA sensors and 0-5, 0-20 or 4-20 mA sensors connected in a three-wire circuit can be connected to them. To connect a two-wire sensor to the input of a secondary device with three input terminals (+ U, input and common), use the "+ U" and "input" terminals, the "common" terminal remains free.

Since the sensors, as already mentioned above, can have not only a 4-20 mA output, but, for example, 0-5 or 0-20 mA, or they cannot be connected in a two-wire circuit due to their large energy consumption (more than 3 mA) , then a three-wire connection scheme is used. In this case, the supply circuits of the sensor and the output signal circuits are separate. Sensors with a three-wire connection usually have an active output. That is, if a supply voltage is applied to the sensor with an active output and a load resistance is connected between its output and common output terminals, then a current proportional to the value of the measured parameter will run in the output circuit.

Secondary devices usually have a sufficiently low-power built-in power supply to power the sensors. The maximum output current of built-in power supplies is usually in the range of 22-50 mA, which is not always enough to power sensors with high power consumption: electromagnetic flow meters, infrared gas analyzers, etc. In this case, to power the three-wire sensor, you have to use an external, more powerful power supply unit that provides the required power. The power supply built into the secondary is not used.

A similar circuit for switching on three-wire sensors is usually used when the voltage of the power supply built into the device does not correspond to the supply voltage that is allowed to be supplied to this sensor. For example, the built-in power supply has an output voltage of 24V, and the sensor can be supplied with a voltage of 10 to 16V.

Some secondary devices may have multiple input channels and a power supply that is powerful enough to power external sensors. It should be remembered that the total power consumption of all sensors connected to such a multichannel device must be less than the power of the built-in power source intended for their power supply. In addition, when studying the technical characteristics of the device, it is necessary to clearly distinguish the purpose of the power supply units (sources) built into it. One built-in source is used to power directly the secondary device itself - for operating the display and indicators, output relays, the electronic circuit of the device, etc. This power supply can be quite powerful. The second built-in source is used to power only the input circuits - the sensors connected to the inputs.

Before connecting the sensor to a secondary device, you should carefully study the operating instructions for this equipment, determine the types of inputs and outputs (active / passive), check that the power consumed by the sensor and the power of the power supply (built-in or external) match, and only then make the connection. Actual designations of input and output terminals of sensors and devices may differ from those given above. So the terminals "Bx (+)" and "Bx (-)" can have the designation + J and -J, + 4-20 and -4-20, + In and -In, etc. The "+ U pit" terminal can be designated as + V, Supply, + 24V, etc., the "Output" terminal - Out, Sign, Jout, 4-20 mA, etc., the "common" terminal - GND , -24V, 0V, etc., but this does not change the meaning.

Sensors with a current output having a four-wire connection scheme have the same connection scheme as two-wire sensors with the only difference that the four-wire sensors are powered via a separate pair of wires. In addition, four-wire sensors can have both, which must be considered when choosing a wiring diagram.

Did you like the article? Share it
To the top