精心编制的 S7-300 PID 使用说明

合集下载

S7-300PID控制说明

S7-300PID控制说明

S7-300的PID控制的方法1、这是一个典型的PID控制系统。

通过模拟量4--20mA的传感器来监视水池的液位,对应PLC的0-27648的工程值,经这个比例转换成水池的液位。

对应的液位是你液位传感器对应的最高量程。

这个值就是PID的反馈值。

阀门调节由量模拟量输出控制阀门调节开度,控制你水池的液位。

2、无法与实际水位对应(读的参数不知道表示什么意思)?在PID调节中有不同的物理量,因此在参数设定中需将其规格化。

参数规格化:1.规格化概念及方法:PID参数中重要的几个变量,给定值,反馈值和输出值都是用0.0~1.0之间的实数表示,因此,需要将模拟输入转换为0.0~1.0的数据,或将0.0~1.0的数据转换为模拟输出,这个过程称为规格化。

规格化的方法:(即变量相对所占整个值域范围内的百分比对应与27648数字量范围内的量)。

对于输入和反馈,执行:变量*100/27648,然后将结果传送到PV-IN和SP-INT,对于输出变量,执行:LMN*27648/100,然后将结果取整传送给PQW即可;2.例:输入参数:SP_INT(给定值):0--100%的实数。

假定模块的输入变量量程为0-10Mpa,则SP_IN的范围0.0-1.00对应0-10米.可以根据这一比例关系来设置给定值。

例:如给定5.0米SP_INT(给定值)=5.0/(10.0-0.0)*100.0=50.0(50%)PV_IN(过程值,即反馈值):0--100%的实数。

此值来自与阀门阀位(开度)的相应的压力反馈值。

其范围0.0-1.0对应0-100%.即,当模拟量模板输入为数值为27648时则对应100%(量程的上限),数值为0时则对应0%(量程的下限)。

可以根据这一比例关系来换算PV_IN值。

例:如输入数值为12000时PV_IN(过程值,即反馈值)=12000/27648*100.0=43.403(43.403%)输出参数:当通过PID控制器(FB41)运算后,即得出调节值LMN_PER,该值已转化范围为0-27648的整型数值。

S7-300PID控制说明

S7-300PID控制说明

S7-300的PID控制的方法1、这是一个典型的PID控制系统。

2、通过模拟量4--20mA的传感器来监视水池的液位,对应PLC的0-27648的工程值,经这个比例转换成水池的液位。

对应的液位是你液位传感器对应的最高量程。

这个值就是PID的反馈值。

3、阀门调节由量模拟量输出控制阀门调节开度,控制你水池的液位。

4、2、无法与实际水位对应(读的参数不知道表示什么意思)5、在PID调节中有不同的物理量,因此在参数设定中需将其规格化。

参数规格化:6、 1.规格化概念及方法:PID参数中重要的几个变量,给定值,反馈值和输出值都是用~之间的实数表示,因此,需要将模拟输入转换为~的数据,或将~的数据转换为模拟输出,这个过程称为规格化。

规格化的方法:(即变量相对所占整个值域范围内的百分比对应与27648数字量范围内的量)。

对于输入和反馈,执行:变量*100/27648,然后将结果传送到PV-IN和SP-INT,对于输出变量,执行:LMN*27648/100,然后将结果取整传送给PQW即可;7、 2.例:8、输入参数:9、SP_INT(给定值):0--100%的实数。

10、假定模块的输入变量量程为0-10Mpa,则SP_IN的范围对应0-10米.可以根据这一比例关系来设置给定值。

例:如给定米11、SP_INT(给定值)=(50%)12、PV_IN(过程值,即反馈值):0--100%的实数。

13、此值来自与阀门阀位(开度)的相应的压力反馈值。

其范围对应0-100%.即,当模拟量模板输入为数值为27648时则对应100%(量程的上限),数值为0时则对应0%(量程的下限)。

14、可以根据这一比例关系来换算PV_IN值。

例:如输入数值为12000时15、PV_IN(过程值,即反馈值)=12000/27648*=(%)16、输出参数:17、当通过PID控制器(FB41)运算后,即得出调节值LMN_PER,该值已转化范围为0-27648的整型数值。

西门子S7-300_400PLC的PID调节功能模块的详细说明

西门子S7-300_400PLC的PID调节功能模块的详细说明

