Using External Routines

External routines are programs or functions developed outside of the
Logix Designer
application programming environment using commonly available programming languages, such as C or C++. If an external routine is properly developed as a Windows DLL, the
SoftLogix
controller can execute the routine as part of a
Logix Designer
application project.
To configure your system to execute an external routine:
  • add the external routine to the Controller Organizer
  • use a JXR instruction within a ladder diagram routine to call the external routine
You can add an external routine to the Controller Organizer the same way you create a new ladder routine.
To add an external routine to the Controller Organizer:
  1. Right click the Main Program folder, and choose New Routine.
    The New Routine dialog appears.
  2. Name the routine, and choose External Routine from the Type pull-down menu.
  3. Click OK.
  4. From the Controller Organizer, right click the routine you just created and choose Open.
    The Routine Properties dialog appears, from which you can specify the DLL you want to execute.
  5. When specifying the DLL to execute:
    On this tab:
    Do this:
    General
    Verify the general information for the external routine is correct, as it should appear in the Controller Organizer.
    Configuration
    1. Browse to select the DLL file that contains the function you want to execute.
    2. Select which function to execute within the DLL.
How the project stores and downloads an external routine
To use an external routine, you add (also known as "map") a DLL file to the Controller Organizer of a
Logix Designer
application project (as shown on the previous two pages). You select the original DLL file that contains the function you want to execute. The
Logix Designer
application makes a copy of that DLL and stores it in an external routines directory that is created where the associated ACD file is stored. For example, if the project MyProject.ACD is in C:\
Logix Designer
\Projects, mapping a DLL to that project stores a copy of the DLL file in the directory C:\
Logix Designer
\Projects\ExternalRoutines\MyProject\.
When the you download the project to the controller, the mapped DLL is also downloaded to the target controller and a copy of the DLL is placed in the slot directory of the controller. For example, if you download MyProject.ACD to a controller in slot 4, the external routine DLL file is downloaded to C:\Program Files\
Rockwell Automation
\
SoftLogix
5800\Data\slot04.
Because this process creates copies of the original DLL file, you can execute different versions of the same DLL on
SoftLogix
controllers in different slots of the same virtual chassis. The DLL for one slot is completely independent of the DLL in another slot. For this reason, if you update a DLL, you must remap the DLL to its correct controller. This ensures that the DLL file gets copied and downloaded to the appropriate locations.
Linking an individual DLL file to a specific controller and slot can be useful for debugging changes or testing new versions of an external routine. You can load different versions into controllers in different slots without having to actually update controllers that are performing plant control.
NOTE:
Take care when copying a project that includes an external routine. In addition to the ACD file, you must also copy the external routines folder associated with that ACD file.
To call an external routine from a ladder routine in your project:
  • Use the Jump to External Routine (JXR) instruction
Type checking
The following table describes the type checking that occurs between the
Logix Designer
application and the external routine for the parameters that they pass.
Logix Designer
Data Type
C++ Type
Passing Method
Type Checking
Arrays
BOOL
bool
by reference
strong type checking
by reference
INT
short
by value
DINT
long
int
SINT
char
REAL
float
user-defined structure
structure
by reference
weak type checking
The check only determines whether a structure is being passed to a structure parameter. Data types and sizes are not checked.
by reference
Array sizes are not checked, but the size information if passed through the control structure
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.