Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Structured text

From Wikipedia, the free encyclopedia
Programming language for programmable logic controllers
For the lightweight text markup languages, seeStructuredText andreStructuredText.

Structured text, abbreviated asST orSTX, is one of the five languages supported by theIEC 61131-3 standard, designed forprogrammable logic controllers (PLCs).[1][2] It is a high level language that isblock structured and syntactically resemblesPascal, on which it is based.[3] All of the languages shareIEC61131 Common Elements. The variables and function calls are defined by the common elements so different languages within the IEC 61131-3 standard can be used in the same program.

Complex statements and nested instructions are supported:

  • Iteration loops (REPEAT-UNTIL; WHILE-DO)
  • Conditional execution (IF-THEN-ELSE; CASE)[3]
  • Functions (SQRT(), SIN())

Sample program

[edit]
(* simple state machine *)TxtState:=STATES[StateMachine];CASEStateMachineOF1:ClosingValve();StateMachine:=2;2:OpeningValve();ELSEBadCase();END_CASE;

Unlike in some other programming languages, there is nofall through for the CASE statement: the first matching condition is entered, and after running its statements, the CASE block is left without checking other conditions.

Additional ST programming examples

[edit]
// PLC configurationCONFIGURATIONDefaultCfgVAR_GLOBALb_Start_Stop:BOOL;// Global variable to represent a boolean.b_ON_OFF:BOOL;// Global variable to represent a boolean.Start_StopAT%IX0.0:BOOL;// Digital input of the PLC (Address 0.0)ON_OFFAT%QX0.0:BOOL;// Digital output of the PLC (Address 0.0). (Coil)END_VAR// Schedule the main program to be executed every 20 msTASKTick(INTERVAL:=t#20ms);PROGRAMMainWITHTick:Monitor_Start_Stop;END_CONFIGURATIONPROGRAMMonitor_Start_Stop// Actual ProgramVAR_EXTERNALStart_Stop:BOOL;ON_OFF:BOOL;END_VARVAR// Temporary variables for logic handlingONS_Trig:BOOL;Rising_ONS:BOOL;END_VAR// Start of Logic// Catch the Rising Edge One Shot of the Start_Stop inputONS_Trig:=Start_StopANDNOTRising_ONS;// Main Logic for Run_Contact -- Toggle ON / Toggle OFF ---ON_OFF:=(ONS_TrigANDNOTON_OFF)OR(ON_OFFANDNOTONS_Trig);// Rising One Shot logicRising_ONS:=Start_Stop;END_PROGRAM

Function block example

[edit]
//=======================================================================// Function Block Timed Counter :  Incremental count of the timed interval//=======================================================================FUNCTION_BLOCKFB_Timed_CounterVAR_INPUTExecute:BOOL:=FALSE;// Trigger signal to begin Timed CountingTime_Increment:REAL:=1.25;// Enter Cycle Time (Seconds) between countsCount_Cycles:INT:=20;// Number of Desired Count CyclesEND_VARVAR_OUTPUTTimer_Done_Bit:BOOL:=FALSE;// One Shot Bit indicating Timer Cycle DoneCount_Complete:BOOL:=FALSE;// Output Bit indicating the Count is completeCurrent_Count:INT:=0;// Accumulating Value of CounterEND_VARVARCycleTimer:TON;// Timer FB from Command LibraryCycleCounter:CTU;// Counter FB from Command LibraryTimerPreset:TIME;// Converted Time_Increment in Seconds to MSEND_VAR// Start of Function Block programmingTimerPreset:=REAL_TO_TIME(in:=Time_Increment)*1000;CycleTimer(in:=ExecuteANDNOTCycleTimer.Q,pt:=TimerPreset);Timer_Done_Bit:=CycleTimer.Q;CycleCounter(cu:=CycleTimer.Q,r:=NOTExecute,pv:=Count_Cycles);Current_Count:=CycleCounter.cv;Count_Complete:=CycleCounter.q;END_FUNCTION_BLOCK

References

[edit]
  1. ^Bacidore, Mike (16 May 2018)."Should I limit programming to ladder logic or use all standards within IEC 61131?".Control Design.
  2. ^Stevic, Tom (5 May 2017)."A very short history of PLC programming platforms".Control Design.
  3. ^abRoos, Nieke. "Programming PLCs using Structured Text". Department of Computing Science, University of Nijmegen.CiteSeerX 10.1.1.49.2016.{{cite journal}}:Cite journal requires|journal= (help)
Retrieved from "https://en.wikipedia.org/w/index.php?title=Structured_text&oldid=1311678594"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp