CntReadStatus


Function

Gets the status of the specified channel.

Format

Ret = CntReadStatus ( Id , ChNo , &Sts )

Parameters

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

ChNo [C: short] [Python: ctypes.c_short]
Specifies the channel number which you want to get for.

Sts [C: short *] [Python: ctypes.POINTER(ctypes.c_short)]
Specifies the address of variable to get status.

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

1:General-purpose input"1"
0:General-purpose input"0"

D1 :EQ

Count-match state

1:Count data mismatch
0:Count data match

D2 :U/D

Count direction state

1:Down counting
0:Up counting

D3

Not use

1 fixed

D4 :B

B Phase input state

1:B Phase input"1"
0:B Phase input"0"

D5 :A

A Phase input state

1:A Phase input"1"
0:A Phase input"0"

D6 :Z

Z Phase input state

1:Z Phase input"1"
0:Z Phase input"0"

D7 :AI

Abnormal input detection

1:Abnormal
0:Normal

Return Value

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

Definition

Value

Description

CNT_ERR_SUCCESS

0

Normal Complete

CNT_ERR_DLL_INVALID_ID

10001

Invalid ID is specified.

CNT_ERR_DLL_CALL_DRIVER

10002

Driver cannot be called (failed in ioctl).

CNT_ERR_DLL_BUFF_ADDRESS

10101

Invalid data buffer address.

CNT_ERR_SYS_CH_NO

20201

Channel number is outside the range.

The other errors: (See also: Details of Error Code)

Initial Value

None

Remarks

Get the status of the specified channel.
You can use this status to make sure whether the signal of counter each phase has operated.
For general-purpose input, it is convenient to use the dedicated function CntInputDIByte.

For "Device with high-performance counter", please use CntReadStatusEx.
Only a part of status can be retrieved in CntReadStatus.

"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 CntSetCountMatchEvent function when you want to recognize the edge of "Counter match" on the case for the faster frequency pulse.

Example

C

Ret = CntReadStatus ( Id , ChNo , &Sts );
 

Python

Ret = ccnt.CntReadStatus ( Id , ChNo , ctypes.byref(Sts) )
 

See Also

CntStartCount CntReadStatusEx CntSetCountMatchEvent