Group Topic1Simple PID Controllers for the S7-300/400OverviewThis programming example shows a method for programming a Proportional Integral Derivative (PID) controller on a S7 PLC. The example is already a fully functioning program, needing only for the user to tie the actual inputs and outputs to appropriate variables to be a working controller. This program is suitable for simple PID applications.For complex PID applications, Siemens offers the SIMATIC S7 Standard Control software package, which offers numerous features that this applications tip lacks. These features include alarming, scaling, deadband control, feed-forward control, range limiting, ramp/soak steps, and an integrated scheduler. The Standard Control package includes a Windows-based configuration tool that greatly simplifies configuring and tuning a PID loop.To prepare a user to make these programming changes, the text will explain the basics of the PID controller implemented in the sample code. Below is a brief outline for the rest of this document:1.What does the example program do?2.Where do you use a PID controller?3.Auto Mode vs. Manual Mode4.What does a PID controller do, and how?5.What are the Sample, Gain, Rate, and Reset?6.How is the Error figured?7.How is the Proportional term figured?8.How is the Integral term figured?9.How is the Derivative term figured?10.What if the final Output is too high?11.What should the user add to make the program work for his system?12.Adjusting the Reset, Rate, Gain, Sample time and Mode during run-timePID ExploredWhat does the example program do?示例程序的用途?This programming example is a skeleton program for a true PID controller and, as such, requires that the user make a few additions (i.e. read/write input/output variables) before it is fully functional. Before discussing these, however, let’s get a better feel for what a PID program actually does through a brief example.When do you use a PID controller?Figure 2.1 shows a picture of an example system to which a user might connect a PID controller. The figure shows a water tank sitting atop a hot plate, with a temperature control device for the hot plate and a small, monitored turbine for measuring the rate of the steam flow. This is a system that will work with a PID controller because of the relationship between the two variables: You can directly control the steam flow rate by adjusting the temperature of the hot plate. Figure 2.2 shows how both variables relate to the PID controller.The variable which represents the state of the system being controlled is called the ‘Process Variable.’ In our example above, you can see that the rate at which the steam spins the turbine is a good indicator of the event that we are trying to control: the speed at which the water is being boiled off. The output is the variable which, being altered by the controller, can affect the process variable by different degrees based on its intensity -- By turning the hot plate up, the water boils more quickly, more steam is produced, and the turbine’s speed increases. Therefore, when a variable that accurately reflects the state of the process and an adjustable control which proportionally affects the process variable, then it is possible to use a PID controller. Common systems using PID controllers are air conditioning systems, solution mixing, heaters, etc.Auto Mode vs. Manual Mode自动模式和手动模式There are two settings available on our PID controller. Putting a controller in Manual mode causes the PID loop do nothing, so that the user can directly control the output. The second, Auto, is the mode in which the PID loop is actually controlling the system. For the rest of this text, it will be assumed that the controller is in Auto mode.What does the PID controller do, and how does it do it? PID控制器作些什么?如何去做?Quite simply, a PID controller adjusts the value of its output to try and balance the value of the process variable to a given ‘setpoint.’To calculate the output value for a given instance, the controller finds the value of three different terms (using its user defined Sample time, Gain, Rate, and Reset values along with the calculated Error value): a Proportional term, an Integral term, and a Derivative term.Output = M P + M I + M DFormula 2.1What are the Sample, Gain, Rate, and Reset, and where do they come from?The sample rate is the cycle time (in milliseconds) at which the PID loop recalculates the output. The gain controls the sensitivity of the output calculation by affecting the influence of all the terms. The reset is a time given in milliseconds which is used to increase or decrease the influence of the Integral term in the equation. Finally, the rate value is used to control the influence of the Derivative term in the equation. Each of these values needs to be preset by the user before the PID controller starts.If the user does not want integral action (no I in the PID calculation), then a value of infinity or a value of 0 should be specified for the integral time. If the user does not want derivative action (no D in the PID calculation), then a value of 0 should be specified for the derivative time. If the user does not want proportional action (no P in the PID), then a value of 0 should be specified for the gain (gain is normally a multiplier in the integral and derivative coefficient calculation, but is removed from the coefficient calculation, if gain = 0, to allow I, ID, or D loop control).How is the Error figured? 误差是如何计算的?Error is figured as the difference between the normalized values of the setpoint and the process variable. The controller calculates this value in three steps. The first two steps are to change both the setpoint and the process variable into values that are based on a 0 to 1 (normalized) scale. This is done using the formulae:SP = raw_SP / max_valPV = raw_PV / max_valFormulae 2.2 & 2.3In the above formulae, the raw_SP and raw_PV values are the actual values that come into the controller, and the max_val term is the maximum value that either can take on. For example, ifthe values of raw_SP and raw_PV were being read in as values from 0 to 27,648, then the max_val term would have the value 27,648.After these two values have been calculated, the error term is figured as follows:Error = SP - PVFormula 2.4How is the Proportional term calculated?The proportional term, M P, is calculated using the following equation:M P = Gain * ErrorFormula 2.2Going back to our earlier example with the water tank, the proportional term says that as the speed of the turbine increases further above the setpoint, the heat is decreased proportionally to bring the speed down. As the turbine slows below the setpoint, the heat is increased to proportionally to bring the speed up.How is the Integral Term calculated? 积分项如何计算?The integral term, M I, is calculated using the following equation:M I = Bias + (C I * Error)Formula 2.3In this equation, two new terms are introduced. The first, C I, is the coefficient系数 of the Integral term, and is calculated from the Reset:C I = Gain * (Sample / Reset)Formula 2.4Both the Sample and Reset terms were introduced earlier, but in this equation their uses become apparent. The larger the Reset value is, the less impact the integral term will have onthe output, while larger Sample times give it a bigger influence (Sample time also affects the Derivative term, which will be explained later).The Bias term in Formula 2.3 represents (technically speaking) the area under the curve of a graph plotting the Error vs. time.Abstractly, however, the Bias value (ideally) grows to an output level that keeps the system stable, letting the Proportional and Derivative terms handle any small fluctuations. In relation to our water tank example from earlier, this means that eventually the Bias portion of M I would be the only significant contribution to the final output value, and the M P and M D terms would only be active (non-zero) when a fluctuation occurred.At a time n the equations for M I and the Bias term are:M I,n = Bias n-1 + (C I * Error)Bias n = M I,nFormula 2.5How is the Derivative term calculated?微分项如何计算?The derivative formula for a given time n is calculated with the following equation:M D = C D * (PV n-1 - PV n)Formula 2.6This formula only introduces 1 new term, C D, which is calculated using Formula 2.7.C D = Gain * (Rate / Sample)Formula 2.7The Sample term (which is also used in figuring C I) is the sample time from earlier. In the Derivative term, the Sample time is indirectly proportional to the derivative component, while the Rate is directly proportional.What if the final output value is too high?如果最终输出值太高怎么办?During many processes (such as the water tank example earlier), the Process variable doesn’t respond immediately to a change in the value of the output -- if the water in the tank were ice cold, then even an output of 100% is not going to cause an instantaneous increase in steam flow. Likewise, setting the output to 0% when the water is boiling doesn’t provide an immediate reduction in steam production.Because of this ‘system inertia,’ the output value for a give time could take on a value greater than 100% or less than 0%. In response to this, the PID program implements Output Clamping. If the output is greater than 100%, then it is clamped to 100%. If the output falls lower than 0%, then it is held to 0%.The only problem left to solve lies with the Bias portion of the Integral term. When the output for a system remains at 100% for a long period of time (such as when heating up cold water in our tank from earlier), the integral sum (which the Bias term represents) can grow to extremely large values. This means that when the variable starts responding, the Bias term will be keeping the calculated output well over 100% until it can be wound down. This generally results in the output swinging wildly from one limit to the other, but can be avoided using Bias Clamping. There are a few different types of Bias Clamping, but the only pertinent one here is the one used in the program. There are two different conditions which cause Bias clamping to occur and two formulae as well:If Output > 1Bias = 1 - (M P + M D)Formula 2.8If Output < 0Bias = -(M P + M D)Formula 2.9As the formulae show, when the Output grows to be greater than 1, the value of the Bias is adjusted so that the sum of M P, M D, and the Bias will be 1. Likewise, when the Output slips below 0, the value of the Bias is adjusted so that the above sum will be 0. The adjusted Bias value is then clamped such that its maximum value is 1 and its minimum value is 0.What should be added to make the program work for the system?1. Read in the Process Variable2. Write the Output3. Set the Setpoint4. Adjust the scale for the Input and Setpoint5. Adjust the scale for the Output6. Adjust the Reset, Rate, Gain, and Sample time values.Read in the Process VariableThe Process variable (the variable which accurately reflects the state of the system to be controlled) should be passed to the PV parameter of the function block.Write the OutputThe OUT parameter of the PID loop should be set to the analog output being controlled in the PID function block call.Set the SetpointThe user’s code must pass the Setpoint value to the PID function block via the SP parameter.Adjust the scale for the Process Variable and Setpoint 调整过程值和设定点值。

