15.07.2013 Views

Automatic control function programming manual ladder language

Automatic control function programming manual ladder language

Automatic control function programming manual ladder language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16.1 General<br />

Programming in C Language<br />

Programming the automatic <strong>control</strong> <strong>function</strong> in C has the following advantages:<br />

- the programmes are structured (use of explicit variable names, <strong>language</strong> syntax, data structure, character strings,<br />

etc.)<br />

- libraries of <strong>function</strong>s can be used (management of character strings, arithmetic, etc.)<br />

- the user can write <strong>function</strong> libraries available for use by several applications.<br />

All the tasks can be written in C.<br />

All the variables of the exchange area are accessible to programmes written in C.<br />

Functions exec(..) and exechdl(..) are used to manage the C executables resulting from the C compiler in a <strong>ladder</strong><br />

module.<br />

! CAUTION<br />

When a pointer is used, it must be correctly initialised. If this check is not made, there is a<br />

risk of generating a "prohibited address" fault.<br />

For instance, the return code of the MALLOC <strong>function</strong> must be tested before using the<br />

address returned by the <strong>function</strong>.<br />

16.2 Call Executable Module exec<br />

Syntax<br />

exec(whexec, {arg }6 )<br />

whexec: Logic identifier of the executable module to be called.<br />

arg: Arguments (if any), extended on 32 bits and passed via the stack.<br />

Calls an executable module generated from a C-<strong>language</strong> compiler.<br />

Principle<br />

The (signed) arguments arg are extended on 32 bits and stacked in accordance with the C-<strong>language</strong> convention (the<br />

first argument is at the top of the stack). whexec is not stacked.<br />

The logic identifier whexec is provided by <strong>function</strong> exechdl().<br />

The system analyses whexec and calls the associated executable module.<br />

Return code<br />

If OK<br />

The value returned by the C-<strong>language</strong> executable module.<br />

en-938846/7 16 - 3<br />

16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!