CntNotifyCountUp


Function

Performs the specification of count match notify and the setting of comparison register. Supports multi-processing.

Format

Ret = CntNotifyCountUp ( Id , ChNo , RegNo , Count , hWnd )

Parameters

Id [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CntInit.

ChNo [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the channel number for setting.

RegNo [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the register number of comparison register.

Allowable range:

Device with sampling function : 0 or 1

Device without sampling function : Fixed 0

Count [ VB.NET: Integer ] [ C, C++: unsigned long ] [ C#: uint ] [ Python: ctypes.c_ulong ]
Specify the setting comparison value to comparison register.

Allowable range:
24-bit counter data : 0H <= Count <= FFFFFFH
32-bit counter data : 0H <= Count <= FFFFFFFF
H

hWnd [ VB.NET: IntPtr ] [ C, C++: HWND ] [ C#: IntPtr ] [ Python: ctypes.wintypes.HANDLE ]
Specify the window handle that receives the count match message.
The window handle can be retrieved by m_hWnd for VC.
Specify 0 when using callback without using window message.

Return Value

Ret [ VB.NET: Integer ] [ C, C++: long ] [ C#: int ] [ Python: ctypes.c_long ]

Definition

Value

Description

CNT_ERR_SUCCESS

0

Normality completion

CNT_ERR_SYS_RECOVERED_FROM_STANDBY

7

Execute the function CntResetDevice to return from the standby mode.

CNT_ERR_DLL_INVALID_ID

10001

Invalid ID was specified.

CNT_ERR_DLL_CALL_DRIVER

10002

CNT driver can't be called (Failed in the device I/O control).

CNT_ERR_DLL_CREATE_THREAD

10005

Failed in the creation of the thread (Failed in CreateThread).

CNT_ERR_DLL_HWND

10200

Window handle is invalid.

CNT_ERR_SYS_NOT_SUPPORTED

20001

This function can't be used by this device.

CNT_ERR_SYS_BOARD_EXECUTING

20002

Cannot use while by another device works.

CNT_ERR_SYS_USING_OTHER_PROCESS

20003

Cannot use because another process is using the device.

CNT_ERR_SYS_CH_VALUE

20203

Counter value is out of range.

CNT_ERR_SYS_CH_NO

20201

Channel number is out of range.

CNT_ERR_SYS_REGNO

20204

Compare register number is out of range.

The others: (See also: Details of Error Code)

Initial Value

The initial value of comparison register is 0.

Remarks

This function sets of interrupt that occurs by comparing count value that is a function of the counter device and sets comparison register.
The message can notify when comparison value set by setting the comparison register and count value have matched.
Moreover, the pulse of the length specified by function CntSetPulseWidth is output to outside.
Please specify parameter hWnd to 0 when only the pulse is outputted and the count match need not be detected by the application.

If CntResetDevice is called, interrupt becomes invalid.

The number of processes that can receive event notifications varies depending on the device.
For details, please refer to the list of the number of available processes.

The following messages are posted to the specified window handle when interrupt occurs.

Definition

Value

Description

CNTM_COUNTUP_CH0

1100H

Count match, channel number 0

CNTM_COUNTUP_CH1

1101H

         "                               1

CNTM_COUNTUP_CH2

1102H

         "                               2

CNTM_COUNTUP_CH3

1103H

         "                               3

CNTM_COUNTUP_CH4

1104H

         "                               4

CNTM_COUNTUP_CH5

1105H

         "                               5

CNTM_COUNTUP_CH6

1106H

         "                               6

CNTM_COUNTUP_CH7

1107H

         "                               7

The following information are contained in wParam and lParam that is the parameter of the message respectively.
* HIWORD and LOWORD show the high-word and low-word.

Definition

Description

LOWORD(wParam)

ID retrieved from CntInit

HIWORD(wParam)

Direction

lParam

Comparison value

[Definition of Direction]

Definition

Value

Description

CNTM_DIR_UP

1

UP

CNTM_DIR_DOWN

2

DOWN

Please refer to the sample program of each language for the describing details of message processing.

When using CPSN-CNT-3201I in combination with CPSN-MCB271-xxx
  By using this function, the comparison value of the count that outputs a one-shot pulse can be set.
  However, event notification to the application cannot be performed.
  Specify 0 for hWnd.

For Ethernet devices
  If communication with the device is lost, the process will be unregistered and events will no longer be notified.
  If you want to perform event notification again, please make the settings again using this function.

  You can check the registration status of the current process using the CntGetNetCommunicationInfo function.

Example

Sets the count match notify by comparison register value 10000 for channel 0.

VB.NET

Dim Ret As Integer
Ret = CntNotifyCountUp ( Id , 0 , 0 , 10000 , Handle )
 

C, C++

long Ret;
Ret = CntNotifyCountUp ( Id , 0 , 0 , 10000 , m_hWnd );
 

C#

int Ret;
Ret = cnt.NotifyCountUp ( Id , 0 , 0 , 10000 , Handle );
 

Python

Ret = ctypes.c_long()
handle = ctypes.windll.user32.FindWindowW(0, "Interrupt")
Ret.value = ccnt.CntNotifyCountUp ( Id , 0 , 0 , 10000 , handle )
 

See Also

CntStopNotifyCountUp CntSetPulseWidth CntSetOutputHardwareEvent CntGetNetCommunicationInfo