NexMotion  1.4.0
Open Robots & Machines [WIP]
IO_Control_Functions

I/O Control Functions. More...

Collaboration diagram for IO_Control_Functions:

Functions

RTN_ERR FNTYPE NMC_GetInputMemorySize (I32_T DevID, U32_T *PRetSizeByte)
 Get the size of mapped input(Input) memory. More...
 
RTN_ERR FNTYPE NMC_GetOutputMemorySize (I32_T DevID, U32_T *PRetSizeByte)
 Get the size of mapped output (Output) memory. More...
 
RTN_ERR FNTYPE NMC_ReadInputMemory (I32_T DevID, U32_T OffsetByte, U32_T SizeByte, void *PRetValue)
 Read the mapped input (Input) memory. More...
 
RTN_ERR FNTYPE NMC_ReadOutputMemory (I32_T DevID, U32_T OffsetByte, U32_T SizeByte, void *PRetValue)
 Read the mapped output (Output) memory. More...
 
RTN_ERR FNTYPE NMC_WriteOutputMemory (I32_T DevID, U32_T OffsetByte, U32_T SizeByte, const void *PValue)
 Write the mapped output (Output) memory. More...
 
RTN_ERR FNTYPE NMC_ReadInputBit (I32_T DevID, U32_T OffsetByte, U32_T BitIndex, BOOL_T *PRetBitValue)
 Read the mapped input memory by bit, word or dword. More...
 
RTN_ERR FNTYPE NMC_ReadInputI8 (I32_T DevID, U32_T OffsetByte, I8_T *PRetI8Value)
 
RTN_ERR FNTYPE NMC_ReadInputI16 (I32_T DevID, U32_T OffsetByte, I16_T *PRetI16Value)
 
RTN_ERR FNTYPE NMC_ReadInputI32 (I32_T DevID, U32_T OffsetByte, I32_T *PRetI32Value)
 
RTN_ERR FNTYPE NMC_ReadOutputBit (I32_T DevID, U32_T OffsetByte, U32_T BitIndex, BOOL_T *PRetBitValue)
 Read the mapped output memory by bit, word or dword. More...
 
RTN_ERR FNTYPE NMC_ReadOutputI8 (I32_T DevID, U32_T OffsetByte, I8_T *PRetI8Value)
 
RTN_ERR FNTYPE NMC_ReadOutputI16 (I32_T DevID, U32_T OffsetByte, I16_T *PRetI16Value)
 
RTN_ERR FNTYPE NMC_ReadOutputI32 (I32_T DevID, U32_T OffsetByte, I32_T *PRetI32Value)
 
RTN_ERR FNTYPE NMC_WriteOutputBit (I32_T DevID, U32_T OffsetByte, U32_T BitIndex, BOOL_T BitValue)
 Write the mapped output memory by bit, word or dword. More...
 
RTN_ERR FNTYPE NMC_WriteOutputI8 (I32_T DevID, U32_T OffsetByte, I8_T I8Value)
 
RTN_ERR FNTYPE NMC_WriteOutputI16 (I32_T DevID, U32_T OffsetByte, I16_T I16Value)
 
RTN_ERR FNTYPE NMC_WriteOutputI32 (I32_T DevID, U32_T OffsetByte, I32_T I32Value)
 

Detailed Description

I/O Control Functions.

Function Documentation

RTN_ERR FNTYPE NMC_GetInputMemorySize ( I32_T  DevID,
U32_T PRetSizeByte 
)

Get the size of mapped input(Input) memory.

Parameters
DevIDDevice ID (DevID)
PRetSizeByteThe size of I/O output memory will be returned after the function is called successfully. Unit: byte.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
NMC_GetInputMemorySize() is used to read the accessible range of the I/O memory in the controller (0 to the return size, in bytes). Different controllers (different models) may have different I/O memory sizes that can be controlled, so this API can be used to confirm the actual reachable range.

The function can be called after the device is started.

Examples:

Reference:

RTN_ERR FNTYPE NMC_GetOutputMemorySize ( I32_T  DevID,
U32_T PRetSizeByte 
)

Get the size of mapped output (Output) memory.

Parameters
DevIDDevice ID (DevID)
PRetSizeByteThe size of I/O output memory will be returned after the function is called successfully. Unit: byte.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
NMC_GetOutputMemorySize () is used to read the accessible range of the I/O memory in the controller (0 to the return size, in bytes). Different controllers (different models) may have different I/O memory sizes that can be controlled, so this API can be used to confirm the actual reachable range.

The function can be called after the device is started.

Examples:

Reference:

