西門子6SL3055-0AA00-3PA1
概述
本例描述了用S7-200實(shí)現(xiàn)PID控制功能。這個(gè)程序是一個(gè)帶過程仿真的獨(dú)立執(zhí)行的PID例子,,它很容易修改后與模擬模塊EM235一起使用,。
例圖

程序結(jié)構(gòu)圖

程序及注解
初始化部分將PID的所有值復(fù)位,并定義了計(jì)算P舊控制器的控制周期Tc.計(jì)算PID過程中,,出現(xiàn)了某些數(shù)字方面的問題,,以及控制周期丁c的計(jì)算。山于掃描時(shí)間的限制,,除法運(yùn)算通過移位來實(shí)現(xiàn)(1024近似為1000),,而未調(diào)用專門的除法子程序。
微分和積分是另外2個(gè)比較靈敏的數(shù)學(xué)運(yùn)算,,采用如下公式:
微分運(yùn)算:










西門子6SL3055-0AA00-3PA1
一,、時(shí)間繼電器:
TON 使能=1計(jì)數(shù),計(jì)數(shù)到設(shè)定值時(shí)(一直計(jì)數(shù)到32767),,定時(shí)器位=1,。使能=0復(fù)位(定時(shí)器位=0)。
TOF 使能=1,,定時(shí)器位=1,,計(jì)數(shù)器復(fù)位(清零)。使能由1到0負(fù)跳變,,計(jì)數(shù)器開始計(jì)數(shù),,到設(shè)定值時(shí)(停止計(jì)數(shù)),定時(shí)器位=0,。如下圖:

圖1:使能=1時(shí),,TOF(T38)的觸點(diǎn)動(dòng)作圖

圖2:使能斷開后,計(jì)數(shù)到設(shè)定值后,TOF(T38)的觸點(diǎn)動(dòng)作圖(其中T38常開觸點(diǎn)是在使能由1到0負(fù)跳變后計(jì)數(shù)器計(jì)時(shí)到設(shè)定值后變?yōu)?的)
TONR 使能=1,,計(jì)數(shù)器開始計(jì)數(shù),,計(jì)數(shù)到設(shè)定值時(shí),計(jì)數(shù)器位=1,。使能斷開,,計(jì)數(shù)器停止計(jì)數(shù),計(jì)數(shù)器位仍為1,,使能位再為1時(shí),,計(jì)數(shù)器在原來的計(jì)數(shù)基礎(chǔ)上計(jì)數(shù)。
以上三種計(jì)數(shù)器可以通過復(fù)位指令復(fù)位,。
正交計(jì)數(shù)器 A相超前B相90度,,增計(jì)數(shù)
B相超前A相90度,減計(jì)數(shù)
當(dāng)要改變計(jì)數(shù)方向時(shí)(增計(jì)數(shù)或減計(jì)數(shù)),,只要A相和B相的接線交換一下就可以了,。
二、譯碼指令和編碼指令:
譯碼指令和編碼指令執(zhí)行結(jié)果如圖所示:

DECO是將VW2000的第十位置零(為十進(jìn)制的1024),,ENCO輸入IN低位為1的是第3位,把3寫入VB10(二進(jìn)制11),。