S7-300使用方法说明

S7-300使用方法说明

S7-300 系列PLC组态简介一、系统构成西门子S7-300系列的常用组件主要有电源模块(1)、CPU模块(1)、开关量模块(2)、开关量输出模块(2)、模拟量输入模块(2)、模拟量输出模块。

说明如下:1.电源模块:PS307—5A;为PLC系统提供稳定的24V直流电源。

2.CPU模块:CPU314;是系统的核心负责程序的运行,数据的存储与处理,与上位机的通讯和数据的传输。

3.开关量输入模块:SM321;可进行32路开关量的检测,输入信号为24V有效,若输入为无源触点,可利用电源模块提供24V驱动信号。

4.开关量输出模块:SM322;可提供8路开关量输出,为继电器输出方式;分为4组每两路公用一个公共端。

5.模拟量输入模块:SM331;为实现对8路模拟量数据采集,输入信号可以是电流信号、电压信号、热电偶输入、热电阻输入,可根据不同的应用场合对模块进行设置。

6.模拟量输出模块:SM332;可提供4路模拟量输出信号,根据应用可将各路输出设置为电压输出或电流输出。

图1、系统模块组成。

二、硬件组态1.基本机架(中心机架)机架即是用于安装固定各个模块的专用槽架。

PLC的各个模块就遵循一定的规则固定在上面。

