Required to write a formula for a command

Forum Home Forums Understanding the Software Using Formulas Required to write a formula for a command

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #10041
    dp_palai
    Participant

    Hello, I have two Modbus Coils.One is a command mapped to a output channel. Other is an input signal mapped to an input channel. I need the command value to be altered with the condition of the input signal.
    Condition is, if command value is 1 and input signal becomes 1, command value should become 0. After that if we send command value 1 again, the command value should be 1 that is it works as usual.
    Thanks in advance.

    • This topic was modified 2 years, 1 month ago by Mikhail.
    #10042
    Mikhail
    Moderator

    Hello,

    1. Add a new formula into the Formulas table like:

    public double ConvertCmd()
    {
      if (Cmd > 0)
        return Val(101) > 0 ? 1 : 0;
      else
        return Val(101) > 0 ? 0 : 1;
    }
    

    where 101 is the input channel number.
    Update conditions according to the required logic.

    2. Use this function in the formula of the output channel.
    ConvertCmd()

    • This reply was modified 2 years, 1 month ago by Mikhail.
    #10045
    dp_palai
    Participant

    Thanks for your response.
    I am sorry after I upload the configuration when I open the web user interface by entering the user name & password it says ‘Server is Unavailable’. It seems like the formula has an issue. Please help.

    #10048
    dp_palai
    Participant

    I get the following error,
    error CS1520: Method must have a return type

    #10049
    dp_palai
    Participant

    Hello,
    I solved the problem by changing the first line of code as follows,
    public double ConvertCmd()
    {
    if (Cmd > 0)
    return Val(101) > 0 ? 1 : 0;
    else
    return Val(101) > 0 ? 0 : 1;
    }

    But my requirement is something as below which is not happening,
    I enter the command through a Toggle on the scheme View. The output channel for that is 127. So when to switch on the corresponding device I keep the channel value 1. By that Modbus coil which is mapped to it remains 1. Now when I make an input channel 1 in my case 171 through a Modbus coil, the output channel 127/mapped Modbus coil should become 0 automatically. I am sorry that is not happening through the formula. Please help me. Thanks in advance.

    #10051
    Mikhail
    Moderator

    Hello,
    Thank you for the fix. I updated the above formula.

    > the output channel 127/mapped Modbus coil should become 0 automatically
    An output channel does not store any value. It only describes how commands are sent.
    If you need to send command depending on input channel value, Automatic Control Module can help, https://rapidscada.org/download-all-files/download-automatic-control-module/

    I’m not sure that I understand the question clearly. Screenshots would clarify.

    #10052
    dp_palai
    Participant

    Hello Mikhail! Hope you are doing well. Thanks a lot for the prompt response. Can I make a new output channel where a command can be sent using a formula without any manual entry for the command? The formula will enable the condition where it sends command value 0, when an input channel value becomes 1. Now I will have an output channel let’s say 128 mapped to the Modbus output coil. I have an input channel, 171 mapped to the Modbus input bit. Now when the input bit is ON, the output channel sends by itself a value 0 to the mapped output Modbus coil.

    I am sorry if my words are difficult to understand.
    Thanks for the link of the module. I will be sure considering it when we will have requirements of larger control logic.
    Thanks.

    #10053
    Mikhail
    Moderator

    Hello,

    > Can I make a new output channel where a command can be sent using a formula without any manual entry for the command?
    To send command automatically without any manual entry, you need Automatic Control Module.

    #10056
    dp_palai
    Participant

    Thanks for the response.

    #12025
    victorlam
    Participant

    Hello,

    May I know the reason for stating the formula as double not to use int as a simple one?

    #12029
    Mikhail
    Moderator

    Hello,
    Because the Double data type allow sto use fractional part of a number.

    #12810
    myscada
    Participant

    My case is a little different. In the device properties, only one Modbus coil is mapped to both an input channel and an output channel. I need to send commands based on the value of the input channel (if the input value is 0, the send value is 1, if the input value is 1, the send value is 0).

    So I use a toggle scheme to display the input values and send command. There is no formula for the output channel, it works.

    #12815
    Mikhail
    Moderator

    A toggle on a scheme generates commands depending on its value.

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