CntPreset


Function

Presets the count value of specified channel. Supports multi-processing.

Format

Ret = CntPreset ( Id , ChNo , ChNum , PresetData )

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#: out short ] [ Python: ctypes.POINTER(ctypes.c_short) ]
Specify the base address of array storing channel number.

ChNum [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the number of channels in array ChNo.

PresetData [ VB.NET: Integer ] [ C, C++: unsigned long * ] [ C#: out uint ] [ Python: ctypes.POINTER(ctypes.c_ulong) ]
Specify the base address of array storing the preset data value.

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_CH_NO

20201

Channel number is out of range.

CNT_ERR_SYS_CH_NUM

20202

Number of channels is out of range.

CNT_ERR_SYS_CH_VALUE

20203

Counter value is out of range.

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

Initial Value

None

Remarks

Sets the count value of specified channel. The channel number is put in the array and passed.
The preset value is put in the array and passed.
Store corresponding preset value in the array in the order of storing the channel number in the array.

Specifications based on devices

CNT-3204IN-ETH
CNT-3204IN-USB
CNT-3204MT-LPE
CNT-3208M-PE
CNT32-4MT(LPCI)

CNT32-8M(PCI)

The preset value is applied to the device at the timing when the CntPreset function is called.

CNT24-4(PCI)H

CNT24-4D(PCI)H

CPS-CNT-3202I

CPSN-CNT-3201I

CPSN-CNT-3201I2

Processing differs depending on whether the count is running or stopped.

When the count is running, the preset value is applied to the device at the timing when the CntPreset function is called.

 

When the count is stopped, the preset value is retained inside the driver at the timing when the CntPreset function is called, but it is not applied to the device.

The preset value inside the driver is applied to the device when the CntStartCount function is called.

Example

Presets the count value of channel 0 to 0, channel 1 to 10000.

VB.NET

Dim Ret As Integer
Dim ChNo(1) As Short
ChNo(0) = 0
ChNo(1) = 1
Dim PresetData(1) As Integer
PresetData(0) = 0
PresetData(1) = 10000
Ret = CntPreset( Id , ChNo , 2 , PresetData )
 

C, C++

long Ret;
short ChNo[2];
ChNo[0] = 0;
ChNo[1] = 1;
unsigned long PresetData[2];
PresetData[0] = 0;
PresetData[1] = 10000;
Ret = CntPreset( Id , ChNo , 2 , PresetData );
 

C#

int Ret;
short[] ChNo = new short[2];
ChNo[0] = 0;
ChNo[1] = 1;
uint[] PresetData = new uint[2];
PresetData[0] = 0;
PresetData[1] = 10000;
Ret = cnt.Preset( Id , out ChNo , 2 , out PresetData );
 

Python

Ret = ctypes.c_long()
ChNoType = ctypes.c_short * 2
ChNo = ChNoType()
ChNo[0] = 0
ChNo[1] = 1
PresetDataType = ctypes.c_ulong * 2
PresetData = PresetDataType()
PresetData[0] = 0
PresetData[1] = 10000
Ret.value = ccnt.CntPreset( Id , ChNo , 2 , PresetData )
 

See Also

CntStartCount