每个机架中:插槽1为电源模板插槽;插槽2为CPU模板插槽;插槽3留给通讯模板接口模板及扩展模板。

插槽4以后留给应用模板。

每个模块最多可以安装8个应用模块。

模块的底部通过总线连接器与前后的模块想连接,构成一个整体系统。

中心机架至少应装配电源模块和CPU模块,再根据需要配置其他功能模块。

说明:所谓插槽,在这里只是抽象的概念,S7—300系统中的机架物理形态上只是一个槽形轨道,上面没有具体的插槽,模块也只是按一定顺序固定在上面,模块之间也无须保留空间,而是紧密地相邻安装。

插槽的概念只有在对系统进行软件组态时才能具体化。

(软件组态将在后面介绍)2.机架的扩展当基本机架不能满足系统要求时,可通过扩展机架对系统进行扩展,扩展方式有两种:①、用IM365模板:可扩展一个机架,需用两块IM365模板,连接长度最长为一米。

S7-300 PID用法

S7-300 PID用法

用西门子s7_300实现PID控制
在OB35中实现PID控制程序,OB35是一个以固定时间间隔循环执行的组织块,Hardware Config界面里可以设置间隔时间,而这也即是PID的采样时间。

应该注意设置的间隔值比OB35中程序运行时间长,否则会造成系统异常。

P:Kc 增大,系统余差减小,但不能消失.随着Kc 的增大,相应的过渡过程由不振荡变为临界振荡或衰减振荡.
I:积分作用能消除余差.Ti 小表示积分作用强,积分作用越强,过渡过程的振荡越剧烈. D:在比例作用的基础上增加微分作用将使系统的过度过程的振荡程度降低,提高了系统的稳定性.但微分作用不能太强.即Td 不能太大.否则会因反应速度太快引起系统剧烈振荡。

PID调节温度控制实例(西门子S7-300)

PID调节温度控制实例(西门子S7-300)

PID调节温度控制实例(西门⼦S7-300)控制要求
1.⽔罐⽔温设置在50℃
2.误差值在±1℃
硬件配置
设计⽅案
1.采样:使⽤ PT100 热电阻经过变送器把⽔缸温度传送给S7-300 PLC。

2. 数据的处理:在 S7-300 PLC 中经过 PID 调节运算输出模拟量信号到功率调节器中。

3.温度调节:在功率调节器中把对应的模拟量转化为对应的功率来驱动热得快;
程序编写
1. 创建名称为PID调节的⼯程,添加CPU314C-2DP.西门⼦CPU314C-2DP,⾃带有模
拟量输⼊输出通道,⽆需扩展模块,在这⾥我们要注意他们的地址,以及输⼊输出的测量类型与测量范围。

这次试验⽤的是4-20mA的变送器,输出我们采⽤0-10V电压输出,这些参数需要在硬件组态时进⾏设置,设置好以后注意编译保存下载。

2.程序的编写
3.PID 调节
⾸先在开始菜单中打开PID 调节⾯板,如下图所⽰:。

S7-300使用说明书

一、S7-300初始化尽量使用window2000,Windows XP。

