User Manual Owner's manual

Rockwell Automation Publication 1789-UM002J-EN-P - December 2012 115
Chapter 7
Develop External Routines
This chapter describes how to use Microsoft Visual Studio to create external
routines. Instructions include how to use ‘Test Mode’ in detail, so that you can
test your external routine prior to running the routine with the controller’s
outputs enabled.
A SoftLogix 5800 controller executes an external routine as specified by
a JXR instruction.
Considerations For External
Routines
The external routines feature is an extremely flexible and powerful capability of
the SoftLogix 5800 product. The routines can be written in C or C++ when
using any commercial off-the-shelf development tool, such as Microsoft Visual
Studio, that can generate a Windows compatible DLL (dynamic link library).
The SoftLogix controller at runtime performs a ‘LoadLibrary to invoke the
external routine DLL's code from within the memory and process space of the
SoftLogix 5800 controller.
Because the user's external routine DLL runs in the memory and process space of
the SoftLogix 5800 controller, it is possible that incorrectly written user code can
errantly overwrite memory locations that are being used by the controller. Care
must also be taken when creating threads and assigning priorities, because this can
also impact the operation of the SoftLogix 5800 controller.
Topic Page
Considerations For External Routines 115
How the SoftLogix Controller Executes External Routines 116
Create Synchronous, Single-threaded External Routines 117
Project Files 118
Create an HTML Resource 123
Add Version Information to an External Routine DLL 128
Build and Download External Routines 130
Update an Existing External Routine 130
Create Multi-threaded External Routines 130
Debug External Routines 136
Data Type Support 138
Export Functions by Using C++ Export Style 144
Other Considerations 146