0

I have a input variable c_timTransmissionRate which is usually initalized using the persistent variable list. The default value for the persistent variable list in the function block TxRaw is then overriden by the instanciating function block ´TxDbc´. This again is application specific overriden in the persistent variable list itself.

In a few cases the value for c_timTransmissionRate is provided dynamically by the instanciating function block TxTsc1 during runtime.

My problem is that I currently always see the original TIME#0ms value in the debugger instead of the values given in the persistent variable list.

Extract of my current code:

FUNCTION_BLOCK TxRaw
 VAR_INPUT PERSISTENT CONSTANT
  c_timTransmissionRate : TIME := T#0ms;
 END_VAR
  (* instructions *)
END_FUNCTION_BLOCK

FUNCTION_BLOCK Tx
VAR
 tx : TxRaw;
END_VAR
  (* instructions *)
 tx();
  (* instructions *)
END_FUNCTION_BLOCK

FUNCTION_BLOCK TxTsc1 EXTENDS Tx
  (* instructions *)
  tx.c_timTransmissionRate := PI()*THUMB();
  SUPER^();
END_FUNCTION_BLOCK

FUNCTION BLOCK TxDbc EXTENDS Tx
VAR
 tx : TX := (c_timTransmissionRate := T#20ms);
END_VAR
  (* instructions *)
  SUPER^();
END_FUNCTION_BLOCK
Torsten Knodt
  • 477
  • 1
  • 5
  • 20
  • 2
    It does not make sense to use CONSTANT together with VAR_INPUT. – Felix Keil Apr 08 '16 at 05:36
  • Thanks for the feedback Felix. I assumed that ˋCONSTANTˋ declares the variable as immutable in the POU like for functions in C. Am I wrong there? – Torsten Knodt Apr 08 '16 at 06:09
  • 1
    You can use CONSTANT with VAR only. Somehow if it is combined with VAR_INPUT it gets ignored / no error and you can still change your VAR_INPUT CONSTANT variables. If you try to change a VAR CONSTANT variable you get a compiler error. But you can still change VAR CONSTANT variables manually in online view. – Felix Keil Apr 14 '16 at 12:50

0 Answers0