STEP7V52或以上版本1.2 通信1、设置通信`设置或添加PC Adapter(MPI), Property 按钮Local Connection 属性页COM 1 19200,注意一般连接到计算机的串行口1。

其他参数不需要设置,注意选择PC Adapter,不要有其他的,例如pc/ppi。

1.3 硬件组态2、新建工程在SIMATIC Manager中新建工程,也可以通过wizard向导建立。

选中右边的工程名,Insert Station SIMATIC 300。

双击Hardware,从而进入HW CONFIG窗口。

Option>Insert NEW GSE文件。

把MM420, ET200等GSD文件加入。

在hw config,如图所示,插入RAC-300机架。

选中机架第二栏,双击CPU-300>CPU313C-2DP,注意准确的编号。

默认地址2。

双击DP,选择Property按钮。

选择NEW,选择1.5MBPS,如果出现警告,可以选择187kpbs。

依次在SLOT 1,2,3位置插入其他模块。

0 电源模块S7-300DI 地址:256-263DO 地址:256-259选中DP线,然后双击ET200S,如图所示,插入ET200S.选择,依次在SLOT 1,2,3位置插入其他模块。

6ES7 138-4CA00-0AA0 PM-E DC24V6ES7 134-4GB50-0AB0 2AI I 2DMU地址I address264-2676ES7 134-4JB50-0AB0 2AI RTD地址I address268-271插入MM420选择4PKW, 2PZD (PPO1)2AX地址I address 280-283 Q address 268-271全部保存1.4 下装硬件组态并检测在SIMATIC Manager中,选择工程,选择PLC>Clear/Reset,可以清除原来的配置信息。

S7-300_PID参数说明


BOOL BOOL BOOL BOOL
FALSE / TRUE FALSE / TRUE FALSE / TRUE FALSE / TRUE FALSE / TRUE >=1ms -100.0 to +100.0(%) or phys.value 1 -100.0 to +100.0(%) or phys.value 1
MAN GAIN TI TD TM_LAG DEADB_W
in in in in in in
手动值 增益 积分时间 微分时间 微分延时 死区
REAL REAL TIME TIME TIME REAL
0.0 2
DB*.DBD16.0 DB*.DBD20.0 DB*.DBD24.0 DB*.DBD28.0 DB*.DBD32.0 DB*.DB0.1
PVPER_ON
in
过程变量输入开关 BOOL
FALSE / TRUE
FALSE
DB*.DBD0.2
P_SEL I_SEL INT_HOLD I_ITL_ON D_SEL CYCLE SP_INT
in in in in in in in
比例作用开关 积分作用开关
TRUE TRUE FALSE FALSE FALSE T#1S 0.0
DB*.DBD0.3 DB*.DBD0.4 DB*.DBD0.5 DB*.DBD0.6
微分作用开关 循环时间 设定值
BOOL TIME REAL
D_SEL=1微分作用启动。 D_SEL=0微分作用停止。
DB*.DBD0.7 DB*.DBD2.0 DB*.DBD6.0
DB*.DBD44.0 DB*.DBD48.0 DB*.DBD52.0 DB*.DBD56.0 DB*.DBD60.0 DB*.DBD64.0 DB*.DBD68.0 DB*.DBD72.0 DB*.DBD76.0 DB*.DBD78.0 DB*.DBD78.1 DB*.DBD80.0 DB*.DBD84.0 DB*.DBD88.0 DB*.DBD92.0 DB*.DBD96.0

S7-300使用说明书

一、S7-300初始化尽量使用window2000,Windows XP。

STEP7V52或以上版本1.2 通信1、设置通信`设置或添加PC Adapter(MPI), Property 按钮Local Connection 属性页COM 1 19200,注意一般连接到计算机的串行口1。

其他参数不需要设置,注意选择PC Adapter,不要有其他的,例如pc/ppi。

1.3 硬件组态2、新建工程在SIMATIC Manager中新建工程,也可以通过wizard向导建立。

选中右边的工程名,Insert Station SIMATIC 300。

双击Hardware,从而进入HW CONFIG窗口。

Option>Insert NEW GSE文件。

把MM420, ET200等GSD文件加入。

在hw config,如图所示,插入RAC-300机架。

选中机架第二栏,双击CPU-300>CPU313C-2DP,注意准确的编号。

默认地址2。

双击DP,选择Property按钮。

选择NEW,选择1.5MBPS,如果出现警告,可以选择187kpbs。

依次在SLOT 1,2,3位置插入其他模块。

