Showing results 1 to 4 of 4

Thread: sub program multi output value

  1. #1
    Join Date
    28.11.2017
    Posts
    10

    Default sub program multi output value

    hi ,
    i would like to write a sub-program with multible outputs values, 

    when i compile my straton program hi have an error, Variable, constant expression or function call expected

  2. #2
    Join Date
    08.12.2015
    Posts
    35

    Default Re: sub program multi output value

    Hi,

    If you have this error, I think this is because you are trying to do it in an ST program.
    If you want to recover multiple outputs on a Sub-Program, you have to use the same syntax as if it was an UDFB, even if a sub-program has no instance name.
    The best is with an example.

    Let's say you have a sub-program with this structure:
      MySP:
        IN_1 : IN
        IN_2 : IN
        OUT_1 : OUT
        OUT_2 : OUT

    Then in your ST program you must do something like that
      MySP ( Input_1, Input_2 );
      Output_1 := MySP.OUT_1;
      Output_2 := MySP.OUT_2;

    This should work

  3. #3
    Join Date
    28.11.2017
    Posts
    10

    Default Re: sub program multi output value

    yes it is an ST sub program, you mean i need to define it as UDFB?

  4. #4
    Join Date
    08.12.2015
    Posts
    35

    Default Re: sub program multi output value

    Quote Originally Posted by mos89 View Post
    yes it is an ST sub program, you mean i need to define it as UDFB?

    Ah no, you just have to use the same syntax.
    I mean, normally, with a Sub-Program with only one output you can do something like:
        Output_1 := MySP ( Input_1, Input_2 );

    But with several outputs you can't.
    So you have to do "like if it was an UDFB".
    For example, with a counter:
        Inst_CTU(...);
        CtuIsFull := Inst_CTU.Q;
        CtuValue := Inst_CTU.CV;

    So for a sub-program, with, for example, two outputs called 'OUT_1' and 'OUT_2' (inside of the Sub-Program), you have to do something like:
        MySP ( Input_1, Input_2 );
        Output_1 := MySP.OUT_1;
        Output_2 := MySP.OUT_2;

    But you can keep it as a sub-program
    (just take care about not calling many times the sub-program at different places, because when recovering the outputs values, as it is not instanciated, there can be some bad values)

Similar Threads

  1. Analogue Output Command Processing
    By LeeCapula in forum zenon Energy Edition
    Replies: 2
    Last Post: 28th March 2018, 15:33
  2. Replies: 1
    Last Post: 29th September 2017, 10:52
  3. Cross Reference to Errors/Warnings in output window
    By vishaldesai137 in forum zenon Supervisor
    Replies: 1
    Last Post: 31st August 2015, 08:21
  4. Replies: 0
    Last Post: 11th March 2010, 16:04
  5. How can I produce event for Binary Output in all executions?
    By shahramkh59 in forum zenon Supervisor
    Replies: 2
    Last Post: 26th November 2009, 10:20

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •