CntReadStatus


Function

Retrieves the status of specified channel. Supports multi-processing.

Format

Ret = CntReadStatus ( Id , ChNo , Sts )

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 retrieving.

Sts [ VB.NET: Short ] [ C, C++: short * ] [ C#: out short ] [ Python: ctypes.POINTER(ctypes.c_short) ]
Specify the address of the variable that retrieves the status. Each bit is defined as the following Definition.

D7

D6

D5

D4

D3

D2

D1

D0

AI

Z

A

B

1

U/D

EQ

U

 

Bit

Description

Value

D0 :U

General-purpose input status

0:General-purpose input [0]
1:General-purpose input [1]

D1 :EQ

Count match status

0:Count data matched
1:Count data not matched

D2 :U/D

Count direction status

0:In up-count
1:In down-count

D3

Not used

1 fixed

D4 :B

B-phase input status

0:B-phase input [0]
1:B-phase input [1]

D5 :A

A-phase input status

0:A-phase input [0]
1:A-phase input [1]

D6 :Z

Z-phase input status

0:Z-phase input [0]
1:Z-phase input [1]

D7 :AI

Abnormal input error detection

0:Normal
1:Abnormal

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_BUFF_ADDRESS

10101

Invalid data buffer address.

CNT_ERR_SYS_BOARD_EXECUTING

20002

Cannot use while by another device works.

CNT_ERR_SYS_CH_NO

20201

Channel number is out of range.

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

Initial Value

0

Remarks

Retrieves the status of specified channel.
Status can be used to confirm whether the signal of each phase of the counter operates.
As for a general-purpose input, it is more convenient to use specific function CntInputDIByte.

Please use CntReadStatusEx for "Device with sampling function".
Only a part of status can be retrieved in CntReadStatus.

When the status was read, "Abnormal input error detection"(D7:AI) is cleared.
But, if the notify of counter error is enabled by function CntNotifyCounterError, these status is always 0.

You can always read the general-purpose input even if you set other than the general-purpose by CntSetInputHardwareEvent.

"Count match register 0"(D1:EQ) is "0:Matched" on the moment which the count value is equal as "Count match register".
On the other case, "Count match register 0"(D1:EQ) is "1:Not matched".
Please use CntNotifyCountUp function when you want to recognize the edge of "Counter match" on the case for the faster frequency pulse.

Example

Retrieves the status of channel 0.

VB.NET

Dim Ret As Integer
Dim Sts As Short
Ret = CntReadStatus ( Id , 0 , Sts )
 

C, C++

long Ret;
short Sts;
Ret = CntReadStatus ( Id , 0 , &Sts );
 

C#

int Ret;
short Sts;
Ret = cnt.ReadStatus ( Id , 0 , out Sts );
 

Python

Ret = ctypes.c_long()
Sts = ctypes.c_short()
Ret.value = ccnt.CntReadStatus ( Id , 0 , ctypes.byref(Sts) )
 

See Also

CntInputDIByte CntReadStatusEx CntNotifyCounterError CntSetInputHardwareEvent CntNotifyCountUp