Forum Home › Forums › Understanding the Software › Using Formulas › Change output state by formula
- This topic has 6 replies, 2 voices, and was last updated 2 weeks, 6 days ago by
Mikhail.
-
AuthorPosts
-
January 14, 2025 at 12:49 pm #15991
BamKR
ParticipantHello,
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.
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?January 15, 2025 at 10:55 am #16001Mikhail
ModeratorI 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.January 23, 2025 at 9:26 am #16095BamKR
ParticipantThanks 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:
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; }
?
January 23, 2025 at 1:29 pm #16098Mikhail
ModeratorV0.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.January 23, 2025 at 1:30 pm #16099Mikhail
ModeratorVal(52)
is a wrong formula because it refers the channel itself.January 29, 2025 at 8:58 am #16107BamKR
ParticipantHi,
Finally works how it should, I think i tried solve this problem from wrong side.
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.
January 29, 2025 at 11:16 am #16108Mikhail
ModeratorHi,
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.
-
AuthorPosts
- You must be logged in to reply to this topic.