.

Controller Digital I/O Functions

Why the change?

In the previous 03.02.00 MPI release, a new set of functions were introduced to access dedicated and general purpose I/O. In order to ensure a consistent interface when accessing all I/O, changes were made to the MPI. The following set of functions have been added to the 03.03.00 MPI release for accessing the digital I/O directly attached to a controller.

What has Changed?

Deprecated Interface
(03.02.00 and before)
New Interface
(03.03.00 and after)
Functions
mpiControlIoGet
mpiControlIoSet

Functions
mpiControlDigitalIn
mpiControlDigitalOutSet
mpiControlDigitalOutGet

Structures
MPIControlIo
.
. Definitions
MPIControlInMAX
MPIControlOutMAX

The original functions and enumerations are still available and will have the same functionality as they did prior to 03.03.00 MPI release. See MPI Version Numbering. The original definitions have been moved to mpiDepricated.h.

NOTE: An existing application can still use the deprecated interface without any source code changes. However, new or existing applications that want to use the extended functions should use the new interface.

See Also: Controller Digital I/O Overview

Sample Code

The following sample code examples show how to modify existing code to the new interface.

Example 1

If the original code to read the current state of controller input 3 was:


MPIControlIo controlIo;
long input3; mpiControlIoGet( control, &controlIo );

input3 = ( controlIo.input[0] & MPIControlInputUSER3) >>
MPIXmpControlIOBitUSER3_IN;

The equivalent code using the new interface would be:


unsigned long input3;
mpiControlDigitalIn( control, 3, 1, &input3 );

Example 2

If the original code to clear controller output 2 was:


MPIControlIo controlIo;

mpiControlIoGet( control, &controlIo );

controlIo.output[0] &= ~ MPIControlOutputUSER_2;

mpiControlIoSet( control, &controlIo );

The equivalent code using the new interface would be:


mpiControlDigitalOutSet( control, 2, 1, 0 );

              


       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2021 Motion Engineering