×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Bar coding and automation FAQ

PLC Tips

A-B User Funtion Routines by techshoot
Posted: 2 Oct 01

Many people don't realize that it is possible to write a function in the PLC5 and SLC500 processors that you can pass values to and receive an answer back.  This is very useful when you have a great deal of code to place in multiple places.  Example of adding 100 to a number below:

1) Create a new file for you function routine
2) The first instruction will be an SBR N7:  An integer address for holding the number you want to add (N7:10 example) but make it unique or create a new data file with local scope.  Then place an output instruction, OTE B/100 for example.
3) Next rung start do an ADD 100 N7:10 N7:11 to add 100 to your number.
4) The final rung is RET N 7:11 N7:11 is the result of the ADD instruction and this will be sent back to the calling JSR below.

5) In your LAD 2 File, add a JSR with your function program file number and add an input parameter of N7:0 at the end of the logic and keep hitting the enter in the graphic until you see Return Parameter and enter N7:1.
6) Put a value in N7:0 and run the program, N7:1 will always show as 100 more than N7:0.

Back to Bar coding and automation FAQ Index
Back to Bar coding and automation Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close