Forum Home › Forums › Understanding the Software › Using Formulas › Required to write a formula for a command
Tagged: formula, Interlocks
- This topic has 12 replies, 4 voices, and was last updated 1 year, 4 months ago by Mikhail.
-
AuthorPosts
-
February 4, 2022 at 2:11 am #10041dp_palaiParticipant
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, 8 months ago by Mikhail.
February 4, 2022 at 5:28 pm #10042MikhailModeratorHello,
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, 8 months ago by Mikhail.
February 6, 2022 at 9:12 am #10045dp_palaiParticipantThanks 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.February 6, 2022 at 1:44 pm #10048dp_palaiParticipantI get the following error,
error CS1520: Method must have a return typeFebruary 6, 2022 at 5:19 pm #10049dp_palaiParticipantHello,
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.February 7, 2022 at 12:08 pm #10051MikhailModeratorHello,
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.
February 7, 2022 at 1:17 pm #10052dp_palaiParticipantHello 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.February 8, 2022 at 12:27 pm #10053MikhailModeratorHello,
> 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.February 9, 2022 at 7:22 am #10056dp_palaiParticipantThanks for the response.
January 27, 2023 at 6:20 am #12025victorlamParticipantHello,
May I know the reason for stating the formula as double not to use int as a simple one?
January 27, 2023 at 8:33 am #12029MikhailModeratorHello,
Because the Double data type allow sto use fractional part of a number.June 15, 2023 at 12:28 pm #12810myscadaParticipantMy 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.
June 16, 2023 at 10:36 am #12815MikhailModeratorA toggle on a scheme generates commands depending on its value.
-
AuthorPosts
- You must be logged in to reply to this topic.