Thread Content
Let’s see which programming expert can help translate the following program – it’s so difficult. This module has four pins: INPUT: IN, PT; OUTPUT: Q, ET. FUNCTION_BLOCK TM (*External Interface*) VAR_INPUT IN : BOOL ; (*Input*) PT : TIME ; (*Pulse Time*) END_VAR VAR_OUTPUT Q : BOOL ; (*Output Pulse*) ET : TIME ; (*Elapsed Time*) END_VAR VAR M : BOOL ; (*State*) T0 : DT ; (*Start Time*) END_VAR IF NOT Q THEN IF IN AND NOT M THEN Q := TRUE ; T0 := GetTimer() ; END_IF ; IF NOT IN THEN ET := T#0ms ; END_IF ; ELSE ET := GetTimer() - T0 ; IF ET >= PT THEN ET := PT ; Q := FALSE ; END_IF ; IF ET < PT THEN Q := M; END_IF; END_IF ; M := IN ; END_FUNCTION_BLOCK
This should be a program written in TRICON’s ST structured text. It’s actually just a pulse trigger; IN is the input for detecting pulses, while PT is used to set the pulse duration. Q is the pulse output, while ET indicates how long the pulse has been triggered.
There’s no point in using ST to write programs; it’s much better to use FBD and LAD for that.
Yes, it doesn’t make much sense to use ST for it, but it is still widely used in current systems
Thank you. It’s really difficult; I truly can’t understand it. I’m used to programming with function blocks before, so thanks
ST is flexible and allows for whatever kind of control is desired; it can be used for functions that are difficult to achieve with conventional logic, serving as an advanced approach to control.