Change output state by formula

Forum Home Forums Understanding the Software Using Formulas Change output state by formula

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15991
    BamKR
    Participant

    Hello,

    I have buttons in my scheme, where each button is a production product. When I push button data should be transferred to individual channels, I managed to do it using formula like that:

    
    public int test1()
    {
     SetVal(29, 1);
     SetVal(30, 1500);
     SetVal(49, 1);
     SetVal(50, 1);
     SetVal(52, 1);
     return 0;
    }
    

    channels are associated with formats, for example in channel 29, value 1 mean “Product_1”, value 2 “Product_2” etc. Buttons in output formula have channel number with tittle formula on output. Like on screenshot.

    https://imgur.com/a/WkWKTE4

    I have problem with change state of output in the same formula, I want send impuls to my modbus device. I tried use in the same way formula SetVal(52, 1) where 52 it’s a number of channel of output and 1 it’ a value of state for format on; off .I tries to change the output status in all possible ways but it still not work. I have also simple button, which have only reset function which I sending to my device, and there everything works. Have you any idea hot to solve this problem, please?

    • This topic was modified 1 month ago by BamKR.
    • This topic was modified 1 month ago by BamKR.
    • This topic was modified 1 month ago by BamKR.
    • This topic was modified 1 month ago by BamKR.
    • This topic was modified 1 month ago by Mikhail.
    #16001
    Mikhail
    Moderator

    I have problem with change state of output in the same formula, I want send impuls to my modbus device.

    Hello,
    The output value depends on the formula. In your formula 0 is returned. Also you should specify a device and Tag code for the channel.

    #16095
    BamKR
    Participant

    Thanks for answer.

    You mean to specify tag code and device in channels configuration or in formula? In channel configuration I definied all this parameters. Like on image:

    https://imgur.com/a/u8CGmrt

    and formula after correction

    public int test1()
    {
     SetVal(29, 1);
     SetVal(30, 1500);
     SetVal(49, 1);
     SetVal(50, 1);
     return 0;
     SetVal(52, 1);
     return 1;
    }

    ?

    • This reply was modified 3 weeks, 5 days ago by BamKR.
    • This reply was modified 3 weeks, 5 days ago by BamKR.
    #16098
    Mikhail
    Moderator

    V0.2 is the tag code of the channel. When a user sends a command to this channel 52, the command value should be transferred to Communicator. You can see it in ScadaComm.log.

    #16099
    Mikhail
    Moderator

    Val(52) is a wrong formula because it refers the channel itself.

    #16107
    BamKR
    Participant

    Hi,

    Finally works how it should, I think i tried solve this problem from wrong side.

    https://imgur.com/a/VPoaMpk

    First I changed formula

    public int test1()
    {
        int result = 0; 
        SetVal(29, 1);
        SetVal(30, 1500);
        SetVal(49, 1);
        SetVal(50, 1);
        SetVal(52, 1);
        result = 1; 
        return result;
    }

    After I changed configuration at channel [31] where works formula on output, everythings works ok. I defined code tag and device on channel 31, before I done always all configurations on channel 52 where value is being set by formula. It is litlle bit strange for me why it works when I defines parameters on channel 31 (code, device) but no works when I do it for channel 52 while the formula refers to this channel. I thought all configurations should be done for channel which is referred in formula but configuration should be done on channel which execute formula, I’m right?

    Thanks for help.

    #16108
    Mikhail
    Moderator

    Hi,

    I thought all configurations should be done for channel which is referred in formula but configuration should be done on channel which execute formula, I’m right?

    Both is possible. A channel should not call SetVal for itself. When you need to change a channel itself, return a new value from the formula.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.