DioSetCountMatchValue


Function

Sets the comparison register.

Format

Ret = DioSetCountMatchValue ( Id , ChNo , ChNum , CompareRegNo, CompareCount )

Parameters

Id [ C, C++: short] [Python: ctypes.c_short]
Specifies the device ID retrieved from DioInit.

ChNo [ C, C++: short *] [Python: ctypes.POINTER(ctypes.c_short)]
Specifies the start address of the array that stores the channel numbers to set.

ChNum [ C, C++: short] [Python: ctypes.c_short]
Specifies the number of channels specified in ChNo.

CompareRegNo [ C, C++: short *] [Python: ctypes.POINTER(ctypes.c_short)]
Specifies the start address of the array that stores the register number of the comparison registers.

Device

Settable value

CPSN-DI-16BCL

0 only

CompareCount [ C, C++: unsigned int *] [Python: ctypes.POINTER(ctypes.c_uint)]
Specifies the start address of the array that stores the comparison values to be set in the comparison registers.

Specifiable range:
For 32-bit counter devices : 0h <= Count <= FFFFFFFFh

Return Value

Ret [ C, C++: long] [Python: ctypes.c_long]

Definition

Value

[Dec]

Description

DIO_ERR_SUCCESS

0

Normal complete

DIO_ERR_DLL_INVALID_ID

10001

Invalid ID is specified.

DIO_ERR_DLL_CALL_DRIVER

10002

Driver cannot be called (failed in ioctl).

DIO_ERR_DLL_BUFF_ADDRESS

10100

Invalid data buffer address.

DIO_ERR_SYS_NOT_SUPPORTED

20001

This function cannot be used for this device.

DIO_ERR_SYS_CH_NO

20105

Channel No. is outside the setting range.

DIO_ERR_SYS_CH_NUM

20106

Channel number is outside the setting range.

DIO_ERR_SYS_CMP_REG_NO

20800

Comparision register No. is outside the setting range.

DIO_ERR_SYS_CMP_REG_VAL

20801

Comparision register value is outside the setting range.

The other errors: (See also: Error code details)

Remarks

- You can use DioGetCountStatus to check if it matches the specified count value.

Example

It sets the comparison value=500 for the comparison register0 of Channel0.
And it sets the comparison value=1000 for the comparison register0 of Channel1.

C, C++

long Ret;

short ChNo[2]
short CompareRegNo[2];
unsigned long CompareCount[2];

ChNo[0] = 0;
ChNo[1] = 1;
CompareRegNo[0] = 0;
CompareRegNo[1] = 0;
CompareCount[0] = 500;
CompareCount[1] = 1000;

Ret = DioSetCountMatchValue(Id, &ChNo[0], 2, &CompareRegNo[0], &CompareCount[0]);
 

Python

Ret = ctypes.c_long()

ChNoType = ctypes.c_short * 2
ChNo = ChNoType()
CompareRegNoType = ctypes.c_short * 2
CompareRegNo = CompareRegNoType()
CompareCountType = ctypes.c_ulong * 2
CompareCount = CompareCountType()

ChNo[0] = 0
ChNo[1] = 1
CompareRegNo[0] = 0
CompareRegNo[1] = 0
CompareCount[0] = 500
CompareCount[1] = 1000

Ret.value = cdio.DioSetCountMatchValue(Id, ChNo, 2, CompareRegNo, CompareCount)
 

See Also

DioGetCountStatus