Sign in to follow this  
Followers 0
Hoobs

Sample code for a user-defined function or FB?

5 posts in this topic

Sorry for such a noob question, but I'm still figuring out the OMRON-specific  implementation details for ST...    I can't find anywhere what the language syntax is to define a function or function block of my own in ST.  I can see how to do it in ladder, but I'd rather do it in ST because I will be calling it from ST as opposed to ladder.

The "standard" way is with a FUNCTION_BLOCK keyword, etc., but the OMRON NJ series doesn't seem to know anything about this syntax, either in-line or in a function or function block that's been added to the project.

How do I define my own function or function block in ST?

Thanks!
--Hoobs

Share this post


Link to post
Share on other sites

A Function Block is just another type of variable, so you need to define it in either Internal or Global Variables. E.g. make a MyPID Variable with type of PIDAT Function Block.

Then in ST you just simply call the instance name MyPID. I will contain all the In/Out of the PIDAT Function Block

1 person likes this

Share this post


Link to post
Share on other sites

You create your function blocks in their own programs in the Functions and Function Blocks folder in the Multiview Explorer.  You don't declare them inside a program, they are their own programs.

1 person likes this

Share this post


Link to post
Share on other sites

Not sure if this is what you are asking, but each function block help file shows the structured text implementation of that Function block.  See below:

5a1d9e76cbf2c_FBSTHelp.thumb.jpg.2dc0a8c

as @innoaloe mentioned, you have to create the instance first.  Once the local instance is created, you can then start to type the instance name into your Structured Text and the type ahead help will recognize it as well.  See below:

5a1d9f7995506_FBSTHelp2.thumb.jpg.58012f

Functions however are a bit different. You can just type in the name of the function and it will be recognized:

5a1da0462f1de_FunctionSTHelp.jpg.a70e467

1 person likes this

Share this post


Link to post
Share on other sites

Thanks guys!  Makes sense now...  I was so buried down in ST-land I forgot to look up at the IDE and see that I had to define them first in the multi-view.  DOH!

Hoobs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0