0 电源模块S7-300DI 地址:256-263DO 地址:256-259选中DP线,然后双击ET200S,如图所示,插入ET200S.选择,依次在SLOT 1,2,3位置插入其他模块。

6ES7 138-4CA00-0AA0 PM-E DC24V6ES7 134-4GB50-0AB0 2AI I 2DMU地址I address264-2676ES7 134-4JB50-0AB0 2AI RTD地址I address268-271插入MM420选择4PKW, 2PZD (PPO1)2AX地址I address 280-283 Q address 268-271全部保存1.4 下装硬件组态并检测在SIMATIC Manager中,选择工程,选择PLC>Clear/Reset,可以清除原来的配置信息。

S7-300的PID控制


。了以可就用调会要需只�题问些这等等算运分微、算运分积、算运例
现实来 14BF 用使何如�表仪规常替代来 14BF 的 CLP003-7S 用使是就的做要们我天今
、度例比�即。数参 D、I、P 定设够能该应就器制控 DIP 是然既�器制控的里表仪规常们我于 当相就 14BF�制控 DIP 现实来 14BF 块模用使以可们我�CLP003-7S 子门西习学过经
制控 DIP 现实 14BF 用使
示所图下如 在接直以可此因 。口端的 14BF 到看以可里 53BO 在以所的 14BF 用调里 53BO 在是们我 。数参设接直上口端些这
这用调去间时段一隔每要需只们我�的算运 DIP 现实来用是它�序程子个一于当相 14BF
可率频的用调�了以可就 14BF 用调里 53BO 在们我以所。制控 DIP 现实以可就”序程子“一
景背要还么什为�数参赋口端 14BF 给接直以可面里 53BO 在以可然既�问会人有里这到
���呢 BD 块据数
下看观你迎欢,用使何如讲们我节一下�了识认的本基个一了有 14BF 对经已们我节一这过经
。节一
。等钮按换切动自/动手有又�数参 DIP 改更以可上板面的表仪规常。间时分微、间时分积
。理管与制控中集们我于便不且而�高常非得变会就本成制控 DIP 的路多实现要果如�制控 DIP 的路一现实能只就器制控个一里表仪规常而�制控 DIP 到用要常常中域领化动自在
。定设上口端的 14BF 在就数参的变改常经要。定设面里 BD 在接直就们我 �的变改常经要需不数参些有�数参设方地个两在时同以可们我�点缺优的法方种两合结 。了以只就 量变的应相变改要需只数参变改要需们我当�数参有存面里量变�量变个一是数参赋口端给 。了数参的面里表据数改更能不就后之 CLP 到载下 序程当以所 �量变个一是能不�值定固个一是能只数参面里表据数在�数参置设方地个两在以可们我以所 有果如 �数参设口端的 14BF 给里 53BO 在有没有户用 �查检先会中程过行运在 CLP 实其 。数参取去面里表据数景背到就有没果如�数参的上口端用使接直就。置设面 Nhomakorabea性属在以
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

定时中断组织块OB35西门子S7-300/400有9个定时中断组织块:OB30、OB31、OB32、OB33、OB34、OB35、OB36、OB37、OB38 。

CPU可以定时中断去执行这些模块中的程序,即:每隔一段时间就停止当前的程序,转去执行定时中断组织块中的程序,执行结速后再返回。

相当于单片机的定时中断。

这9个组织块功能相同,你可以选择其中之一使用,区别是它们的中断优先级不同,如果程序中用到了多个定时中断组织块,应设好它们的执行优先级。

S7-300CPU 可用的定时中断组织模块是OB35,在300站点的硬件组态中,打开CPU 属性设置可以看到其它的中断组织块为灰色。

OB35默认的调用时间间隔为100ms 我们可以根据需要更改,定时范围是1-60000毫秒(ms)设置中断时间间隔如下图所示注意:设置的时间必须大于OB35中程序执行所花费的时间。

例如:如果中断时间间隔为50ms而OB35中的程序花费的时间是70ms,那么OB35中的程序还没执行完毕就产生第二次中断,程序就会出错,这显然是我们不想看到的结果。

以现在的技术,让你间隔一小时去月球拿一块石头你能做到吗去月球所用的时间大于去月球的时间间隔,你做不到吧正确设置:中断时间间隔大于OB35中程序执行完毕一次所需的时间使用FB41实现PID控制在自动化领域中常常要用到PID控制,而常规仪表里一个控制器就只能实现一路的PID 控制,如果要现实多路的PID控制成本就会变得非常高,而且不便于我们集中控制与管理。

