Hello, I want to use R_TRIG in a Function Block written in ST. When I write a line like R_TRIG(SignalToWatch,Output); I get the error “Funktionsbausteininstanz ‘R_TRIG’ ist nicht vorhanden”. When i create a local variable “R_TRIG1” of type “R_TRIG” the error I get is “Ungültiger Parameterausdruck.” .
Hovering over the code displays a tooltip “Die Deklaration der Parameter des Funktionsbausteins ‘R_TRIG’ wurde verändert”.
How do i create an instance of R_TRIG in ST?
Greetings, JimmyPesto
Hi Jimmy, I don’t have a PLC with me at the moment, but does this not work?
Thanks, this worked fine.
R_TRIG1 Variable is automatically created when dropping it in the ST Code from the components list (in Engineer 2019.3).
There should be an option to create this by hitting right klick on the ST Code → DE:“Neue Varbiable anlegen” (I guess smth. like “Create new Variable” in english version).
But this is greyed out. Thanks
Hi Jimmy, You’re right, a right-click option to create a function instance would be handy. But I guess the editor just sees the new instance name as a text string, and it would be tough for it to guess what function you’re intending to call. In the case of variables it only has a (relatively) few options to choose from, and it can take a reasonable guess. If you’re copying and pasting function calls, another way to create new instances is to declare them manually in the Variables table, similar to the entries that are created automatically. - Martin.
Hmm … I don’t get the errors you mentioned when manually entering a function declaration in the Variable Table … see the video below. Is this not working for you? ================= EDIT: Note the format of the function call, including the argument list, which is defined by the IEC 61131 specification. If your function call does not follow the standard format, I guess this could cause the errors you are seeing … ?
The easiest way I have found, is to define the R_Trig or any other FB in the local variable sheet first and the call the function in the ST code. for convince, I also have a variable group one for my function blocks and so one. This makes it easier to keep a better overview and find variables. But this is just a personal preference.