PACSystems C Toolkit - Calling C Blocks ka21t0000008XtEAAU | Emerson Customer Center

PACSystems C Toolkit - Calling C Blocks


PACSystem C program blocks can not call other PACSystem C program blocks.


The PACSystem C Toolkit is provided on the supplementary disk of the Proficy Machine Edition PLC Logic Developer software. This toolkit will compile C programs to run on either the RX3i, the RX7i, or Both. A different command line is used to compile in one of those three ways. The toolkit executes inside a dos box using the command prompt. The three compile statements are:

compileCPACRX3i <file name>

compileCPACRX7i <file name>

compileCPACRX <file name>

The result of the compilation is a C block with a filename like MyCBlock.gefElf. This C block is brought in to the Proficy Machine Edition programming environment by right clicking on Program Blocks and selecting Add C Block ... as can be seen below.

Once the C block has been added, you must add the same number of parameters as the C block was designed to support, both on the Input and Output side. This is accomplished by clicking on the C block name and then the ellipses (three dots) in the inspector window which is labeled Parameters. This dialog appears:

Now that the C block has been written, compiled, included in the project, and its input and output parameters have been declared, it can then be called from the other programming languages including Relay Ladder Logic (LD), Structured Text (ST) and Function Block Diagram (FBD). In addition to being called from the other languages, the block can be configured to execute as a Timed Interrupt, I/O Interrupt, or a Module Interrupt.

To use the C Block in LD or FBD simply program the Call instruction and select the C block from the list. Remember to populate the input and output parameters at the call instance.

To use the C block in ST, select one of the following:

Call to an unparametrized C block:


Call to a parametrized block using the informal convention:

My_C_Block(my_Input1, my_Input2, my_Output2, my_Output1);

Call to a parametrized block using the formal convention (parameters can be in any order):

My_C_Block(Out1 => my_Output1, In1 := my_Input1, In2 := my_Input2,Out2 => my_Output2);

Because C programs can get rather lengthy and complex, you can break your C program block down into multiple C files and compile them all together as one application.

If you want to have multiple C files compiled and linked together, you need to create a file called “sources” and include a line that specifies the files to compile. This line must start with the word “CFILENAMES=” (all capitals, no spaces) followed by the filenames (there can be multiple spaces or tabs between “CFILENAMES=” and the first file and multiple spaces or tabs between each filename). An example of this line is shown below:

CFILENAMES= myCFile1.c myCFile2.c myCFile3.c

At compile time, simply type:


And the system knows to use the “sources” file previously created. The output in this case would be a file named:


This method can be used to replace the need to call once C block from another. Also other languages can call C blocks back to back as an alternative.