经过学习西门子S7-300PLC,我们可以使用模块FB41来实现PID控制,FB41就相当于我们常规仪表里的控制器,既然是PID控制器就应该能够设定P、I、D参数。

即:比例度、积分时间、微分时间。

常规仪表的面板上可以更改PID参数,又有手动/自动切换按钮等。

今天我们要做的就是使用S7-300PLC 的FB41来代替常规仪表,如何使用FB41来实现PID控制的呢??FB41是一个功能块,它所能实现的功能(PID)已经由专业人员设计好,我们只要调用它,并根据我们的需要来更改相应的参数即可使用。

所以我们不用理会FB41是如何实现比例运算、积分运算、微分运算等等这些问题,只需要会调用就可以了。

现在我们已经知道FB41就相当于常规仪表里的一个控制器了,那么我们是如何使用FB41并给它设置相应的参数呢??FB41相当于一个子程序,它是用来实现PID运算的,我们只需要每隔一段时间去调用这一“子程序”就可以实现PID控制。

所以我们在OB35里调用FB41就可以了,调用的频率可以在属性里面设置。

我们是在OB35里调用FB41的所以在OB35里可以看到FB41的端口。

因此可以直接在这些端口上直接设参数。

如下图所示到这里有人会问,既然可以在OB35里面可以直接给FB41端口赋参数,为什么还要背景数据块DB呢其实PLC在运行过程中会先检查,用户有没有在OB35里给FB41的端口设参数,如果有就直接使用端口上的参数,如果没有就到背景数据表里面去取参数。

所以我们可以在两个地方设置参数,在数据表里面参数只能是一个固定值,不能是一个变量,所以当程序下载到PLC之后就不能更改数据表里面的参数了。

给端口赋参数是一个变量,变量里面存有参数,当我们需要改变参数只需要改变相应的变量就只以了。

结合两种方法的优缺点,我们可以同时在两个地方设参数,有些参数不需要经常改变的,我们就直接在DB里面设定。

要经常改变的参数就在FB41的端口上设定。

经过这一节我们已经对FB41有了一个基本的认识了,下一节我们讲如何使用,欢迎你观看下一节。

FB41背景数据块参数设置使用FB41作PID控制时,设置参数非常烦琐,下面是单回路PID控制的参数设置实例,在表格第三列有的就是我们需要设置的,空白的我们就不用改变,按默认值就可以了。

参数描述设置实例COM_RST完全重启动FALSE MAN_ON手动/自动PVPER_ON测量值选择FALSEP_SEL比例输出开关TRUEI_SEL积分输出开关TRUEIN_HOLD积分输出冻结I_ITL_ON积分初始化D_SEL微分输出开关CYCLE采样量时,条件CYCLE>=1ms100msSP_INT给定值在引脚中设置PV_IN测量值1在引脚中设置PV_PER测量值2MAN手动值GAIN比例增益按默认TI积分时间,条件TI>=CYCLE按默认TD微分时间,条件TD>=CYCLETM_LAG 微分作用时滞时间,条件TM_LAG>=CYCLE/2DEADB_W死区宽度LMN_HLM控制器输出上限LMN_LLM控制器输出下限PV_FAC过程变量因子PV_OFF过程变量偏移LMN_FAC控制器输出因子LMN_OFF控制器输出偏移I_ITLVAL积分初始化值DISV 扰动量(前馈控制系统中才用到)LMN控制器输出值在引脚中设置LMN_PER控制器输出值(格式化后)QLMN_HLM达到上限QLMN_LLM达到下限LMN_P比例分量输出LMN_I积分分量输出LMN_D微分分量输出PV测量值输出ER实际误差关于FB41块的各个管脚的功能A:所有的输入参数:COM_RST: BOOL: 重新启动PID:当该位TURE时:PID执行重启动功能,复位PID内部参数到默认值;通常在系统重启动时执行一个扫描周期,或在PID进入饱和状态需要退出时用这个位;MAN_ON:BOOL:手动值ON;当该位为TURE时,PID功能块直接将MAN的值输出到LMN,这可以在PID框图中看到;也就是说,这个位是PID的手动/自动切换位;PEPER_ON:BOOL:过程变量外围值ON:过程变量即反馈量,此PID可直接使用过程变量PIW(不推荐),也可使用PIW规格化后的值(常用),因此,这个位为FALSE;P_SEL:BOOL:比例选择位:该位ON时,选择P(比例)控制有效;一般选择有效;I_SEL:BOOL:积分选择位;该位ON时,选择I(积分)控制有效;一般选择有效;INT_HOLD BOOL:积分保持,不去设置它;I_ITL_ON BOOL:积分初值有效,I-ITLVAL(积分初值)变量和这个位对应,当此位ON时,则使用I-ITLVAL变量积分初值。

