.

Transitioning to the New CAN I/O Functions

Why the change?

In the previous MPI release, 03.02.00, a new set of functions were introduced to access dedicated and general purpose I/O. To ensure a consistent interface for other I/O, a new set of functions were added to the MPI in the 03.03.00 release for accessing the I/O attached to CANOpen nodes.

The new interface has one function for accessing single or multiple digital bits, which should reduce any confusion between the original two functions in the 03.02.00 release with very similar names: meiCanNodeDigitalInputGet and meiCanNodeDigitalInputsGet.

 

What Has Changed?

Deprecated Interface
(03.02.00 and before)
New Interface
(03.03.00 and after)
Functions
meiCanNodeDigitalInputGet
meiCanNodeDigitalInputsGet

meiCanNodeDigitalOutputGet
meiCanNodeDigitalOutputSet
meiCanNodeDigitalOutputsGet
meiCanNodeDigitalOutputsSet

meiCanNodeAnalogInputGet

meiCanNodeAnalogOutputGet
meiCanNodeAnalogOutputSet

Functions
meiCanNodeDigitalIn

meiCanNodeDigitalOutGet
meiCanNodeDigitalOutSet

meiCanNodeAnalogIn

meiCanNodeAnalogOutSet
meiCanNodeAnalogOutGet

Structures
MEICanDigitalIO
 

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 meiDepricated.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: CAN I/O Overview

 

Sample Code

The new analog functions now return a 16-bit signed number, not a double. This allows the true bits from each analog channel to be accessed. This is useful when using 4-20mA slices from MEI (TSIO-6006 and TSIO-6008) since these will return the number 8000h if the current is below the minimum sensor threshold of 3mA.

Example 1

If the original code to read the current state of input 3 on node 5 was:

 

long input3;
meiCanNodeDigitalInputGet( can, 5, 3, &input3 );

The equivalent code using the new interface would be:

 

unsigned long input3;
meiCanNodeDigitalIn( can, 5, 3, 1, &input3 );

Example 2

If the original code to read the current state of inputs 2, 3 and 4 on node 5 was:

 

long inputs; MEICanDigitalIO canInputs; meiCanNodeDigitalInputsGet( can, 5, &canInputs );
inputs = ( canInputs.data[0] >> 2 ) & 0x7;

The equivalent code using the new interface would be:

 

unsigned long inputs;
meiCanNodeDigitalIn( can, 5, 2, 3, &inputs );

Example 3

If the original code to clear outputs 8 to 15 on node 5 was:

 

MEICanDigitalIO canOutputs;

meiCanNodeDigitalOutputsGet( can, 5, &canOutputs );

canOutputs.data[0] &= ~0xFF00;

meiCanNodeDigitalOutputsSet( can, 5, &canOutputs );

The equivalent code using the new interface would be:

 

meiCanNodeDigitalOutSet( can, 5, 8, 8, 0, 1 );


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