(1) 功能塊FC實(shí)參的指針存到調(diào)用塊的L堆棧;
(2) 調(diào)用塊的地址和返回位置存儲(chǔ)在塊堆棧,調(diào)用塊的局部數(shù)據(jù)壓入L堆棧;
(3) 功能塊存儲(chǔ)臨時(shí)變量的L堆棧區(qū)被推入L堆棧上部;
(4) 當(dāng)被調(diào)用功能塊FC結(jié)束時(shí),先前塊的信息存儲(chǔ)在塊堆棧中,臨時(shí)變量彈出L堆棧。
因?yàn)楣δ軌KFC不用背景數(shù)據(jù)塊,不能分配初始數(shù)值給功能塊FC的局部數(shù)據(jù),所以必須給功能塊FC提供實(shí)參。
STEP 7為功能塊FC提供了一個(gè)特殊的返回值輸出參數(shù)(關(guān)鍵字:RET_VAL)。當(dāng)在文本文件中創(chuàng)建功能塊FC時(shí),你可以在定義功能塊FC命令后輸入數(shù)據(jù)類(lèi)型(如BOOL或INT)。對(duì)文本文件進(jìn)行編譯時(shí),STEP 7會(huì)自動(dòng)生成RET_VAL輸出參數(shù)。當(dāng)用STEP 7的程序編輯器(Program Editor)以增量模式創(chuàng)建功能塊FC時(shí),可在FC的變量聲明表中聲明一個(gè)輸出參數(shù)RET_VAL,并指明其數(shù)據(jù)類(lèi)型。
功能塊編程與調(diào)用舉例
對(duì)功能塊編程分兩步進(jìn)行:步是定義局部變量(填寫(xiě)局部變量表);第二步是編寫(xiě)要執(zhí)行的程序,可以用梯形圖或語(yǔ)句表兩種形式編程,并在編程過(guò)程中使用定義了的局部變量(數(shù)據(jù))。
定義局部變量的工作內(nèi)容包括:
(1) 分別定義形參、靜態(tài)變量和臨時(shí)變量(FC塊中不包括靜態(tài)變量);
(2) 確定各變量的聲明類(lèi)型(Decl.)、變量名(Name)和數(shù)據(jù)類(lèi)型(Data Type),還要為變量設(shè)置初始值(Initial Value)(盡管對(duì)有些變量初始值不一定有意義)。如果需要還可為變量注釋(Comment)。在增量編程模式下,STEP 7將自動(dòng)產(chǎn)生局部變量地址(Address)。
寫(xiě)功能塊程序時(shí),可以用以下兩種方式使用局部變量:
(1) 使用變量名,此時(shí)變量名前加前綴“#”,以區(qū)別于在符號(hào)表中定義的符號(hào)地址。增量方式下,前綴會(huì)自動(dòng)產(chǎn)生。
(2) 直接使用局部變量的地址,這種方式只對(duì)背景數(shù)據(jù)塊和L堆棧有效。
在調(diào)用FB塊時(shí),要說(shuō)明其背景數(shù)據(jù)塊。背景數(shù)據(jù)塊應(yīng)在調(diào)用前生成,其順序格式與變量聲明表必須保持一致。在增量方式下,調(diào)用FB塊時(shí),STEP 7會(huì)自動(dòng)提醒并生成背景數(shù)據(jù)塊。此時(shí)也為背景數(shù)據(jù)塊設(shè)置了初始值,該初始值與變量聲明表中的相同。當(dāng)然也可以為背景數(shù)據(jù)塊設(shè)置當(dāng)前值(Current Value),即存儲(chǔ)在CPU中的數(shù)值。
1.二分頻器
假設(shè)功能塊FC10是二分頻器產(chǎn)生程序,功能是對(duì)不同的輸入位進(jìn)行二分頻處理。以下給出了FC10的變量聲明表和語(yǔ)句表程序。在程序中使用了跳變沿檢測(cè)指令。
1) FC10的變量聲明表(見(jiàn)表5.3)
IDEC APW199DY USPP APW199DY
APW MCLEAN TEG10 NSPP TEG10
APW MCLEAN TEG10 USPP TEG10
IDEC APW299D-S-24V NSPP APW299DS24V
IDEC APW-299D-R-120?V NSPP APW299DR120V
TEXAS INSTRUMENTS SEMI SN74LVCC3245AP?W FNFP SN74LVCC3245AP?W
IDEC APW-199R24V USPP APW199R24V
IDEC APW299D-A-24V USPP APW299DA24V
IDEC APW299D-Y-24V NSFP APW299DY24V
IDEC APW299D-Y-24V USPP APW299DY24V
IDEC APW1126S USPP APW1126S
IDEC APW-199 NSFP APW199
IDEC APW-199 NSPP APW199
IDEC APW-199 USPP APW199
IDEC APW199D-A-120V NSFP APW199DA120V
IDEC APW199D-A-120V NSPP APW199DA120V
IDEC APW199D-A-120V USPP APW199DA120V
IDEC APW199D-G-120V NSFP APW199DG120V
IDEC APW199D-G-24V NSFP APW199DG24V
IDEC APW199D-G-24V USPP APW199DG24V
IDEC APW199D-R-120V NSFP APW199DR120V
IDEC APW199D-R-120V NSPP APW199DR120V
IDEC APW199D-R-120V USPP APW199DR120V
IDEC APW199D-R-24V NSFP APW199DR24V
IDEC APW199D-R-24V USPP APW199DR24V
IDEC APW199D-S-24V NSFP APW199DS24V
IDEC APW199D-W-120V NSFP APW199DW120V
IDEC APW199D-W-120V USPP APW199DW120V
IDEC APW199-G-120V NSFP APW199G120V
IDEC APW199-G-120V USPP APW199G120V
IDEC APW2126G USPP APW2126G
IDEC APW299D-G-120V NSFP APW299DG120V
IDEC APW299D-G-120V NSPP APW299DG120V
IDEC APW299D-G-120V USPP APW299DG120V
IDEC APW-299D-R-120?V NSFP APW299DR120V
IDEC APW-299D-R-120?V USPP APW299DR120V
IDEC APW299D-W-120V NSFP APW299DW120V
IDEC APW299D-W-120V USPP APW299DW120V
IDEC APW2LD-G NSFP APW2LDG
IDEC APW299-E-R-120?V NSPP APW299ER120V
IDEC APW299-E-R-24V NSPP APW299ER24V
IDEC APW299DW6V USPP APW299DW6V
IDEC APW1126D-A NSFP APW1126DA
IDEC APW1126D-A USPP APW1126DA
TEXAS INSTRUMENTS SEMI SN74LVCC4245AP?W FNFP SN74LVCC4245AP?W
VT50XX #31783
72V AMETEK LOW WIND GENERATOR MOTOR
Ametek USG Pressure Gauge 132784 P1929
Ametek Accuforce AF5-R-ND Gage with Load Cell, Scale, Lab, Tool, Test Equipment
Ametek Hunter Spring 50 lbs. Mechanical Force Gauge
Ametek Dixson BB101P Programmable Bargraph 0 Horiz
Ametek Brushless 24 VDC Vacuum motor and Driver
Ametek Accu Force Torque Chek Digital Torge Gauge 0-200 Oz In
2 NEW AMETEK 1025-D1SP 1025D1SP FOOT AND PALM SWITCH
AMETEK PANALARM 50A1-120A RELAY AUX 120VAC 60HZ 8.5VA - USED w/GUARANTEE
Ametek Gemco Patriot 950A1-6-F-X-X-?X-10-X Quik Stik LDT
Ametek Gemco Patriot 951A-C1-0100-N?2-X-E Quik Stik LDT
Ametek Prestolite 350 Amp Relay NSN 5945-01-165-10?65
AMETEK CONTROLLER 24VDC, 5A, #48132-01, 6NV85, 11-52VDC
AMETEK RO-3300 REVERSE OSMOSIS SYSTEM
Dixson Instruments Bargraph BB101 AJTX4 / 20MADCV8850 Ametek NEW
AMETEK Brushless Blower 24VDC, 2.5A, 36CFM, Vacuum 13.0
Pittman/Ametek Motor, 19.7:1 Ration GM9413C555
AMETEK 1025A1DPX DOUBLE POLE FOOT SWITCH
NOS! AMETEK SPRING RESILIENCY TESTER A799571 6635-00-470-15?47
NEW AMETEK WATER FILTRATION RB25-20 SEDIMENT CARTRIDGE 25 MICRON NOMINAL
Lamb Ametek 117572-12 Vacuum Blower
~ Lamb Ametek 116757-13 2-stage 5.7" Vacuum Motor M-W
AMETEK 4M949 VACUUM MOTOR NEW 120V 4M949
Ametek Lamb Vacuum Cleaner Motor, 116392-00
AMETEK 115923 4M903 THRU-FLOW VACUUM BLOWER/MOTOR 2-STAGE 5.7" 120V
Ametek Lamb 115v 50/60hz Vacuum Motor 115962
Ametek Lamb 120v 50/60hz Vacuum Motor 116297-00
AMETEK LAMB VACUUM MOTOR 116757-13 NEW 120 VOLTS
Lamb-Ametek #119433-13 24V 5.7 3 Stage Vacuum Motor
Ametek Prestolite Contactor; 24V; #JFA-4002A; #4050-421
AMETEK CONTROLS 93PSG0002DD7AC / 93P DIGITAL PRESSURE
Drexelbrook Ametek Enclosure with 700-0001-016 Series Sensing Element *NEW*
AMETEK 89PGTB300G2CB PRESSURE TRANSDUCER 300 PSI NEW
AMETEK PHOTO DIODE ASSEMBLY PART NUMBER 471130901
Ametek RELAY 1500GL1S8OCX NIB
Ametek Drexelbrook Dumpstar Level Control Model 406-6000 700-0202-036
Ametek Lamb Electric Vacum motor
AMETEK LN-150 INSPECTION FORCE GAGE
Pittman/Ametek Motor, 38.3:1 Ratio GM9413D109
AMETEK PANALARM SC100-120A NEW 8 PIN / 11 PIN RELAY SC100120A
AMETEK Rotron Motor M22F055-3008-0?28-3HIS-3471SF?-CCW 27.6 VDC
VT50XX #31783
NICE LOT OF 15 ACCURAY Control Interface Boards (2175)
ACCURAY 2-067441-002 SCANNER PRINTED CIRCUIT BOARD MODULE CARD PCB 55216
ACCURAY 064851-001
ACCURAY SCANNER CIRCUIT BOARD BD40DM 60155750-001 PCB MODULE CARD HEDP-G 58689
ACCURAY 8-061594-003 PC BOARD AD-7-061595-00?3
ACCURAY 8-061588-002 I/O BOARD 8061588002
ACCURAY 9-085158-001 SCANNER CONTROL PCB PRINTED CIRCUIT BOARD CARD MODULE 58639
ABB ACCURAY 084903-001 TEST PANEL 084903001
ACCURAY 2-067441-002 PCB BOARD EXCELLENT CONDITION
ACCURAY 64844-002 USPP 64844002
ACCURAY 67461-002 USPP 67461002
ACCURAY 67461-003 USPP 67461003
ACCURAY 69242-002 USPP 69242002
ACCURAY 60155750-001 SCANNER CIRCUIT BOARD PCB MODULE CARD HEDP-G BD40DM 55217
ACCURAY 1180M AD-6-054449-05?7 CONTROL PANEL DISPLAY MODULE ASSEMBLY 58700
ACCURAY 083892002 NSFP 083892002
ACCURAY 085217-001 INTERFACE CIRCUIT BOARD MODULE CARD 56756
ACCURAY 083964-001 NSPP 083964001
ACCURAY 064860-003 PC CIRCUIT BOARD MODULE CAD FDI PLC CARD 54543
ACCURAY 085156-001 REV. DC PC BOARD 085156001
ACCURAY 100680-002 USPP 100680002
ACCURAY INPUT OUTPUT 8-085217-001 I/O CIRCUIT BOARD W/R600M ELECTROMETER 58648
ACCURAY 085354-001 NSPP 085354001
VT50XX #31783