一般当发现PID功能的积分值增长比较慢或系统反应不够时可以考虑使用积分初值;D_SEL :BOOL:微分选择位,该位ON时,选择D(微分)控制有效;一般的控制系统不用;CYCLE :TIME:PID采样周期,一般设为200MS;SP_INT:REAL:PID的给定值;PV_IN :REAL:PID的反馈值(也称过程变量);PV_PER:WORD:未经规格化的反馈值,由PEPER-ON选择有效;(不推荐)MAN :REAL:手动值,由MAN-ON选择有效;GAIN :REAL:比例增益;TI :TIME:积分时间;TD :TIME:微分时间;TM_LAG:TIME:和微分有关;DEADB_W:REAL:死区宽度;如果输出在平衡点附近微小幅度振荡,可以考虑用死区来降低灵敏度;LMN_HLM:REAL:PID上极限,一般是100%;LMN_LLM:REAL:PID下极限;一般为0%,如果需要双极性调节,则需设置为-100%;(正负10V输出就是典型的双极性输出,此时需要设置-100%);PV_FAC:REAL:过程变量比例因子PV_OFF:REAL:过程变量偏置值(OFFSET)LMN_FAC:REAL:PID输出值比例因子;LMN_OFF:REAL:PID输出值偏置值(OFFSET);I_ITLVAL:REAL:PID的积分初值;有I-ITL-ON选择有效;DISV :REAL:允许的扰动量,前馈控制加入,一般不设置;B:部分输出参数说明:LMN :REAL:PID输出;LMN_P :REAL:PID输出中P的分量;(可用于在调试过程中观察效果)LMN_I :REAL:PID输出中I的分量;(可用于在调试过程中观察效果)LMN_D :REAL:PID输出中D的分量;(可用于在调试过程中观察效果)非常实用的pid参数整定:FB41的PID:一、在ob35里面插入FB41,方框顶上会有红字,输入一个类似“DB120”的,系统会问你要不要生成这个Db,yes就可以二、大部分参数不要填,默认就行,下面是常用参数,用变量连接:1、MAN_ON:用一个bool量,如m0.0,为true则手动,为false则自动;2、cycle:T#100MS,这个值与ob35默认的100ms一致;3、SP_INT:MD2,是hmi发下来的设定值,0-100.0的范围,real型;4、PV_IN:md6,实际测量值,比如压力,要从piw×××转换为0-100.0的量程;5、MAN:MD10,op值,也就是手动状态下的阀门输出,real型,0-100.0的范围;6、GAIN:md14,Pid的P啊,默认写1-2吧(系统默认是2),调试的时候再改7、TI:MW20,pid的i啊.默认写T#30S吧,调试的时候改;8、DEAD_W:md22,死区,就是sp和pv的偏差死区,0-100.0的范围,默认0,调试的时候改;输出:9、LMN:MD26,0-100。

0,最终再用fc106转换为word型move到pqw×××,如果pid运算结果不再有工艺条件其他限制可以用LMN_PER更简单就不用fc106了。

三、用plcsim模拟1、手动man_on=true,看输出是否等于man;2、自动man_on=false,调整pv或者sp,使得有偏差大于死区,看输出变化,这里的模拟只能说明pid工作了,不能测试实际调节效果啊。

3、如果需要反作用,有三种方法:a、pv和sp颠倒输入b、p值用负的c、输出用100减/service/answer/solution.asp?Q_id=20022&ci d=1029PID常用口诀: 参数整定找最佳,从小到大顺序查,先是比例后积分,最后再把微分加,曲线振荡很频繁,比例度盘要放大,曲线漂浮绕大湾,比例度盘往小扳,曲线偏离回复慢,积分时间往下降,曲线波动周期长,积分时间再加长,曲线振荡频率快,先把微分降下来,动差大来波动慢,微分时间应加长,理想曲线两个波,前高后低4比1目前工业自动化水平已成为衡量各行各业现代化水平的一个重要标志。

同时,控制理论的发展也经历了古典控制理论、现代控制理论和智能控制理论三个阶段。

智能控制的典型实例是模糊全自动洗衣机等。

自动控制系统可分为开环控制系统和闭环控制系统。

一个控制系统包括控制器、传感器、变送器、执行机构、输入输出接口。

相关文档
最新文档