• Not Answered

Delta V Support for Structure Text Language

Hi 

Do we have Delta V DCS support for Structured Text Language.

If yes 

Do we have any example how it is done...

7 Replies

  • Yes, SFCs contain actions written with structured text.
  • In reply to rhamlin:

    CALC block is kind of structured text as well.
  • In reply to Lun.Raznik:

    So can i create my own function blocks in structured text , do we have any limitation ?
    Do you have any example what structure it follow...
    Is it aligned with IEC61131 guidelines?
  • In reply to Shaswat Raj:

    The purpose of Structured text is to provide flexibility to create algorithms that are not natively provided in the Function blocks of the system. The design language of DeltaV follows IEC61131. Structured Text programming is provided within the context of the CALC, ACT and CND blocks as well as the Actions and Transition statements in the SFC/Phase logic structures.

    The key to using structured Text is to know what it is beneficial or useful, versus creating your own function blocks to do things that are already accomplished in the native blocks of the system.

    DeltaV provides the ability to create a "custom" block within a module, which can be created as an Embedded block, or as a Composite block that is linked in a module (and you can convert a linked Composite to an Embedded Block if you need uniquely modify an instance). Within these custom blocks you create an algorithm with standard Function blocks which can include the CALC, ACT and CND blocks where Structured text can be brought to bear.

    Structured text is not a compiled program. The text follows IEC61131 and functions, Operands and Operators are documented in BOL, with examples for each. It is intended to be part of control strategy, inserted into the data flow as a function block to execute some logic in coordination with the overall strategy of the module. It is not intended to be used to write massive sequences or complex functions.

    You should read the sections of BOL for the CALC, ACT and CND blocks as well as the SFC section. BOL provides an explanation of all the functions and their syntax. There you will find information on If-Then-Else, While-Do loops, Goto and Label structures as well as the use of declared and undeclared variables.

    Key things to know is the syntax for the expression. The expression editor has a palette for most operands and functions, but not all, so refer to BOL. There are buttons to insert internal and external references. Using these will show you the correct syntax.

    One thing that gets you is the end of line ";" marker. If you forget this, the expression parser will indicate it is expecting something on line X, but this is due to lack of end marker in previous line.

    The Calc block has Floating point input and output connectors while the CND and ACT block have fixed discrete output and input respectively. In many cases, you should be thinking of using multiple blocks each with their own limited function and avoid trying to write everything in one module. In this way, you can see the result state of each block which makes it easer to determine where the logic may not be providing the desired result.

    I used a CALC block to create an iterative convergence calculation for an Ethelene compensation algorithm written in C. The program had 11 characterizing curves which I implemented in 11 Signal Characterizing blocks rather than attempt to write that in structured text. The convergence calculation provided the Z factor based on the pressure, temperature and flow variables. All of this was encapsulated in a Composite block (my custom block) with input connections for the variables and output connections for the results. Only part of the logic was in structured text, leveraging the native blocks to do what they do best.

    I've seen many clever engineers create there own version of a standard block because they felt they needed a feature the native blocks did not provide. One insisted to build his own PID block because he wanted to use the Parallel algorithm. He then had to create his own logic for output tracking, Integral Tracking, Cascade, Auto and manual modes and deal with reset windup because he did not implement Back Calculation and initialization features all standard in the PID block. Huge waste of energy, and controller CPU as these structured text algorithms are massively more CPU intensive than the compiled block.

    Structured text is a powerful tool to solve those logic and calculation problems not addressed with native blocks. It should be your last option and really only used when the problem cannot be effectively solved with native blocks (here I mean that if the native block solution is too convoluted or involves too many blocks, and an Expression will solve it more eloquently, use the expression. Just be wise about it).

    Note that the DCC and AT blocks also use structured Text for their the individual Interlock, Permissive and Force Setpoint functions.

    Andre Dicaire

  • In reply to Andre Dicaire:

    Someone suggested I add a couple of things. Usually I'm told my posts are too long.

    As with any program, error checking is important. DeltaV values are accompanied with a Status field and standard function blocks use that to guide their execution. Is the value BAD, Uncertain or Good? Is it Limited? Are there abnormal conditions to consider with writing the expression. If you do a calculation using a signal that has BAD status, should you pass that BAD status to the result? Some users have used CALC blocks to strip out the STATUs because they did not understand its purpose. Writing good solid code starts by understanding the environment and having the right level of Error checking and Status handling.

    Andre Dicaire

  • In reply to Andre Dicaire:

    There is a sub-status that Andre left out. (No one is more surprised than I that he left something out, but here we are).
    There is a sub-status called CONSTANT. The PID function block looks at the status of the IN parameter. If the sub-status of the IN parameter is CONST, then the reset function of the PID block is inhibited and the loop will probably come to a steady state offset.
  • In reply to DBacker:

    Thanks Denis. BOL explains the status word in more detail. Constant is actually part of the Limit status. the Status byte is 8 bits, with the two least significant bits giving you four states; 00=Not Limited, 01= LowLimted, 10=Hilimited and 11 = Constant.

    The two most significant bits give you the signal quality 00 = BAD, 01= Uncertain, 10= GoodNonCascade and 11= Good Cascade.

    so we have xxyyyyzz, were xx is quality, zz is limit, and yyyy is sub-status. For each Quality status, there is a range of sub status that further explain the status of the signal, like why is it BAD, it may be in GOODCascade and waiting to initialize or indicate Cascade is not invited.

    To help use this .ST field, there are constants defined that you can use. So say the signal status is BAD/No Usable value/Limited. Because there are four states for Limited, there could be four different integer values for BAD/No Usable Value. There are up to 64 possible BAD status values depending on the combination of Substatus and Limit status. Instead of using bitwise operators and fancy logic to isolate the status, simply use the constant Value.ST = BAD or UNCERTAIN or GOOD. This does the work for you. Similarly for Limit, you can use Value.ST = LIMITED_CONSTANT, LOWLIMITED or HI_LIMITED. there are also TRUE, FALSE Boolean comparisons and CAS, MAN, AUTO, RCAS, ROUT, IMAN, LO for mode comparisons. Note that for Mode, AUTO can be 16 and 24 depending on if the source is from an native block or an FF block. Using the constants allows you to write an expression that will work with both.

    There also reserved Keywords you should be aware of. Look up Constants in BOL for more. You will also find more information on each sub-status.

    Andre Dicaire