• Shawn Tierney commented on lesson Lesson 44: VFDs for Motor Control (Digital Only) 4 years, 3 months ago

    Good morning Nghia,

    Yes, that is a very valid way to write your code, however how you structure your routine will have a big effect on how easy others are able to follow your code.

    For instance, this is one way to keep everything organized and easy to follow when you have subroutines jumping to other subroutines:

    R01 Main Routine (JSR to R10)

    R10 Feeder System Main Routine (JSR to R11, 12, and 13)
    R11 Feeder System Alarms
    R12 Feeder System Control
    R13 Feeder System xyz

    A note on AOIs:

    One advantage of using an AOI is that each instance has it's own tags, whereas re-using the same subroutine by different processes requires also writing code to clean up any internal variables (so they don't have left over values in their internal variables from the previous call)

    That said, one of the advantages of subroutines is you can edit them online, which you can't do with AOIs.

    Hope this helps!

    Shawn Tierney,
    Instructor at The Automation School