首先我们了解一下什么是数字量和模拟量?为什么PLC需要使用模拟量?
First, let’s understand what digital and analog quantities are? Why does PLC need to use analog quantities?
数字量 digital quantity
数字量是物理量的一种。它们的变化在时间上是不连续的,总是发生在一系列离散的瞬间。这一类物理量叫做 数字量。也就是离散量,指的是分散开来的、不存在中间值的量。
Digital quantity is a type of physical quantity. Their changes are discontinuous in time and always occur in a series of discrete moments. This type of physical quantity is called digital quantity. That is, discrete quantities refer to quantities that are scattered and do not have intermediate values.
模拟量 Analog quantity
模拟量是指变量在一定范围连续变化的量;也就是在一定范围(定义域)内可以取任意值(在值域内)。
Analog quantity refers to the quantity of a variable that changes continuously within a certain range; that is, it can take any value (within the value range) within a certain range (definition domain).
数字量是分立量,而不是连续变化量,只能取几个分立值,如二进制数字变量只能取两个值。
Digital quantities are discrete quantities, not continuously changing quantities. They can only take on a few discrete values. For example, a binary digital variable can only take on two values.
那么对于实际的工业应用而言,数字量和模拟量都是必不可少的。
So for actual industrial applications, both digital and analog quantities are essential.
因为在工厂的自动化控制中,我们需要对温度,压力,液位,深度等等数据进行监控并控制。
Because in factory automation control, we need to monitor and control data such as temperature, pressure, liquid level, depth, etc.
比如说一个锅炉的控制,我们需要水烧到一定温度,一般来说该温度是可调的,比如说50摄氏度,或者70摄氏度,而数字量则不能满足这些条件。
For example, for the control of a boiler, we need water to be heated to a certain temperature. Generally speaking, the temperature is adjustable, such as 50 degrees Celsius or 70 degrees Celsius, but digital quantities cannot meet these conditions.
再举个例子,一些化工企业需要测量液体的酸碱度,那么酸碱度不可以用数字量的0或者1表示,只能使用模拟量,PH6.5,PH7.0等等才可以清晰的描绘出实际的数据。
For another example, some chemical companies need to measure the pH of liquids, so the pH cannot be represented by digital quantities of 0 or 1. Only analog quantities, PH6.5, PH7.0, etc. can be used to clearly depict the actual pH. data.
Hardware includes selection and wiring. Selection means selecting different analog quantities and PLCs for different working conditions. For example, the analog quantities use 0-10V, 4-20ma, 0-20ma, or special thermocouple signals, etc.
The second is wiring. Don’t underestimate wiring. There are different wiring methods for different PLCs.
For the Siemens S7-300 series, we need to use the expansion module, open Siemens STEP7, select the appropriate PLC and analog modules, and add the modules.
For PLC, each analog value has a fixed address. This address can be identified and calculated in the program, and the appropriate address can be added intelligently.
According to the field device, select the appropriate range. If you are measuring temperature, you need to use a specific temperature module and select the appropriate temperature signal. Regarding temperature control, we have introduced it in previous articles. Friends who need it can go find it.
For voltage signals, there are many optional types, which can be selected according to the signal type of the actual device. For example, -10V-10V, -5V-5V, -1V-1V, 1-5V.
Of course, there are many analog expansion modules in the Siemens series. In addition to those used in this article, there are many other voltage signals used in different fields. As shown below.
For current signals, they are divided into two-wire systems and four-wire systems, which need to be selected according to the actual instrument.
As shown in the figure above, after selecting the analog input type, you need to switch the hardware range card to the corresponding position.
Remember to cut off the power before disassembling the module, then power on and download the hardware configuration after adjustment.
For other PLCs, there is no step to replace the range card. You only need to connect the line directly to the PLC analog input module.
For those who are new to PLC programming, programming of analog input and output modules is much more difficult than using bit variables for general program control, because it is not only program programming, but also involves the derivation and conversion of analog quantities. problem of use. Different sensor transmitters perform conversion through different analog input and output modules, and their conversion formulas are different. If the conversion formula selected is incorrect, the program compiled will definitely be wrong.
In fact, for PLC, all it can accept is -32767-32767 data. We need to convert this data into the actual data we need.
It means converting the data of analog channel 304 into actual data with a range of 0-500, and assigning the data to MW104.
The analog output is the opposite, converting the data from MW104 to 0-100% analog data. For example, if the external signal PQW320 is 0-10V, it corresponds to 0V-10V.
This picture is the expression form of analog output and you can save it. Easy to find.
This is part of a not too complicated feeding program. The program is easy to understand. It is a radar level meter in a large silo. The characteristic of the radar level meter in this project is that it can detect raw materials of 0.5-10 meters. position, because of production reasons, the silo needs to ensure that there is always raw material.
Therefore, we need to replenish the material when the silo is lower than about 2 meters to ensure that the raw materials in the silo are sufficient, and stop when it reaches 9 meters to prevent the raw materials from accumulating outside.