RTN_ERR FNTYPE NMC_ReadInputBit ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  BitIndex,
BOOL_T PRetBitValue 
)

Read the mapped input memory by bit, word or dword.

Parameters
DevIDDevice ID (DevID)
OffsetByteMemory offset (byte) from 0
BitIndexBit index in a byte, value must be 0~7
[out]PRetBitValueReturn bit value (0 or 1)
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
The function can be called after the device is started.

Examples:

Reference:

RTN_ERR FNTYPE NMC_ReadInputMemory ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  SizeByte,
void *  PRetValue 
)

Read the mapped input (Input) memory.

Parameters
DevIDDevice ID (DEVID)
OffsetByteMemory offset (byte) from 0.
SizeByteSize of the memory to be read.
PRetValueThe contents within the specified memory segment will be saved into the variable after the function is called successfully.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
Please refer to the I/O Control chapter for information on how to map I/O to the controller's internal I/O memory. This function can be called after the controller is started. Suppose an I/O device sets its DI-0 to DI-15 to the first Byte and the second Byte of the I/O Input memory. I want to read the value of the fourth DI input (DI-3). Please refer to the following example

Examples:

RTN_ERR ret;
U32_T offsetByte = 0;
U32_T sizeByte = 2;
U16_T diValue = 0;
U16_T di_03;
ret = NMC_ReadInputMemory( devId, offsetByte, sizeByte, &diValue );
di_03 = ( diValue >> 3 ) & 1;

Reference:

RTN_ERR FNTYPE NMC_ReadOutputBit ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  BitIndex,
BOOL_T PRetBitValue 
)

Read the mapped output memory by bit, word or dword.

Parameters
DevIDDevice ID (DevID)
OffsetByteMemory offset (byte) from 0
BitIndexBit index in a byte, value must be 0~7
[out]PRetBitValueReturn bit value (0 or 1)
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
The function can be called after the device is started.

Examples:

Reference:

RTN_ERR FNTYPE NMC_ReadOutputMemory ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  SizeByte,
void *  PRetValue 
)

Read the mapped output (Output) memory.

Parameters
DevIDDevice ID (DevID)
OffsetByteMemory offset (byte) from 0.
SizeByteSize of the memory to be read.
PRetValueThe contents within the specified memory segment will be saved into the variable after the function is called successfully.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
Please refer to the I/O Control chapter for information on how to map I/O to the controller's internal I/O memory. This function can be called after the controller is started. Suppose an I/O device sets its DO-0 to DO-15 to the first Byte and the second Byte of the I/O output memory. I want to read the value of the fourth DO output (DO-3). Please refer to the following example:

Examples:

RTN_ERR ret;
U32_T offsetByte = 0;
U32_T sizeByte = 2;
U16_T doValue = 0;
U16_T do_03;
ret = NMC_ReadOutputMemory( devId, offsetByte, sizeByte, &doValue );
do_03 = ( doValue >> 3 ) & 1;

Reference:

RTN_ERR FNTYPE NMC_WriteOutputBit ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  BitIndex,
BOOL_T  BitValue 
)

Write the mapped output memory by bit, word or dword.

Parameters
DevIDDevice ID (DevID)
OffsetByteMemory offset (byte) from 0
BitIndexBit index in a byte, value must be 0~7
BitValueBit value (0 or 1) to be set
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
The function can be called after the device is started.

Examples:

Reference:

RTN_ERR FNTYPE NMC_WriteOutputMemory ( I32_T  DevID,
U32_T  OffsetByte,
U32_T  SizeByte,
const void *  PValue 
)

Write the mapped output (Output) memory.

Parameters
DevIDDevice ID (DevID)
OffsetByteMemory offset (byte) from 0.
SizeByteSize of the memory to be read.
PValueset the value into output memory
Todo:
Update the description of PValue
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:
Please refer to the I/O Control chapter for information on how to map I/O to the controller's internal I/O memory. This function can be called after the controller is started. Suppose an I/O device has its DO-0 to DO-15 set to the first Byte and the second Byte of the I/O output memory. I want to set the value of the fourth output point (DO 3). Refer to the following example:

Examples:

RTN_ERR ret;
U32_T offsetByte = 0;
U32_T sizeByte = 2;
U16_T doValue = 0;
U16_T do_03;
NMC_ReadOutputMemory( devId, offsetByte, sizeByte, &doValue );
doValue = doValue | ( ( 1 << 3 ) ); // Set bit 3 ON
//doValue = doValue & (~( 1 << 3 ) ); // Set bit 3 OFF
NMC_WriteOutputMemory( devId, offsetByte, sizeByte, &doValue );

Reference: