GPF-6320

Transcription

GPF-6320
UCNT(PCI/C-PCI)
GPF-6320
Windows Driver Software for Multi-Function/High-Speed Counter Board
Help for Windows
www.interface.co.jp
GPF-6320 Help for Windows
Contents
Chapter 1
Introduction
5
1.1 Overview...........................................................................................................................5
1.2 Features............................................................................................................................5
Chapter 2
Product Specifications
6
2.1 Functional Specifications ..................................................................................................6
2.2 Product Composition.........................................................................................................7
2.3 Usage Note for x64 Environment ......................................................................................9
Chapter 3
Installation
10
3.1 Installation.......................................................................................................................10
Chapter 4 Programming Guide
11
4.1 Execution Procedure.......................................................................................................11
4.1.1 Initializing a Device.............................................................................................11
4.1.2 Configuring the Measurement Mode ..................................................................11
4.1.3 Configuring the Counter Function.......................................................................12
4.1.4 Starting the Count...............................................................................................12
4.1.5 Stopping the Count.............................................................................................12
4.1.6 Configuring/Retrieving the Counter Value ..........................................................13
4.1.7 Retrieving the Status of the Input Pins................................................................13
4.1.8 Sampling for the Latch Counter Value ................................................................14
4.1.9 Controlling the Digital Input/Output.....................................................................15
4.1.10 Callback Routine ..............................................................................................15
4.1.11 Closing the Device............................................................................................15
4.2 Configuring the Level ......................................................................................................15
4.3 Board Identification .........................................................................................................16
4.3.1 The Identification of MATHECON Classembly Devices/ECO3 Counter Type .....16
Chapter 5
Reference
17
5.1 List of DLL Functions for Multi-Function Counter ............................................................17
5.1.1 UcntOpen ...........................................................................................................19
5.1.2 UcntClose...........................................................................................................21
5.1.3 UcntGetDeviceInfo .............................................................................................23
5.1.4 UcntReset...........................................................................................................25
5.1.5 UcntSetPulseCountMode ...................................................................................28
5.1.6 UcntGetPulseCountMode...................................................................................34
5.1.7 UcntSetFreqAvgMode ........................................................................................39
5.1.8 UcntGetFreqAvgMode........................................................................................43
Copyright2004, 20014 Interface Corporation. All rights reserved.
1
GPF-6320 Help for Windows
5.1.9 UcntSetCycleMode.............................................................................................46
5.1.10 UcntGetCycleMode ..........................................................................................51
5.1.11 UcntSetPhaseDiffMode ....................................................................................53
5.1.12 UcntGetPhaseDiffMode....................................................................................58
5.1.13 UcntSetTimerMode ..........................................................................................60
5.1.14 UcntGetTimerMode ..........................................................................................63
5.1.15 UcntSetFreqDividerMode .................................................................................65
5.1.16 UcntGetFreqDividerMode.................................................................................68
5.1.17 UcntSetPulseGeneratorMode ..........................................................................71
5.1.18 UcntGetPulseGeneratorMode ..........................................................................74
5.1.19 UcntSetLoadData .............................................................................................77
5.1.20 UcntGetLoadData.............................................................................................79
5.1.21 UcntSetBaseClock ...........................................................................................81
5.1.22 UcntGetBaseClock ...........................................................................................83
5.1.23 UcntSetTriggerConfig.......................................................................................85
5.1.24 UcntGetTriggerConfig ......................................................................................87
5.1.25 UcntSetTriggerChannel....................................................................................89
5.1.26 UcntGetTriggerChannel ...................................................................................92
5.1.27 UcntSetComparatorConfig ...............................................................................94
5.1.28 UcntGetComparatorConfig ...............................................................................98
5.1.29 UcntSetFilter...................................................................................................102
5.1.30 UcntGetFilter ..................................................................................................104
5.1.31 UcntSetLatchMode.........................................................................................107
5.1.32 UcntGetLatchMode ........................................................................................110
5.1.33 UcntSetCounter..............................................................................................113
5.1.34 UcntReadCounter...........................................................................................115
5.1.35 UcntReadLatchCounter ..................................................................................117
5.1.36 UcntSetComparator........................................................................................119
5.1.37 UcntGetComparator .......................................................................................122
5.1.38 UcntGetStaus .................................................................................................125
5.1.39 UcntSetSamplingConfig .................................................................................129
5.1.40 UcntGetSamplingConfig .................................................................................131
5.1.41 UcntGetSamplingData....................................................................................133
5.1.42 UcntClearSamplingData.................................................................................135
5.1.43 UcntGetSamplingStatus .................................................................................137
5.1.44 UcntStartCount...............................................................................................140
5.1.45 UcntStopCount ...............................................................................................143
5.1.46 UcntLatchCount..............................................................................................145
5.1.47 UcntSetDOEnable ..........................................................................................147
5.1.48 UcntGetDOEnable..........................................................................................150
5.1.49 UcntInputDI ....................................................................................................153
Copyright 2004, 2014 Interface Corporation. All rights reserved.
2
GPF-6320 Help for Windows
5.1.50 UcntOutputDO................................................................................................156
5.1.51 UcntSetEventMask.........................................................................................159
5.1.52 UcntGetEventMask ........................................................................................162
5.1.53 UcntSetEvent .................................................................................................165
5.1.54 UcntKillEvent ..................................................................................................171
5.1.55 UcntOutputSync .............................................................................................173
5.1.56 UcntSetPhysicalMemorysSize........................................................................175
5.1.57 UcntGetDriverInfo...........................................................................................177
5.2 List of DLL Function for High-Speed Counter................................................................179
5.2.1 HScntOpen.......................................................................................................180
5.2.2 HScntClose ......................................................................................................182
5.2.3 HScntGetDeviceInfo.........................................................................................184
5.2.4 HScntReset ......................................................................................................186
5.2.5 HScntSetMode .................................................................................................188
5.2.6 HScntGetMode.................................................................................................190
5.2.7 HScntReadCounter ..........................................................................................192
5.2.8 HScntGetStaus.................................................................................................194
5.2.9 HScntStartCount ..............................................................................................196
5.2.10 HScntStopCount.............................................................................................198
5.2.11 HScntSetEventMask ......................................................................................200
5.2.12 HScntGetEventMask ......................................................................................204
5.2.13 HScntSetEvent ...............................................................................................208
5.2.14 HScntKillEvent................................................................................................214
5.2.15 HScntSetDOEnable........................................................................................216
5.2.16 HScntGetDOEnable .......................................................................................218
5.2.17 HScntInputDI ..................................................................................................220
5.2.18 HScntOutputDO .............................................................................................222
5.2.19 HScntSetTimerConfig.....................................................................................224
5.2.20 HScntGetTimerConfig ....................................................................................227
5.2.21 HScntGetTimerCount .....................................................................................230
5.2.22 HScntSetFilter ................................................................................................233
5.2.23 HScntGetFilter................................................................................................235
5.3 Structure .......................................................................................................................237
5.3.1 UCNTDEVICEINFO Structure ..........................................................................237
5.3.2 UCNTSAMPLCONFIG Structure ......................................................................237
5.3.3 UCNTEVENTREQ Structure ............................................................................240
5.3.4 HSCNTDEVICEINFO Structure........................................................................241
5.3.5 HSCNTEVENTREQ Structure ..........................................................................242
5.4 Return Values ...............................................................................................................244
5.4.1 Return Value for Multi-function Counter ...........................................................244
5.4.2 Return Value for High-Speed Counter ..............................................................247
Copyright 2004, 2014 Interface Corporation. All rights reserved.
3
GPF-6320 Help for Windows
Chapter 6
Sample Programs
248
6.1 Sample Programs .........................................................................................................248
Chapter 7
Utilities
250
7.1 Operation Test Utility Program (IFUcntCounter) ...........................................................250
7.2 CardBus ID Configuration Utility Program.....................................................................256
7.2.1 Configuring the ID Number ...............................................................................256
7.3 Memory Size Configuration Utility .................................................................................257
7.3.1 Starting the Utility Program...............................................................................257
7.3.2 Selecting a Device............................................................................................257
7.3.3 Configuring the Memory Size ...........................................................................257
7.3.4 Configuring the Memory Size ...........................................................................258
Chapter 8
How to Use .NET
259
8.1 Overview.......................................................................................................................259
8.2 Class Library .................................................................................................................259
8.2.1 Creating the Class Library ................................................................................259
8.2.2 Adding Class Library Reference .......................................................................260
8.3 Notes ............................................................................................................................260
8.3.1 Variables called by reference ...........................................................................260
8.3.1 Structure...........................................................................................................260
Chapter 9
Sample Programs for .NET
261
9.1 Execution Procedure.....................................................................................................261
9.2 List of Sample Programs...............................................................................................262
Chapter 10
Terms of Use
263
10.1 Limited Warranty.........................................................................................................263
10.2 Copyrights and Intellectual Property Rights ................................................................263
10.3 Warning Regarding Medical and Clinical Use of Our Products.............................................263
10.4 Prohibition of Reproduction.........................................................................................263
10.5 Limitation of Liability....................................................................................................264
10.6 Trademark ..................................................................................................................264
Copyright 2004, 2014 Interface Corporation. All rights reserved.
4
GPF-6320 Help for Windows
Chapter 1
Introduction
1.1 Overview
The GPF-6320 software controls Interface multi-counter/high-speed counter modules from your application
running on Windows. Application software should link a provided dynamic link library (DLL) and control the
board to the application programming interface (API).
1.2 Features
• The GPF-6320 provides seven measurement modes: pulse counter, average frequency meter, cycle meter,
phase-shifted pulse width meter, timer, divider, and pulse generator.
• The GPF-6320 supports the pulse count of encoder counter.
• Up to six channels (multi-function channel: 4, high-speed channel: 2) can be controlled individually.
• The GPF-6320 allows to save the specified number of the latched counter values and input pin status on the
memory. By using the internal clock to latch, the sampling is performed at the specified cycle.
• The callback routine can be called when the interrupt occurred.
• The GPF-6320 supports the counter start/stop and digital input/output functions by the external signals.
• The GPF-6320 is attached the useful utility which uses the counter of the each measurement mode and sample
program.
• The Help included in this software explains how to use the functions. Refer to it as you develop your
programs.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
5
GPF-6320 Help for Windows
Chapter 2
Product Specifications
2.1 Functional Specifications
Function
Number of Devices
Measurement Mode
Sampling
General purpose digital
input/output
Event notification and
callback function
Description/Specification
16 devices (max.) for each model.
Each channel for the multi-function counter is applicable to the
following measurement modes.
• Pulse counter
one-pulse/dir, upward/downward pulse, phase-shifted pulse,
internal base clock
• Average frequency meter
one-pulse/dir, upward/downward pulse, phase-shifted pulse
• Cycle (pulse width) meter
All cycles, high-pulse width, low-pulse width, duty ratio
(high/low-pulse width)
• Phase-shifted pulse width meter
phase-shifted pulse width, all phase-shifted pulse width
• Timer
• Divider
• Pulse generator
Each channel for the high-speed counter is applicable to the
following mode.
• Pulse count (Gated single-phase pulse mode)
For multi-function counter can sample the counter value at the
timing of the internal/external clock.
• 7 points per channel (multi-function counter)
• 4 points (high-speed counter)
When the following events occur, the events are signaled and callback
routines are called.
This DLL notifies the occurrence of the following events
• Carry/borrow detection
• Count comparator output (OUTA/OUTB)
• External trigger (start/stop)
• Phase-shifted pulse detection
• External latch, base clock latch
• External preload
• Sampling completion
• Specified number of sampling completion
• FIFO overrun error for sampling
Copyright 2004, 2014 Interface Corporation. All rights reserved.
6
GPF-6320 Help for Windows
2.2 Product Composition
Item
Management file
File Name
GPF6320.VER
Latest information
Installer
Multi-function
counter utility
Memory size
configuration utility
Sample programs
Visual C# .NET
README.HTM
SETUP.EXE
Visual C++
Visual Basic .NET
Visual Basic
IFUCNTCOUNTER.EXE
Description
Management information file for Interface
Corporation use
Latest information
Installation program
Utility
IFUCNTMEM.exe
Memory size configuration utility for DMA transfer
*for 64-bit OS only
IFCUcnt
IFCHScnt
UcntPulseCount
HScntPulseCount
UcntPulseCount
UcntFreqAvg
UcntCycle
UcntPhaseDiff
UcntTimer
UcntFreqDivider
UcntPulseGenerator
UcntSampling
HScntPulseCount
EncoderPulseCount
PulseDutySampling
SinglePulseCount
IFCUcnt
IFCHScnt
UcntPulseCount
HScntPulseCount
UcntPulseCount
UcntFreqAvg
UcntCycle
UcntPhaseDiff
UcntTimer
UcntFreqDivider
UcntPulseGenerator
UcntSampling
HScntPulseCount
EncoderPulseCount
PulseDutySampling
SinglePulseCount
Sample program for Visual C# .NET
Sample program for Visual C++
Sample program for Visual Basic .NET
Sample program for Visual Basic
Copyright 2004, 2014 Interface Corporation. All rights reserved.
7
GPF-6320 Help for Windows
(Continued)
Item
Delphi
File Name
Description
Sample program for Delphi
UcntPulseCount
UcntFreqAvg
UcntCycle
UcntPhaseDiff
UcntTimer
UcntFreqDivider
UcntPulseGenerator
UcntSampling
HScntPulseCount
EncoderPulseCount
PulseDutySampling
SinglePulseCount
IFUCNT.DLL
DLL
Dynamic link library file
IFHSCNT.DLL
IFUCNT.LIB
Import library file
IFHSCNT.LIB
MSVCRT.DLL
C run-time shared DLL
CP63201.SYS
Device drivers
Driver for Windows 2000 and the later versions
CP63202.SYS
CP63201.INF
Driver install file for Windows 2000 and the later
CP63202.INF
versions
CP63203.INF
PCI6323041.INF
PCI6323042.INF
CP63201.CAT
CP63202.CAT
CP63203.CAT
PCI6323041.CAT
PCI6323042.CAT
CP63201.SLD
SLD file for Windows Embedded
CP63202.SLD
CP63203.SLD
IFUCNT.H
Header file
Header file for Visual C++
IFHSCNT.H
IFUCNT.BAS
Header file for Visual Basic
IFHSCNT.BAS
IFUCNT.PAS
Header file for Delphi
IFHSCNT.PAS
Help
HELP.PDF
Help (PDF)
Note: The sample programs for Visual C# .NET and Visual Basic .NET were created with
Visual C# .NET 2003, Visual Basic .NET 2003, respectively.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
8
GPF-6320 Help for Windows
2.3 Usage Note for x64 Environment
The setting value of the number of samplings is limited under the x64 environment. After installation, the
maximum default value of the number of samplings is 16384.
The sampling function performs bus master transfer to the internal buffer allocated in the driver and the size of
internal buffer depends on the number of samplings specified by the UctSetSamplingConfig function.
In a x64 environment, the internal buffer is allocated at when the operating system starts and the driver is loaded.
The arbitral allocation size of internal buffer can be set with the memory configuration utility.
To use the function under 16384 or bigger number of samplings, increase the allocated size of internal buffer.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
9
GPF-6320 Help for Windows
Chapter 3
Installation
3.1 Installation
Refer to README for installation.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
10
GPF-6320 Help for Windows
Chapter 4 Programming Guide
This chapter explains how to control the device. The procedure of fundamental device control is as follows.
Sample code is written in C.
4.1 Execution Procedure
4.1.1 Initializing a Device
The UcntOpen function initializes a device.
Initialize the specified device by passing the divice name allocated to the device to be used (“IFUCN1” through
“IFUCN256”) as an argument. After initialization is completed, the device is accessible.
hDevice = UcntOpen(“IFUCNT1”);
The device driver assigns the device name as follows.
IFUCNT1, IFUCNT2, . . . , IFUCNT256
A device handle is returned to hDevice after the device successfully initialized. The device handle allows you to
reference the device and must be specified when a function is called.
4.1.2 Configuring the Measurement Mode
This product supports the following measurement modes.
• Pulse counter mode (the UcntSetPulseCountMode function)
• Average frequency meter mode (the UcntSetFreqAvgMode function)
• Cycle meter mode (the UcntSetCycleMode function)
• Phase-shifted pulse width meter mode (the UcntSetPhaseDiffMode function)
• Timer mode (the UcntSetTimerMode function)
• Divider mode (the UcntSetFreqDividerMode function)
• Pulse generator mode (the UcntSetPulseGeneratorMode function)
When the measurement mode is changed to another mode, the settings is initialized. Before changing the
measurement mode, make sure that the counting and sampling are stopped.
Immediately after the following situation, the pulse counter mode is specified as the default setting mode.
• The device is opened by the UcntOpen function.
• The device is initialized by the UcntReset function.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
11
GPF-6320 Help for Windows
4.1.3 Configuring the Counter Function
Confugure the basic motion by the functional mode setting functions. Then, configure the other counter
functions.
The following counter functions are configurable. (The function names are in parentheses. )
- Preload data setting (the UcntSetLoadData function)
- Base clock setting (the UcntSetBaseClock function)
- Start/stop trigger mode setting (the UcntSetTriggerConfig function)
- Trigger channel setting (the UcntSetTriggerConfig function)
- Comparator output mode setting (the UcntSetTriggerChannel function)
- Digital filter setting (the UcntSetFilter function)
Note: Available setting depends on the current measurement mode. If a measurement mode that
prohibits changing is applied, the IFUCNT_ERROR_INVALID_FUNC_MODE is returned.
4.1.4 Starting the Count
The UcntStartCount function enables the counter function.
nRet = UcntStartCount(hDevice, 0x01, IFUCNT_CMD_START);
By specifying channel for count start to the second parameter, synchronous start of multiple channels
becomes possible. Above code shows only channel 1 starts counting.
To start the count by the external input specified to the start trigger, specify the
FUCNT_CMD_EXWAIT to the start command.
nRet = UcntStartCount(hDevice, 0x01, IFUCNT_CMD_EXWAIT);
4.1.5 Stopping the Count
The UcntStopCount function stops the counter function.
nRet = UcntStopCount(hDevice, 0x01, IFUCNT_CMD_STOP);
By specifying the channel to stop counting to the second parameter, multiple channels can be stopped
synchronously. Above code shows only channel 1 stops counting.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
12
GPF-6320 Help for Windows
4.1.6 Configuring/Retrieving the Counter Value
The UcntSetCounter function sets the counter value in advance.
dwCounter[0] = 10000;
nRet = UcntSetCounter(hDevice, 0x01, dwCounter);
The specified value to the array is configured as the default setting value of the counter. By specifying the
channels to be configured the counter values to the second parameter, the counter values can be configured
for multiple channels at the same time. In the codes above shows only channel 1 is configured.
This product supprots the following two methods to retrieve the counter value.
• Normal counter reading
• Latch counter reading
nRet = UcntReadCounter(hDevice, 0x01, dwCounter);
When the UcntReadCounter function is called, the latest counter value can be read.
nRet = UcntReadLatchCounter(hDevice, 0x01, dwCounter);
When the UcntReadLatchCounter function is called, the counter value that is kept in the device at the last latch
timing can be read.
For the cycle meter or phase-shifted pulse meter mode, the latch counter value should be read. For the other
modes, the counter and latch counter value can be read if necessary.
To latch the counter value at the timing specified by the software, call the UcntLatchCount function. (The value
for multiple channels can be latched synchronously.)
4.1.7 Retrieving the Status of the Input Pins
The UcntGetStatus function retrieves the status of every input pins of each channel.
nRet = UcntGetStatus(hDevice, 0x01, dwStatus);
By passing the head address of the array to the function, the status of multiple channels can be retrieved
synchronously. (Above code shows the status for only channel 1 is retrieved.)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
13
GPF-6320 Help for Windows
4.1.8 Sampling for the Latch Counter Value
The specified number of the counter value status and input pin status that kept at the latch process can be
retrieved. To sample at the specified cycle, configure the latch at the timing of the internal clock.
After setting the measurement mode, configure the sampling, including the number of sampling data to be
saved, repeat count, and the number of generated events.
UCNTSMPLCONFIG SmplConfig;
SmplConfig.dwSmplNum
= 1000;
SmplConfig.dwSmplEventNum = 500;
SmplConfig.dwRepeat
SmplConfig.dwStatusMode
SmplConfig.dwErrCtrl
= 1;
= IFUCNT_NO_STATUS;
= IFUCNT_FREERUN;
nRet = UcntSetSampingConfig(hDevice, 1, &SmplConfig);
The UcntSetSamplingConfig function configures the sampling, and the UcntStartCount function starts
the sampling.
nRet = UcntStartCount(hDevice, 0x01, IFUCNT_CMD_START |
IFUCNT_CMD_SAMPLING);
The start command for counter and sampling is specified with OR operator.
The UcntStopCount function stops the sampling.
nRet = UcntStopCount(hDevice, 0x01, IFUCNT_CMD_STOP | IFUCNT_CMD_SAMPLING);
The stop command for the counter and sampling is specified with OR operator.
The UcntGetSamplingStatus function retrieves the sampling status.
nRet = UcntGetSamplingStatus(hDevice, 1, &dwSmplStatus, &dwSmplCount, &dwRepCount);
The current sampling status, the number of competed samplings, and repetition time is stored to the specified
variable.
The UcntClearSamlingData function retrieves the data that sampling is completed.
DWORD dwSmplData[1000];
DWORD dwSmplDataNum = 1000;
nRet = UcntGetSamplingData(hDevice, 1, dwSmplData, &dwSmplDataNum);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
14
GPF-6320 Help for Windows
4.1.9 Controlling the Digital Input/Output
The UcntOutputDO and UcntInputDI functions control the digital input/output.
Immediately after opening the device, the digital output can be controlled only by OUTA and OUTB of each
channel. To control the digital output by using the pins except for OUTA and OUTB, call the
UcntSetDOEnable function.
nRet = UcntSetDOEnable(hDevice, 0xFF);
In this case, do not connect between the pin that controlled by the UcntSetDOEnable function and
equipment such as an encoder. The device and external devices may be broken.
4.1.10 Callback Routine
The registered callback routine functions (messages, events) are called when interrupt events occur. To register
the function, use the UcntSetEvent function. To mask or unmask interrupt event sources, use the
UcntSetEventMask function. By setting “1” to the bit that corresponds to each interrupt event, the callback
routine function and message become enabled.
4.1.11 Closing the Device
The UcntClose function closes the device and releases the resources.
nRet = UcntClose(hDevice);
4.2 Configuring the Level
This section explains how to configure the levels before pulse output start and after pulse output stop.
Sample codes of functions are written in C.
Changing Level before Pulse Output
The pulse output level is High just after device open. To configure the output level to Low, use the
UcntSetPulseGeneratorMode function.
The output level after pulse output is the same level as that of when the output stops. If the level is High when
the output stops, it is High after pulse output. And if the level is Low when the output stops, it is Low after pulse
output. To configure the output level after pulse output to low, use UcntSetPulseGeneratorMode function again.
Configuring the output level before pulse output to Low
(1) Pulse generator mode settings (Configuring OUT A output. 384 kHZ, Duty 20%)
nRet = UcntSetPulseGeneratorMode(hDeviceHandle, 1, 1, 26, 13, IFUCNT_OUTB_NO);
(2) Pulse output
nRet = UcntStartCount(hDeviceHandle, 0x0F, IFUCNT_CMD_START);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
15
GPF-6320 Help for Windows
(3) Pulse stop
nRet = UcntStopCount(hDeviceHandle, 0x0F, IFUCNT_CMD_STOP);
(4) Pulse generator mode settings (Configuring OUT A output from High to Low)
nRet = UcntSetPulseGeneratorMode(hDeviceHandle, 1, 1, 26, 5, IFUCNT_OUTB_NO);
(5) Pulse output (Pulse output the default value at Low level)
nRet = UcntStartCount(hDeviceHandle, 0x0F, IFUCNT_CMD_START);
4.3 Board Identification
4.3.1 The Identification of MATHECON Classembly Devices/ECO3 Counter Type
The counter of MATHECON Classembly Devices and ECO3 Classembly Devices are indicated as follows in
the device manager.
- CH 1 through CH4
- CH 5 through CH8
“Interface PCI-632304[UCNT]<CNT1>”
“Interface PCI-632304[UCNT]<CNT2>”
The above product has two devices. Therefore a device name is allocated to each device.
Open each device to control them by functions.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
16
GPF-6320 Help for Windows
Chapter 5
Reference
5.1 List of DLL Functions for Multi-Function Counter
No.
Function
Initializing
1
UcntOpen
2
UcntClose
3
UcntGetDeviceInfo
4
UcntReset
Setting/ retrieving the Mode
5
UcntSetPulseCountMode
6
UcntGetPulseCountMode
7
UcntSetFreqAvgMode
8
UcntGetFreqAvgMode
9
UcntSetCycleMode
10 UcntGetCycleMode
11 UcntSetPhaseDiffMode
12 UcntGetPhaseDiffMode
13 UcntSetTimerMode
14 UcntGetTimerMode
15 UcntSetFreqDividerMode
16 UcntGetFreqDividerMode
17 UcntSetPulseGeneratorMode
18 UcntGetPulseGeneratorMode
Setting/ Retrieving the Functions
19 UcntSetLoadData
20 UcntGetLoadData
21 UcntSetBaseClock
22 UcntGetBaseClock
23 UcntSetTriggerConfig
24 UcntGetTriggerConfig
25 UcntSetTriggerChannel
26 UcntGetTriggerChannel
27 UcntSetComparatorConfig
28 UcntGetComparatorConfig
29 UcntSetFilter
30 UcntGetFilter
31 UcntSetLatchMode
32 UcntGetLatchMode
Setting/ Retrieving the Counter
33 UcntSetCounter
34 UcntReadCounter
35 UcntReadLatchCounter
36 UcntSetComparator
37 UcntGetComparator
Description
Opens the device.
Closes the device.
Retrieves the device information.
Resets the setting and clears the counter.
Sets to the pulse count mode.
Retrieves the settings of pulse count mode.
Sets to the average frequency meter mode.
Retrieves the settings of average frequency meter mode.
Sets the cycle meter mode.
Retrieves the settings of cycle meter mode.
Sets phase-shifted pulse width meter.
Retrieves the settings of phase-shifted pulse width meter mode.
Sets the timer mode.
Retrieves the settings of timer mode.
Sets to the divider mode.
Retrieves the settings of divider mode.
Sets the pulse generator mode.
Retrieves the settings of pulse generator mode.
Configures the preload data.
Retrieves the settings of preload data.
Configures the internal base clock.
Retrieves the settings of internal base clock.
Configures the external trigger condition.
Retrieves the settings of external trigger condition.
Configures the external trigger channel.
Retrieves the settings of external trigger channel.
Configures the condition of matching detection.
Retrieves the condition of matching detection.
Configures the digital filter.
Retrieves the settings of digital filter.
Configures the latch mode.
Retrieves the settings of the latch mode.
Sets the preload value to the counter.
Reads the counter.
Reads the latch counter value.
Configures the comparator reference counter.
Retrieves the settings of comparator reference counter.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
17
GPF-6320 Help for Windows
No.
Function
Retrieving the Status
38 UcntGetStatus
Description
Retrieves the counter status.
Sampling
39 UcntSetSamplingConfig
40 UcntGetSamplingConfig
41 UcntGetSamplingData
42 UcntClearSamplingData
43 UcntGetSamplingStatus
Start/Stop the Count
44 UcntStartCount
45 UcntStopCount
46 UcntLatchCount
Digital Input/Output
47 UcntSetDOEnable
48 UcntGetDOEnable
49 UcntInputDI
50 UcntOutputDO
Setting/ retrieving the Interrupt
51 UcntSetEventMask
52 UcntGetEventMask
53 UcntSetEvent
54 UcntKillEvent
Internal synchronous Settings
55 UcntOutputSync
Configures the sampling conditions.
Retrieves the settings of sampling conditions.
Retrieves the sampling data from the internal buffer.
Clears the sampling data in the internal buffer.
Retrieves the sampling status.
Starts counting.
Stops counting.
Latches the count value.
Configures the output.
Retrieves the general output.
Retrieves the status of input.
Controls the output.
Masks interrupt events.
Retrieves interrupt event mask setting.
Registers a callback routine.
Deletes a registered callback routine.
Controls internal synchronous output. (this function is
applicable only to the PCI-632302)
64-bit Operating System
56 UcntSetPhysicalMemorysSize Configures the internal buffer size.
57 UcntGetDriverInfo
Retrieves the OS information and internal buffer size.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
18
GPF-6320 Help for Windows
5.1.1 UcntOpen
Description
The UcntOpen function opens a multi-function counter board and enables subsequent accesses to the board.
Syntax
C (for x86)
HANDLE UcntOpen(
LPCTSTR lpszName
);
C (for x64)
HANDLE UcntOpen(
LPCSTR lpszName
);
// Device name
// Device name
Visual Basic
Declare Function UcntOpen Lib "IFUcnt.DLL"(_
ByVal
As String_
lpszName
‘ Device name
)As Long
Delphi
function UcntOpen(
String
// Device name
lpszName:
):THandle; stdcall; external 'IFUcnt.DLL';
Parameter
lpszName
Specifies the device name to open.
Return Value
The UcntOpen function returns a valid handle when the process is successfully completed. Otherwise, this
function returns INVALID_HANDLE_VALUE if the process is failed.
Comment
To open the device, specify a device name of the device, IFUCNTx (x = 1 to 256), assigned by the device driver.
The device names are listed in the Device Manager.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
19
GPF-6320 Help for Windows
Example
Opening the device whose device name is IFUCNT1.
C (32-bit compiler)
HANDLE DeviceHandle;
DeviceHandle = UcntOpen(“IFUCNT1”);
C (UNICODE is defined in a 32-bit compiler)
HANDLE DeviceHandle;
DeviceHandle = UcntOpen((LPCTSTR)“IFUCNT1”);
HANDLE DeviceHandle;
char* lpszName = “IFUCNT1”;
DeviceHandle = UcntOpen((LPCTSTR)lpszName);
HANDLE DeviceHandle;
LPCWSTR UnicodeName = L"IFUCNT1";
char DeviceName[256];
int len;
len = WideCharToMultiByte(CP_ACP, 0, UnicodeName, -1, NULL, 0, NULL,
NULL);
WideCharToMultiByte(CP_ACP, 0, UnicodeName, -1, DeviceName, len, NULL,
NULL);
DeviceHandle = UcntOpen((LPCTSTR)DeviceName);
C (64-bit compiler)
HANDLE DeviceHandle;
DeviceHandle = UcntOpen(“IFUCNT1”);
Visual Basic
Dim Name As String
Dim DeviceHandle As Long
Name = "IFUCNT1" & Chr( 0 )
DeviceHandle = UcntOpen(Name)
Delphi
Dim Name As String
Dim DeviceHandle As Long
Name = "IFUCNT1" & Chr( 0 )
DeviceHandle = UcntOpen(Name)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
20
GPF-6320 Help for Windows
5.1.2 UcntClose
Description
The UcntClose function closes a multi-function counter board and releases the resources that is used to access
devices. Any subsequent accesses to the board are forbidden.
Syntax
C
INT UcntClose(
HANDLE
hDeviceHandle
);
// Device handle
Visual Basic
Declare Function UcntClose Lib “IfUcnt.DLL”(_
ByVal hDeviceHandle
As Long_
‘ Device handle
)As Long
Delphi
function UcntClose(
THandle
// Device handle
hDeviceHandle:
): Integer; stdcall; external ‘IfUcnt.DLL’;
Parameter
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
Return Value
The UcntClose function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comments
• To access the board again, call the UcntOpen function.
• If this function is executed during sampling, the sampling stops.
• Each configurations are cleared after closing the device.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
21
GPF-6320 Help for Windows
Example
Closing the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
.
.
.
nRet = UcntClose(hDeviceHandle);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFUCNT1” & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
.
.
.
nRet = UcntClose(hDeviceHandle)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFUCNT1’;
hDeviceHandle := UcntOpen(lpszName);
.
.
.
nRet := UcntClose(hDeviceHandle);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
22
GPF-6320 Help for Windows
5.1.3 UcntGetDeviceInfo
Description
The UcntGetDeviceInfo function retrieves information of the multifunction counter device.
Syntax
C
INT UcntGetDeviceInfo(
HANDLE
hDeviceHandle,
PUCNTDEVICEINFO
pDeviceInfo
// Device handle
// Pointer to UCNTDEVICEINFO
// structure
);
Visual Basic
Declare Function UcntGetDeviceInfo Lib “IfUcnt.DLL”(_
ByVal hDeviceHandle As Long_
‘ Device handle
ByRef pDeviceInfo
As UCNTDEVICEINFO_ ‘ reference to
‘ UCNTDEVICEINFO structure
)As Long
Delphi
function UcntGetDeviceInfo (
THandle;
hDeviceHandle:
var pDeviceInfo: UCNTDEVICEINFO
// Device handle
// reference to
// UCNTDEVICEINFO structure
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
pDeviceInfo
Specifies the device handle obtained by the UcntOpen function.
Points to the UCNTDEVICEINFO structure to store retrieved device
information. Refer to 5.3 Structure for descriptions of structures.
Return Value
The UcntGetDeviceInfo function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
23
GPF-6320 Help for Windows
Example
Retrieving the information of the device of “IFUCNT1”.
C
INT nRet;
HANDLE hDeviceHandle;
UCNTDEVICEINFO DeviceInfo;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetDeviceInfo(hDeviceHandle, &DeviceInfo);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim DeviceInfo As UCNTDEVICEINFO
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetDeviceInfo(hDeviceHandle, DeviceInfo)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
DeviceInfo: UCNTDEVICEINFO;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetDeviceInfo(hDeviceHandle, DeviceInfo);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
24
GPF-6320 Help for Windows
5.1.4 UcntReset
Description
The UcntReset function resets the settings and clears the counter of the specified channel.
Syntax
C
INT UcntReset(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwMode
);
// Device handle
// Channel selection
// Reset item
Visual Basic
Declare Function UcntReset Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal dwChSel
As Long,_
‘ Channel selection
ByVal dwMode
As Long_
‘ Reset item
)As Long
Delphi
function UcntReset(
THandle;
// Device handle
hDeviceHandle:
Dword;
// Channel selection
dwChSel:
Dword
// Reset item
dwMode:
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to initialize the settings and clear the counter.
Bit
bit31 to
bit3
bit2
bit1
bit0
bit4
Description Reserved
Channel 4 Channel 3 Channel 2 Channel 1
Set “1” to the corresponding bit to specify the channel,. Multiple channels can
be specified.
Example) To specify four channels from channel 1 to channel 4, specify Fh.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
25
GPF-6320 Help for Windows
dwMode
Specifies a reset item.
Code
IFUCNT_RESET_DEVICE
Description
Motion settings reset
The motion setting of the specified
channel is reset and set to the default
setting values. If sampling is running, it
will stop.
IFUCNT_CLEAR_COUNTER Counter clear
The counter, latch counter, counter
FIFO, and status are cleared.
To reset motion settings and clear the counter synchronously, specify each
identifier with OR.
Return Value
The UcntReset function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
26
GPF-6320 Help for Windows
Example
Initializing and counter resetting channel 1 of “IFUCNT1”.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntReset(hDeviceHandle, 0x01, IFUCNT_RESET_DEVICE |
IFUCNT_RESET_COUNTER);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntReset(hDeviceHandle, &H01, IFUCNT_RESET_DEVICE or
IFUCNT_RESET_COUNTER)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntReset(hDeviceHandle, $01, IFUCNT_RESET_DEVICE |
IFUCNT_RESET_COUNTER);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
27
GPF-6320 Help for Windows
5.1.5 UcntSetPulseCountMode
Description
The UcntSetPulseCountMode function configures to the pulse count mode.
Syntax
C
INT UcntSetPulseCountMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwCountMode,
DWORD
dwLoadMode,
DWORD
dwLatchMode
);
//
//
//
//
//
Device handle
Channel selection
Count mode
Pre-load mode
Latch mode
Visual Basic
Declare Function UcntSetPulseCountMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwCountMode
As Long,_
‘ Count mode
ByVal dwLoadMode
As Long,_
‘ Pre-load mode
ByVal dwLatchMode
As Long_
‘ Latch mode
)As Long
Delphi
function UcntSetPulseCountMode(
hDeviceHandl THandle;
// Device handle
e:
Integer;
nChannel:
// Channel selection
dwCountMode: Dword;
// Count mode
Dword;
dwLoardMode:
// Pre-load mode
dwLatchMode: Dword
// Latch mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
28
GPF-6320 Help for Windows
dwCountMode
Specifies the identifiers of the pulse count mode and count direction with OR. If
you do not specify the count direction, the normal direction is set by default.
Count mode
Identifier
IFUCNT_COUNT_P_DIR_1
Count mode
Single-phase pulse count mode
with direction: single-edge
evaluation
IFUCNT_COUNT_P_DIR_2
Single-phase pulse count mode
with direction: double-edge
evaluation
IFUCNT_COUNT_U_D_1
Upward/downward pulse count
mode: single-edge evaluation
IFUCNT_COUNT_PHASE_1
Phase-shifted pulse count mode:
single-edge evaluation
IFUCNT_COUNT_PHASE_2
Phase-shifted pulse count mode:
double-edge evaluation
IFUCNT_COUNT_PHASE_4
Phase-shifted pulse count mode:
quad-edge evaluation
IFUCNT_COUNT_INTERNAL_CLOCK Internal base clock count mode
Count direction
Identifier
Description
IFUCNT_DIR_NORMAL Normal direction (upward)
IFUCNT_DIR_REVERS Reverse direction (downward)
dwLoadMode
Specifies the setting values of preload mode.
Bit
bit31 to bit6 bit5
bit4
Reserved
CLC1 CLC0
Description
bit3
L1P
bit2
ZP
CLS1, CLS0: Specifies the counter external load (clear) condition.
CLC1 CLC0
Description
0
0
External load is invalid.
0
1
When the phase Z is enabled.
1
0
When LA and phase Z is enabled.
1
1
Forbidden
ZP: Specifies the phase Z logic.
ZP
Description
0
Phaze Z normal (rising edge, high-level)
1
Phaze Z reverse (Falling edge, low-level)
LAP: Specifies the polarity of LA.
LA
Description
0
Phaze LA reverse (Falling edge, low-level)
1
Phaze LA normal (rising edge, high-level)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
29
bit1
CLS1
bit0
CLS0
GPF-6320 Help for Windows
CLC0, CLC1: Specifies the external load (clear) mode.
CLC1 CLC0
Description
0
0
Asynchronous edge
0
1
Synchronous edge
1
0
Asynchronous level
1
1
Forbidden
dwLatchMode
Specifies the setting values of latch mode.
Bit
Description
Bit
Description
Bit
Description
bit31 to bit16
Reserved
bit15
SYNC2
bit14
SYNC1
bit13 to
bit12
Reserved
bit7
bit6
bit5
bit4
CKL
EXL Reserved CKL
LOAD LOAD
bit11
bit10
C/B
PEAK
bit3
LBF
LT
Bit2
LBR
LT
bit1
LAF
LT
bit9 to
bit8
Reserved
bit0
LAR
LT
* SUNC1 and SYNC2 are applicable only to the PCI-632302.
* PEAK and C/B are applicable only to the PCI-632304.
LARLT: Specifies the latch setting at the rising edge of LA.
LAFLT: Specifies the latch setting at the falling edge of LA.
LBRLT: Specifies the latch setting at the rising edge of LB.
LBFLT: Specifies the latch setting at the falling edge of LB.
LBFLT, LBRLT, LAFLT, LARLT
0
1
Description
Disabled
Enabled
CKL: Specifies the latch setting by the internal base clock.
CKL
Description
0
Disabled
1
Enabled
EXLLOAD: Specifies the counter load settings after the external latch.
EXLLOAD Description
0
Not load
1
Load
CKLLOAD: Specifies the counter load setting after the internal base clock latch.
CKLLOAD Description
0
Not load
1
Load
Copyright 2004, 2014 Interface Corporation. All rights reserved.
30
GPF-6320 Help for Windows
PEAK: Specifies the counter latch settings at peak hold (when the counter
rotation changes).
* applicable only to the PCI-632304
PEAK
Description
0
Disabled
1
Enabled
C/B: Specifies the latch settings when carry/borrow occurs.
*applicable only to the PCI-632304
C/B
Description
0
Disabled
1
Enabled
SYNC1: Specifies the latch settings by internal synchronous line 1.
*applicable only to the PCI-632302
SYNC1
Description
0
Disabled
1
Enabled
SYNC2: Specifies the latch settings by internal synchronous line 2.
*applicable only to the PCI-632302
SYNC2
Description
0
Disabled
1
Enabled
Return Value
The UcntSetPulseCountMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comments
<Pulse Count Mode>
In the pulse count mode, the following can be counted.
- External pulse from phase A and phaze B of each channel
- Internal base clock (by the UcntSetBaseClock function)
The external load function loads preload data is loaded to the counter at the phase Z signal or phase Z signal and
LA. When the preload data is set to 0 (default value), the function clears the preload data. To set the preload
data, call the UcntSetLoadData function. The external latch by LA and LB, and constant frequency latch by
internal base clock can be configurable.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
31
GPF-6320 Help for Windows
<Timing Chart for Pulse Count Mode>
Single-phase pulse with direction
Upward/downward pulse
Phase-shifted pulse
A
A
A
B
B
B
External pulse
External load (clear) Z
LA
External latch
Start
Stop
Start/stop LB
Count value
Comparison register B (500)
350
Comparison register A (200)
Read register
FIFO
0
350
Matching output OUTA Counter = 200
Matching output OUTB 200≦Counter ≦500
Copyright 2004, 2014 Interface Corporation. All rights reserved.
32
GPF-6320 Help for Windows
Example
Configuring the pulse count mode as follows on the device whose device name is IFUCNT1.
- Pulse count mode: phase-shifted pulse count mode
- Count edge evaluation: quad-edge evaluation
- Counter clear (load): the rising edge of phase Z signal
- External latch: no external latch
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetPulseCountMode(hDeviceHandle, 1, IFUCNT_COUNT_PHASE_4,
0x01, 0x00);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetPulseCountMode(hDeviceHandle, 1, IFUCNT_COUNT_PHASE_4,
&H01, &H00)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetPulseCountMode(hDeviceHandle, 1, IFUCNT_COUNT_PHASE_4,
$01, $00);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
33
GPF-6320 Help for Windows
5.1.6 UcntGetPulseCountMode
Description
The UcntGetPulseCountMode function retrieves the pulse count mode.
Syntax
C
INT UcntGetPulseCountMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwCountMode,
PDWORD
pdwLoadMode,
PDWORD
pdwLatchMode
//
//
//
//
//
//
//
//
Device handle
Channel selection
Pointer to the variable to
retrieve the count mode
Pointer to the variable to
retrieve the pre-load mode
Pointer to the variable to
retrieve the latch mode
);
Visual Basic
Declare Function UcntGetPulseCountMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwCountMode
As Long,_
‘ Pass by reference to retrieve
‘ count mode
ByRef pdwLoadMode
As Long,_
‘ Pass by reference to retrieve
‘ pre-load mode
ByRef pdwLatchMode
As Long_
‘ Pass by reference to retrieve
‘ latch mode
)As Long
Delphi
function UcntGetPulseCountMode(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword;
pdwCountMode:
var pdwLoadMode: Dword;
// Device handle
// Channel selection
// Pass by reference to retrieve
// count mode
// Pass by reference to retrieve
// pre-load mode
var
Dword
// Pass by reference to retrieve
pdwLatchMode:
// latch mode
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
34
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve setting information.
pdwCountMode
Points to a variable to store the count mode setting value.
Specifies the identifier of count mode and count direction to the variable with OR.
Count mode
Identifier
IFUCNT_COUNT_P_DIR_1
Count mode
Single-phase pulse count mode
with direction: single-edge
evaluation
IFUCNT_COUNT_P_DIR_2
Single-phase pulse count mode
with direction: double-edge
evaluation
IFUCNT_COUNT_U_D_1
Upward/downward pulse count
mode: single-edge evaluation
IFUCNT_COUNT_PHASE_1
Phase-shifted pulse count mode:
single-edge evaluation
IFUCNT_COUNT_PHASE_2
Phase-shifted pulse count mode:
double-edge evaluation
IFUCNT_COUNT_PHASE_4
Phase-shifted pulse count mode:
quad-edge evaluation
IFUCNT_COUNT_INTERNAL_CLOCK Internal base clock count mode
Retrieves the count direction.
Identifier
Description
IFUCNT_DIR_NORMAL Normal direction (upward)
IFUCNT_DIR_REVERS Reverse direction (downward)
pdwLoadMode
Points to a variable to receive the preload mode setting values.
Bit
bit31 to
bit5
bit4
bit3
bit2
bit6
L1P
ZP
Description Reserved CLC1 CLC0
bit1
bit0
CLS1
CLS0
CLS1, CLS0: Retrieves the counter external load (clear) conditions.
CLC1
CLC0
Description
0
0
External load is invalid.
0
1
When the phase Z is enabled.
1
0
When LA and phase Z is enabled.
1
1
Forbidden
ZP: Retrieves the phase Z logic.
ZP
Description
0
Phaze Z normal (Rising edge, high-level)
1
Phaze Z reverse (Falling edge, low-level)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
35
GPF-6320 Help for Windows
LAP: Retrieves the polarity of LA.
LA
Description
0
Phaze LA normal (Falling edge, low-level)
1
Phaze LA (Rising edge, high-level)
CLC0, CLC1: Retrieves the external load (clear) mode.
CLC1
CLC0
Description
0
0
Asynchronous edge
0
1
Synchronous edge
1
0
Asynchronous level
1
1
Forbidden
pdwLatchMode
Points to a variable to receive the external latch mode setting value.
Bit
Description
Bit
Description
Bit
Description
bit31 to bit16
Reserved
bit15
SYNC2
bit14
SYNC1
bit13 to
bit12
Reserved
bit7
bit6
bit5
bit4
CKL
EXL Reserved CKL
LOAD LOAD
bit11
bit10
C/B
PEAK
bit3
LBF
LT
Bit2
LBR
LT
bit1
LAF
LT
bit9 to
bit8
Reserved
bit0
LAR
LT
LARLT: Specifies the latch setting at the rising edge of LA.
LAFLT: Specifies the latch setting at the falling edge of LA.
LBRLT: Specifies the latch setting at the rising edge of LB.
LBFLT: Specifies the latch setting at the falling edge of LB.
LBFLT, LBRLT, LAFLT, LARLT
Description
0
Disabled
1
Enabled
CKL: Specifies the latch setting by the internal base clock.
CKL
Description
0
Disabled
1
Enabled
EXLLOAD: Specifies the counter load settings after the external latch.
EXLLOAD Description
0
Not load
1
Load
CKLLOAD: Specifies the counter load setting after the internal base clock latch.
CKLLOAD Description
0
Not load
1
Load
Copyright 2004, 2014 Interface Corporation. All rights reserved.
36
GPF-6320 Help for Windows
PEAK: Retrieves the counter latch settings at peak hold (when the counter
rotation changes).
PEAK
Description
0
Disabled
1
Enabled
C/B: Retrieves the latch settings when carry/borrow occurs.
C/B
Description
0
Disabled
1
Enabled
SYNC1: Retrieves the latch settings by internal synchronous line 1.
SYNC1
Description
0
Disabled
1
Enabled
SYNC2: Retrieves the latch settings by internal synchronous line 2.
SYNC2
Description
0
Disabled
1
Enabled
Return Value
The UcntGetPulseCountMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
37
GPF-6320 Help for Windows
Example
Retrieving the pulse count mode settting information of channel 2 on the device whose device name is
IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCountMode;
DWORD dwLoadMode;
DWORD dwLatchMode;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetPulseCountMode(hDeviceHandle, 2, &dwCountMode,
&dwLoadMode,&dwLatchMode);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCountMode As Long
Dim dwLoadMode As Long
Dim dwLatchMode As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetPulseCountMode(hDeviceHandle, 2, dwCountMode,
dwLoadMode, dwLatchMode)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCountMode: Dword;
dwLoadMode: Dword;
dwLatchMode: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetPulseCountMode(hDeviceHandle, 1, dwCountMode,
dwLoadMode, dwLatchMode);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
38
GPF-6320 Help for Windows
5.1.7 UcntSetFreqAvgMode
The UcntSetFreqAvgMode function configures the average frequency meter mode.
Syntax
C
INT UcntSetFreqAvgMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwCountMode,
DWORD
dwClock
);
//
//
//
//
Device handle
Channel selection
Count mode
Base clock
Visual Basic
Declare Function UcntSetFreqAvgMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwCountMode
As Long,_
‘ Count mode
ByVal dwClock
As Long_
‘ Base clock
)As Long
Delphi
function UcntSetFreqAvgMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwCountMode:
// Count mode
Dword
dwClock:
// Base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
39
GPF-6320 Help for Windows
dwCountMode
Specifies the identifier of counter mode and count direction in logical addition.
If the count direction is not specified, the normal direction is specified by default.
Identifier
IFUCNT_COUNT_P_DIR_1
IFUCNT_COUNT_P_DIR_2
IFUCNT_COUNT_U_D_1
IFUCNT_COUNT_PHASE_1
IFUCNT_COUNT_PHASE_2
IFUCNT_COUNT_PHASE_4
Count mode
Single-phase pulse count mode with
direction: single-edge evaluation
Single-phase pulse count mode with
direction: double-edge evaluation
Upward/downward pulse count mode:
single-edge evaluation
Phase-shifted pulse count mode:
single-edge evaluation
Phase-shifted pulse count mode:
double-edge evaluation
Phase-shifted pulse count mode:
quad-edge evaluation
Count direction.
Identifier
Description
IFUCNT_DIR_NORMAL
IFUCNT_DIR_REVERS
dwClock
Normal direction (upward)
Reverse direction (downward)
Specifies the base clock in the range of 0 to 16777215 (or 0 to FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntSetFreqAvgMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
40
GPF-6320 Help for Windows
Comments
<Average frequency Meter Mode>
In the average frequency meter mode, the average frequency for the pulse by phase A and B can be counted.
How to meter the average frequency is as follows.
1. The counter at the timing of the internal base clock specified by dwClock is latched (cleared).
2. The pulse is counted within the fixed period.
3. The average frequency is retrieved.
To retrieve the count value, call the UcntReadLatchCounter function because the latched data is recognized as
the data for one cycle. If the UcntReadCounter function is called, unnecessary data may be retrieved because
the count value is retrieved during meter.
To calculate the average frequency in Hz, use the following equation:
Average frequency [Hz] = The number of count clocks / Base clock interval.
If 1 [s] is specified to the base clock interval, the frequency is the count value retrieved by the
UcntReadLatchCounter function. When starting the count by the UcntStartCount function, specify
IFUCNT_CMD_START.
<Timing Chart for the Average Frequency Meter Mode>
Phase-shifted pulse
Upward/downward pulse
Single-phase pulse with direction
A
A
A
B
B
B
External pulse
Start
LA
Soft start
Internal base clock
Count value
Comparison register B (650)
600
Comparison register A (550)
500
400
Clear
Latch
Read register
FIFO
0
Clear
Latch
400
OUTA
OUTB
Copyright 2004, 2014 Interface Corporation. All rights reserved.
41
Clear
Latch
500
600
GPF-6320 Help for Windows
Example
Configuring the average freqency meter mode on the device whose device name is IFUCNT1 as follows.
- Single-phase pulse count mode with direction: Single-edge evaluation
- Base clock: 10 ms
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetFreqAvgMode(hDeviceHandle, 1, IFUCNT_COUNT_P_DIR_1,
100000);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetFreqAvgMode(hDeviceHandle, 1, IFUCNT_COUNT_P_DIR_1,
100000)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetFreqAvgMode(hDeviceHandle, 1, IFUCNT_COUNT_P_DIR_1,
100000);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
42
GPF-6320 Help for Windows
5.1.8 UcntGetFreqAvgMode
The UcntGetFreqAvgMode function retrieves the average frequency meter mode.
Syntax
C
INT UcntGetFreqAvgMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwCountMode,
PDWORD
//
//
//
//
//
//
pdwClock
Device handle
Channel selection
Pointer to the variable to
retrieve count mode
Pointer to the variable to
retrieve base clock
);
Visual Basic
Declare Function UcntGetFreqAvgMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwCountMode
As Long,_
‘ Pass by reference to
‘ retrieve count mode
ByRef pdwClock
As Long_
‘ Pass by reference to
‘ retrieve base clock
)As Long
Delphi
function UcntGetFreqAvgMode(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword;
pdwCountMode:
var pdwClock:
Dword
// Device handle
// Channel selection
// Pass by reference to
// retrievecount mode
// Pass by reference to retrieve
// base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to retrieve.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
43
GPF-6320 Help for Windows
pdwCountMode
Points to a variable to store the counter mode setting value.
Specifies the identifier of counter mode and count direction to the variable.
Count mode
Identifier
IFUCNT_COUNT_P_DIR_1
IFUCNT_COUNT_P_DIR_2
IFUCNT_COUNT_U_D_1
IFUCNT_COUNT_PHASE_1
IFUCNT_COUNT_PHASE_2
IFUCNT_COUNT_PHASE_4
Count mode
Single-phase pulse count mode with
direction: single-edge evaluation
Single-phase pulse count mode with
direction: double-edge evaluation
Upward/downward pulse count mode:
single-edge evaluation
Phase-shifted pulse count mode:
single-edge evaluation
Phase-shifted pulse count mode:
double-edge evaluation
Phase-shifted pulse count mode:
quad-edge evaluation
Retrieves the count direction.
Identifier
Description
IFUCNT_DIR_NORMAL Normal direction (upward)
IFUCNT_DIR_REVERS Reverse direction (downward)
pdwClock
Retrieves the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntGetFreqAvgMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
44
GPF-6320 Help for Windows
Example
Retrieving the average freqency meter mode on the device whose device name is IFUCNT1 as follows.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCountMode;
DWORD dwClock;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetFreqAvgMode(hDeviceHandle, 1, &dwCountMode, &dwClock);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCountMode As Long
Dim dwClock As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetFreqAvgMode(hDeviceHandle, 1, dwCountMode, dwClock)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCountMode: Dword;
dwClock: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetFreqAvgMode(hDeviceHandle, 1, dwCountMode, dwClock);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
45
GPF-6320 Help for Windows
5.1.9 UcntSetCycleMode
Description
The UcntSetCycleMode function configures the cycle meter mode.
Syntax
C
INT UcntSetCycleMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwCountType,
DWORD
dwClock
);
//
//
//
//
Device handle
Channel selection
Cycle meter mode
Base clock
Visual Basic
Declare Function UcntSetCycleMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwCountType
As Long,_
‘ Cycle meter mode
ByVal dwClock
As Long_
‘ Base clock
)As Long
Delphi
function UcntSetCycleMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwCountType:
// Cycle meter mode
Dword
dwClock:
// Base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwCountType
Specifies the type of cycle meter modes.
Code
Description
IFUCNT_CYCLE_NORMAL
Meters pulse cycle.
IFUCNT_CYCLE_HIGH
Meters high pulse width.
IFUCNT_CYCLE_LOW
Meters low pulse width.
IFUCNT_CYCLE_HIGH_LOW Meters low pulse width and high pulse width.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
46
GPF-6320 Help for Windows
dwClock
Specifies the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntSetCycleMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comment
<Cycle Meter Mode>
In the cycle meter mode, the pulse from LA is metered periodically. How to meter the cycle is as follows.
1. The count by the internal base clock is latched (cleared) at the timing of the rising edge of the LA signal.
2. Input pulse width from LA is retrieved from latch counter.
To improve the accuracy of the cycle meter, specify the cycle of the internal base clock to short because the
count value of internal clock specified by dwClock is the cycle to meter. If short clock cycle is specified,
available maximum cycle is short.
To retrieve the count value, call the UcntReadLatchCounter function because the latched data is recognized as
the data for one cycle. If the UcntReadCounter function is called, unnecessary data may be retrieved because the
count value is retrieved during measurement.
To calculate the pulse cycle, use the following equation:
Pulse cycle [s] = The number of count clocks / Base clock.
When starting the count by the UcntStartCount function, specify IFUCNT_CMD_EXWAIT. After calling the
start function, the count is started at the rising edge of the first input pulse (LA).
Copyright 2004, 2014 Interface Corporation. All rights reserved.
47
GPF-6320 Help for Windows
<Timing Chart for the Number of Cycle Meter>
Start
LA
Base clock
Count value
Comparison register B (650)
Comparison register A (550)
600
500
Clear
Latch
Read register
FIFO
0
Clear
Latch
500
Clear
Latch
500
600
OUTA
OUTB
In the cycle meter mode, the count value of the base clock counted from the rising edge to the second rising
edge of LA is latched.
<Timing Chart for High Pulse Width Meter>
Start
Stop
Start
Stop
LA
Base clock
Count value
Comparison register B (600)
500
Comparison register A (450)
400
Clear
Latch
Read register
FIFO
0
Clear
Latch
400
500
OUTA
OUTB
In the high pulse width meter mode, the count value of the base clock counted from the rising edge to the falling
edge of LA. In the low pulse width meter mode, the count value of the base clock counted from falling edge to
the rising edge of LA.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
48
GPF-6320 Help for Windows
<Timing Chart for Duty Ratio Meter>
Start
LA
Base clock
Count value
Comparison register B (650)
Comparison register A (550)
600
400
Clear
Latch
Read register
FIFO
0
Clear
Latch
400
Clear
Latch
600
500
OUTA
OUTB
In the duty ratio meter mode (high or low pulse width meter mode), the counter value is latched (cleared) at the
rising edge and falling edge of all LA signals. In this case, the high pulse width and low pulse width is latched
by turns. By using both of pulse widths, duty ratio can be metered.
To confirm that the latch count value is low pulse or high pulse, call the UcntGetStatus function to confirm the
status when the count is latched.
The status of the LA signal before or after the latch timing can be confirmed.
- LABFE (before latch timing): low
- LAAFT (after latch timing): high
In the case of above status, the counter is latched at the rising edge of LA and latch count value is low pulse
width.
- LABFE (before latch timing): high
- LAAFT (after latch timing): low
In the case of above status, the counter is latched at the falling edge of LA and latch count value is high pulse
width.
If the LABEF and LAAFT are not changed, the counter is latched by the sources except for the LA signal.
(During the high or low pulse width meter, count value is invalid.)
When IFUCNT_ADD_STATUS (function to add the status information) is specified at the sampling
configuration, count value and status information above can be retrieved at the counter latch timing
synchronously. This status retrieval function will be useful to meter duty ratio.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
49
GPF-6320 Help for Windows
Example
Configuring the cycle meter mode on the device whose device name is IFUCNT1 as follows.
- High pulse width meter mode
- Base clock: 1 ms
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetCycleMode(hDeviceHandle, 1, IFUCNT_CYCLE_HIGH, 10000);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetCycleMode(hDeviceHandle, 1, IFUCNT_CYCLE_HIGH, 10000)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetCycleMode(hDeviceHandle, 1, IFUCNT_CYCLE_HIGH, 10000);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
50
GPF-6320 Help for Windows
5.1.10 UcntGetCycleMode
Description
The UcntGetCycleMode function retrieves the cycle meter mode.
Syntax
C
INT UcntGetCycleMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwCountType,
PDWORD
pdwClock
//
//
//
//
//
//
Device handle
Channel selection
Pointer to variable to retrieve
Cycle meter mode
Pointer to variable to retrieve
Base clock
);
Visual Basic
Declare Function UcntGetCycleMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwCountType
As Long,_
‘ Pass by reference to variable
‘ to Cycle meter mode
ByRef pdwClock
As Long_
‘ Pass by reference to variable
‘ to retrieve Base clock
)As Long
Delphi
function UcntGetCycleMode(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword;
pdwCountType:
var pdwClock:
Dword
// Device handle
// Channel selection
// Pass by reference to variable
// to retrieve Cycle meter mode
// Pass by reference to variable
// to Base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwCountType
Points to a variable to store the kind of cycle meter modes.
Code
Description
IFUCNT_CYCLE_NORMAL
Pulse cycle.
IFUCNT_CYCLE_HIGH
High pulse width.
IFUCNT_CYCLE_LOW
Low pulse width.
IFUCNT_CYCLE_HIGH_LOW Low pulse width and high pulse width.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
51
GPF-6320 Help for Windows
pdwClock
Points to a variable to store the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntGetCycleMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the cycle meter mode of channel 2 on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCountType;
DWORD dwClock;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetCycleMode(hDeviceHandle, 2, &dwCountType, &dwClock);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCountType As Long
Dim dwClock As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetCycleMode(hDeviceHandle, 2, dwCountType, dwClock)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCountType: Dword;
dwClock: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetCycleMode(hDeviceHandle, 2, dwCountType, dwClock);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
52
GPF-6320 Help for Windows
5.1.11 UcntSetPhaseDiffMode
Description
The UcntSetPhaseDiffMode function configures phase-shifted pulse width meter.
Syntax
C
INT UcntSetPhaseDiffMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwCountType,
DWORD
dwClock
);
//
//
//
//
Device handle
Channel selection
Phase-shifted pulse width meter
Base clock
Visual Basic
Declare Function UcntSetPhaseDiffMode
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByVal dwCountType
As Long,_
ByVal dwClock
)As Long
As Long_
Lib "IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Phase-shifted pulse width
meter
‘ Base clock
Delphi
function UcntSetPhaseDiffMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwCountType:
// Phase-shifted pulse width meter
Dword
dwClock:
// Base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwCountType
Specifies the kind of phase-shifted pulse width meter modes.
Code
Description
IFUCNT_PHASE_DIFF_NORMAL Phase-shifted pulse width between LA
and LB.
IFUCNT_PHASE_DIFF_ALL
All phase-shifted pulse width of LA
and LB.
dwClock
Specifies the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stopped
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Copyright 2004, 2014 Interface Corporation. All rights reserved.
53
GPF-6320 Help for Windows
Return Value
The UcntSetPhaseDiffMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comment
<Phase-Shifted Pulse Width Meter Mode>
In the phase-shifted pulse width meter mode, the phase-shifted pulse width is measured from LA and LB. How
to measure the pulse width is as follows.
1. Count by the internal base clock is started at the rising edge of LA.
2. By latching (clearing) the count at the rising edge of LB, the pulse width between LA input and LB input
is retrieved from latch counter.
To improve the accuracy of the phase-shifted pulse width meter, specify the phase-shifted pulse width of the
internal base clock to short because the count value of internal clock specified by dwClock is the pulse width. If
short clock cycle is specified, available maximum phase-shifted pulse width is short.
To retrieve the count value, call the UcntReadLatchCounter function because the latched data is recognized as
the data for one cycle. If the UcntReadCounter function is called, unnecessary data may be retrieved because the
count value is retrieved during measurement.
To calculate the phase-shifted pulse width, use the following equation:
Phase-shifted pulse width [s] = The number of count clocks / Base clock.
When starting the count by the UcntStartCount function, specify IFUCNT_CMD_EXWAIT. After calling the
start function, the count is started at the rising edge of the first input pulse (LA).
Copyright 2004, 2014 Interface Corporation. All rights reserved.
54
GPF-6320 Help for Windows
<Timing Chart for Phase-Shifted Pulse Width Meter Mode>
Start
Start
Stop
LA
Stop
LB
Base clock
Count value
Comparison register B (700)
Comparison register A (550)
600
500
Clear
Latch
Read register
FIFO
Clear
Latch
0
500
600
OUTA
OUTB
In the phase-shifted pulse width meter mode, the count is started at the risind edge of LA. The count is stoped
and latched (cleared) at the rising edge of LB.
<Timing Chart for All Phase-Shifted Pulse Widths Meter Mode>
Start
LA
LB
Base clock
Count value
Comparison register B (650)
600
Comparison register A (550)
500
400
Read register
FIFO
0
Clear
Latch
Clear
Latch
500
500
Clear
Latch
500
Clear
Latch
600
Clear
Latch
400
Clear
Latch
500
OUTA
OUTB
In the all phase-shifted pulse width meter mode, the count is started at the rising edge of LA. The count is
latched (cleared) when LA and LB is as follows.
- LA: rising edge to falling edge
- LB: rising edge to falling edge
Copyright 2004, 2014 Interface Corporation. All rights reserved.
55
GPF-6320 Help for Windows
To confirm the event sources of the latch count value, call the UcntGetStatus function.
The LA signal status before or after the latch timing can be confirmed by the status information.
- LABEF (before latch timing): low
- LAAFT (after latch timing): high
In the avobe case, the counter is latched at the rising edge of LA.
- LABEF (before latch timing): high
- LAAFT (after latch timing): low
In the avobe case, the counter is latched at the falling edge of LA.
The LB signal status before or after the latch timing can be confirmed as well as LA.
When IFUCNT_ADD_STATUS is specified at the sampling configuration, the count value and status
information can be retrieved at the counter latch timing synchronously. This status retrieval function will be
useful to measure all phase-shifted pulse widths.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
56
GPF-6320 Help for Windows
Example
Specifing the phase-shifted pulse width meter mode of channel 1 on the device whose device name is
IFUCNT1 as follows.
- Phase-shifted pulse width meter between LA and LB
- Base clock: 100 us
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetPhaseDiffMode(hDeviceHandle, 1,
IFUCNT_PHASE_DIFF_NORMAL, 1000);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetPhaseDiffMode(hDeviceHandle, 1,
IFUCNT_PHASE_DIFF_NORMAL, 1000)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetPhaseDiffMode(hDeviceHandle, 1,
IFUCNT_PHASE_DIFF_NORMAL, 1000);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
57
GPF-6320 Help for Windows
5.1.12 UcntGetPhaseDiffMode
Description
The UcntGetPhaseDiffMode function retrieves phase-shifted pulse width meter mode.
Syntax
C
INT UcntGetPhaseDiffMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwCountType,
PDWORD
pdwClock
// Device handle
// Channel selection
// Pointer to the variable to retrieve
// Phase-shifted pulse width meter
// Pointer to the variable to retrieve
// base clock
);
Visual Basic
Declare Function UcntGetPhaseDiffMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pdwCountType
As Long,_ ‘ Pass by reference to the variable
‘ to retrieve phase-shifted pulse
‘ width meter
ByRef pdwClock
As Long_ ‘ Pass by reference to the variable
‘ to retrieve base clock
)As Long
Delphi
function UcntGetPhaseDiffMode(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword;
pdwCountType:
// Device handle
// Channel selection
// Pass by reference to the variable to
// retrieve phase-shifted pulse width
// meter
var pdwClock:
Dword
// Pass by reference to the variable to
// retrieve base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwCountType
Points to a variable to store the kind of phase-shifted pulse width
meter modes.
Code
Description
IFUCNT_PHASE_DIFF_NORMAL Phase-shifted pulse width between LA and
LB.
IFUCNT_PHASE_DIFF_ALL
All phase-shifted pulse width of LA and LB.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
58
GPF-6320 Help for Windows
dwClock
Points to a variable to store the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stopped
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntGetPhaseDiffMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the phase-shifted pulse width meter mode of channel 1 on the device whose device name is
IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCountType;
DWORD dwClock;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetPhaseDiffMode(hDeviceHandle, 1, &dwCountType, &dwClock);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCountType As Long
Dim dwClock As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetPhaseDiffMode(hDeviceHandle, 1, dwCountType, dwClock)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCountType: Dword;
dwClock: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetPhaseDiffMode(hDeviceHandle, 1, dwCountType, dwClock);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
59
GPF-6320 Help for Windows
5.1.13 UcntSetTimerMode
The UcntSetTimerMode function configures the timer mode.
Syntax
C
INT UcntSetTimerMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwClock
);
// Device handle
// Channel selection
// Timer clock
Visual Basic
Declare Function UcntSetTimerMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwClock
As Long_
‘ Timer clock
)As Long
Delphi
function UcntSetTimerMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwClock:
// Timer clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwClock
Specifies the timer clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntSetTimerMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
60
GPF-6320 Help for Windows
Comment
In the timer mode, the timer is measured by counting the internal base clock. To retrieve the counter value, call
the UcntReadCounter or UcntReadLatchCounter function. (To use the latch counter, the count is latched at the
specified timing.)
The counter is counted up by the internal base clock cycle specified by dwClock.
To occur the interval timer event at the specified cycle, set the counter matching event by using the
UcntSetComparatorConfig function and set the counter to clear at the counter matching.
<Count of Timer Mode>
Internal base clock
(100 ns to 1.6777251 s)
*
32-bit counter
(1 through 4,294,967,295)
Comparison register A
Comparison register B
Copyright 2004, 2014 Interface Corporation. All rights reserved.
61
GPF-6320 Help for Windows
Example
Configuring the timer mode of channel 1 on the device whose device name is IFUCNT1 as follows.
- Timer clock: 1 [s]
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetTimerMode(hDeviceHandle, 1, 10000000);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetTimerMode(hDeviceHandle, 1, 10000000)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetTimerMode(hDeviceHandle, 1, 10000000);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
62
GPF-6320 Help for Windows
5.1.14 UcntGetTimerMode
The UcntGetTimerMode function retrieves the timer mode.
Syntax
C
INT UcntGetTimerMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwClock
// Device handle
// Channel selection
// Pointer to the variable
//to retrieve timer clock
);
Visual Basic
Declare Function UcntGetTimerMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwClock
As Long_
‘ Pass by reference to the
‘ variable to retrieve
‘ timer clock
)As Long
Delphi
function UcntGetTimerMode(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pdwClock:
Dword
// Device handle
// Channel selection
// Pass by reference to the
// variable to retrieve
// timer clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwClock
Points to a variable to store the timer clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntGetTimerMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
63
GPF-6320 Help for Windows
Example
Retrieving the timer mode of channel 1 on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwClock;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetTimerMode(hDeviceHandle, 1,&dwClock);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwClock As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetTimerMode(hDeviceHandle, 1, dwClock)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwClock: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetTimerMode(hDeviceHandle, 1, dwClock);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
64
GPF-6320 Help for Windows
5.1.15 UcntSetFreqDividerMode
Description
The UcntSetFreqDividerMode function configures the divider mode.
Syntax
C
INT UcntSetFreqDividerMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwDivisor,
DWORD
dwPulseWide,
DWORD
dwLogic,
DWORD
dwOUTB
);
// Device handle
// Channel selection
// Divider (number of pulses)
// Output width (number of pulses)
// Output logic
// OUTB output setting
Visual Basic
Declare Function UcntSetFreqDividerMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwDivisor
As Long,_
‘ Divider (number of pulses)
ByVal dwPulseWide
As Long,_
‘ Output width (number of pulses)
ByVal dwLogic
As Long,_
‘ Output logic
ByVal dwOUTB
As Long_
‘ OUTB output setting
)As Long
Delphi
function UcntSetFreqDividerMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwDivisor:
// Divider (number of pulses)
Dword;
dwPulseWide:
// Output width (number of pulses)
Dword;
dwLogic:
// Output logic
Dword
dwOUTB:
// OUTB output setting
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwDivisor
Specifies the divider cycle of input pulse in the range of 0 to 4294967294(FFFFFFFEh).
dwPulseWide
Specifies the output pulse width in the range of 0 to 4294967294 (FFFFFFFEh).
Note: Output pulse width should be specified less than cycle value.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
65
GPF-6320 Help for Windows
dwLogic
Specifies the output logic.
dwLogic
Description
0
Positive logic
1
Negative logic
dwOUTB
Specifies the output setting of OUTB.
Code
Description
IFUCNT_OUTB_STOP
Not output
IFUCNT_OUTB_OUT
Output the pulse as the same as OUTA.
IFUCNT_OUTB_REV
Output the pulse reversed OUTA.
Return Value
The UcntSetFreqDividerMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comments
In the divider mode, the pulse output is performed at the specified divider cycle from OUTA and OUTB. How
to measure the pulse width is as follows.
1. The pulse of phase A is counted. (upward/downward pulse count mode, single-edge evaluation)
2. Output for OUTA (OUTB) is set to low level during the counter value in the range from comparison
counter A to comparison counter B.
3. The pulse of specified cycle is created.
The value of comparison counter A corresponds to high pulse width. The value of comparison counter B
corresponds to divider cycle.
<Timing Chart for Divider Mode>
The pulse is created depending on the combination of count for the external clock and matching detection
output. When the comparison register is changed by using the UcntSetComparator function during operation,
the divider cycle will be changed.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
66
GPF-6320 Help for Windows
Example
Configuring the divider mode of channel 1 on the device whose device name is IFUCNT1 as follows.
- Divider cycle: 1/1000
- Output pulse width: 10
- Positive logic
- OUTB reverse output
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetFreqDividerMode(hDeviceHandle, 1, 1000, 10, 0,
IFUCNT_OUTB_REV);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetFreqDividerMode(hDeviceHandle, 1, 1000, 10, 0,
IFUCNT_OUTB_REV)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetFreqDividerMode(hDeviceHandle, 1, 1000, 10, 0,
IFUCNT_OUTB_REV);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
67
GPF-6320 Help for Windows
5.1.16 UcntGetFreqDividerMode
Description
The UcntGetFreqDividerMode function retrieves the divider mode.
Syntax
C
INT UcntGetFreqDividerMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwDivisor,
PDWORD
pdwPulseWide,
PDWORD
pdwLogic,
PDWORD
pdwOUTB
// Device handle
// Channel selection
// Pointer to the variable to
// retrieve divider
// Pointer to the variable to
// retrieve output width
// Pointer to the variable to
// retrieve the output logic
// Pointer to the variable to
// retrieve the OUTB output settings
);
Visual Basic
Declare Function UcntGetFreqDividerMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pdwDivisor
As Long,_ ‘ Pass by reference to the variable
‘ to retrieve divider
ByRef pdwPulseWide
As Long,_ ‘ Pass by reference to the variable
‘ to retrieve the output width
ByRef pdwLogic
As Long,_ ‘ Pass by reference to the
‘ variable to retrieve the output
‘ logic
ByRef pdwOUTB
As Long_
‘ Pass by reference to the variable
‘to retrieve the OUTB output settings
)As Long
Delphi
function UcntGetFreqDividerMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
var pdwDivisor:
Dword;
// Pass by reference to the variable
// to retrieve divider
var
Dword;
// Pass by reference to the variable to
pdwPulseWide:
// retrieve the output width
var pdwLogic:
Dword;
// Pass by reference to the
// variable to retrieve the output logic
var pdwOUTB:
Dword
// Pass by reference to the variable to
// retrieve the OUTB output settings
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
68
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwDivisor
Points to a variable to store the divider cycle of input pulse in the range of 0 to
4294967295 (or 0 to FFFFFFFFh).
Points to a variable to store the output pulse width in the range of 0 to 4294967295
(or 0 to FFFFFFFFh).
pdwPulseWide
pdwLogic
Points to a variable to store the output logic.
dwLogic
Description
0
Positive logic
1
Negative logic
pdwOUTB
Points to a variable to store the output setting of OUTB.
Code
Description
IFUCNT_OUTB_STOP
Not output
IFUCNT_OUTB_OUT
Output the pulse as the same as OUTA.
IFUCNT_OUTB_REV
Output the pulse reversed OUTA.
Return Value
The UcntGetFreqDividerMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
69
GPF-6320 Help for Windows
Example
Retrieving the divider mode of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwDivisor;
DWORD dwPulseWide;
DWORD dwLogic;
DWORD dwOUTB;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetFreqDividerMode(hDeviceHandle, 1, &dwDivisor,
&dwPulseWide, &dwLogic, &dwOUTB);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwDivisor As Long
Dim dwPulseWide As Long
Dim dwLogic As Long
Dim dwOUTB As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetFreqDividerMode(hDeviceHandle, 1, dwDivisor,
dwPulseWide, dwLogic, dwOUTB)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwDivisor: Dword;
dwPulseWide: Dword;
dwLogic: Dword;
dwOUTB: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetFreqDividerMode(hDeviceHandle, 1, dwDivisor,
dwPulseWide, dwLogic, dwOUTB);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
70
GPF-6320 Help for Windows
5.1.17 UcntSetPulseGeneratorMode
Description
The UcntSetPulseGeneratorMode function configures the pulse generator mode.
Syntax
C
INT UcntSetPulseGeneratorMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwClock,
DWORD
dwCycleWide,
DWORD
dwHPulseWide,
DWORD
dwOUTB
);
//
//
//
//
//
//
Device handle
Channel selection
Base clock
Pulse frequency
High pulse width
OUTB output settings
Visual Basic
Declare Function UcntSetPulseGeneratorMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwClock
As Long,_
‘ Base clock
ByVal dwCycleWide
As Long,_
‘ Pulse frequency width
ByVal dwHPulseWide
As Long,_
‘ High pulse width
ByVal dwOUTB
As Long_
‘ OUTB output settings
)As Long
Delphi
function UcntSetPulseGeneratorMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwClock:
// Base clock
Dword;
dwCycleWide:
// Pulse frequency width
Dword;
dwHPulseWide:
// High pulse width
Dword
dwOUTB:
// OUTB output settings
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwClock
Specifies the base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Copyright 2004, 2014 Interface Corporation. All rights reserved.
71
GPF-6320 Help for Windows
dwCycleWide
Specifies the pulse cycle width (the number of clocks) in the range of 0 to
4294967294 (FFFFFFFEh).
dwHPulseWide
Specifies the high pulse width (the number of clocks) in the range of 0 to
4294967294 (FFFFFFFEh).
Note: High pulse width should be less than pulse cycle width.
dwOUTB
Specifies the output setting of OUTB.
Code
Description
IFUCNT_OUTB_STOP
Not output
IFUCNT_OUTB_OUT
Output the pulse as the same as OUTA.
IFUCNT_OUTB_REV
Output the pulse reversed OUTA.
Return Value
The UcntSetPulseGeneratorMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comment
In the pulse generator mode, pulse output is performed at the specified cycle from OUTA and OUTB. How to
create the pulse is as follows.
1. The count is started by the internal base clock.
2. Output for OUTA (OUTB) is set to low level during the counter value in the range from comparison
counter A to comparison counter B.
3. The pulse of specified cycle is created.
The value of comparison counter A corresponds to high pulse width. The value of comparison counter B
corresponds to cycle. Then, duty ratio is determined by using the ratio of the comparison counter value.
To calculate the output pulse frequency in Hz, use the following equation:
Output frequency [Hz] = 10000000 / (base clock * pulse cycle width).
To calculate the duty ration in %, use the following equation:
Duty ratio [%] = (high pulse width / pulse cycle width) * 100.
<Timing Chart for Pulse Generator Mode>
Internal base clock
Start
LA
Soft start
Comparison
register B
Count
Comparison
register A
OUTA
Copyright 2004, 2014 Interface Corporation. All rights reserved.
72
GPF-6320 Help for Windows
The pulse is created depending on the combination of count for the internal clock and matching detection output.
When the internal base clock or the comparison register is changed by using the UcntSetBaseClock or
UcntSetComparator function during operation, the pulse cycle will be changed.
Example
Configuring the pulse generator mode of channel 1 on the device whose device name is IFUCNT1 as follows.
- Output frequency: 5 MHz
- Duty ratio: 50%
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetPulseGeneratorMode(hDeviceHandle, 1, 1, 2, 1,
IFUCNT_OUTB_NO);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetPulseGeneratorMode(hDeviceHandle, 1, 1, 2, 1,
IFUCNT_OUTB_NO)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetPulseGeneratorMode(hDeviceHandle, 1, 1, 2, 1,
IFUCNT_OUTB_NO);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
73
GPF-6320 Help for Windows
5.1.18 UcntGetPulseGeneratorMode
Description
The UcntGetPulseGeneratorMode function retrieves the pulse generator mode.
Syntax
C
INT UcntGetPulseGeneratorMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwClock,
PDWORD
pdwCycleWide,
PDWORD
pdwHPulseWide,
PDWORD
pdwOUTB
//
//
//
//
//
//
//
//
//
//
Device handle
Channel selection
Pointer to the variable to
retrieve base clock
Pointer to the variable to
retrieve pulse frequency width
Pointer to the variable to
retrieve high pulse width
Pointer to the variable to
retrieve OUTB output settings
);
Visual Basic
Declare Function UcntGetPulseGeneratorMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pdwClock
As Long,_ ‘ Pass by reference to retrieve
‘ the variable to base clock
ByRef pdwCycleWide
As Long,_ ‘ Pass by reference to retrieve
‘ the variable to pulse ‘ frequency
‘ width
ByRef pdwHPulseWide As Long,_ ‘ Pass by reference to retrieve
‘ the variable to high pulse ‘ width
ByRef pdwOUTB
As Long_
‘ Pass by reference to retrieve
‘ the variable to OUTB output ‘ settings
)As Long
Delphi
function UcntGetPulseGeneratorMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
var pdwClock:
Dword;
// Pass by reference to retrieve
// the variable to base clock
var
Dword;
// Pass by reference to retrieve
pdwCycleWide:
// the variable to pulse frequency width
var
Dword;
// Pass by reference to retrieve
pdwHPulseWide:
// the variable to high pulse width
var pdwOUTB:
Dword
// Pass by reference to retrieve
// the variable to OUTB output settings
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
74
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwClock
Points to a variable to store the base clock setting in the range of 0 to
16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stop
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
pdwCycleWide
Points to a variable to store the pulse cycle width (the number of clock) in
the range of 0 to 4294967294 (FFFFFFFEh).
pdwHPulseWide
Points to a variable to store the high pulse width (the number of clock) in the
range of 0 to 4294967294 (FFFFFFFEh).
pdwOUTB
Points to a variable to store the output setting of OUTB.
Code
Description
IFUCNT_OUTB_STOP
Not output
IFUCNT_OUTB_OUT
Output the pulse as the same as OUTA.
IFUCNT_OUTB_REV
Output the pulse reversed OUTA.
Return Value
The UcntGetPulseGeneratorMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
75
GPF-6320 Help for Windows
Example
Retrieving the pulse generator mode of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwClock;
DWORD dwCycleWide;
DWORD dwHPulseWide;
DWORD dwOUTB;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetPulseGeneratorMode(hDeviceHandle, 1, &dwClock,
&dwCycleWide, &dwHPulseWide, &OUTB);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwClock As Long
Dim dwCycleWide As Long
Dim dwHPulseWide As Long
Dim dwOUTB As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetPulseGeneratorMode(hDeviceHandle, 1, dwClock,
dwCycleWide, dwHPulseWide, dwOUTB)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwClock: Dword;
dwCycleWide: Dword;
dwHPulseWide: Dword;
dwOUTB: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetPulseGeneratorMode(hDeviceHandle, 1, dwClock,
dwCycleWide, dwHPulseWide, dwOUTB);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
76
GPF-6320 Help for Windows
5.1.19 UcntSetLoadData
Description
The UcntSetLoadData function configures the preload data.
Syntax
C
INT UcntSetLoadData(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwLoadData
);
// Device handle
// Channel selection
// Preload data
Visual Basic
Declare Function UcntSetLoadData Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwLoadData
As Long_
‘ Preload data
)As Long
Delphi
function UcntSetLoadData(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwLoadData:
// Preload data
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwLoadData
Specifies the preload data in the range of 0 to 4294967295 (FFFFFFFFh).
Return Value
The UcntSetLoadData function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
77
GPF-6320 Help for Windows
Example
Configuring the preload data of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetLoadData(hDeviceHandle, 1, 0);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetLoadData(hDeviceHandle, 1, 0)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetLoadData(hDeviceHandle, 1, 0);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
78
GPF-6320 Help for Windows
5.1.20 UcntGetLoadData
Description
The UcntGetLoadData function retrieves the preload data.
Syntax
C
INT UcntGetLoadData(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwLoadData
//
//
//
//
Device handle
Channel selection
Pointer to the variable to
retrieve preload data
);
Visual Basic
Declare Function UcntGetLoadData Lib
ByVal hDeviceHandle As Long,_
ByVal nChannel
As Long,_
ByRef pdwLoadData
As Long_
"IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Pointer to the variable to
‘ retrieve preload data
)As Long
Delphi
function UcntGetLoadData(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
var
Dword
// Pointer to the variable to
pdwLoadData:
// retrieve preload data
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwLoadData
Points to a variable to store the preload data in the range of 0 to
4294967295 (or 0 to FFFFFFFFh).
Return Value
The UcntGetLoadData function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
79
GPF-6320 Help for Windows
Example
Retrieving the preload data of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwLoadData;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetLoadData(hDeviceHandle, 1, &dwLoadData);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwLoadData As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetLoadData(hDeviceHandle, 1, dwLoadData)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwLoadData: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetLoadData(hDeviceHandle, 1, dwLoadData);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
80
GPF-6320 Help for Windows
5.1.21 UcntSetBaseClock
Description
The UcntSetBaseClock function configures the internal base clock.
Syntax
C
INT UcntSetBaseClock(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwClock
);
// Device handle
// Channel selection
// Internal base clock
Visual Basic
Declare Function UcntSetBaseClock Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwClock
As Long_
‘ Internal base clock
)As Long
Delphi
function UcntSetBaseClock(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwClock:
// Internal base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwClock
Specifies the internal base clock in the range of 0 to 16777215 (FFFFFFh).
dwClock
Base Clock Cycle
0
Stopped
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntSetBaseClock function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
81
GPF-6320 Help for Windows
Example
Configuring the internal base clock of channel 1 on the device whose device name is IFUCNT1 to 1 ms.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetBaseClock(hDeviceHandle, 1, 1000 * 10);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetBaseClock(hDeviceHandle, 1, 1000 * 10)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetBaseClock(hDeviceHandle, 1, 1000 * 10);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
82
GPF-6320 Help for Windows
5.1.22 UcntGetBaseClock
Description
The UcntGetBaseClock function retrieves the internal base clock.
Syntax
C
INT UcntGetBaseClock(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwClock
// Device handle
// Channel selection
// Pointer to variable to retrieve
// base clock
);
Visual Basic
Declare Function UcntGetBaseClock Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwClock
As Long_
‘ Pass by reference to variable
‘ to retrieve internal base clock
)As Long
Delphi
function UcntGetBaseClock(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pdwClock:
Dword
// Device handle
// Channel selection
// Pass by reference to variable
// to retrieve internal base clock
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwClock
Points to a variable to store the internal base clock in the range of 0 to 16777215
(FFFFFFh).
dwClock
Base Clock Cycle
0
Stopped
1
100 [ns]
.
.
.
.
.
.
16777215
1.6777215 [s]
Return Value
The UcntGetBaseClock function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
83
GPF-6320 Help for Windows
Example
Retrieving the internal base clock of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwClock;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetBaseClock(hDeviceHandle, 1, &dwClock);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwClock As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetBaseClock(hDeviceHandle, 1, dwClock)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwClock: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetBaseClock(hDeviceHandle, 1, dwClock);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
84
GPF-6320 Help for Windows
5.1.23 UcntSetTriggerConfig
Description
The UcntSetTriggerConfig function configures the trigger condition.
Syntax
C
INT UcntSetTriggerConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwTrgStart,
DWORD
dwTrgStop
);
//
//
//
//
Visual Basic
Declare Function UcntSetTriggerConfig
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByVal dwTrgStart
As Long,_
ByVal dwTrgStop
As Long_
)As Long
Device handle
Channel selection
Start trigger condition
Stop trigger condition
Lib "IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Start trigger condition
‘ Stop trigger condition
Delphi
function UcntSetTriggerConfig(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword;
dwTrgStart:
// Start trigger condition
Dword
dwTrgStop:
// Stop trigger condition
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwTrgStart
Specifies the start-trigger condition. If more than two condition is selected, use
OR operator.
Code
Description
IFUCNT_LA_R
Rising edge of LA
IFUCNT_LA_F
Falling edge of LA
IFUCNT_LB_R
Rising edge of LB
IFUCNT_LB_F
Falling edge of LB
dwTrgStop
Specifies the stop-trigger condition. If more than two condition is selected, use
OR operator.
Code
Description
IFUCNT_LA_R
Rising edge of LA
IFUCNT_LA_F
Falling edge of LA
IFUCNT_LB_R
Rising edge of LB
IFUCNT_LB_F
Falling edge of LB
Copyright 2004, 2014 Interface Corporation. All rights reserved.
85
GPF-6320 Help for Windows
Return Value
The UcntSetTriggerConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Configuring the trigger condition of channel 2 on the device whose device name is IFUCNT1 as follows:
- Start-trigger condition: Rising edge of LA
- Stop-trigger condition: Rising edge of LB
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetTriggerConfig(hDeviceHandle, 2, IFUCNT_LA_R,
IFUCNT_LB_F);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetTriggerConfig(hDeviceHandle, 2, IFUCNT_LA_R,
IFUCNT_LB_F)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetTriggerConfig(hDeviceHandle, 2, IFUCNT_LA_R,
IFUCNT_LB_F);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
86
GPF-6320 Help for Windows
5.1.24 UcntGetTriggerConfig
Description
The UcntGetTriggerConfig function retrieves the trigger condition.
Syntax
C
INT UcntGetTriggerConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwTrgStart,
PDWORD
pdwTrgStop
//
//
//
//
//
//
Device handle
Channel selection
Pointer to the variable to
retrieve start trigger condition
Pointer to the variable to
retrieve stop trigger condition
);
Visual Basic
Declare Function UcntGetTriggerConfig Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pdwTrgStart
As Long,_ ‘ Pass by reference to the variable
‘ to retrieve start trigger condition
ByRef pdwTrgStop
As Long_
‘ Pass by reference to the variable
‘ to retrieve stop trigger condition
)As Long
Delphi
function UcntGetTriggerConfig(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pdwTrgStart:
Dword;
// Device handle
// Channel selection
// Pass by reference to the variable
// to retrieve start trigger condition
var pdwTrgStop:
Dword
// Pass by reference to the variable
// to retrieve stop trigger condition
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
dwTrgStart
Points to a variable to store the start-trigger condition.
Code
Description
IFUCNT_LA_R
Rising edge of LA
IFUCNT_LA_F
Falling edge of LA
IFUCNT_LB_R
Rising edge of LB
IFUCNT_LB_F
Falling edge of LB
Copyright 2004, 2014 Interface Corporation. All rights reserved.
87
GPF-6320 Help for Windows
dwTrgStop
Points to a variable to store the stop-trigger condition.
Code
Description
IFUCNT_LA_R
Rising edge of LA
IFUCNT_LA_F
Falling edge of LA
IFUCNT_LB_R
Rising edge of LB
IFUCNT_LB_F
Falling edge of LB
Return Value
The UcntGetTriggerConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to theReturn Values.
Example
Retrieving the trigger condition of channel 2 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwTrgStart;
DWORD dwTrgStop;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetTriggerConfig(hDeviceHandle, 2, &dwTrgStart,
&dwTrgStop);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwTrgStart As Long
Dim dwTrgStop As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetTriggerConfig(hDeviceHandle, 2, dwTrgStart, dwTrgStop)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwTrgStart: Dword;
dwTrgStop: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetTriggerConfig(hDeviceHandle, 2, dwTrgStart, dwTrgStop);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
88
GPF-6320 Help for Windows
5.1.25 UcntSetTriggerChannel
Description
The UcntSetTriggerChannel function configures the trigger channel.
Syntax
C
INT UcntSetTriggerChannel(
HANDLE
hDeviceHandle,
INT
nChannel,
INT
nTrgChannel,
DWORD
dwTrgMode
);
//
//
//
//
Device handle
Channel selection
Trigger channel selection
Trigger mode
Visual Basic
Declare Function UcntSetTriggerChannel Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal nTrgChannel
As Long,_
‘ Trigger channel selection
ByVal dwTrgMode
As Long_
‘ Trigger mode
)As Long
Delphi
function UcntSetTriggerChannel(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Integer;
nTrgChannel:
// Trigger channel selection
Dword
dwTrgMode:
// Trigger mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwTrgChannel
Specifies the channel for trigger source.
dwTrgMode
Specifies the trigger mode.
Code
IFUCNT_TRG_NORMAL
IFUCNT_TRG_SINGLE
Description
Normal mode
(Start-trigger and stop-trigger are repeated.)
Single mode
(Start-trigger and stop-trigger are performed once.)
Return Value
The UcntSetTriggerChannel function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
89
GPF-6320 Help for Windows
Comment
The counter operation for specified channel can be controlled at the start/stop-trigger timing for the channel
specified by dwTrgChannel.
UcntSetTriggerChannel(hDeviceHandle, 1, 1, IFUCNT_TRG_NORMAL);
UcntSetTriggerChannel(hDeviceHandle, 2, 1, IFUCNT_TRG_NORMAL);
UcntSetTriggerChannel(hDeviceHandle, 3, 1, IFUCNT_TRG_NORMAL);
UcntSetTriggerChannel(hDeviceHandle, 4, 1, IFUCNT_TRG_NORMAL);
Above examples show that the start/stop-trigger condition for channel 1 is applied. The counter start and stop
can be controlled for channel 1 to channel 4 at the same time.
Example
Configuring the trigger channel of channel 1 on the device whose device name is IFUCNT1 as follows:
- Channel for trigger souce: Channel 1
- Trigger mode: Normal mode
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetTriggerConfig(hDeviceHandle, 4, IFUCNT_LA_R,
IFUCNT_LB_F);
nRet = UcntSetTriggerChannel(hDeviceHandle, 1, 4, IFUCNT_TRG_NORMAL);
nRet = UcntSetTriggerChannel(hDeviceHandle, 2, 4, IFUCNT_TRG_NORMAL);
nRet = UcntSetTriggerChannel(hDeviceHandle, 3, 4, IFUCNT_TRG_NORMAL);
nRet = UcntSetTriggerChannel(hDeviceHandle, 4, 4, IFUCNT_TRG_NORMAL);
:
:
nRet = UcntStartCount(hDeviceHandle, 0x08, IFUCNT_CMD_EXWAIT);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetTriggerConfig(hDeviceHandle,
IFUCNT_LB_F)
nRet = UcntSetTriggerChannel(hDeviceHandle,
nRet = UcntSetTriggerChannel(hDeviceHandle,
nRet = UcntSetTriggerChannel(hDeviceHandle,
nRet = UcntSetTriggerChannel(hDeviceHandle,
:
:
nRet = UcntStartCount(hDeviceHandle, &H08,
Copyright 2004, 2014 Interface Corporation. All rights reserved.
90
4, IFUCNT_LA_R,
1,
2,
3,
4,
4,
4,
4,
4,
IFUCNT_TRG_NORMAL)
IFUCNT_TRG_NORMAL)
IFUCNT_TRG_NORMAL)
IFUCNT_TRG_NORMAL)
IFUCNT_CMD_EXWAIT)
GPF-6320 Help for Windows
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetTriggerConfig(hDeviceHandle, 4, IFUCNT_LA_R,
IFUCNT_LB_F);
nRet := UcntSetTriggerChannel(hDeviceHandle, 1, 4, IFUCNT_TRG_NORMAL);
nRet := UcntSetTriggerChannel(hDeviceHandle, 2, 4, IFUCNT_TRG_NORMAL);
nRet := UcntSetTriggerChannel(hDeviceHandle, 3, 4, IFUCNT_TRG_NORMAL);
nRet := UcntSetTriggerChannel(hDeviceHandle, 4, 4, IFUCNT_TRG_NORMAL);
:
:
nRet := UcntStartCount(hDeviceHandle, $08, IFUCNT_CMD_EXWAIT);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
91
GPF-6320 Help for Windows
5.1.26 UcntGetTriggerChannel
Description
The UcntSetTriggerChannel function retrieves the trigger channel.
Syntax
C
INT UcntGetTriggerChannel(
HANDLE
hDeviceHandle,
INT
nChannel,
PINT
pnTrgChannel,
PDWORD
//
//
//
//
//
//
//
pdwTrgMode
Device handle
Channel selection
Pointer to the
variableto retrieve
trigger channel
Pointer to the variable to
variableto retrieve trigger mode
);
Visual Basic
Declare Function UcntGetTriggerChannel Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pnTrgChannel
As Long,_ ‘ Pass by reference to
‘ to retrieve trigger
ByRef pdwTrgMode
As Long_
‘ Pass by reference to
‘ to retrieve trigger
)As Long
the variable
channel
the variable
mode
Delphi
function UcntGetTriggerChannel(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pnTrgChannel:
Integer;
// Device handle
// Channel selection
// Pass by reference to the variable
// to retrieve trigger channel
var pdwTrgMode:
Dword
// Pass by reference to the variable
// to retrieve trigger mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
nTrgChannel
Points to a variable to store the channel for trigger source.
dwTrgMode
Points to a variable to store the trigger mode.
Code
Description
IFUCNT_TRG_NORMAL Normal mode
(Start-trigger and stop-trigger are repeated.)
IFUCNT_TRG_SINGLE
Single mode
(Start-trigger and stop-trigger are performed once.)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
92
GPF-6320 Help for Windows
Return Value
The UcntGetTriggerChannel function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the trigger channel condition of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
INT nTrgChannel;
DWORD dwTrgMode;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetTriggerChannel(hDeviceHandle, 1, &nTrgChannel,
&dwTrgMode);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim nTrgChannel As Long
Dim dwTrgMode As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetTriggerChannel(hDeviceHandle, 1, nTrgChannel, dwTrgMode)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
nTrgChannel: Integer;
dwTrgMode: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetTriggerChannel(hDeviceHandle, 1, nTrgChannel,
dwTrgMode);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
93
GPF-6320 Help for Windows
5.1.27 UcntSetComparatorConfig
Description
The UcntSetComparatorConfig function configures the condition of matching detection.
Syntax
C
INT UcntSetComparatorConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwCmpChSel,
DWORD
dwOUTAConfig,
DWORD
//
//
//
//
//
//
//
dwOUTBConfig
Device handle
Channel selection
Channel condition(OUTA)
matching detection condition
(OUTA)
matching detection condition
(OUTB)
);
Visual Basic
Declare Function UcntSetComparatorConfig Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByVal dwCmpChSel
As Long,_ ‘ Channel condition(OUTA)
ByVal dwOUTAConfig
As Long,_ ‘ matching detection condition
‘ (OUTA)
ByVal dwOUTBConfig
As Long_
‘ matching detection condition
‘ (OUTB)
)As Long
Delphi
function UcntSetComparatorConfig(
THandle;
hDeviceHandle:
Integer;
nChannel:
Dword;
dwCmpChSel:
Dword;
dwOUTAConfig:
// Device handle
// Channel selection
// Channel condition(OUTA)
// matching detection condition
// (OUTA)
Dword
dwOUTBConfig:
// matching detection condition
// (OUTB)
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
94
GPF-6320 Help for Windows
dwCmpChSel
Specifies the channel to use the condition of matching detection.
bit31 to bit4
Bit
bit3
bit2
bit1
Description
Reserved
AEQCH4 AEQCH3 AEQCH2
bit0
AEQCH1
AEQCH1 to AEQCH4: Specifies the channel condition setting.
AEQCH4 AEQCH3 AEQCH2
AEQCH1
Description
0
0
0
0
Forbidden
Comparison matching
0
0
0
1
condition for channel 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
AND condition of
comparison matching
1
1
1
1
condition for channel 1 to
channel 4
Note: The condition of matching detection specified by the
UcntSetComparatorConfig function is valid for only OUTA.
dwOUTAConfig
Specifies the condition of matching detection for OUTA.
bit
bit31 to bit6 bit5 bit4 bit3
bit7
AEQ AEQ AEQ AEQ
Description Reserved
1
0
T
LD
bit2
bit1
bit0
AEQ
OP2
AEQ
OP1
AEQ
OP0
AEQOP0 to AEQOP2: Specifies the output form.
AEQOP2
AEQOP1
AEQOP0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
Description
The output for matching detection is
invalid.
While the condition is satisfied, the
low-level output is operated.
While the condition is satisfied, the
high-level output is operated.
1 us (low pulse)
10 us (low pulse)
100 us (low pulse)
Low latch output
High latch output
AEQLD: Specifies the preload setting at the matching detection.
AEQLD
Description
0
Not use the preload.
1
Uses the preload.
AEQT: Specifies the comparison timing.
AEQT
Description
0
The comparison is always performed.
The comparison is performed when latching to the read
1
register.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
95
GPF-6320 Help for Windows
AEQ0, AEQ1: Specifies the comparison condition.
AEQ1 AEQ0
Description
0
0
Counter value = Comparison register A
0
1
Counter value <= Comparison register A
1
0
Counter value <= Comparison register A
1
1
Comparison register A < Counter value < Comparison
register B
dwOUTBConfig
Specifies the condition of matching detection for OUTB.
bit31 to bit7 bit6
Bit
bit5
bit4
bit3 bit2 bit1 bit0
BEQ BEQ BEQ BEQ
Description Reserved BEQ1 BEQ0 BEQT
LD OP2 OP1 OP0
BEQOP0 to BEQOP2: Specifies the output form.
BEQOP2
BEQOP1
BEQOP0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
Description
The output for matching detection is
invalid.
While the condition is satisfied, the
low-level output is operated.
While the condition is satisfied, the
high-level output is operated.
1 us (low pulse)
10 us (low pulse)
100 us (low pulse)
Low latch output
High latch output
BEQLD: Specifies the preload setting at the matching detection.
BEQLD
Description
0
Not use the preload.
1
Uses the preload.
BEQT: Specifies the setting of comparison timing.
BEQT
Description
0
The comparison is always performed.
The comparison is performed when latching to the read
1
register.
BEQ0, BEQ1: Specifies the comparison condition setting.
BEQ1 BEQ0
Description
0
0
Counter value = Comparison register B
0
1
Counter value <= Comparison register B
1
0
Counter value => Comparison register B
Comparison register A <= Counter value <= Comparison register B
1
1
Return Value
The UcntSetComapratorConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
96
GPF-6320 Help for Windows
Example
Configuring the conditin of matching detection of channel 1 on the device whose device name is IFUCNT1 as
follows:
- OUTA: The condition for channel 1 is applied.
- Output form: Low level output when the comparision counter value and comparison register A matches.
- OUTB: No detection
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetComparatorConfig(hDeviceHandle, 1, 0x1, 0x01, 0x00);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetComparatorConfig(hDeviceHandle, 1, &H1, &H01, &H00)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetComparatorConfig(hDeviceHandle, 1, $1, $01, $00);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
97
GPF-6320 Help for Windows
5.1.28 UcntGetComparatorConfig
Description
The UcntGetComparatorConfig function retrieves the condition of matching detection.
Syntax
C
INT UcntGetComparatorConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwCmpChSel,
PDWORD
pdwOUTAConfig,
PDWORD
pdwOUTBConfig
// Device handle
// Channel selection
// Pointer to the variable to retrieve
// channel condition(OUTA)
//Pointer to the variable to retrieve
// matching detection condition
(OUTA)
// Pointer to the variable to retrieve
// matching detection condition
(OUTB)
);
Visual Basic
Declare Function UcntGetComparatorConfig Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_ ‘ Device handle
ByVal nChannel
As Long,_ ‘ Channel selection
ByRef pdwCmpChSel
As Long,_ ‘ Pass by reference to the
‘ variable to retrieve channel
‘ condition(OUTA)
ByRef pdwOUTAConfig
As Long,_ ‘ Pass by reference to the
‘ variable to retrieve matching
‘ detection condition (OUTA)
ByRef pdwOUTBConfig
As Long_
‘ Pass by reference to the
‘ variable to retrieve matching
‘ detection condition (OUTB)
)As Long
Delphi
function UcntGetComparatorConfig(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pdwCmpChSel:
Dword;
// Device handle
// Channel selection
// Pass by reference to the
// variable to retrieve channel
// condition(OUTA)
var pdwOUTAConfig: Dword;
// Pass by reference to the
// variable to retrieve matching
// detection condition (OUTA)
var pdwOUTBConfig: Dword
// Pass by reference to the
// variable to retrieve matching
// detection condition (OUTB)
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
98
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
dwCmpChSel
Points to a variable to receive the channel to use the condition of matching
detection.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Description
Reserved
AEQCH4 AEQCH3 AEQCH2 AEQCH1
AEQCH1 to AEQCH4: Retrieves the channel condition.
AEQCH4
AEQCH3
AEQCH2
AEQCH1
0
0
0
0
Description
Forbidden
Comparison matching condition
0
0
0
1
for channel 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
AND condition of comparison
1
1
1
1
matching condition for channel
1 to channel 4
Note: The condition of matching detection specified by the
UcntSetComparatorConfig function is valid for only OUTA.
dwOUTAConfig
Points to a variable to store the condition of matching detection for OUTA.
bit31 to bit7 bit6
bit
bit5
bit4
bit3
bit2
bit1
bit0
Description
Reserved AEQ1 AEQ0
AEQ
T
AEQ
LD
AEQ
OP2
AEQ
OP1
AEQOP0 to AEQOP2: Retrieves the output form.
AEQOP2
AEQOP1
AEQOP0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
Description
The output for matching detection was
invalid.
While the condition was satisfied, the
low-level output was operated.
While the condition was satisfied, the
high-level output was operated.
1 us (low pulse)
10 us (low pulse)
100 us (low pulse)
Low latch output
High latch output
AEQLD: Retrieves the preload setting at the matching detection.
AEQLD
Description
0
Not use the preload.
1
Uses the preload.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
99
AEQ
OP0
GPF-6320 Help for Windows
AEQT: Retrieves the comparison timing.
AEQT
Description
0
The comparison was always performed.
1
The comparison was performed when latching to the read register.
AEQ0, AEQ1: Retrieves the comparison condition.
AEQ1 AEQ0
Description
0
0
Counter value = Comparison register A
0
1
Counter value <= Comparison register A
1
0
Counter value => Comparison register A
Comparison register A <= Counter value <= Comparison register B
1
1
dwOUTBConfig
Points to a variable to store the condition of matching detection for
OUTB.
bit31 to bit7
Bit
bit6
bit5
bit4
bit3 bit2 bit1 bit0
BEQ BEQ BEQ BEQ
Description Reserved BEQ1 BEQ0 BEQT
LD OP2 OP1 OP0
BEQOP0 to BEQOP2: Retrieves the output form.
BEQOP2
BEQOP1
BEQOP0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
Description
The output for matching detection was
invalid.
While the condition was satisfied, the
low-level output was operated.
While the condition was satisfied, the
high-level output was operated.
1 us (low pulse)
10 us (low pulse)
100 us (low pulse)
Low latch output
High latch output
BEQLD: Retrieves the preload setting at the matching detection.
BEQLD
Description
0
Not use the preload.
1
Uses the preload.
BEQT: Retrieves the comparison timing.
BEQT
Description
0
The comparison was always performed.
1
The comparison was performed when latching to the read register.
BEQ0, BEQ1: Retrieves the comparison condition.
BEQ1 BEQ0
Description
0
0
Counter value = Comparison register B
0
1
Counter value <= Comparison register B
1
0
Counter value => Comparison register B
Comparison register A <= Counter value <= Comparison register B
1
1
Copyright 2004, 2014 Interface Corporation. All rights reserved.
100
GPF-6320 Help for Windows
Return Value
The UcntGetComapratorConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the condition of matching detection of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCmpChSel;
DWORD dwOUTAConfig;
DWORD dwOUTBConfig;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetComparatorConfig(hDeviceHandle, 1, &dwCmpChSel,
&dwOUTAConfig,
&dwOUTBConfig);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCompChannel As Long
Dim dwOUTAConfig As Long
Dim dwOUTBConfig As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetComparatorConfig(hDeviceHandle, 1, dwCmpChSel,
dwOUTAConfig, dwOUTBChannel)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCompChannel: Dword;
dwOUTAConfig: Dword;
dwOUTBConfig: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetComparatorConfig(hDeviceHandle, 1, dwCmpChSel,
dwOUTAConfig,
dwOUTBChannel);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
101
GPF-6320 Help for Windows
5.1.29 UcntSetFilter
Description
The UcntSetFilter function configures the digital filter.
Syntax
C
INT UcntSetFilter(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwFilter
);
// Device handle
// Channel selection
// Digital filter
Visual Basic
Declare Function UcntSetFilter Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwFilter
As Long_
‘ Digital filter
)As Long
Delphi
function UcntSetFilter(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwFilter:
// Digital filter
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen
function.
nChannel
Specifies the channel to configure.
dwFilter
Specifies the digital filter value.
Bit
Description
bit15
FCLK
bit14
FCNT
14
bit13
FCNT
13
bit12
FCNT
12
bit11
FCNT
11
bit10
FCNT
10
bit9
FCNT
9
bit8
FCNT
8
Bit
bit7
bit6
Description FCNT FCNT
7
6
bit5
FCNT
5
bit4
FCNT
4
bit3
FCNT
3
bit2
FCNT
2
bit1
FCNT
1
bit0
FCNT
0
FCLK: Specifies the base clock for the digital filter.
FCNT0 to FCNT14: Specifies the number of count for the digital filter.
Base clock
0
1
The number of counts
FCLK
100 (ns)
10 (us)
FCNT0 to FCNT14
0
Stopped
Stopped
1
100 (ns)
10 (us)
2
200 (ns)
20 (us)
.
.
.
.
.
.
.
.
.
32,767
3.2767 (ms)
327.67 (ms)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
102
GPF-6320 Help for Windows
Return Value
The UcntSetFilter function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Example
Configuring the digital filter (filter cycle: 1 ms) of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetFilter(hDeviceHandle, 1, 0x8064);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetFilter(hDeviceHandle, 1, &H8064)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet = UcntSetFilter(hDeviceHandle, 1, $8064);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
103
GPF-6320 Help for Windows
5.1.30 UcntGetFilter
Description
The UcntGetFilter function retrieves the digital filter.
Syntax
C
INT UcntGetFilter(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwFilter
//
//
//
//
Device number
Retrieved channel
Pointer to the variable
to retrieve digital filter
);
Visual Basic
Declare Function UcntGetFilter Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle, As Long,_
‘ Device number
ByVal nChannel,
As Long,_
‘ Retrieved channel
ByRef pdwFilter
As Long_
‘ Pass by reference to the
‘ variable to
‘ retrieve digital filter
)As Long
Delphi
function UcntGetFilter(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pdwFilter:
Dword
// Device number
// Retrieved channel
// Pass by reference to the
// variable to
// retrieve digital filter
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwFilter
Points to a variable to store the digital filter value.
Bit
Description
bit15
FCLK
bit14
FCNT
14
bit13
FCNT
13
bit12
FCNT
12
bit11
FCNT
11
bit10
FCNT
10
bit9
FCNT
9
bit8
FCNT
8
Bit
Description
bit7
FCNT
7
bit6
FCNT
6
bit5
FCNT
5
bit4
FCNT
4
bit3
FCNT
3
bit2
FCNT
2
bit1
FCNT
1
bit0
FCNT
0
Copyright 2004, 2014 Interface Corporation. All rights reserved.
104
GPF-6320 Help for Windows
FCLK: Retrieves the base clock for the digital filter.
FCNT0 to FCNT14: Retrieves the number of count for the digital filter.
Base clock
0
1
The number of counts
FCLK
100 (ns)
10 (us)
FCNT0 to FCNT14
0
Stop
Stop
1
100 (ns)
10 (us)
2
200 (ns)
20 (us)
.
.
.
.
.
.
.
.
.
32,767
3.2767 (ms)
327.67 (ms)
Return Value
The UcntGetFilter function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
105
GPF-6320 Help for Windows
Example
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwFilter;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetFilter(hDeviceHandle, 1, &dwFilter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwFilter As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetFilter(hDeviceHandle, 1, dwFilter)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwFilter: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetFilter(hDeviceHandle, 1, dwFilter);
Retrieve the digital filter of channel 1 on the device whose device name is IFUCNT1.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
106
GPF-6320 Help for Windows
5.1.31 UcntSetLatchMode
Description
The UcntSetLatchMode function configures the latch mode.
Syntax
C
INT UcntSetLatchMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwLatchMode
);
// Device handle
// Channel selection
// Latch mode
Visual Basic
Declare Function UcntSetLatchMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwLatchMode
As Long_
‘ Latch mode
)As Long
Delphi
function UcntSetLatchMode(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwLatchMode:
// Latch mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
pdwFilter
Specifies the setting value of the latch mode.
Bit
Description
Bit31 through bit16
Reserved
Bit
Description
bit15
SYNC
2
bit14
SYNC
1
bit13
bit12
Reserved
bit11
C/B
bit10
PEAK
Bit
bit7
CKL
LOAD
bit6
bit5
bit4
EXL Reserved CKL
LOAD
bit3
LBF
LT
bit2
LBR
LT
Description
* SUNC1 and SYNC2 are applicable only to the PCI-632302.
* PEAK and C/B are configurable only in the PCI-632304.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
107
bit9
bit8
Reserved
bit1
LAF
LT
bit0
LAR
LT
GPF-6320 Help for Windows
LARLT: Retrieves the latch setting at the rising edge of LA
LAFLT: Retrieves the latch setting at the falling edge of LA
LBRLT: Retrieves the latch setting at the rising edge of LB
LBFLT: Retrieves the latch setting at the falling edge of LB
LBFLT, LBRLT, LAFLT, LARLT
Description
0
Disabled
1
Enabled
CKL: Specifies the latch setting by an internal base clock
CKL
Description
0
Disabled
1
Enabled
EXLLOAD: Specifies the counterload setting after external latch.
EXLLOAD
Description
0
Unloaded
1
Loaded
CKLLOAD: Specifies the counterload setting after internal base clock
latch
CKLLOAD
Description
0
Unloaded
1
Loaded
PEAK: Specifies the latch setting at peak hold (when the rotation
direction changes)
* applicable only to the PCI-632304
PEAK
Description
0
Unloaded
1
Loaded
C/B: Specifies the latch setting by carry/borrow occurrence
* applicable only to the PCI-632304
C/B
Description
0
Disabled
1
Enabled
SYNC1: Specifies the latch setting by internal synchronous line 1
* applicable only to the PCI-632302
SYNC1
Description
0
Disabled
1
Enabled
SYNC2: Specifies the latch setting by internal synchronous line 2
* applicable only to the PCI-632302
SYNC2
Description
0
Disabled
1
Enabled
Copyright 2004, 2014 Interface Corporation. All rights reserved.
108
GPF-6320 Help for Windows
Return Value
The UcntSetLatchMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Configuring the latch mode of the channel 1 on the device whose device name is IFUCNT1 (latch by
carry/borrow occurrence)
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetLatchMode(hDeviceHandle, 1, 0x800);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetLatchMode(hDeviceHandle, 1, &H800)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet = UcntSetLatchMode(hDeviceHandle, 1, $800);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
109
GPF-6320 Help for Windows
5.1.32 UcntGetLatchMode
Description
The UcntGetLatchMode function retrieves the latch mode.
Syntax
C
INT UcntGetLatchMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwLatchMode
//
//
//
//
Device number
Retrieved channel
Pointer to the variable to retrieve
latch mode
);
Visual Basic
Declare Function UcntGetLatchMode Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle, As Long,_
‘ Device number
ByVal nChannel,
As Long,_
‘ Retrieved channel
ByRef pdwLatchMode
As Long_
‘ Pass by reference to the
‘ variable to retrieve latch mode
)As Long
Delphi
function UcntGetLatchMode(
THandle;
hDeviceHandle:
// Device number
Integer;
nChannel:
// Retrieved channel
var
Dword
// Pass by reference to the
pdwLatchMode:
// variable to retrieve latch mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve the setting information.
pdwLatchMode
Point to the variable to retrieve the setting value of the latch mode.
The following table shows the stored values.
Bit
Description
Bit
Description
Bit
Bit31 through bit16
Reserved
bit15
SYNC
2
bit7
CKL
Description
LOAD
bit14
SYNC
1
bit13
bit12
Reserved
bit11
C/B
bit10
PEAK
bit6
bit5
bit4
EXL Reserved CKL
LOAD
bit3
LBF
LT
bit2
LBR
LT
Copyright 2004, 2014 Interface Corporation. All rights reserved.
110
bit9
bit8
Reserved
bit1
LAF
LT
bit0
LAR
LT
GPF-6320 Help for Windows
LARLT: Retrieves the latch setting at the rising edge of LA
LAFLT: Retrieves the latch setting at the falling edge of LA
LBRLT: Retrieves the latch setting at the rising edge of LB
LBFLT: Retrieves the latch setting at the falling edge of LB
LBFLT, LBRLT, LAFLT, LARLT
Description
0
Disabled
1
Enabled
CKL: Retrieves the latch setting by an internal base clock
CKL
Description
0
Disabled
1
Enabled
EXLLOAD: Retrieves the counterload setting after external latch.
EXLOAD
Description
0
Unloaded
1
Loaded
CKLLOAD: Retrieves the counterload setting after internal base
clock latch
CKLLOAD
Description
0
Unloaded
1
Loaded
PEAK: Retrieves the latch setting at peak hold (when the rotation
direction changes)
PEAK
Description
0
Unloaded
1
Loaded
C/B: Retrieves the latch setting by carry/borrow occurrence
C/B
Description
0
Disabled
1
Enabled
SYNC1: Retrieves the latch setting by internal synchronous line 1
SYNC1
Description
0
Disabled
1
Enabled
SYNC2: Retrieves the latch setting by internal synchronous line 2
SYNC2
Description
0
Disabled
1
Enabled
Return Value
The UcntGetLatchMode function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
111
GPF-6320 Help for Windows
Example
Retrieving the latch mode of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwLatchMode;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetLatchMode(hDeviceHandle, 1, &dwLatchMode);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwLatchMode As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetLatchMode(hDeviceHandle, 1, dwLatchMode)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwLatchMode: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetLatchMode(hDeviceHandle, 1, dwLatchMode);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
112
GPF-6320 Help for Windows
5.1.33 UcntSetCounter
Description
The UcntSetCounter function configures the counter value.
Syntax
C
INT UcntSetCounter(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwCounter
// Device handle
// Channel selection
// Pointer to the array to store
// preload data
);
Visual Basic
Declare Function UcntSetCounter Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_
‘ Device handle
ByVal dwChSel
As Long,_
‘ Channel selection
ByRef pdwCounter
As Long_
‘ Pass by reference to the array
‘ to store preload data
)As Long
Delphi
function UcntSetCounter(
hDeviceHandl THandle;
// Device handle
e:
Dword;
dwChSel:
// Channel selection
var
Dword
// Pass by reference to the array
pdwCounter:
// to store preload data
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
dwChSel
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be set at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Description
Reserved
CH4
CH3
CH2
CH1
pdwCounter
Points to an array to store the preload data.
dwCounter[0] to dwCounter[3]: Preload data for channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The UcntSetCounter function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
113
GPF-6320 Help for Windows
Example
Configuring the counter value of channel 1 to channel 4 on the device whose device name is IFUCNT1 to 100
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCounter[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
.
.
.
dwCounter[0] = 100;
dwCounter[1] = 100;
dwCounter[2] = 100;
dwCounter[3] = 100;
nRet = UcntSetCounter(hDeviceHandle, 0x0F, dwCounter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCounter(0 To 3) As Long
lpszName = “IFUCNT1” & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
.
.
.
dwCounter(0) = 100;
dwCounter(1) = 100;
dwCounter(2) = 100;
dwCounter(3) = 100;
nRet = UcntSetCounter(hDeviceHandle, &H0F, dwCounter(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCounter: Array[0..3] of Dword;
lpszName := ‘IFUCNT1’;
hDeviceHandle := UcntOpen(lpszName);
.
.
.
dwCounter[0] := 100;
dwCounter[1] := 100;
dwCounter[2] := 100;
dwCounter[3] := 100;
nRet := UcntSetCounter(hDeviceHandle, $0F, dwCounter[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
114
GPF-6320 Help for Windows
5.1.34 UcntReadCounter
Description
The UcntReadCounter function retrieves the counter value.
Syntax
C
INT UcntReadCounter(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwCounter
//
//
//
//
Device handle
Channel selection
Pointer to the array to store
counter value
);
Visual Basic
Declare Function UcntReadCounter Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_
‘ Device handle
ByVal dwChSel
As Long,_
‘ Channel selection
ByRef pdwCounter
As Long_
‘ Pass by reference to store
‘ counter value
)As Long
Delphi
function UcntReadCounter(
THandle;
hDeviceHandle:
Dword;
dwChSel:
var pdwCounter:
Dword
// Device handle
// Channel selection
// Pass by reference to the array
// to store counter value
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
dwChSel
Specifies the channel to retrieve. The value 1 is specified to the
corresponding bit. Multiple channels can be retrieved at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Channel
4
Channel
3
Channel
2
Channel
1
Description
Reserved
pdwCounter
Points to an array to store the preload data.
dwCounter[0] to dwCounter[3]: Preload data for channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The UcntReadCounter function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
115
GPF-6320 Help for Windows
Example
Retrieving the counter value of channel 1 to channel 4 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCounter[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntReadCounter(hDeviceHandle, 0x0F, dwCounter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCounter(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntReadCounter(hDeviceHandle, &H0F, dwCounter(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCounter: Array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntReadCounter(hDeviceHandle, $0F, dwCounter[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
116
GPF-6320 Help for Windows
5.1.35 UcntReadLatchCounter
Description
The UcntReadLatchCounter function retrieves the latch counter value.
Syntax
C
INT UcntReadLatchCounter(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwLatchCounter
//
//
//
//
Device handle
Channel selection
Pointer to the array to store
latch counter value
);
Visual Basic
Declare Function UcntReadLatchCounter
ByVal hDeviceHandle
As Long,_
ByVal dwChSel
As Long,_
ByRef pdwLatchCounter As Long_
Lib "IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Pass by reference to the array
‘ to store latch counter value
)As Long
Delphi
function UcntReadLatchCounter(
THandle;
hDeviceHandle:
// Device handle
Dword;
dwChSel:
// Channel selection
var
Dword
// Pass by reference to the array
pdwLatchCounter:
// to store latch counter value
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to retrieve. 1 returned to the corresponding bit.
Multiple channels can be retrieved at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Channel
4
Channel
3
Channel
2
Channel
1
Description
Reserved
pdwLatchCounter Points to an array to store the latch counter value.
dwCounter[0] to dwCounter[3]: latch counter value for channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The UcntReadLatchCounter function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
117
GPF-6320 Help for Windows
Example
Retrieving the latch counter value of channel 1 to channel 4 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwLatchCounter[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntReadCounter(hDeviceHandle, 0x0F, dwLatchCounter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwLatchCounter(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntReadCounter(hDeviceHandle, &H0F, dwLatchCounter(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwLatchCounter: Array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
nRet := UcntReadCounter(hDeviceHandle, $0F, dwLatchCounter[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
118
GPF-6320 Help for Windows
5.1.36 UcntSetComparator
Description
The UcntSetComparator function configures the comparison reference counter value.
Syntax
C
INT UcntSetComparator(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwComSel,
PDWORD
pdwComparatorA,
PDWORD
pdwComparatorB
//
//
//
//
//
//
//
Device handle
Channel selection
Comparator selection
Pointer to the array to store
comparison reference counter A value
Pointer to the array to store
comparison reference counter B value
);
Visual Basic
Declare Function UcntSetComparator Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_ ‘ Device handle
ByVal dwChSel
As Long,_ ‘ Channel selection
ByVal dwCmpSel
As Long,_ ‘ Comparator selection
ByRef pdwComparatorA As Long,_ ‘ Pass by reference to the array
‘ to store comparison reference
‘ counter A value
ByRef pdwComparatorB As Long_
‘ Pass by reference to the array to
‘ store comparison reference
‘ counter B value
)As Long
Delphi
function UcntSetComparator(
THandle;
hDeviceHandle:
// Device handle
Dword;
dwChSel:
// Channel selection
Dword;
dwCmpSel:
// Comparator selection
var
Dword;
// Pointer to the array to store
pdwComparatorA:
// comparison reference counter A value
var
Dword
// Pass by reference to the array to store
pdwComparatorB:
// comparison reference counter B value
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
119
GPF-6320 Help for Windows
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be specified at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Channel 4 Channel 3 Channel 2 Channel 1
Description
Reserved
dwCmpSel
Specifies the comparator to configure.
dwCmpSel
Description
0
Specifies the comparator for the comparison counter A and B.
1
Specifies the comparator for the sub-comparison counter A and B.
When 1 is specified to dwCmpSel, the comparison counter setting does not
change immediately. The comparison counter value will be changed after
performing the matching detection of current setting value.
pdwComparatorA
Points to comparison counter A or an array to store the setting value.
dwCounter[0] to dwCounter[3]: Comparison counter A setting value for
channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
pdwComparatorB
Points to an array to store the comparison counter B setting value.
dwCounter[0] to dwCounter[3]: Comparison counter B setting value for
channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The UcntSetComparator function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
120
GPF-6320 Help for Windows
Example
Configuring the comparison counter value of channel 1 on the device whose device name is IFUCNT1 as
follows:
- Comparison counter value A: 100
- Comparison counter value B: 200
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwComparatorA[4];
DWORD dwComparatorB[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
dwComparatorA[0] = 100;
dwComparatorB[0] = 200;
nRet = UcntSetComparator(hDeviceHandle, 0x01, 0, dwComparatorA,
dwComparatorB);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwComparatorA(0 To 3) As Long
Dim dwComparatorB(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
dwComparatorA(0) = 100;
dwComparatorB(0) = 200;
nRet = UcntSetComparator(hDeviceHandle, &H01, 0, dwComparatorA(0),
dwComparatorB(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwComparatorA: Array[0..3] of Dword;
dwComparatorB: Array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
dwComparatorA[0] := 100;
dwComparatorB[0] := 200;
nRet := UcntSetComparator(hDeviceHandle, $01, 0,
dwComparatorA[0], dwComparatorB[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
121
GPF-6320 Help for Windows
5.1.37 UcntGetComparator
Description
The UcntGetComparator function retrieves the comparison reference counter value.
Syntax
C
INT UcntGetComparator(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwComparatorA,
PDWORD
//
//
//
//
//
//
//
//
pdwComparatorB
Device handle
Channel selection
Pointer to the array to store
comparison reference counter
A value
Pointer to the array to store
comparison reference counter
B value
);
Visual Basic
Declare Function UcntGetComparator Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_ ‘ Device handle
ByVal dwChSel
As Long,_ ‘ Channel selection
ByRef pdwComparatorA As Long,_ ‘ Pass by reference to the array
‘ to store comparison reference
‘ counter A value
ByRef pdwComparatorB As Long_
‘ Pass by reference to the array
‘ to store comparison reference
‘ counter B value
)As Long
Delphi
function UcntGetComparator(
THandle;
hDeviceHandle:
Dword;
dwChSel:
var
Dword;
pdwComparatorA:
// Device handle
// Channel selection
// Pointer to the array to store
// comparison reference counter
// A value
var
Dword
// Pass by reference to the array
pdwComparatorB:
// to store comparison reference
// counter B value
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to retrieve. The value 1 is specified to the corresponding
bit. Multiple channels can be retrieved at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Channel 4 Channel 3 Channel 2 Channel 1
Description
Reserved
Copyright 2004, 2014 Interface Corporation. All rights reserved.
122
GPF-6320 Help for Windows
pdwComparatorA
Points to an array to store the comparison counter A setting value.
dwCounter[0] to dwCounter[3]: Comparison counter A setting value for
channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
pdwComparatorB
Points to an array to store the comparison counter B setting value.
dwCounter[0] to dwCounter[3]: Comparison counter B setting value for
channel 1 to channel 4
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The UcntGetComparator function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
123
GPF-6320 Help for Windows
Example
Retrieving the comparison counter value of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwComparatorA[4];
DWORD dwComparatorB[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetComparator(hDeviceHandle, 0x01, dwComparatorA,
dwComparatorB);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwComparatorA(0 To 3) As Long
Dim dwComparatorB(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetComparator(hDeviceHandle, &H01, dwComparatorA(0),
dwComparatorB(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwComparatorA: Array[0..3] of Dword;
dwComparatorB: Array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetComparator(hDeviceHandle, $01, dwComparatorA[0],
dwComparatorB[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
124
GPF-6320 Help for Windows
5.1.38 UcntGetStaus
Description
The UcntGetStatus function retrieves the motion status.
Syntax
C
INT UcntGetStatus(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwStatus
//
//
//
//
Device handle
Channel selection
Pointer to the array to
store status
);
Visual Basic
Declare Function UcntGetStatus Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long,_
dwChSel
‘ Channel selection
ByRef
As Long_
pdwStatus
‘ Pass by reference to the
‘ array to store status
)As Long
Delphi
function UcntGetStatus(
THandle;
hDeviceHandle:
Dword;
dwChSel:
var pdwStatus:
Dword
// Device handle
// Channel selection
// Pass by reference to the
// array to store status
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
dwChSel
Specifies the channel to retrieve. 1 is returned to the corresponding bit.
Multiple channels can be retrieved at the same time.
bit31 to bit4
Bit
bit3
bit2
bit1
bit0
Channel 4 Channel 3 Channel 2 Channel 1
Description
Reserved
pdwStatus
Points to an array to store the counter status.
dwStatus[0] to dwStatus[3]: Counter status for channel 1 to channel 4.
Bit
bit31 through bit20
bit19
bit18
bit17
bit16
Description
Reserved
BL
CL
ItoR
RtoI
Bit
bit15
bit14
bit13
Description Reserved LTST2
LTST1
bit12
bit11
LTST0 LBAFT
bit10
bit9
bit8
LAAFT LBBEF LABEF
Bit
bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
Description
ST1
ST0
U/D
LB
LA
Z
B
A
Copyright 2004, 2014 Interface Corporation. All rights reserved.
125
GPF-6320 Help for Windows
A, B, LA, LB, Z: Status of input pin
A, B, LA, LB, Z
Description
0
Low
1
High
U/D: Count direction
U/D
Description
0
Downward
1
Upward
ST0, ST1: Start/stop status
ST1
ST0
Description
0
0
Stop
0
1
Start
1
0
Wait for external start
1
1
Unused
LABEF, LBBEF: LA and LB statuses before the external latch
LBBEF, LABEF
Description
0
Low
1
High
LAAFT, LBAFT: LA and LB statuses after the external latch
LAAFT, LBAFT
Description
0
Low
1
High
LTST0, LTST1: Latch status
LTST2 LTST1 LTST0
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
Description
No latch
Soft latch
External latch
Internal base clock latch
Internal synchronous line 1 latch
Internal synchronous line 2 latch
Reserved
Reserved
Rtol: Latch by the rotative direction change from positive (count-up) to
negative (count-down) rotation
* can be retrieved only in the PCI-632304
Rtol
Description
0
Unlatched
1
Latched
Copyright 2004, 2014 Interface Corporation. All rights reserved.
126
GPF-6320 Help for Windows
ltoR: Latch by the rotative direction change from negative (count-down) to
positive (count-up) rotation
* can be retrieved only in the PCI-632304
ltoR
Description
0
Unlatched
1
Latched
CL: Latch by carry
* can be retrieved only in the PCI-632304
CL
Description
0
Unlatched
1
Latched
BL: Latch by borrow
* can be retrieved only in the PCI-632304
BL
Description
0
Unlatched
1
Latched
Return Value
The UcntGetStatus function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
127
GPF-6320 Help for Windows
Example
Retrieving the counter status of channel 1 to channel 4 on the device whose device name is IFUCNT1
C
INT nRet;
DWORD dwStatus[4];
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetStatus(hDeviceHandle, 0x0F, dwStatus);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwStatus(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetStatus(hDeviceHandle, &H0F, dwStatus(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwStatus: array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetStatus(hDeviceHandle, $0F, dwStatus[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
128
GPF-6320 Help for Windows
5.1.39 UcntSetSamplingConfig
Description
The UcntSetSamplingConfig function configures the sampling condition.
Syntax
C
INT UcntSetSamplingConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
PUCNTSMPLCONFIG pSmplConfig
//
//
//
//
Device handle
Channel selection
Pointer to the structure for
sampling condition setting
);
Visual Basic
Declare Function UcntSetSamplingConfig Lib
ByVal hDeviceHandle As Long,_
‘
ByVal nChannel
As Long,_
‘
ByRef pSmplConfig
As
‘
UCNTSMPLCONFIG_ ‘
‘
)As Long
"IFUcnt.DLL"(_
Device handle
Channel selection
Pass by reference to the
structure for sampling
condition setting
Delphi
function UcntSetSamplingConfig(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pSmplConfig: UCNTSMPLCONFIG
// Device handle
// Channel selection
// Pass by reference to the
// structure for
// sampling condition setting
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
pSmplConfig
Points to the UCNTSAMPLCONFIG structure to store the sampling condition.
Return Value
The UcntSetSamplingConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
129
GPF-6320 Help for Windows
Example
C
INT nRet;
HANDLE hDeviceHandle;
UCNTSMPLCONFIG SmplConfig;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
SmplConfig.dwSmplNum = 1000;
SmplConfig.dwSmplEventNum = 100;
SmplConfig.dwSmplRepeat = 1;
SmplConfig.dwStatusMode = IFUCNT_ADD_STATUS;
SmplConfig.dwErrCtrl = IFUCNT_FREERUN;
nRet = UcntSetSamplingConfig(hDeviceHandle, 1, &SmplConfig);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim SmplConfig As UCNTSMPLCONFIG
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
SmplConfig.dwSmplNum = 1000
SmplConfig.dwSmplEventNum = 100
SmplConfig.dwSmplRepeat = 1
SmplConfig.dwStatusMode = IFUCNT_ADD_STATUS
SmplConfig.dwErrCtrl = IFUCNT_FREERUN
nRet = UcntSetSamplingConfig(hDeviceHandle, 1, SmplConfig)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
SmplConfig: UCNTSMPLCONFIG;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
SmplConfig.dwSmplNum := 1000;
SmplConfig.dwSmplEventNum := 100;
SmplConfig.dwSmplRepeat := 1;
SmplConfig.dwStatusMode := IFUCNT_ADD_STATUS;
SmplConfig.dwErrCtrl := IFUCNT_FREERUN;
nRet := UcntSetSamplingConfig(hDeviceHandle, 1, SmplConfig);
Configure the sampling condition of channel 1 on the device whose device name is IFUCNT1.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
130
GPF-6320 Help for Windows
5.1.40 UcntGetSamplingConfig
Description
The UcntGetSamplingConfig function retrieves the sampling condition.
Syntax
C
INT UcntGetSamplingConfig(
HANDLE
hDeviceHandle,
INT
nChannel,
PUCNTSMPLCONFIG pSmplConfig
//
//
//
//
Device handle
Channel selection
Pointer to the structure for
sampling condition retrieval
);
Visual Basic
Declare Function UcntGetSamplingConfig Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pSmplConfig
As
‘ sampling condition retrieval
UCNTSMPLCONFIG_ ‘ Pass by reference to the
‘ structure for
‘ sampling condition retrieval
)As Long
Delphi
function UcntGetSamplingConfig(
THandle;
hDeviceHandle:
Integer;
nChannel:
var pSmplConfig: UCNTSMPLCONFIG
// Device handle
// Channel selection
// Pass by reference to the
// structure for
// sampling condition retrieval
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pSmplConfig
Points to the UCNTSAMPLCONFIG structure to store the sampling condition.
Return Value
The UcntGetSamplingConfig function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
131
GPF-6320 Help for Windows
Example
Retrieving the sampling condition of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
UCNTSMPLCONFIG SmplConfig;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetSamplingConfig(hDeviceHandle, 1, &SmplConfig);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim SmplConfig As UCNTSMPLCONFIG
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetSamplingConfig(hDeviceHandle, 1, SmplConfig)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
SmplConfig: UCNTSMPLCONFIG;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetSamplingConfig(hDeviceHandle, 1, SmplConfig);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
132
GPF-6320 Help for Windows
5.1.41 UcntGetSamplingData
Description
The UcntGetSamplingData function retrieves the sampling data from the internal buffer.
Syntax
C
INT UcntGetSamplingData(
HANDLE
hDeviceHandle,
INT
nChannel,
PVOID
pSmplData,
PDWORD
// Device handle
// Channel selection
// Pointer to the array to store
// sampling data
// Pointer to the variable to store
// the number of retrieved data
pdwDataNum
);
Visual Basic
Declare Function UcntGetSamplingData Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long,_
nChannel
‘ Channel selection
ByRef
As Any,_
pSmplData
‘ Pass by reference to the array
‘ to store sampling data
ByRef
As Long_
pdwDataNum
‘ Pass by reference to the variable
‘ to store the number of retrieved
‘ data
)As Long
Delphi
function UcntGetSamplingData(
THandle;
hDeviceHandle:
Integer;
nChannel:
Pointer;
pSmplData:
// Device handle
// Channel selection
// Beginning address of the array
// to store sampling data
var pdwDataNum: Dword
// Pass by reference to the variable
// to store the number of retrieved
// data
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve the sampling data.
pSmplData
Points to an array to store the sampling data.
pdwDataNum
Points to a variable to store the number of sampling data that you want.
The number of acquired data is stored after completing the function.
Return Value
The UcntGetSamplingData function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
133
GPF-6320 Help for Windows
Example
Retrieving the 1000 sampling data of channel 1 (32-bit counter with status information) on the device whose
device name is IFUCNT1
C
INT nRet;
PVOID pSmplData;
DWORD dwDataNum;
HANDLE hDeviceHandle;
HANDLE hHeap;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
dwDataNum = 1000;
hHeap = GetProcessHeap();
pSmplData = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwDataNum *
sizeof(DWORD) * 2);
nRet = UcntGetSamplingData(hDeviceHandle, 1, pSmplData, &dwDataNum);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim SmplData(1000, 2) As Long
Dim dwDataNum As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
dwDataNum = 1000
nRet = UcntGetSamplingData(hDeviceHandle, 1, SmplData(0,0) ,
dwDataNum)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
pSmplData: Pointer;
dwDataNum: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
dwDataNum := 1000;
pSmplData := AllocMem(dwDataNum * SizeOf(Dword) * 2);
nRet := UcntGetSamplingData(hDeviceHandle, 1, pSmplData, dwDataNum);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
134
GPF-6320 Help for Windows
5.1.42 UcntClearSamplingData
Description
The UcntClearSamplingData function clears the internal buffer.
Syntax
C
INT UcntClearSamplingData(
HANDLE
hDeviceHandle,
INT
nChannel
);
// Device handle
// Channel selection
Visual Basic
Declare Function UcntClearSamplingData Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long_
nChannel
‘ Channel selection
)As Long
Delphi
function UcntClearSamplingData(
THandle;
hDeviceHandle:
// Device handle
Integer
nChannel:
// Channel selection
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to clear the sampling data.
Return Value
The UcntClearSamplingData function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
135
GPF-6320 Help for Windows
Example
Clearing the internal buffer to store the sampling data of channel 1 on the device whose device name is
IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntClearSamplingData(hDeviceHandle, 1);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntClearSamplingData(hDeviceHandle, 1)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntClearSamplingData(hDeviceHandle, 1);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
136
GPF-6320 Help for Windows
5.1.43 UcntGetSamplingStatus
Description
The UcntGetSamplingStatus function retrieves the sampling status.
Syntax
C
INT UcntGetSamplingStatus(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwSmplStatus,
PDWORD
pdwSmplCount,
PDWORD
pdwRepCount
// Device handle
// Channel selection
// Pointer to the variable to store status
// Pointer to the variable to store
// the completed sampling count
// Pointer to the variable to store
// the repeat count
);
Visual Basic
Declare Function UcntGetSamplingStatus Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long,_
nChannel
‘ Channel selection
ByRef
pdwSmplStatus As Long,_
‘ Pass by reference to the variable
‘ to store status
ByRef
As Long,_
pdwSmplCount
‘ Pass by reference to the variable
‘ to store the completed sampling
‘ count
ByRef
As Long_
pdwRepCount
‘ Pass by reference to the variable
‘ to store the repeat count
)As Long
Delphi
function UcntGetSamplingStatus(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword;
pdwSmplStatus:
var
Dword;
pdwSmplCount:
// Device handle
// Channel selection
// Pass by reference to the variable
// to store status
// Pass by reference to the variable
// store the completed sampling
// count
var pdwRepCount: Dword
// Pass by reference to the variable
// to store the repeat count
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
137
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwSmplStatus
Points to a variable to store the sampling status.
Code
Value
Description
IFUCNT_SMPL_START
1
Sampling is running.
IFUCNT_SMPL_STOP
2
Sampling stopped.
IFUCNT_SMPL_ERR_STOP
3
Sampling is stopped by error.
pdwSmplCount
Points to a variable to store the number of completed sampling.
pdwRepCount
Points to a variable to store the number of current sampling
repetition times.
Return Value
The UcntGetSamplingStatus function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
138
GPF-6320 Help for Windows
Example
Retrieving the sampling status of channel 1 on the device whose device name is IFUCNT1
C
INT nRet;
DWORD dwSmplStatus;
DWORD dwSmplCount;
DWORD dwRepCount;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetSmplStatus(hDeviceHandle, 1, &dwSmplStatus,
&dwSmplCount, &dwRepCount);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwSmplStatus As Long
Dim dwSmplCount As Long
Dim dwRepCount As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetSmplStatus(hDeviceHandle, 1, dwSmplStatus, dwSmplCount,
dwReplCount)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwSmplStatus: Dword;
dwSmplCount: Dword;
dwRepCount: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetSmplStatus(hDeviceHandle, 1, dwSmplStatus, dwSmplCount,
dwRepCount);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
139
GPF-6320 Help for Windows
5.1.44 UcntStartCount
Description
The UcntStartCount function starts the count.
Syntax
C
INT UcntStartCount(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwStartMode
);
// Device handle
// Channel selection
// Start mode
Visual Basic
Declare Function UcntStartCount Lib
ByVal
hDeviceHandle As Long,_
ByVal
As Long,_
dwChSel
ByVal
As Long_
dwStartMode
)As Long
"IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Start mode
Delphi
function UcntStartCount(
THandle;
hDeviceHandle:
// Device handle
Dword;
dwChSel:
// Channel selection
Dword
dwStartMode:
// Start mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be specified at the same time.
Bit
Description
dwStartMode
bit31 to bit4
Reserved
Specifies the start mode.
Code
IFUCNT_CMD_START
IFUCNT_CMD_EXWAIT
bit3
Channel 4
bit2
Channel 3
bit1
Channel 2
bit0
Channel 1
Description
Software start
Wait for the external start
(external trigger start)
Specifies the following identifier to start sampling
Code
Description
IFUCNT_CMD_SAMPLING Sampling start
* Sampling start and start mode can be specified at the same time with
logical add.
StartMode = IFUCNT_CMD_START | IFUCNT_CMD_SAMPLING;
StartMode = IFUCNT_CMD_EXWAIT | IFUCNT_CMD_SAMPLING;
* Software start and external start wait cannot be specified at the same time.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
140
GPF-6320 Help for Windows
Return Value
The UcntStartCount function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comments
- When multiple channels operate simultaneously, they are processed in turn within the driver. Therefore, the
start time between channels will be delayed about 500 ns .
When simultaneous start by the hardware is performed, use the UcntSetTriggerChannel function to
synchronize the counter control.
- When IFUCNT_CMD_EXWAIT is specified, the counter waits for starting the count by the external
input.
- When IFUCNT_CMD_SAMPLING is specified, use OR operator with another commands. Then, the
sampling data transfer starts for the specified internal buffer.
- If the trigger channel is changed to another channel with the UcntSetTriggerChannel fuction, the commands
for sampling start and counter start need to be executed separetely.
Example
C
Channel 1 --- uses the trigger conditons of channel 3, performs sampling
Channel 2 --- uses the trigger conditons of channel 3, performs sampling
Channel 3 --- uses the trigger conditons of channel 3, does not perform sampling
UcntSetTriggerConfig(hDeviceHandle, 3, IFUCNT_LA_R, IFUCNT_LB_F);
UcntSetTriggerChannel(hDeviceHandle, 1, 3, IFUCNT_TRG_NORMAL);
UcntSetTriggerChannel(hDeviceHandle, 2, 3, IFUCNT_TRG_NORMAL);
UcntSetTriggerChannel(hDeviceHandle, 3, 3, IFUCNT_TRG_NORMAL);
// Configuring the sampling of channel 1 and channel 2
UcntStartCount(hDeviceHandle, 0x03, IFUCNT_CMD_SAMPLING);
// Configuring channel 3 to standby status for external trigger
UcntStartCount(hDeviceHandle, 0x04, IFUCNT_CMD_EXWAIT);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
141
GPF-6320 Help for Windows
Example
Starting the count of channel 1 through channel 4 on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntStartCount(hDeviceHandle, 0x0F, IFUCNT_CMD_START);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntStartCount(hDeviceHandle, &H0F, IFUCNT_CMD_START)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntStartCount(hDeviceHandle, $0F, IFUCNT_CMD_START);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
142
GPF-6320 Help for Windows
5.1.45 UcntStopCount
Description
The UcntStopCount function stops the count.
Syntax
C
INT UcntStopCount(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwStopMode
);
// Device handle
// Channel selection
// Stop mode
Visual Basic
Declare Function UcntStopCount Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long,_
dwChSel
‘ Channel selection
ByVal
As Long_
dwStopMode
‘ Stop mode
)As Long
Delphi
function UcntStopCount(
THandle;
hDeviceHandle:
// Device handle
Dword;
dwChSel:
// Channel selection
Dword
dwStopMode:
// Stop mode
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be specified at the same time.
Bit
Description
dwStopMode
bit31 to bit4
Reserved
bit3
Channel 4
Specifies the stop mode.
Code
IFUCNT_CMD_STOP
IFUCNT_CMD_SAMPLING
bit2
Channel 3
bit1
Channel 2
bit0
Channel 1
Description
Stops the count.
Stops the sampling.
Return Value
The UcntStopCount function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
143
GPF-6320 Help for Windows
Comment
- When multiple channels operate simultaneously, they are processed in turn within the driver. Therefore, the
start time between channels will be delayed about 500 ns .
When simultaneous start by the hardware is performed, use the UcntSetTriggerChannel function to
synchronize the counter control.
When the channels are synchronized with the UcntSetTriggerChannel function, all the controls including start,
stop, and wait are synchronized.
Example
Stopping the count of channel 1 on the device whose device name is IFUCNT1 and terminating the sampling
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntStopCount(hDeviceHandle, 0x01, IFUCNT_CMD_STOP |
IFUCNT_CMD_SAMPLING);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntStopCount(hDeviceHandle, &H01, IFUCNT_CMD_STOP or
IFUCNT_CMD_SAMPLING)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntStopCount(hDeviceHandle, $01, IFUCNT_CMD_STOP |
IFUCNT_CMD_SAMPLING);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
144
GPF-6320 Help for Windows
5.1.46 UcntLatchCount
Description
The UcntLatchCount function latches the count value.
Syntax
C
INT UcntLatchCount(
HANDLE
hDeviceHandle,
DWORD
dwChSel
);
// Device handle
// Channel selection
Visual Basic
Declare Function UcntLatchCount Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_ ‘ Device handle
ByVal
As Long_ ‘ Channel selection
dwChSel
)As Long
Delphi
function UcntLatchCount(
THandle;
hDeviceHandle:
// Device handle
Dword
dwChSel:
// Channel selection
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
dwChSel
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be specified at the same time.
Bit
Description
bit31 to bit4
Reserved
bit3
Channel 4
bit2
Channel 3
bit1
Channel 2
bit0
Channel 1
Return Value
The UcntLatchCount function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
145
GPF-6320 Help for Windows
Example
Latching the counter value of channel 1 to channel 4 on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntLatchCount(hDeviceHandle, 0x0F);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntLatchCount(hDeviceHandle, &H0F)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntLatchCount(hDeviceHandle, $0F);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
146
GPF-6320 Help for Windows
5.1.47 UcntSetDOEnable
Description
The UcntSetDOEnable function configures the general purpose output.
Syntax
C
INT UcntSetDOEnable(
HANDLE
hDeviceHandle,
DWORD
dwOutEnable
// Device handle
// Specifies pins that is enabled
// to output
);
Visual Basic
Declare Function UcntSetDOEnable Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_ ‘ Device handle
ByVal dwOutEnable
As Long_
‘ Specifies pins that is enabled to
‘ output
)As Long
Delphi
function UcntSetDOEnable(
THandle; // Device handle
hDeviceHandle:
Dword
dwOutEnable:
// Specifies pins that is enabled to output
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
147
GPF-6320 Help for Windows
Parameters
hDeviceHandle
dwOutEnable
Specifies the device handle obtained by the UcntOpen function.
Specifies the pin to be allowed to output.
dwOutEnable
bit0
IO0
bit1
IO1
bit2
IO2
bit3
IO3
bit4
IO4
bit5
IO5
bit6
IO6
bit7
IO7
Description
General purpose output setting for 1A, 1B, 1Z, and 1LA
0
Forbidden
1
Permissive
General purpose output setting for 2A, 2B, 2Z, and 2LA
0
Forbidden
1
Permissive
General purpose output setting for 3A, 3B, 3Z, and 3LA
0
Forbidden
1
Permissive
General purpose output setting for 4A, 4B, 4Z, and 4LA
0
Forbidden
1
Permissive
General purpose output setting for 1LB, 2LB, 3LB, and 4LB
0
Forbidden
1
Permissive
General purpose output setting for 1OUTA, 1OUTB,
2OUTA, and 2OUTB
0
Forbidden
1
Permissive
General purpose output setting for 3OUTA, 3OUTB,
4OUTA, and 4OUTB
0
Forbidden
1
Permissive
Output setting for 1CLR, 1GATE, 2CLR, and 2GATE
0
Forbidden
1
Permissive
Return Value
The UcntSetDOEnable function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comment
When the device is opened by using the UcntOpen function, OUTA and OUTB (IO5 and IO6) for each channel
are allowed to output. Before calling the UcntOutputDO function, set the output setting for the pin which you
want to control by using the UcntSetDOEnable function. After the general purpose outpu of OUTA and OUTB
(IO5 and IO6) are set to forbidden, frequency dividing output and pulse generator output will not be performed.
To use these output mode, set to allow the OUTA and OUTB (IO5 and IO6) pins for general purpose output.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
148
GPF-6320 Help for Windows
Example
Allowing the following pins on the device whose device name is IFUCNT1 for general purpose outptut
- 1A, 1B, 1Z, 1LA
- 1OUTA, 1OUTB, 2OUTA, 2OUTB, 3OUTA, 3OUTB, 4OUTA, 4OUTB
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetDOEnable(hDeviceHandle, 0x61);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetDOEnable(hDeviceHandle, &H61)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
nRet := UcntSetDOEnable(hDeviceHandle, $61);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
149
GPF-6320 Help for Windows
5.1.48 UcntGetDOEnable
Description
The UcntGetDOEnable function retrieves the setting information of general purpose output.
Syntax
C
INT UcntGetDOEnable(
HANDLE
hDeviceHandle,
PDWORD
pdwOutEnable
// Device handle
// Pointer to the variable to
// retrieve output enabled status
);
Visual Basic
Declare Function UcntGetDOEnable Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByRef pdwOutEnable
As Long_
‘ Pass by reference to the variable
‘ to retrieve output enabled
‘ status
)As Long
Delphi
function UcntGetDOEnable(
THandle;
hDeviceHandle:
// Device handle
var
Dword
// Pass by reference to the variable
pdwOutEnable:
// to retrieve output enabled status
): Integer; stdcall; external 'IFUcnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
150
GPF-6320 Help for Windows
Parameters
hDeviceHandle
pdwOutEnable
Specifies the device handle obtained by the UcntOpen function.
Points to a variable to store the pin setting.
dwOutEnable
bit0
IO0
bit1
IO1
bit2
IO2
bit3
IO3
bit4
IO4
bit5
IO5
bit6
IO6
bit7
IO7
Description
Output setting for 1A, 1B, 1Z, and 1LA
0
Forbidden
1
Permissive
Output setting for 2A, 2B, 2Z, and 2LA
0
Forbidden
1
Permissive
Output setting for 3A, 3B, 3Z, and 3LA
0
Forbidden
1
Permissive
General purpose output setting for 4A, 4B, 4Z, and 4LA
0
Forbidden
1
Permissive
General purpose output setting for 1LB, 2LB, 3LB, and
4LB
0
Forbidden
1
Permissive
General purpose output setting for 1OUTA, 1OUTB,
2OUTA, and 2OUTB
0
Forbidden
1
Permissive
General purpose output setting for 3OUTA, 3OUTB,
4OUTA, and 4OUTB
0
Forbidden
1
Permissive
General purpose output setting for 1CLR, 1GATE, 2CLR,
and 2GATE
0
Forbidden
1
Permissive
Return Value
The UcntGetDOEnable function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
151
GPF-6320 Help for Windows
Example
Retrieving the pin setting to enable on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwOutEnabl;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetDOEnable(hDeviceHandle, &dwOutEnable);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwOutEnable As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetDOEnable(hDeviceHandle, dwOutEnable)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwOutEnable: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetOutEnable(hDeviceHandle, dwOutEnable);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
152
GPF-6320 Help for Windows
5.1.49 UcntInputDI
Description
The UcntInputDI function retrieves the status of digital input.
Syntax
C
INT UcntInputDI(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwDI
//
//
//
//
Device handle
Channel selection
Pointer to the variable to retrieve
the status of general purpose input
);
Visual Basic
Declare Function UcntInputDI Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByRef nChannel
As Long,_
‘ Channel selection
ByRef pdwDI
As Long_
‘ Pass by reference to the
‘ variable to retrieve the
‘ status of general purpose input
)As Long
Delphi
function UcntInputDI(
THandle;
hDeviceHandle:
Dword;
nChannel:
var pdwDI:
Dword
// Device handle
// Channel selection
// Pass by reference to the variable
// to retrieve the status of general
// purpose input
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve the digital output status.
Range: 1 to 4, IFUCNT_CH_HS
pdwDI
Points to a variable to store the input status. The retrieved status depends on
the channel specified by nChannel.
<nChannel: 1 to 4>
Bit
bit31 to bit7 bit6
bit5
Reserved OUTB OUTA
Description
Copyright 2004, 2014 Interface Corporation. All rights reserved.
153
bit4
LB
bit3
LA
bit2
Z
bit1
B
bit0
A
GPF-6320 Help for Windows
The table below is for the PCI-632302.
nChannel=1
Bit
Description
bit31 to bit16
Reserved
Bit
Description
bit15 to bit11
Reserved
Bit
Description
Bit7 to bit5
Reserved
bit4
LB
bit3
LA
bit10
IN3
bit9
IN2
bit8
IN1
bit2
Z
bit1
B
bit0
A
bit10
IN6
bit9
IN5
bit8
IN4
nChannel=2
Bit
Description
bit31 to bit16
Reserved
Bit
Description
bit15 to bit11
Reserved
Bit
Bit7 to bit5
Description Reserved
bit4
LB
bit3
LA
bit2
Z
bit1
B
bit0
A
<nChannel: IFUCNT_CH_HS>
Bit
Description
bit31 to bit4
Reserved
bit3
2GATE
bit2
1GATE
bit1
2CLR
bit0
1CLR
- bit data = 1: “High”
- bit data =0: “Low”
Return Value
The UcntInputDI function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
154
GPF-6320 Help for Windows
Example
Retrieving the general purpose input status of channel 1 on the device whose device name is IFUCNT1.
C
INT nRet;
DWORD dwDI;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntInputDI(hDeviceHandle, 1, &dwDI);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwDI As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntInputDI(hDeviceHandle, 1, dwDI)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwDI: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntInputDI(hDeviceHandle, 1, dwDI);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
155
GPF-6320 Help for Windows
5.1.50 UcntOutputDO
Description
The UcntOutputDO function controls the general purpose output.
Syntax
C
INT UcntOutputDO(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwDO
);
// Device handle
// Channel selection
// General purpose output
Visual Basic
Declare Function UcntOutputDO Lib "IFUcnt.DLL"(_
ByVal
hDeviceHandle As Long,_
‘ Device handle
ByVal
As Long,_
nChannel
‘ Channel selection
ByVal
As Long_
dwDO
‘ General purpose output
)As Long
Delphi
function UcntOutputDO(
THandle;
hDeviceHandle:
// Device handle
Dword;
nChannel:
// Channel selection
Dword
dwDO:
// General purpose output
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
nChannel
dwDO
Specifies the device handle obtained by the UcntOpen function.
Specifies the channel to control the digital output.
Range: 1 to 4, IFUCNT_CH_HS
Specifies the digital output. The digital output depends on the channel
specified by nChannel.
<nChannel: 1 to 4>
Bit
bit31 to bit7
bit6
bit5
bit4
bit3
bit2
bit1
bit0
Description
Reserved
OUTB
OUTA
LB
LA
Z
B
A
The table below is for the PCI-632302.
nChannel=1
Bit
Description
Bit
Description
bit31 to bit16
Reserved
Bit15 to bit12
Reserved
Bit
bit7
Bit6
Description Reserved OUTA
Copyright 2004, 2014 Interface Corporation. All rights reserved.
156
bit5
OUTB
bit11 bit10 bit9
bit8
OUT4 OUT3 OUT2 OUT1
bit4 to bit0
Reserved
GPF-6320 Help for Windows
nChannel=2
Bit
Description
bit31 to bit16
Reserved
Bit
Description
bit15 to bit12
Reserved
Bit
bit7
Bit6
Description Reserved OUTB
bit11 bit10 bit9
bit8
OUT8 OUT7 OUT6 OUT5
bit5
OUTA
bit4 to bit0
Reserved
<nChannel: IFUCNT_CH_HS>
Bit
Description
bit31 to bit4
Reserved
bit3
2GATE
bit2
1GATE
bit3
2GATE
bit2
1GATE
bit1
2CLR
bit0
1CLR
- bit data = 1: “High”
- bit data = 0: “Low”
<nChannel: IFUCNT_CH_HS>
Bit
Description
bit31 to bit4
Reserved
bit1
2CLR
bit0
1CLR
Return Value
The UcntOutputDO function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comments
Notes to use products other than the PCI-632302
• The UcntOutputDO function
By using the UcntOutuptDO function, the output status for the input pin such as A, B, Z, LA, and LB can be
changed. Before calling the UcntOutputDO function, confirm the connection. Because the external equipment
may be damaged when the UcntOutputDO function is called while the external equipment is connected with
the input pin for pulse output.
• The UcntSetDOEnable function
When the device is opened with the UcntOpen function, OUTA and OUTB for each channel are allowed to
output. Before calling the UcntOutputDO function, configure the output setting for the pin which you want to
control by using the UcntSetDOEnable function.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
157
GPF-6320 Help for Windows
Example
Configuring A of channel 1 on the device whose device name is IFUCNT1 to high.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwOutEnable;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetOutEnable(hDeviceHandle, &dwOutEnable);
nRet = UcntSetOutEnable(hDeviceHandle, dwOutEnable | 0x01);
nRet = UcntOutputDO(hDeviceHandle, 1, 0x01);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwOutEnable As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetDOEnable(hDeviceHandle, dwOutEnable)
nRet = UcntSetDOEnable(hDeviceHandle, dwOutEnable or &H01)
nRet = UcntOutputDO(hDeviceHandle, 1, &H01)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwOutEnable: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetDOEnable(hDeviceHandle, dwOutEnable);
nRet := UcntSetDOEnable(hDeviceHandle, dwOutEnable | $01);
nRet := UcntOutputDO(hDeviceHandle, 1, $01);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
158
GPF-6320 Help for Windows
5.1.51 UcntSetEventMask
Description
The UcntSetEventMask function masks interrupt events.
Syntax
C
INT UcntSetEventMask(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwEventMask
);
// Device handle
// Channel selection
// Interrupt mask
Visual Basic
Declare Function UcntSetEventMask Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle
As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByVal dwEventMask
As Long_
‘ Interrupt mask
)As Long
Delphi
function UcntSetEventMask(
THandle;
hDeviceHandle:
// Device handle
Integer;
nChannel:
// Channel selection
Dword
dwEventMask:
// Interrupt mask
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
dwEventMask
Specifies the mask setting for interrupt events.
dwEventMask
bit23 to bit19
bit18
ORER
bit17
SMPL EQ
bit16
SMPL END
bit15
bit14
EX LOAD
Description
Reserved
Overrun error interrupt event for sampling FIFO
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Interrupt event of the number of specified sampling
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for sampling completion interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Reserved
Event for external preload interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
159
GPF-6320 Help for Windows
(Continued)
dwEventMask
bit13
CLOCK
LATCH
bit12
EX LATCH
bit11
PERR
bit10
bit9
EX STOP
bit8
EX START
bit7
OUTB
FALL
bit6
OUTB
RISE
bit5
OUTA
FALL
bit4
OUTA
RISE
bit3, bit2
bit1
BRF
bit0
CRF
Description
Event for base clock latch interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for external latch interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for interrupt of invalid pulse detection
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Reserved
Event for external stop interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for external start interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching release interrupt of OUTB
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching detection interrupt of OUTB
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching release interrupt of OUTA
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching detection interrupt of OUTA
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Reserved
Borrow interrupt event
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Carry interrupt event
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Return Value
The UcntSetEventMask function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
160
GPF-6320 Help for Windows
Example
Configuring the interrupt event mask of channel 1 on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetEventMask(hDeviceHandle, 1, 0x03);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetEventMask(hDeviceHandle, 1, &H03)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetEventMask(hDeviceHandle, 1, $03);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
161
GPF-6320 Help for Windows
5.1.52 UcntGetEventMask
Description
The UcntGetEventMask function retrieves interrupt event mask setting.
Syntax
C
INT UcntGetEventMask(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwEventMask
// Device handle
// Channel selection
// Pointer to the variable to retrieve
// the status of interrupt mask
);
Visual Basic
Declare Function UcntGetEventMask Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByVal nChannel
As Long,_
‘ Channel selection
ByRef pdwEventMask
As Long_
‘ Pass by reference to the
‘ variable to retrieve the
‘ status of interrupt mask
)As Long
Delphi
function UcntGetEventMask(
THandle;
hDeviceHandle:
Integer;
nChannel:
var
Dword
pdwEventMask:
// Device handle
// Channel selection
// Pass by reference to the
// variable to retrieve the
// status of interrupt mask
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to retrieve.
pdwEventMask
Points to a variable to store the mask setting for interrupt events.
dwEventMask
Description
bit23 to bit19
Reserved
bit18
ORER
Overrun error interrupt event for sampling FIFO
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
bit17
SMPL EQ
Interrupt event of the number of specified sampling
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
bit16
SMPL END Event for sampling completion interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
bit15
Reserved
Copyright 2004, 2014 Interface Corporation. All rights reserved.
162
GPF-6320 Help for Windows
bit14
EX LOAD
bit13
CLOCK
LATCH
bit12
EX LATCH
bit11
PERR
bit10
bit9
EX STOP
bit8
EX START
bit7
OUTB
FALL
bit6
OUTB
RISE
bit5
OUTA
FALL
bit4
OUTA
RISE
bit3, bit2
bit1
BRF
bit0
CRF
Event for external preload interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for base clock latch interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for external latch interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for interrupt of invalid pulse detection
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Reserved
Event for external stop interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for external stop interrupt
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching release interrupt of OUTB
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching detection interrupt of OUTB
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching release interrupt of OUTA
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Event for matching detection interrupt of OUTA
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Reserved
Borrow interrupt event
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Carry interrupt event
0 Mask (interrupt disabled)
1 Unmask (interrupt enabled)
Return Value
The UcntGetEventMask function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
163
GPF-6320 Help for Windows
Example
Retrieving the interrupt event mask setting of channel 1 on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwEventMask;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntGetEventMask(hDeviceHandle, 1, &dwEventMask);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwEventMask As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntGetEventMask(hDeviceHandle, 1, dwEventMask)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwEventMask: Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntGetEventMask(hDeviceHandle, 1, dwEventMask);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
164
GPF-6320 Help for Windows
5.1.53 UcntSetEvent
Description
The UcntSetEvent function registers a callback routine.
Syntax
C
INT UcntSetEvent(
HANDLE
PUCNTEVENTREQ
hDeviceHandle,
pEvent
// Device handle
// Pointer to the structure to
// configure interruption
);
Visual Basic
Declare Function UcntSetEvent Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long,_
‘ Device handle
ByRef pEvent
UCNTEVENTREQ_
‘ Pass by reference to the
‘ structure to configure
‘ interruption
)As Long
Delphi
function UcntSetEvent(
THandle;
hDeviceHandle:
// Device handle
var pEvent:
UCNTEVENTRE // Pass by reference to the
Q
// structure to configure interruption
): Integer; stdcall; external 'IFUcnt.DLL';
Parameters
hDeviceHandle
pEvent
Specifies the device handle obtained by the UcntOpen function.
Points to a use callback function called when interruption is generated and a
structure that configures message.
Return Value
The UcntSetEvent function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comment
Callback routine is defined as follows.
<Syntax>
VOID CALLBACK lpCallBackProc(INT nChannel, DWORD dwEvent, DWORD dwUser );
<Parameters>
nChannel
Contains the channel that interrupts occur.
dwEvent
Contains the source to call callback routine. 1 is set to the corresponding bits.
dwUser
Sets the user data specified at event setting.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
165
GPF-6320 Help for Windows
Example
C (Setting callback routine)
// Callback routine
VOID CALLBACK lpEventProc(INT nChannel, DWORD dwEvent, DWORD dwUser){
// Write the interrupt process.
.
.
.
}
// Main routine
INT nRet;
HANDLE hDeviceHandle;
UCNTEVENTREQ Event;
hDeviceHandle = UcntOpen(“IFUCNT1”);
.
.
.
nRet = UcntSetEventMask(hDeviceHandle, 1, 0x03);
Event.hWnd = NULL;
Event.uMessage[0] = WM_NULL;
Event.uMessage[1] = WM_NULL;
Event.uMessage[2] = WM_NULL;
Event.uMessage[3] = WM_NULL;
Event.hEvent = NULL;
Event.lpCallBackProc = (PLPUCNTCALLBACK)lpEventProc;
Event.dwUser = 0x1234;
nRet = UcntSetEvent(hDeviceHandle, &Event);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
166
GPF-6320 Help for Windows
C (Setting event standby)
INT nRet;
HANDLE hDeviceHandle;
OVERLAPPED OverLapped;
UCNTEVENTREQ Event;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntSetEventMask(hDeviceHandle, 1, 0x03);
OverLapped.hEvent = CreateEvent(0,FALSE,FALSE,NULL);
Event.hWnd = NULL;
Event.uMessage[0] = WM_NULL;
Event.uMessage[1] = WM_NULL;
Event.uMessage[2] = WM_NULL;
Event.uMessage[3] = WM_NULL;
Event.hEvent = OverLapped.hEvent;
Event.lpCallBackProc = NULL;
Event.dwUser = 0x1234;
nRet = UcntSetEvent(hDeviceHandle, &Event);
if (nRet == IFUCNT_ERROR_SUCCESS) {
// event standby
WaitForSingleObject(OverLapped.hEvent, INFINITE);
}
Copyright 2004, 2014 Interface Corporation. All rights reserved.
167
GPF-6320 Help for Windows
Visual Basic (Setting callback routine)
The callback routine should be described in the standard module of the project to call the UcntSetEvent
function.
To pass the adress of procedure by using the parameter of the UcntSetEvent function, use AddressOf operator.
For more details, refer to the examples in the UcntSetEvent function.
By using the AddressOf operator, address for procedure-self is returned to the UcntSetEvent function of DLL.
Dim lpszName As String
Dim hDeviceHandle As Long
Dim Event As UCNTEVENTREQ
Public lpOverlapped As OVERLAPPED
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntSetEventMask(hDeviceHandle, 1, &H03)
lpOverlapped.hEvent = CreateEvent(nul, False, False, nul)
Event.hWnd = 0
Event.uMessage(0) = 0
Event.uMessage(1) = 0
Event.uMessage(2) = 0
Event.uMessage(3) = 0
Event.hEvent = lpOverlapped.hEvent
Event.lpCallBackProc = 0
Event.dwUser = &H1234
nRet = UcntSetEvent(hDeviceHandle, Event);
' event standby
nRet = WaitForSingleObject(lpOverlapped.hEvent, 0)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
168
GPF-6320 Help for Windows
Delphi (Callback routine setting)
// Callback routine
procedure lpEventProc(nChannel: Integer, dwEvent: DWORD, dwUser:
DWORD); stdcall;
var
// Variable definition
begin
// Describes the interrupt process.
.
.
.
end;
// Main routine
var
lpszName: String;
hDeviceHandle: THandle;
Event: UCNTEVENTREQ;
lpszName := ‘IFUCNT1’;
hDeviceHandle := UcntOpen(lpszName);
.
.
.
nRet := UcntSetEventMask(hDeviceHandle, 1, $03);
Event.hWnd := 0;
Event.uMessage[0] := WM_NULL;
Event.uMessage[1] := WM_NULL;
Event.uMessage[2] := WM_NULL;
Event.uMessage[3] := WM_NULL;
Event.hEvent := 0;
Event.lpCallBackProc := lpEventProc;
Event.dwUser := $1234;
nRet := UcntSetEvent(hDeviceHandle, Event);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
169
GPF-6320 Help for Windows
Delphi (Waiting for event)
Configuring the callback routine (or event) and interupt mask of channel 1 on the device whose device name is
IFUCNT1
var
lpszName: String;
hDeviceHandle: THandle;
Event: UCNTEVENTREQ;
OverLapped : TOverLapped;
nRet : Integer;
begin
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntSetEventMask(hDeviceHandle, 1, $03);
OverLapped.hEvent := CreateEvent(nil, False, False, Nil);
Event.hWnd := 0;
Event.uMessage[0] := WM_NULL;
Event.uMessage[1] := WM_NULL;
Event.uMessage[2] := WM_NULL;
Event.uMessage[3] := WM_NULL;
Event.hEvent := OverLapped.hEvent;
Event.lpCallBackProc := 0;
Event.dwUser := $1234;
nRet := UcntSetEvent(hDeviceHandle, Event);
// event standby
WaitForSingleObject(OverLapped.hEvent, INFINITE);
:
end;
.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
170
GPF-6320 Help for Windows
5.1.54 UcntKillEvent
Description
The UcntKillEvent function deletes a registered callback routine.
Syntax
C
INT UcntKillEvent(
HANDLE
hDeviceHandle
);
// Device handle
Visual Basic
Declare Function UcntKillEvent Lib "IFUcnt.DLL"(_
ByVal hDeviceHandle As Long_
‘ Device handle
)As Long
Delphi
function UcntKillEvent(
THandle
hDeviceHandle:
// Device handle
): Integer; stdcall; external 'IFUcnt.DLL';
Parameter
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
Return Value
The UcntKillEvent function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
171
GPF-6320 Help for Windows
Example
Deleting the registered callback routine on the device whose device name is IFUCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
:
nRet = UcntKillEvent(hDeviceHandle);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
:
nRet = UcntKillEvent(hDeviceHandle)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
:
nRet := UcntKillEvent(hDeviceHandle);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
172
GPF-6320 Help for Windows
5.1.55 UcntOutputSync
Description
The UcntOutputSync function controls internal synchronous output.
This function is applicable only to the PCI-632302.
Syntax
C
INT UcntOutputSync(
HANDLE
DeviceHandle,
INT
Channel,
INT
TrgLine,
DWORD
TrgMode
);
//
//
//
//
Device handle
Channel selection
Synchronous line
Trigger mode
Visual Basic
Declare Function UcntOutputSync Lib "IFUcnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
‘ Device handle
ByVal
As Long,_
nChannel
‘ Channel selection
ByVal
As
Long,_
TrgLine
‘ Synchronous line
ByVal
As Long_
TrgMode
‘ Trigger mode
)As Long
Delphi
function UcntOutputSync(
THandle;
hDeviceHandle:
Dword;
nChannel:
Dword;
TrgLine:
Dword
TrgMode:
): Integer; stdcall; external 'IFUcnt.DLL';
Parameter
hDeviceHandle
//
//
//
//
Device handle
Channel selection
Synchronous line
Trigger mode
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies a channel to control synchronous signal line.
TrgLine
Specifies a synchronous line to control.
Code
Description
IFUCNT_SYNC1
Synchronous line 1
IFUCNT_SYNC2
Synchronous line 2
TrgMode
Specifies the trigger mode of the synchronous line.
Code
Description
IFUCNT_DISABLE
Disabled
IFUCNT_UPDN
Updown
Copyright 2004, 2014 Interface Corporation. All rights reserved.
173
GPF-6320 Help for Windows
Return Value
The UcntOutputSync function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comment
This function is applicable only to the PCI-632302.
Example
Enabling the counter updown from the internal synchronous line 1 of the device whose device name is
IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
nRet = UcntOutputSync(hDeviceHandle, 1, IFUCNT_SYNC1, IFUCNT_UPDN);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
nRet = UcntOutputSync(hDeviceHandle, 1, IFUCNT_SYNC1, IFUCNT_UPDN)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
nRet := UcntOutputSync(hDeviceHandle, 1, IFUCNT_SYNC1, IFUCNT_UPDN);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
174
GPF-6320 Help for Windows
5.1.56 UcntSetPhysicalMemorysSize
Description
The UcntSetPhysicalMemorySize function is an API function for 64-bit envirnment. The function configures
the allocated size of internal buffer. Both this API and the IFCNTMEM.EXE can configure the size. To reflect
the configured size after the function is successfully performed, restart the operating system.
Syntax
C
INT UcntSetPhysicalMemorysSize(
HANDLE
DeviceHandle,
INT
Channel,
DWORD
PhysicalMemorysSize
);
Visual Basic
Declare Function UcntSetPhysicalMemorysSize
ByVal
As Long,_
hDeviceHandle
ByVal
As Long,_
nChannel
ByVal
PhysicalMemorysSize As Long_
)As Long
// Device handle
// Channel selection
// Allocated size
Lib "IFUcnt.DLL"(_
‘ Device handle
‘ Channel selection
‘ Allocated size
Delphi
function UcntSetPhysicalMemorysSize(
THandle;
hDeviceHandle:
// Device handle
Dword;
nChannel:
// Channel selection
Dword
PhysicalMemorysSize:
// Allocated size
): Integer; stdcall; external 'IFUcnt.DLL';
Parameter
hDeviceHandle
Specifies the device handle obtained by the UcntOpen function.
nChannel
Specifies the channel to configure.
PhysicalMemorysSize
Specifies the allocated size of internal buffer. (maximum size is
67,076,032 bytes)
Return Value
The UcntSetPhysicalMemorysSize function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
175
GPF-6320 Help for Windows
Example
Configuring the allocated size of internal buffer of channel 1 on the device whose device name is IFUCNT1 to
32768 bytes
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
nRet = UcntSetPhysicalMemorysSize(hDeviceHandle, 1, 32768);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
nRet = UcntSetPhysicalMemorysSize(hDeviceHandle, 1, 32768)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
nRet := UcntSetPhysicalMemorysSize(hDeviceHandle, 1, 32768);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
176
GPF-6320 Help for Windows
5.1.57 UcntGetDriverInfo
Description
The UcntGetDriverInfo function retrieves the architecture information of the operating system and the allocated
size of internal buffer in each channel.The physical memory allocated size is for 64-bit operating system.
Syntax
C
INT UcntGetDriverInfo (
HANDLE
DeviceHandle,
PDWORD
OsArchitecture
PDWORD
PhysicalMemorysSize
);
// Device handle
// OS information
// Internal buffer size
Visual Basic
Declare Function UcntGetDriverInfo
ByVal
As
hDeviceHandle
ByRef
As
OsArchitecture
ByRef
PhysicalMemorysSize As
)As Long
Lib "IFUcnt.DLL"(_
Long,_
‘ Device handle
Long,_
‘ OS information
Long_
‘ Internal buffer size
Delphi
function UcntGetDriverInfo (
THandle;
hDeviceHandle:
// Device handle
var OsArchitecture:
Dword;
// OS information
var
Dword
// Internal buffer size
PhysicalMemorysSize:
): Integer; stdcall; external 'IFUcnt.DLL';
Parameter
hDeviceHandle
OsArchitecture
Specifies the device handle obtained by the UcntOpen function.
Points to the variable to store the operating system information.
The following codes of the operating system information are returned to the
variables.
Code
PhysicalMemorysSize
Description
IFUCNT_OS_ARCHITECTURE_x64
64-bit environment
IFUCNT_OS_ARCHITECTURE_x86
32-bit environment
Points to the array to store the internal buffer size of each channel.
The array must be 32-bit allay, 4 elements.
Array[0] : Internal buffer size of channel 1
Array[1] : Internal buffer size of channel 2
Array[2] : Internal buffer size of channel 3
Array[3] : Internal buffer size of channel 4
Copyright 2004, 2014 Interface Corporation. All rights reserved.
177
GPF-6320 Help for Windows
Return Value
The UcntGetDriverInfo function returns IFUCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the allocated size of internal buffer and the operating system information which is installed in the
device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD Architecture;
DWORD PhysicalMemorysSize[4];
hDeviceHandle = UcntOpen(“IFUCNT1”);
:
nRet = UcntGetDriverInfo(hDeviceHandle, &Architecture,
PhysicalMemorysSize);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim Architecture As Long
Dim PhysicalMemorysSize(0 To 3) As Long
lpszName = "IFUCNT1" & Chr( 0 )
hDeviceHandle = UcntOpen(lpszName)
:
nRet = UcntGetDriverInfo (hDeviceHandle, Architecture,
PhysicalMemorysSize(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
Architecture: Dword;
PhysicalMemorysSize: Array[0..3] of Dword;
lpszName := 'IFUCNT1';
hDeviceHandle := UcntOpen(lpszName);
:
nRet := UcntGetDriverInfo(hDeviceHandle, Architecture,
PhysicalMemorysSize[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
178
GPF-6320 Help for Windows
5.2 List of DLL Function for High-Speed Counter
No.
Function
Description
Initializing
1
HScntOpen
2
HScntClose
3
4
HScntGetDeviceInfo
HScntReset
Opens a device of high-performance counter and enables to
access to the device.
Closes the high-performance counter and releases the resources.
Any subsequent accesses to the card are forbidden.
Retrieves specifications of the device.
Resets the setting and clears the counter of the specified channel.
Setting/ retrieving the Mode
5
6
HScntSetMode
HScntGetMode
Configures the external control mode of counter.
Retrieves the external control mode of counter.
Retrieving the Counter Value
7
HScntReadCounter
Retrieves the counter value.
Retrieving the Status
8
HScntGetStatus
Retrieves the counter status.
Controlling the Counter
9
10
HScntStartCount
HScntStopCount
Starts the count.
Stops the count.
Setting/ retrieving the Interrupt
11
12
13
14
HScntSetEventMask
HScntGetEventMask
HScntSetEvent
HScntKillEvent
Masks interrupt events.
Retrieves the interrupt event mask settings.
Registers a callback routine.
Deletes a registered callback routine.
Digital Input/ Output
15
16
17
18
HScntSetDOEnable
HScntGetDOEnable
HScntInputDI
HScntOutputDO
Configures the output
Retrieves the setting information of output
Retrieves the status of input
Controls the output.
Setting/ retrieving the Interval Timer
19
20
21
HScntSetTimerConfig
HScntGetTimerConfig
HScntGetTimerCount
Sets the interval timer
Retrieves the setting information of the interval timer
Retrieves the count value of interval timer
Setting/ retrieving the Digital Filter
22
23
HScntSetFilter
HScntGetFilter
Sets the digital filter
Retrieve the setting information of the digital filter
* These functions are aplicable only to the following products.
LPC-632102, PEX-632102
Copyright 2004, 2014 Interface Corporation. All rights reserved.
179
GPF-6320 Help for Windows
5.2.1 HScntOpen
Description
The HScntOpen function opens a device of high-speed counter and enables to access the device.
Syntax
C (for x86)
HANDLE HScntOpen(
LPCTSTR
lpszName,
);
// Device name
C (for x64)
HANDLE HScntOpen(
LPCSTR lpszName,
);
// Device name
Visual Basic
Declare Function HScntOpen Lib “IfHScnt.DLL”(_
ByVal
As String_
lpszName
‘Device name
)As Long
Delphi
function HScntOpen(
String
lpszName:
//Device name
):THandle; stdcall; external ‘IfHScnt.DLL’;
Parameter
lpszName
Specifies the device name to open.
Return Value
The HScntOpen function returns a valid handle when the process is successfully completed. Otherwise, this
function returns INVALID_HANDLE_VALUE if the process is failed.
Comment
To open the device, specify a device name of the device, IFHSCNTx (x = 1 to 16), assigned by the device driver
as follows.
CardBus ID Number
0
1
.
.
.
E
F
Device Name
IFHSCNT1
IFHSCNT2
.
.
.
IFHSCNT15
IFHSCNT16
If you use two or more devices, check the device names beforehand. The device names of Interface high-speed
counter are listed in the Device Manager.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
180
GPF-6320 Help for Windows
Example
Opening the device whose device name is IFHSCNT1.
C (32-bit compiler)
HANDLE DeviceHandle;
DeviceHandle = HScntOpen(“IFHSCNT1”);
C (UNICODE is deficned by a 32-bit compiler )
HANDLE DeviceHandle;
DeviceHandle = HScntOpen((LPCTSTR)“IFHSCNT1”);
HANDLE DeviceHandle;
char* lpszName = “IFHSCNT1”;
DeviceHandle = HScntOpen((LPCTSTR)lpszName);
HANDLE DeviceHandle;
LPCWSTR UnicodeName = L"IFHSCNT1";
char DeviceName[256];
int len;
len = WideCharToMultiByte(CP_ACP, 0, UnicodeName, -1, NULL, 0, NULL,
NULL);
WideCharToMultiByte(CP_ACP, 0, UnicodeName, -1, DeviceName, len, NULL,
NULL);
DeviceHandle = HScntOpen((LPCTSTR)DeviceName);
C (64-bit compiler)
HANDLE DeviceHandle;
DeviceHandle = HScntOpen(“IFHSCNT1”);
Visual Basic
Dim Name As String
Dim DeviceHandle As Long
Name = "IFHSCNT1" & Chr( 0 )
DeviceHandle = HScntOpen(Name)
Delphi
var
Name: String;
DeviceHandle: THandle;
Name := 'IFHSCNT1';
DeviceHandle := HScntOpen(Name);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
181
GPF-6320 Help for Windows
5.2.2 HScntClose
Description
The HScntClose function closes the high-speed counter and releases the resources for device access. Any
subsequent accesses to the device are forbidden.
Syntax
C
INT HScntClose(
HANDLE
hDeviceHandle
);
//Device handle
Visual Basic
Declare Function HScntClose Lib “IfHScnt.DLL”(_
ByVal hDeviceHandle
As Long_ ‘Device handle
)As Long
Delphi
function HScntClose(
THandle
hDeviceHandle:
//Device handle
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameter
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
Return Value
The HScntClose function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Comments
- To access to the device again, call the HScntOpen function.
- The configurations are cleared after the device is closed.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
182
GPF-6320 Help for Windows
Example
Closing the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntClose(hDeviceHandle);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntClose(hDeviceHandle)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntClose(hDeviceHandle);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
183
GPF-6320 Help for Windows
5.2.3 HScntGetDeviceInfo
Description
The HScntGetDeviceInfo function retrieves specifications of the device.
Syntax
C
INT HScntGetDeviceInfo(
HANDLE
hDeviceHandle,
PHSCNTDEVICEINFO
pDeviceInfo
);
Visual Basic
Declare Function HScntGetDeviceInfo Lib “IFHScnt.DLL”(_
ByVal hDeviceHandle
As Long_
ByRef pDeviceInfo
As HSCNTDEVICEINFO_
)As Long
Delphi
function HScntGetDeviceInfo (
THandle
hDeviceHandle:
HSCNTDEVICEINFO
var
pDeviceInfo:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
pDeviceInfo
Specifies the device handle obtained by the HScntOpen function.
Points to the HSCNTDEVICEINFO structure to store specifications of the
device.
Return Value
The HScntGetDeviceInfo function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
184
GPF-6320 Help for Windows
Example
Retrieving the specifications of the device whose devicen name is “IFHSCNT1”.
C
INT nRet;
HANDLE hDeviceHandle;
HSCNTDEVICEINFO DeviceInfo;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntGetDeviceInfo(hDeviceHandle, &DeviceInfo);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim DeviceInfo As HSCNTDEVICEINFO
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntGetDeviceInfo(hDeviceHandle, DeviceInfo)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
DeviceInfo: HSCNTDEVICEINFO;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntGetDeviceInfo(hDeviceHandle, DeviceInfo);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
185
GPF-6320 Help for Windows
5.2.4 HScntReset
Description
The HScntReset function resets the setting and clears the counter of the specified channel.
Syntax
C
INT HScntReset(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
HANDLE
dwMode
);
Visual Basic
Declare Function HScntReset
ByVal
hDeviceHandle
ByVal
dwChSel
ByVal
dwMode
)As Long
Lib “IFHScnt.DLL”(_
As Long,_
As Long,_
As Long_
Delphi
function HScntReset(
THandle;
hDeviceHandle:
Dword;
dwChSel:
Dword
dwMode:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
dwChSel
Specifies the channel.
Bit
bit31 to bit2
bit1
bit0
Description
Reserved
Channel 2
Channel 1
To specify the channel, set 1 to the corresponding bit. Multiple channels can
be specified.
Example) To specify four channels (channel 1 to channel 4), specify Fh.
dwMode
Specifies the reset item.
Code
IFHSCNT_RESET_DEVICE
Description
Resets the setting.
The setting for the specified channel is
reset and initialized at the default value.
If sampling is running, it will stop.
IFHSCNT_RESET_COUNTER Clears the counter.
The counter is cleared.
To reset the setting and clear the counter synchronously, specify ORed value.
Return Value
The HScntReset function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
186
GPF-6320 Help for Windows
Example
Resetting channel 1 and clearing the counter for channel 1 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntReset(hDeviceHandle, 0x01,
IFHSCNT_RESET_DEVICE | IFHSCNT_CLEAR_COUNTER);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntReset(hDeviceHandle, &H01,
IFHSCNT_RESET_DEVICE or IFHSCNT_CLEAR_COUNTER)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFUCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntReset(hDeviceHandle, $01,
IFHSCNT_RESET_DEVICE | IFHSCNT_CLEAR_COUNTER);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
187
GPF-6320 Help for Windows
5.2.5 HScntSetMode
Description
The HScntSetMode function configures the external control mode of counter.
Syntax
C
INT HScntSetMode(
HANDLE
hDeviceHandle,
INT
nChannel,
DWORD
dwMode
);
Visual Basic
Declare Function HScntSetMode Lib “IfHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByVal dwMode
As Long_
)As Long
Delphi
function HScntSetMode(
THandle;
hDeviceHandle:
Dword;
nChannel:
Dword
dwMode:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
nChannel
Specifies the channel to configure.
dwMode
Specifies the count mode.
Bit
bit31 to bit3
Reserved
Description
bit2
CLR
bit1
GATE
bit0
Reserved
GATE: Sets the external enable function of the counter by the GATE signal.
GATE
Description
0
External enable function: Disabled
1
External enable function: Enabled
CLR: Sets the external clear function of the counter by the CLR signal.
CLR
Description
0
External clear function: Disabled
1
External clear function: Enabled
Return Value
The HScntSetMode function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
188
GPF-6320 Help for Windows
Comment
Do not start counting by the HScntStartCount function when controlling counter eneble by the GATE signal.
If counting starts, the counter forcibly becomes enable status and the control of the counter enable by the GATE
signal becomes disabled.
Example
Enabling the external counter and clear functions for channel 1 on the device whose device name is
IFHSCNT1.
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntSetMode(hDeviceHandle, 1, 0x06);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntSetMode(hDeviceHandle, 1, &H06)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntSetMode(hDeviceHandle, 1, $06);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
189
GPF-6320 Help for Windows
5.2.6 HScntGetMode
Description
The HScntGetMode function retrieves the external control mode of counter.
Syntax
C
INT HScntGetMode(
HANDLE
hDeviceHandle,
INT
nChannel,
PDWORD
pdwMode
);
Visual Basic
Declare Function HScntGetMode Lib “IFHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByRef pdwMode
As Long_
)As Long
Delphi
function HScntGetMode(
THandle;
hDeviceHandle:
Dword;
nChannel:
var pdwMode:
Dword
): Integer; stdcall; external ‘IFHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
nChannel
Specifies the channel to retrieve.
pdwMode
Points to a variable to store the count mode.
Bit
bit31 to bit3
bit2
Reserved
CLR
Description
bit1
GATE
bit0
Reserved
GATE: Retrieves the external enable function of the counter by the
GATE signal.
GATE
Description
0
External enable function: Disabled
1
External enable function: Enabled
CLR: Retrieves the external counter clear of the counter by the CLR
signal.
CLR
Description
0
External clear function: Disabled
1
External clear function: Enabled
Copyright 2004, 2014 Interface Corporation. All rights reserved.
190
GPF-6320 Help for Windows
Return Value
The HScntGetMode function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Returnvalues.
Example
Retrieving the count mode of channe 2 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwMode;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntGetMode(hDeviceHandle, 2, &dwMode);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwMode As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntGetMode(hDeviceHandle, 2, dwMode)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwMode: Dword;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntGetMode(hDeviceHandle, 2, dwMode);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
191
GPF-6320 Help for Windows
5.2.7 HScntReadCounter
Description
The HScntReadCounter function retrieves the counter value.
Syntax
C
INT HScntReadCounter(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwCounter
);
Visual Basic
Declare Function HScntReadCounter Lib “IFHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByVal dwChSel
As Long,_
ByRef pdwCounter
As Long_
)As Long
Delphi
function HScntReadCounter(
THandle;
hDeviceHandle:
Dword;
dwChSel:
var pdwCounter:
Dword
): Integer; stdcall; external ‘IFHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
dwChSel
Specifies the channel to retrieve. The value 1 is specified to the
corresponding bit. Multiple channels can be retrieved at the same
time.
Bit
bit31 to bit4
bit1
bit0
Reserved
Channel 2 Channel 1
Description
pdwCounter
Points to an array to store the counter value
dwCounter[0], dwCounter[1]: Counter value for channel 1 and
channel 2
Range: 0 to 4294967295 (or 0 to FFFFFFFFh)
Return Value
The HScntReadCounter function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
192
GPF-6320 Help for Windows
Example
Retrieving the counter value of channel 1 and channel 2 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwCounter[2];
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntReadCounter(hDeviceHandle, 0x03, dwCounter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwCounter(0 To 1) As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntReadCounter(hDeviceHandle, &H03, dwCounter(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwCounter: Array[0..1] of Dword;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntReadCounter(hDeviceHandle, $03, dwCounter[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
193
GPF-6320 Help for Windows
5.2.8 HScntGetStaus
Description
The HScntGetStatus function retrieves the counter status.
Syntax
C
INT HScntGetStatus(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
PDWORD
pdwStatus
);
Visual Basic
Declare Function HScntGetStatus Lib “IfHScnt.DLL”(_
ByVal
As Long,_
hDeviceHandle
ByVal
As Long,_
dwChSel
ByRef
As Long_
pdwStatus
)As Long
Delphi
function HScntGetStatus(
THandle;
hDeviceHandle:
Dword;
dwChSel:
Dword
var pdwStatus:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
dwChSel
Specifies the channel to retrieve. Specify 1 to the corresponding bit.
Multiple channels can be retrieved at the same time.
bit31 to bit2
Bit
bit1
bit0
Description
Reserved
Channel 2 Channel 1
pdwStatus
Points to an array to store the counter status.
dwStatus[0], dwStatus[1]: Counter status for channel 1 and channel 2.
bit31 to bit7 bit6 bit5 to bit3 bit2
Bit
bit1
bit0
Description
Reserved ST0 Reserved CLR GATE CLK
ST0: Retrieves the counter status.
ST0
Description
0
Stop
1
Start
CLK, GATE, CLR: Retrieves the status for the input pin.
CLK, GATE, CLR
Description
0
Low
1
High
Copyright 2004, 2014 Interface Corporation. All rights reserved.
194
GPF-6320 Help for Windows
Return Value
The HScntGetStatus function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values
Example
Retrieving the counter status of channel 1 and channel 2 on the device whose device name is IFHSCNT1
C
INT nRet;
DWORD dwStatus[2];
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntGetStatus(hDeviceHandle, 0x03, dwStatus);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwStatus(0 To 1) As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntGetStatus(hDeviceHandle, &H03, dwStatus(0))
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwStatus: array[0..1] of Dword;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntGetStatus(hDeviceHandle, $03, dwStatus[0]);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
195
GPF-6320 Help for Windows
5.2.9 HScntStartCount
Description
The HScntStartCount function starts the count.
Syntax
C
INT HScntStartCount(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwStartMode
);
Visual Basic
Declare Function HScntStartCount Lib “IFHScnt.DLL”(_
ByVal
hDeviceHandle As Long,_
ByVal
As Long,_
dwChSel
ByVal
As Long_
dwStartMode
)As Long
Delphi
function HScntStartCount(
THandle;
hDeviceHandle:
Dword;
dwChSel:
Dword
dwStartMode:
): Integer; stdcall; external ‘IFHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
dwChSel
Specifies the channel to configure. Specify 1 to the corresponding bit.
Multiple channels can be specified at the same time.
Bit
bit31 to bit2
bit1
bit0
Description
Reserved
Channel 2
Channel 1
dwStartMode
Specifies the start mode.
Code
IFHSCNT_CMD_START
Copyright 2004, 2014 Interface Corporation. All rights reserved.
196
Description
Starts counting.
GPF-6320 Help for Windows
Return Value
The HScntStartCount function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Example
Starting the count of channel 1 and channel 2 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntStartCount(hDeviceHandle, 0x03, IFHSCNT_CMD_START);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntStartCount(hDeviceHandle, &H03, IFHSCNT_CMD_START)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntStartCount(hDeviceHandle, $0F, IFHSCNT_CMD_START);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
197
GPF-6320 Help for Windows
5.2.10 HScntStopCount
Description
The HScntStopCount function stops counting.
Syntax
C
INT HScntStopCount(
HANDLE
hDeviceHandle,
DWORD
dwChSel,
DWORD
dwStopMode
);
Visual Basic
Declare Function HScntStopCount Lib “IFHScnt.DLL”(_
ByVal
As Long,_
hDeviceHandle
ByVal
As Long,_
dwChSel
ByVal
As Long_
dwStopMode
)As Long
Delphi
function HScntStopCount(
THandle;
hDeviceHandle:
Dword;
dwChSel:
Dword
dwStopMode:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
dwChSel
Specifies the channel to configure. The value 1 is specified to the
corresponding bit. Multiple channels can be specified at the same time.
bit31 to bit2
Bit
bit1
bit0
Description
Reserved
Channel 2
Channel 1
dwStopMode
Specifies the stop mode.
Code
IFHSCNT_CMD_STOP
Description
Stops counting.
Return Value
The HScntStopCount function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
198
GPF-6320 Help for Windows
Example
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntStopCount(hDeviceHandle, 0x01, IFHSCNT_CMD_STOP);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntStopCount(hDeviceHandle, &H01, IFHSCNT_CMD_STOP)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntStopCount(hDeviceHandle, $01, IFHSCNT_CMD_STOP);
Stop the count of channel 1 on the device whose device name is IFHSCNT1.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
199
GPF-6320 Help for Windows
5.2.11 HScntSetEventMask
Description
The HScntSetEventMask function masks interrupt events.
Syntax
C
INT HScntSetEventMask(
HANDLE hDeviceHandle,
INT
nChannel,
DWORD
dwEventMask
);
Visual Basic
Declare Function HScntSetEventMask Lib “IfHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByVal dwEventMask
As Long_
)As Long
Delphi
function HScntSetEventMask(
THandle;
hDeviceHandle:
Integer;
nChannel:
Dword
dwEventMask:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
nChannel
Specifies the device handle obtained by the HScntOpen function.
Specifies the channel to configure.
Interval timer and input edge interrupt events can be masked by specifying
IFHSCNT_EVENT_CH_TIMER and IFHSCNT_EVENT_CH_EDGE.
IFHSCNT_EVENT_CH_TIMER and IFHSCNT_EVENT_CH_EDGE are
applicable only to the LPC-632102 and PEX-632102.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
200
GPF-6320 Help for Windows
dwEventMask
Specifies the mask setting for interrupt events.
- nChannel: 1, 2
dwEventMask
Description
Reserved
Interrupt event for the rising edge detection of CLR
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit6
CLR RISE
Interrupt event for the falling edge detection of CLR
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit5
GATE FALL Interrupt event for the rising edge detection of GATE
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit4
GATE RISE Interrupt event for the falling edge detection of GATE
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit3 to bit1
Reserved
bit0
CRF
Carry interrupt event
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
* Interval timer interruption is applicable only to the LPC-632102 and
PEX-632102.
bit31 to bit8
bit7
CLR FALL
- nChannel: IFHSCNT_EVENT_CH_TIMER
dwEventMask
Description
bit31 to bit5
Reserved
bit4
SIGT
Interrupt event for interval timer*
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit3 to bit0
Reserved
* Interval timer interrupt mask is applicable to the LPC-632102 and
PEX-632102.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
201
GPF-6320 Help for Windows
- nChannel: IFHSCNT_EVENT_CH_EDGE
dwEventMask
Description
bit31 SFIN16 Interrupt event for the falling edge detection of IN16
bit30 SFIN15 Interrupt event for the falling edge detection of IN15
bit29 SFIN14 Interrupt event for the falling edge detection of IN14
bit28 SFIN13 Interrupt event for the falling edge detection of IN13
bit27 SFIN12 Interrupt event for the falling edge detection of IN12
bit26 SFIN11 Interrupt event for the falling edge detection of IN11
bit25 SFIN10 Interrupt event for the falling edge detection of IN10
bit24 SFIN9
Interrupt event for the falling edge detection of IN9
bit23 SFIN8
Interrupt event for the falling edge detection of IN8
bit22 SFIN7
Interrupt event for the falling edge detection of IN7
bit21 SFIN6
Interrupt event for the falling edge detection of IN6
bit20 SFIN5
Interrupt event for the falling edge detection of IN5
bit19 SFIN4
Interrupt event for the falling edge detection of IN4
bit18 SFIN3
Interrupt event for the falling edge detection of IN3
bit17 SFIN2
Interrupt event for the falling edge detection of IN2
bit16 SFIN1
Interrupt event for the falling edge detection of IN1
bit15 SRIN16 Interrupt event for the rising edge detection of IN16
bit14 SRIN15 Interrupt event for the rising edge detection of IN15
bit13 SRIN14 Interrupt event for the rising edge detection of IN14
bit12 SRIN13 Interrupt event for the rising edge detection of IN13
bit11 SRIN12 Interrupt event for the rising edge detection of IN12
bit10 SRIN11 Interrupt event for the rising edge detection of IN11
bit9
SRIN10 Interrupt event for the rising edge detection of IN10
bit8
SRIN9
Interrupt event for the rising edge detection of IN9
bit7
SRIN8
Interrupt event for the rising edge detection of IN8
bit6
SRIN7
Interrupt event for the rising edge detection of IN7
bit5
SRIN6
Interrupt event for the rising edge detection of IN6
bit4
SRIN5
Interrupt event for the rising edge detection of IN5
bit3
SRIN4
Interrupt event for the rising edge detection of IN4
bit2
SRIN3
Interrupt event for the rising edge detection of IN3
bit1
SRIN2
Interrupt event for the rising edge detection of IN2
bit0
SRIN1
Interrupt event for the rising edge detection of IN1
dwEventMask
0: Masked (interrupt disabled)
1: Unmasked (interrupt enabled)
* Edge detection interrupt mask is applicable to the LPC-632102 and PEX-632102.
Return Value
The HScntSetEventMask function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
202
GPF-6320 Help for Windows
Example
Enabling the carry interrupt event of channel 1 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetEventMask(hDeviceHandle, 1, 0x01);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetEventMask(hDeviceHandle, 1, &H01)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetEventMask(hDeviceHandle, 1, $01);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
203
GPF-6320 Help for Windows
5.2.12 HScntGetEventMask
Description
The HScntGetEventMask function retrieves the interrupt event mask settings.
Syntax
C
INT HScntGetEventMask(
HANDLE hDeviceHandle,
INT
nChannel,
PDWORD pdwEventMask
);
Visual Basic
Declare Function HScntGetEventMask Lib “IfHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByVal nChannel
As Long,_
ByRef pdwEventMask
As Long_
)As Long
Delphi
function HScntGetEventMask(
THandle;
hDeviceHandle:
Integer;
nChannel:
Dword
var pdwEventMask:
): Integer; stdcall; external ‘IfHScnt.DLL’;
Copyright 2004, 2014 Interface Corporation. All rights reserved.
204
GPF-6320 Help for Windows
Parameters
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
nChannel
Specifies the channel to retrieve.
Specify HSCNT_EVENT_CH_TIMER and HSCNT_EVENT_CH_EDGE
to retrieve the mask setting values of interval timer interrupt and input edge
interrupt.
HSCNT_EVENT_CH_TIMER and HSCNT_EVENT_CH_EDGE are
applicable only to the LPC-632102 and PEX-632102.
pdwEventMask
Points to a variable to store the mask setting for interrupt events.
- nChannel: 1, 2
dwEventMask
Description
bit31 to bit8
Reserved
bit7
CLR FALL
Interrupt event for the rising edge detection of CLR
0 Masked (interrupt disabled)
1 Unmasked (interrupt enabled)
bit6
CLR RISE
Interrupt event for the falling edge detection of CLR
0 Masked (interrupt disabled)
1 Unmasked (interrupt enabled)
bit5
GATE FALL
Interrupt event for the rising edge detection of GATE
0 Masked (interrupt disabled)
1 Unmasked (interrupt enabled)
bit4
GATE RISE
Interrupt event for the falling edge detection of
GATE
0 Masked (interrupt disabled)
1 Unmasked (interrupt enabled)
bit3 to bit1
Reserved
bit0
CRF
Carry interrupt event
0 Masked (interrupt disabled)
1 Unmasked (interrupt enabled)
- nChannel: HSCNT_EVENT_CH_TIMER
dwEventMask
Description
Reserved
Interrupt event for interval timer*
0
Masked (interrupt disabled)
1
Unmasked (interrupt enabled)
bit3 to bit0
Reserved
* Interval timer interrupt mask is applicable to the LPC-632102 and
PEX-632102.
bit31 to bit5
bit4
SIGT
Copyright 2004, 2014 Interface Corporation. All rights reserved.
205
GPF-6320 Help for Windows
- nChannel: HSCNT_EVENT_CH_EDGE
dwEventMask
Description
bit31 SFIN16 Interrupt event for the falling edge detection of IN16
bit30 SFIN15 Interrupt event for the falling edge detection of IN15
bit29 SFIN14 Interrupt event for the falling edge detection of IN14
bit28 SFIN13 Interrupt event for the falling edge detection of IN13
bit27 SFIN12 Interrupt event for the falling edge detection of IN12
bit26 SFIN11 Interrupt event for the falling edge detection of IN11
bit25 SFIN10 Interrupt event for the falling edge detection of IN10
bit24 SFIN9
Interrupt event for the falling edge detection of IN9
bit23 SFIN8
Interrupt event for the falling edge detection of IN8
bit22 SFIN7
Interrupt event for the falling edge detection of IN7
bit21 SFIN6
Interrupt event for the falling edge detection of IN6
bit20 SFIN5
Interrupt event for the falling edge detection of IN5
bit19 SFIN4
Interrupt event for the falling edge detection of IN4
bit18 SFIN3
Interrupt event for the falling edge detection of IN3
bit17 SFIN2
Interrupt event for the falling edge detection of IN2
bit16 SFIN1
Interrupt event for the falling edge detection of IN1
bit15 SRIN16 Interrupt event for the rising edge detection of IN16
bit14 SRIN15 Interrupt event for the rising edge detection of IN15
bit13 SRIN14 Interrupt event for the rising edge detection of IN14
bit12 SRIN13 Interrupt event for the rising edge detection of IN13
bit11 SRIN12 Interrupt event for the rising edge detection of IN12
bit10 SRIN11 Interrupt event for the rising edge detection of IN11
bit9
SRIN10 Interrupt event for the rising edge detection of IN10
bit8
SRIN9
Interrupt event for the rising edge detection of IN9
bit7
SRIN8
Interrupt event for the rising edge detection of IN8
bit6
SRIN7
Interrupt event for the rising edge detection of IN7
bit5
SRIN6
Interrupt event for the rising edge detection of IN6
bit4
SRIN5
Interrupt event for the rising edge detection of IN5
bit3
SRIN4
Interrupt event for the rising edge detection of IN4
bit2
SRIN3
Interrupt event for the rising edge detection of IN3
bit1
SRIN2
Interrupt event for the rising edge detection of IN2
bit0
SRIN1
Interrupt event for the rising edge detection of IN1
dwEventMask
0: Masked (interrupt disabled)
1: Unmasked (interrupt enabled)
* Edge detection interrupt mask is applicable to the LPC-632102 and PEX-632102.
Return Value
The HScntGetEventMask function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
206
GPF-6320 Help for Windows
Example
Retrieving the interrupt event mask setting of channel 1 on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwEventMask;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntGetEventMask(hDeviceHandle, 1, &dwEventMask);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwEventMask As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntGetEventMask(hDeviceHandle, 1, dwEventMask)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwEventMask: Dword;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntGetEventMask(hDeviceHandle, 1, dwEventMask);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
207
GPF-6320 Help for Windows
5.2.13 HScntSetEvent
Description
The HScntSetEvent function registers a callback routine.
Syntax
C
INT HScntSetEvent(
HANDLE
PHSCNTEVENTREQ
);
hDeviceHandle,
pEvent
Visual Basic
Declare Function HScntSetEvent Lib “IfHScnt.DLL”(_
ByVal hDeviceHandle
As Long,_
ByRef pEvent
HSCNTEVENTREQ_
)As Long
Delphi
function HScntSetEvent(
THandle;
hDeviceHandle:
var pEvent:
HSCNTEVENTREQ
): Integer; stdcall; external ‘IfHScnt.DLL’;
Parameters
hDeviceHandle
pEvent
Specifies the device handle obtained by the HScntOpen function.
Points to the user callback function that is called when interruption is
generated and the structure to configure message. Refer to Structures for
details.
Return Value
The HScntSetEvent function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
208
GPF-6320 Help for Windows
Comment
Callback routine is defined as follows.
<Syntax>
VOID CALLBACK lpCallBackProc(INT nChannel, DWORD dwEvent, DWORD dwUser );
<Parameters>
nChannel
Interrupted channel
dwEvent
Source to call callback routine
The value 1 is set to the corresponding bits.
dwUser
User data
The user data specified when event is configured is set.
Example
Configuring the callback routine (or event) and interupt mask of channel 1 on the device whose device name is
IFHSCNT1
C (Callback routine)
// Callback routine
void CALLBACK lpEventProc(INT nChannel, DWORD dwEvent, DWORD dwUser){
// Describes the interrupt process.
:
:
}
// Main routine
INT nRet;
HANDLE hDeviceHandle;
HSCNTEVENTREQ Event;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetEventMask(hDeviceHandle, 1, 0xF1);
Event.hWnd = NULL;
Event.uMessage[0] = WM_NULL;
Event.uMessage[1] = WM_NULL;
Event.uMessage[2] = WM_NULL;
Event.uMessage[3] = WM_NULL;
Event.uMessage[4] = WM_NULL;
Event.uMessage[5] = WM_NULL;
Event.uMessage[6] = WM_NULL;
Event.uMessage[7] = WM_NULL;
Event.lpCallBackProc = (PLPHSCNTCALLBACK)lpEventProc;
Event.dwUser = 0x1234;
nRet = HScntSetEvent(hDeviceHandle, &Event);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
209
GPF-6320 Help for Windows
C (Standby for event)
Asynchronous process
INT nRet;
OVERLAPPED OverLapped;
HANDLE hDeviceHandle;
HSCNTEVENTREQ Event;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetEventMask(hDeviceHandle, 1, 0xF1);
OverLapped.hEvent = CreateEvent(0,FALSE,FALSE,NULL);
Event.hWnd = NULL;
Event.uMessage[0] = WM_NULL;
Event.uMessage[1] = WM_NULL;
Event.uMessage[2] = WM_NULL;
Event.uMessage[3] = WM_NULL;
Event.uMessage[4] = WM_NULL;
Event.uMessage[5] = WM_NULL;
Event.uMessage[6] = WM_NULL;
Event.uMessage[7] = WM_NULL;
Event.hEvent = OverLapped.hEvent;
Event.lpCallBackProc = NULL;
Event.dwUser = 0x1234;
nRet = HScntSetEvent(hDeviceHandle, &Event);
if (nRet == IFHSCNT_ERROR_SUCCESS) {
// Wait for an event
// Wait for an event using WaitFirSingleObject
WaitForSingleObject(OverLapped.hEvent, INFINITE);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
210
GPF-6320 Help for Windows
Visual Basic (standby setting)
Because of the language specification of Visual Basic Ver.6.0, any callback routine are not available. Use
message of event function instead.
Assynchronous process
Public lpOverlapped As OVERLAPPED
Dim lpszName As String
Dim hDeviceHandle As Long
Dim Event As HSCNTEVENTREQ
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetEventMask(hDeviceHandle, 1, &HF1)
lpOverlapped.hEvent = CreateEvent(nul, False, False, nul)
Event.hWnd = 0
Event.uMessage(0) = 0
Event.uMessage(1) = 0
Event.uMessage(2) = 0
Event.uMessage(3) = 0
Event.uMessage(4) = 0
Event.uMessage(5) = 0
Event.uMessage(6) = 0
Event.uMessage(7) = 0
Event.hEvent = OverLapped.hEvent
Event.lpCallBackProc = 0
Event.dwUser = &H1234
nRet = HScntSetEvent(hDeviceHandle, Event)
' Wait for an event
' Wait for an event using WaitFirSingleObject
nRet = WaitForSingleObject(lpOverlapped.hEvent, 0)
Copyright 2004, 2014 Interface Corporation. All rights reserved.
211
GPF-6320 Help for Windows
Visual Basic (Callback routine)
// callback routine
procedure lpEventProc(nChannel: Integer; dwEvent: DWORD; dwUser:
DWORD); stdcall;
var
//variable difinition
begin
// writes interrupt event
:
:
end;
// main routine
var
lpszName: String;
hDeviceHandle: THandle;
Event: HSCNTEVENTREQ;
begin
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetEventMask(hDeviceHandle, 1, $F1);
Event.hWnd := 0;
Event.uMessage[0] := WM_NULL;
Event.uMessage[1] := WM_NULL;
Event.uMessage[2] := WM_NULL;
Event.uMessage[3] := WM_NULL;
Event.uMessage[4] := WM_NULL;
Event.uMessage[5] := WM_NULL;
Event.uMessage[6] := WM_NULL;
Event.uMessage[7] := WM_NULL;
Event.hEvent := 0;
Event.lpCallBackProc := lpEventProc;
Event.dwUser := $1234;
nRet := HScntSetEvent(hDeviceHandle, Event);
:
end;
Copyright 2004, 2014 Interface Corporation. All rights reserved.
212
GPF-6320 Help for Windows
Delphi (standby setting)
Assynchronous process
var
OverLapped : TOverLapped;
nRet : Integer;
lpszName: String;
hDeviceHandle: THandle;
Event: HSCNTEVENTREQ;
begin
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetEventMask(hDeviceHandle, 1, $F1);
OverLapped.hEvent := CreateEvent(nil, False, False, Nil);
Event.hWnd := 0;
Event.uMessage[0] := WM_NULL;
Event.uMessage[1] := WM_NULL;
Event.uMessage[2] := WM_NULL;
Event.uMessage[3] := WM_NULL;
Event.uMessage[4] := WM_NULL;
Event.uMessage[5] := WM_NULL;
Event.uMessage[6] := WM_NULL;
Event.uMessage[7] := WM_NULL;
Event.hEvent := OverLapped.hEvent;
Event.lpCallBackProc := lpEventProc;
Event.dwUser := $1234;
nRet := HScntSetEvent(hDeviceHandle, Event);
// Wait for an event
// Wait for an event using WaitFirSingleObject
WaitForSingleObject(OverLapped.hEvent, INFINITE);
:
end;
Copyright 2004, 2014 Interface Corporation. All rights reserved.
213
GPF-6320 Help for Windows
5.2.14 HScntKillEvent
Description
The HScntKillEvent function releases messages and callback routine that runs when an interrupt event is
generated.
Syntax
C
INT HScntKillEvent(
HANDLE
hDeviceHandle
);
Visual Basic
Declare Function HScntKillEvent Lib “IFHScnt.DLL”(_
ByVal
As Long_
hDeviceHandle
)As Long
Delphi
function HScntKillEvent(
THandle
hDeviceHandle:
): Integer; stdcall; external ‘IFHScnt.DLL’;
Parameter
hDeviceHandle
Specifies the device handle obtained by the HScntOpen function.
Return Value
The HScntKillEvent function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
214
GPF-6320 Help for Windows
Example
Releasing the registered callback routine on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
.
.
.
nRet = HScntKillEvent(hDeviceHandle);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = “IFHSCNT1” & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
.
.
.
nRet = HScntKillEvent(hDeviceHandle)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := ‘IFHSCNT1’;
hDeviceHandle := HScntOpen(lpszName);
.
.
.
nRet := HScntKillEvent(hDeviceHandle);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
215
GPF-6320 Help for Windows
5.2.15 HScntSetDOEnable
Description
The HScntSetDOEnable function configures the general purpose output function.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntSetDOEnable(
hDeviceHandle,
HANDLE
dwOutEnable
DWORD
);
Visual Basic
Declare Function HScntSetDOEnable Lib "IFHScnt.DLL"(_
ByVal hDeviceHandle
As Long,_
ByVal dwOutEnable
As Long_
)As Long
Delphi
function HScntSetDOEnable(
hDeviceHandle:
THandle;
dwOutEnable:
Dword
): Integer; stdcall; external 'IFHScnt.DLL';
Parameters
hDeviceHandle
dwOutEnable
Specifies the device handle obtained by the HScntOpen function.
Specifies the pin to be allowed to output.
pdwOutEnable
bit0
bit1
bit2
bit3
Bit4 to bit31
Description
IO0 General purpose output setting for OUT1 to OUT4
0 Forbidden
1 Permissive
IO1 General purpose output setting for OUT5 to OUT8
0 Forbidden
1 Permissive
IO2 General purpose output setting for OUT9 to OUT12
0 Forbidden
1 Permissive
IO3 General purpose output setting for OUT13 to OUT 16
0
Forbidden
1
Permissive
Reserved
Return Value
The HScntSetDOEnable function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
216
GPF-6320 Help for Windows
Comment
• HScntOutputDO function
When the device is opened by using the HScntOpen function, OUT1 to OUT16 pins are prohibited to output.
Before calling the HScntOutputDO function, set the output setting for the pin which you want to control by
using the HScntSetDOEnable function.
Example
Allowing the OUT1 through OUT4 pins on the device whose device name is IFUCNT1 for general purpose
outptut
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetDOEnable(hDeviceHandle, 0x01);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetDOEnable(hDeviceHandle, &H01)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetDOEnable(hDeviceHandle, $01);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
217
GPF-6320 Help for Windows
5.2.16 HScntGetDOEnable
Description
The HScntGetDOEnable function retrieves the general purpose output settings.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntGetDOEnable(
HANDLE
hDeviceHandle,
PDWORD
pdwOutEnable
);
Visual Basic
Declare Function HScntGetDOEnable Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByRef
As Long_
pdwOutEnable
)As Long
Delphi
function HScntGetDOEnable(
THandle;
hDeviceHandle:
Dword
var pdwOutEnable:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameters
hDeviceHandle
pdwOutEnable
Specifies the device handle obtained by the HScntOpen function.
Points to a variable to store the pin setting.
pdwOutEnable
bit0
bit1
bit2
bit3
Bit4 to bit31
Description
IO0
Output setting for OUT1 to OUT4
0 Forbidden
1 Permissive
IO1
Output setting for OUT5 to OUT8
0 Forbidden
1 Permissive
IO2
Output setting for OUT9 to OUT12
0 Forbidden
1 Permissive
IO3
Output setting for OUT13 to OUT 16
0 Forbidden
1 Permissive
Reserved
Copyright 2004, 2014 Interface Corporation. All rights reserved.
218
GPF-6320 Help for Windows
Return Value
The HScntGetDOEnable function returns IFUCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the general purpose output pin setting information on the device whose device name is IFUCNT1
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwOutEnabl;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntGetDOEnable(hDeviceHandle, &dwOutEnable);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwOutEnable As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntGetDOEnable(hDeviceHandle, dwOutEnable)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwOutEnable: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntGetOutEnable(hDeviceHandle, dwOutEnable);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
219
GPF-6320 Help for Windows
5.2.17 HScntInputDI
Description
The UcntInputDI function retrieves the status of general purpose input.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntInputDI(
HANDLE
hDeviceHandle,
PDWORD
pdwDI
);
Visual Basic
Declare Function HScntInputDI Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByRef
As Long_
pdwDI
)As Long
Delphi
function HScntInputDI(
THandle;
hDeviceHandle:
Dword
var pdwDI:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameters
hDeviceHandle
pdwDI
Specifies the device handle obtained by the HScntOpen function.
Points to a variable to store the input status.
Bit
Description
Bit
Description
bit31 to bit16
Reserved
bit8
bit7
IN9
IN8
bit15
IN16
bit6
IN7
Bit Data
1
0
bit14
IN115
bit5
IN6
bit13
IN14
bit4
IN5
bit12
IN13
bit3
IN4
bit11
IN12
bit2
IN3
bit10
IN11
bit1
IN2
bit9
IN10
bit0
IN1
Description
High
Low
Return Value
The HScntInputDI function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
220
GPF-6320 Help for Windows
Example
Retrieving the general purpose input status of IN1 to IN16 on the device whose device name is IFUCNT1
C
INT nRet;
DWORD dwDI;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntInputDI(hDeviceHandle, &dwDI);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwDI As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntInputDI(hDeviceHandle, dwDI)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwDI: Dword;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntInputDI(hDeviceHandle, dwDI);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
221
GPF-6320 Help for Windows
5.2.18 HScntOutputDO
Description
The HScntOutputDO function controls the general purpose output.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntOutputDO(
HANDLE
hDeviceHandle,
DWORD
dwDO
);
Visual Basic
Declare Function HScntOutputDO Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByVal
As Long_
dwDO
)As Long
Delphi
function HScntOutputDO(
THandle;
hDeviceHandle:
Dword
dwDO:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameter
hDeviceHandle
dwDO
Specifies the device handle obtained by the HScntOpen function.
Specifies the general purpose output.
Bit
Description
Bit
Description
bit31 to bit16
Reserved
bit8
bit7
IN9
IN8
bit15
IN16
bit6
IN7
Bit data
1
0
bit14
IN115
bit5
IN6
bit13
IN14
bit4
IN5
bit12
IN13
bit3
IN4
bit11
IN12
bit2
IN3
bit10
IN11
bit1
IN2
bit9
IN10
bit0
IN1
Description
High
Low
Return Value
The HScntOutputDO function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
222
GPF-6320 Help for Windows
Comment
• HScntOutputDO function
By using the HScntOutputDO function, the output status for the input pin such as IN1/OUT1 to IN16/OUT16
can be changed. Before calling the HScntOutputDO function, confirm the connection. Because the external
equipment may be damaged when the HScntOutputDO function is called while the external equipment is
connected with the input pin for pulse output.
• When the device is opened by using the HScntOpen function, OUT1 to OUT16 is prohibited to output.
Before calling the HScntOutputDO function, configure the output setting for the pin which you want to
control by using the HScntSetDOEnable function.
Example
Configuring OUT1 pin on the device whose device name is IFUCNT1 to high
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetOutEnable(hDeviceHandle, 0x01);
nRet = HScntOutputDO(hDeviceHandle, 0x01);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetDOEnable(hDeviceHandle, &H01)
nRet = HScntOutputDO(hDeviceHandle, &H01)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetDOEnable(hDeviceHandle, $01);
nRet := HScntOutputDO(hDeviceHandle, $01);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
223
GPF-6320 Help for Windows
5.2.19 HScntSetTimerConfig
Description
The HScntSetTimerConfig function configures the interval timer.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntSetTimerConfig(
HANDLE
hDeviceHandle,
BYTE
bTimerConfigValue
);
Visual Basic
Declare Function HScntSetTimerConfig Lib "IFHScnt.DLL"( _
ByVal hDeviceHandle
As Long, _
ByVal bTimerConfigValue
As Byte _
)As Long
Delphi
function HScntSetTimerConfig(
THandle;
hDeviceHandle:
Byte
bTimerConfigValue:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameter
hDeviceHandle
bTimerConfigValue
Specifies the device handle obtained by the HScntOpen function.
Specifies the setting value of interval timer.
The interval timer event frequency is obtained by multiplying the
base clock frequency by the clock divisor.
The clock divisor is specified by CTL1, CTL2, CTL3, and CTL4.
The base clock frequency is specified by CTL5, CTL6, and
CTL7.
Bit
bit7
bit6
bit5
bit4
Reserved
CTL7
CTL6
CTL5
Description
Bit
bit3
bit2
bit1
bit0
CTL4
CTL3
CTL2
CTL1
Description
Copyright 2004, 2014 Interface Corporation. All rights reserved.
224
GPF-6320 Help for Windows
Clock Divisor (CTL1 to CTL4)
Clock Divisor
Timer stop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CTL4
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
CTL3
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
CTL2
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
CTL1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Base Clock Frequency (CTL5 to CTL7)
Base Clock Frequency
10us
100us
1ms
10ms
100ms
CTL7
0
0
0
0
1
CTL6
0
0
1
1
0
CTL5
0
1
0
1
0
Return Value
The HScntSetTimerConfig function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Comment
To generate interval timer interrupt event, enable the interrupt events of interval timer with the
HScntSetEventMask and HScntSetEvent functions.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
225
GPF-6320 Help for Windows
Example
Configuring the interval timer on the device whose device name is IFHSCNT1 to 1s (100ms × 10)
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetTimerConfig(hDeviceHandle, 0x4A);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetTimerConfig(hDeviceHandle, &H4A)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntSetTimerConfig(hDeviceHandle, $4A);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
226
GPF-6320 Help for Windows
5.2.20 HScntGetTimerConfig
Description
The HScntGetTimerConfig function retrieves the counter value of the interval timer.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntGetTimerConfig(
HANDLE
hDeviceHandle,
PBYTE
pbTimerConfigValue
);
Visual Basic
Declare Function HScntGetTimerConfig Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByRef
As Byte_
pbTimerConfigValue
)As Long
Delphi
function HScntGetTimerConfig(
THandle;
hDeviceHandle:
Byte
var pbTimerConfigValue:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameter
hDeviceHandle
pbTimerConfigValue
Specifies the device handle obtained by the HScntOpen function.
Points to the variable to store the setting value of interval timer.
The interval timer event frequency is obtained by multiplying the
base clock frequency by the clock divisor.
The clock divisor is specified by CTL1, CTL2, CTL3, and CTL4.
The base clock frequency is specified by CTL5, CTL6, and CTL7.
Bit
bit7
bit6
bit5
bit4
Reserved
CTL7
CTL6
CTL5
Description
Bit
bit3
bit2
bit1
bit0
CTL4
CTL3
CTL2
CTL1
Description
Copyright 2004, 2014 Interface Corporation. All rights reserved.
227
GPF-6320 Help for Windows
Clock Divisor (CTL1 to CTL4)
Clock Divisor
CTL4
Timer is not enabled
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
CTL3
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
CTL2
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
CTL1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Base Clock Frequency (CTL5 to CTL7)
Base Clock Frequency
10us
100us
1ms
10ms
100ms
CTL7
0
0
0
0
1
CTL6
0
0
1
1
0
CTL5
0
1
0
1
0
Return Value
The HScntGetTimerConfig function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
228
GPF-6320 Help for Windows
Example
Retrieving the interval timer setting on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
BYTE bTimerConfigValue;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntGetTimerConfig(hDeviceHandle, &bTimerConfigValue);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim bTimerConfigValue As Byte
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntGetTimerConfig(hDeviceHandle, bTimerConfigValue)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
bTimerConfigValue: Byte;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntGetTimerConfig(hDeviceHandle, bTimerConfigValue);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
229
GPF-6320 Help for Windows
5.2.21 HScntGetTimerCount
Description
The HScntGetTimerCount retrieves the counter value of interval timer.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntGetTimerCount(
HANDLE
hDeviceHandle,
PBYTE
pbTimerCount
);
Visual Basic
Declare Function HScntGetTimerCount Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByRef
As Byte_
pbTimerCount
)As Long
Delphi
function HScntGetTimerCount(
THandle;
hDeviceHandle:
Byte
var pbTimerCount:
): Integer; stdcall; external 'IFHScnt.DLL';
Copyright 2004, 2014 Interface Corporation. All rights reserved.
230
GPF-6320 Help for Windows
Parameter
hDeviceHandle
pbTimerCount
Specifies the device handle obtained by the HScntOpen function.
Specifies the timer configuration data.
The current status configured by HScntSetTimerConfig function is
retrieved by a 4-bit counter.
Bit
bit7
bit6
bit5
bit4
Reserved
Reserved Reserved
Reserved
Description
Bit
bit3
bit2
bit1
bit0
CTL4
CTL3
CTL2
CTL1
Description
Clock Divisor (CTL1 to CTL4)
Count
CTL4
0
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
CTL3
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
CTL2
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
CTL1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Return Value
The HScntGetTimerCount function returns IFHSCNT_ERROR_SUCCESS if the process is successfully
completed. Otherwise, this function returns another code. Please refer to the Return Values.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
231
GPF-6320 Help for Windows
Example
Retrieving the counter value of the interval timer on the device whose device name is IFHSCNT1
C
INT nRet;
HANDLE hDeviceHandle;
BYTE bTimerCount;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntGetTimerCount(hDeviceHandle, &bTimerCount);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim bTimerCount As Byte
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntGetTimerCount(hDeviceHandle, bTimerCount)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
bTimerCount: Byte;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntGetTimerCount(hDeviceHandle, bTimerCount);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
232
GPF-6320 Help for Windows
5.2.22 HScntSetFilter
Description
The HScntSet Filter configures the digital filter.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntSetFilter(
HANDLE
hDeviceHandle,
DWORD
dwFilter
);
Visual Basic
Declare Function HScntSetFilter Lib "IFHScnt.DLL"(_
ByVal
As Long,_
hDeviceHandle
ByVal
As Long_
dwFilter
)As Long
Delphi
function HScntSetFilter(
THandle;
hDeviceHandle:
Dword
dwFilter:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameter
hDeviceHandle
dwFilter
Specifies the device handle obtained by the HScntOpen function.
Specifies the digital filter.
Bit
Description
Bit
Description
Bit
Description
Bit
Description
Bit
Description
bit15
DCLK21
bit11
DCNT23
bit7
DCLK11
bit3
DCNT13
bit31∼bit16
Reserved
bit14
bit13
DCLK20
Reserved
bit10
bit9
DCNT22
DCNT21
bit6
bit5
DCLK10
Reserved
bit2
bit1
DCNT12
DCNT11
bit12
DCNT24
bit8
DCNT20
bit4
DCNT14
bit0
DCNT10
Digital Filter (IN1 to IN8)
Counter Value
DCNT14 to DCNT10
0
1
2
:
31
0
0
Stop
1 [us]
2 [us]
:
31 [us]
Copyright 2004, 2014 Interface Corporation. All rights reserved.
233
1
Stop
10 [us]
20 [us]
:
310 [us]
1
0
Stop
100 [us]
200 [us]
:
3100 [us]
1
-
DCLCK11
DCLCK10
GPF-6320 Help for Windows
Digital Filter (IN9 to In16)
Counter Value
DCNT24 to DCNT20
0
1
2
:
31
0
0
Stop
1 [us]
2 [us]
:
31 [us]
1
Stop
10 [us]
20 [us]
:
310 [us]
1
0
Stop
100 [us]
200 [us]
:
3100 [us]
1
DCLCK21
DCLCK20
-
Return Value
The HScntSetFilter function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Example
Configuring the digital filter (filter cycle: 1ms) to IN 1 through IN 8 and IN 9 through IN 16
C
INT nRet;
HANDLE hDeviceHandle;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntSetFilter(hDeviceHandle, 0x8A8A);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntSetFilter(hDeviceHandle, &H8A8A)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet = HScntSetFilter(hDeviceHandle, $8A8A);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
234
GPF-6320 Help for Windows
5.2.23 HScntGetFilter
Description
The HScntGetFilter retrieves the setting information of the digital filter.
* This function is applicable only to the LPC-632102 and PEX-632102.
Syntax
C
INT HScntGetFilter(
HANDLE
hDeviceHandle,
PDWORD
pdwFilter
);
Visual Basic
Declare Function HScntGetFilter Lib "IFHScnt.DLL"(_
ByVal hDeviceHandle,
As Long,_
ByRef pdwFilter
As Long_
)As Long
Delphi
function HScntGetFilter(
THandle;
hDeviceHandle:
Dword
var pdwFilter:
): Integer; stdcall; external 'IFHScnt.DLL';
Parameter
hDeviceHandle
pdwFilter
Specifies the device handle obtained by the HScntOpen function.
Point to the variable to store the setting value of digital filter. The
following table shows the stored values.
Bit
bit31∼bit16
Reserved
Description
Bit
bit15
bit14
bit13
bit12
DCLK21
DCLK20
Reserved
DCNT24
Description
Bit
bit11
bit10
bit9
bit8
DCNT23
DCNT22
DCNT21
DCNT20
Description
Bit
bit7
bit6
bit5
bit4
DCLK11
DCLK10
Reserved
DCNT14
Description
Bit
bit3
bit2
bit1
bit0
DCNT13
DCNT12
DCNT11
DCNT10
Description
Digital Filter (IN1 to IN8)
Counter Value
DCNT14 to DCNT10
0
1
2
:
31
0
0
Stop
1 [us]
2 [us]
:
31 [us]
Copyright 2004, 2014 Interface Corporation. All rights reserved.
235
1
Stop
10 [us]
20 [us]
:
310 [us]
1
0
Stop
100 [us]
200 [us]
:
3100 [us]
1
-
DCLCK11
DCLCK10
GPF-6320 Help for Windows
Digital Filter (IN9 to In16)
Counter Value
DCNT24 to DCNT20
0
1
2
:
31
0
0
Stop
1 [us]
2 [us]
:
31 [us]
1
Stop
10 [us]
20 [us]
:
310 [us]
1
0
Stop
100 [us]
200 [us]
:
3100 [us]
1
DCLCK21
DCLCK20
-
Return Value
The HScntGetFilter function returns IFHSCNT_ERROR_SUCCESS if the process is successfully completed.
Otherwise, this function returns another code. Please refer to the Return Values.
Example
Retrieving the setting information of the digital filter of IN1 through IN8 and IN9 through IN 16
C
INT nRet;
HANDLE hDeviceHandle;
DWORD dwFilter;
hDeviceHandle = HScntOpen(“IFHSCNT1”);
:
:
nRet = HScntGetFilter(hDeviceHandle, &dwFilter);
Visual Basic
Dim lpszName As String
Dim hDeviceHandle As Long
Dim dwFilter As Long
lpszName = "IFHSCNT1" & Chr( 0 )
hDeviceHandle = HScntOpen(lpszName)
:
:
nRet = HScntGetFilter(hDeviceHandle, dwFilter)
Delphi
var
lpszName: String;
hDeviceHandle: THandle;
dwFilter: Dword;
lpszName := 'IFHSCNT1';
hDeviceHandle := HScntOpen(lpszName);
:
:
nRet := HScntGetFilter(hDeviceHandle, dwFilter);
Copyright 2004, 2014 Interface Corporation. All rights reserved.
236
GPF-6320 Help for Windows
5.3 Structure
5.3.1 UCNTDEVICEINFO Structure
The UCNTDEVICEINFO structure contains the device information. This structure is used by the
UcntGetDeviceInfo function.
typedef struct {
DWORD
dwBoardType;
DWORD
dwBoardID;
} UCNTDEVICEINFO, PUCNTDEVICEINFO;
Member
dwBoardType
Description
Stores the model number.
Example: 632106 is stored in the case of the CBI-2106.
dwBoardID
Stores the board ID number.
5.3.2 UCNTSAMPLCONFIG Structure
The UCNTSAMPLCONFIG structure contains the sampling condition setting. This structure is used by the
UcntSetSamplingConfig and UcntGetSamplingConfig functions.
typedef struct {
DWORD
dwSmplNum;
DWORD
dwSmplEventNnm;
DWORD
dwSmplRepeat;
DWORD
dwStatusMode;
DWORD
dwErrCtrl;
} UCNTSMPLCONFIG, PUCNTSMPLCONFIG;
Member
dwSmplNum
Description
Specifies the number of samplings.
No status information exist <dwStatusMode = IFUCNT_NO_STATUS>
1 to 16,769,008 (FFDFF0 h)
1 to 16,384 (400 h) in the 64-bit OS environment
To specify the bigger number than 16,384, change internal buffer size by
the memory configuration utility (IFUCNTMEM.EXE).
Status information exist <dwStatusMode = IFUCNT_ADD_STATUS>
1 to 8,384,504 (7FEFF8 h)
1 to 8,192 (2000 h) in the 64-bit OS environment
To specify the bigger number than 8,192, change internal buffer size by
the memory configuration utility (IFUCNTMEM.EXE).
Copyright 2004, 2014 Interface Corporation. All rights reserved.
237
GPF-6320 Help for Windows
dwSmplEventNum
Specifies the number of sampling of event notification.
- No status information exist <dwStatusMode = IFUCNT_NO_STATUS>
0 or 1 to 1073741824 (40000000 h)
Note: If 0 is specified, no event occurs.
- Status information exist <dwStatusMode = IFUCNT_ADD_STATUS>
0 or 1 to 536870912 (1h to 20000000 h)
Note: If 0 is specified, no event occurs.
dwSmplRepeat
Specifies the repetition time for sampling.
Range: 0 or 1 to 65,535
Note: If 0 is specified, sampling will be running until the UcntStopSampling
function is called.
dwStatusMode
Adds the status information to the sampling data.
Code
Description
IFUCNT_NO_STATUS
IFUCNT_ADD_STATUS
dwErrCtrl
No addition (default setting value)
Addition
Specifies the operation when the sampling error occurs.
Code
Description
IFUCNT_FREERUN
IFUCNT_STOP_ORER
No operation
The operation is stopped by overrun error.
* When IFUCNT_ADD_STATUS is specified, the counter data (32 bits) and status data (32 bits) at the
occurrence of counter latch are saved.
The following values are stored for the status data (32 bits)
Bit
bit31 to bit20
bit19
bit18
bit17
bit16
Description
Reserved
BL
CL
ItoR
RtoI
Bit
bit15
bit14
bit13
bit12
bit11
bit10
bit9
bit8
Description
Reserved
LTST2
LTST1
LTST0
LBAFT
LAAFT
LBBEF
LABEF
Bit
bit7
bit5
bit4
bit3
bit2
bit1
bit0
bit6
Description
Reserved
LBBEF, LABEF: status of LA and LB just befor e external latch
LBBEF, LABEF
Description
0
Low
1
High
Copyright 2004, 2014 Interface Corporation. All rights reserved.
238
GPF-6320 Help for Windows
LBAFT, LAAFT: status of LA and LB just after external latch
LBAFT, LAAFT
Description
0
Low
1
High
LTST2, LTST1, LTST0: latch status
Description
LTST2
LTST1
LTST0
No latch
0
0
0
Software latch
0
0
1
External latch
0
1
0
Internal base clock latch
0
1
1
Internal synchronous line 1 latch*
1
0
0
Internal synchronous line 2 latch*
1
0
1
* These statuses are applicable only to the PCI-632302.
Rtol: Latch by the rotative direction change from positive (count-up) to negative (count-down) rotation
* can be retrieved only in the PCI-632304
Rtol
Description
0
Unlatched
1
Latched
ltoR: Latch by the rotative direction change from negative (count-down) to positive (count-up) rotation
* can be retrieved only in the PCI-632304
ltoR
Description
0
Unlatched
1
Latched
CL: Latch by carry
* can be retrieved only in the PCI-632304
CL
Description
0
Unlatched
1
Latched
BL: Latch by borrow
* can be retrieved only in the PCI-632304
BL
Description
0
Unlatched
1
Latched
Copyright 2004, 2014 Interface Corporation. All rights reserved.
239
GPF-6320 Help for Windows
5.3.3 UCNTEVENTREQ Structure
The UCNTEVENTREQ structure contains the interrupt event setting. This structure is used for configuration of
callback routine and window message.
typedef struct {
HWND
hWnd;
UINT
uMessage[8];
HANDLE
hInterruptEvent;
PUCNTCALLBACK
lpCallBackProc;
DWORD
dwUser;
} UCNTEVENTREQ, PUCNTEVENTREQ;
Member
hWnd
Description
Specifies a window handle to which messages are posted when interrupts
specified by the UcntSetEventMask function occur.
When a message is posted, the WPARAM and LPARAM parameters of
the message contain the following.
• WPARAM: Interrupt sources
• LPARAM: Value of dwUser
Format is the same elements as that is used for the UcntSetEventMask
and UcntGetEventMask function. WORD data of channel specified by
message is stored.
If you do not use message posting, specify this member as follows:
C: NULL
Visual Basic: 0
Delphi: 0
uMessage[8]
Specifies a message code to post to the window specified by hWnd when
interrupts occur. If you do not use message posting, specify this member
as follows:
C: WM_NULL
Visual Basic: 0
Delphi: WM_NULL.
uMessage
Description
uMessage[0]
uMessage[1]
uMessage[2]
uMessage[3]
uMessage[4] to
uMessage[7]
hEvent
Interrupt message code of channel 1
Interrupt message code of channel 2
Interrupt message code of channel 3
Interrupt message code of channel 4
Reserved (not used)
Specifies the event object handle that will be in the signal status when
interrupts occur. If you do not use an event object, specify this member as
follows:
C: NULL
Visual Basic: 0
Delphi: 0
Copyright 2004, 2014 Interface Corporation. All rights reserved.
240
GPF-6320 Help for Windows
lpCallBackProc
Points to the callback routine. Points an address of user callback routine
to call when interrupts occur. If you do not use a callback routine, specify
this member as follows:
C: NULL
Visual Basic: 0
Delphi: 0
dwUser
Specifies the user data.
5.3.4 HSCNTDEVICEINFO Structure
The HSCNTDEVICEINFO structure contains device information. This structure is used by the
HScntGetDeviceInfo function.
typedef struct {
DWORD
dwBoardType;
DWORD
dwBoardID;
} HSCNTDEVICEINFO, PHSCNTDEVICEINFO;
Member
dwBoardType
Description
Stores the model number.
Example: 632106 is stored in the case of the CBI-632106.
dwBoardID
Stores the board ID number.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
241
GPF-6320 Help for Windows
5.3.5 HSCNTEVENTREQ Structure
The HSCNTEVENTREQ structure contains the interrupt event setting. This structure is used for configuration
of callback routine and window message.
typedef struct {
HWND
hWnd;
UINT
uMessage[8];
HANDLE
hInterruptEvent;
PHSCNTCALLBACK
lpCallBackProc;
DWORD
dwUser;
} HSCNTEVENTREQ, *PHSCNTEVENTREQ;
Member
hWnd
Description
Specifies a window handle to which messages are posted when interrupts
specified by the HScntSetEventMask function is generated.
When a message is posted, the WPARAM and LPARAM parameters of the
message contain the following.
- WPARAM: Interrupt sources
- LPARAM: Value of dwUser
Format is the same elements as that is used for the HScntSetEventMask and
HScntGetEventMask function. WORD data of channel specified by message is
stored.
If you do not use message posting, specify this member as follows:
C: NULL
Visual Basic: 0
Delphi: 0
uMessage[8]
Specifies a message code to post to the window specified by hWnd when
interrupts occur. If you do not use message posting, specify this member as
follows:
C: WM_NULL
Visual Basic: 0
Delphi: WM_NULL.
uMessage
Description
uMessage[0]
uMessage[1]
uMessage[2] to uMessage[5]
uMessage[6]
uMessage[7]
hEvent
Interrupt message code of channel 1
Interrupt message code of channel 2
Reserved
Interval timer interrupt message code
Input edge interrupt message code
Specifies the event object handle that will be in the signal status when interrupts
occur. If you do not use an event object, specify this member as follows:
C: NULL
Visual Basic: 0
Delphi: 0
Copyright 2004, 2014 Interface Corporation. All rights reserved.
242
GPF-6320 Help for Windows
lpCallBackProc
Points an address of user callback routine to call when interrupts occur.
(Callback routines are common for all channels.) If you do not use a
callback routine, specify this member as follows:
C: NULL
Visual Basic: 0
Delphi: 0
dwUser
Specifies the user data.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
243
GPF-6320 Help for Windows
5.4 Return Values
5.4.1 Return Value for Multi-function Counter
Error Code
IFUCNT_ERROR_SUCCESS
IFUCNT_ERROR_NOT_DEVICE
IFUCNT_ERROR_NOT_OPEN
IFUCNT_ERROR_INVALID_HANDLE
IFUCNT_ERROR_ALREADY_OPEN
IFUCNT_ERROR_NOT_SUPPORTED
Value
Description
The process was
successfully completed.
C0000001h The current driver cannot
(-1073741823) be used.
0
C0000002h
(-1073741822)
C0000003h
(-1073741821)
The driver cannot be
opened.
The device handle is
invalid.
C0000004h
(-1073741820)
The specified device
cannot be opened
because it has already
been opened by another
process.
C0000009h The specified function
(-1073741815) is not supported.
IFUCNT_ERROR_INVALID_
PARAMETER
IFUCNT_ERROR_NOT_ALLOCAT_
MEMORY
IFUCNT_ERROR_NOW_SAMPLING
C0000010h
(-1073741808)
C0000021h
(-1073741792)
C0001000h
(-1073737728)
The specified
parameters are invalid.
Not enough memory.
IFUCNT_ERROR_NOW_STOP
C0001001h
(-1073737727)
The sampling is stopped.
IFUCNT_ERROR_NULL_POINTER
C0001002h
(-1073737726)
C0001006h
(-1073737722)
C0001007h
(-1073737721)
C0001008h
(-1073737720)
C0001009h
(-1073737719)
C0001010h
(-1073737712)
C0001011h
(-1073737711)
Specified NULL pointer.
IFHSCNT_ERROR_INVALID_OUT_
ENABLE
IFHSCNT_ERROR_INVALID_DO
IFHSCNT_ERROR_INVALID_FILTER
IFHSCNT_ERROR_INVALID_TIMER
IFUCNT_ERROR_INVALID_FUNC_
MODE
IFUCNT_ERROR_INVALID_
CHANNEL
IFUCNT_ERROR_INVALID_RESET_
MODE
IFUCNT_ERROR_INVALID_COUNT_
MODE
The sampling is running.
The output setting is
invalid.
The output setting is
invalid.
The digital filter setting
is invalid.
The timer setting is
invalid.
The invalid mode is
specified.
The specified channel
number is invalid.
C0001012h The specified reset mode
(-1073737710) is invalid.
C0001013h
(-1073737709)
The specified count
mode is invalid.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
244
Comments/Solutions
Connect the device
correctly and confirm to
display it on the device
manager.
Errors occurred while the
system opens the device.
Use the device handle
obtained by the UcntOpen
function.
The device used by another
process cannot be accessed.
The function is not
available because the
device does not support.
Specify correct values.
Not enough memory is
available to process.
The specified function
cannot be called because the
sampling is running.
The specified function
cannot be called because the
sampling is stopped.
Secure the correct address.
Specify the correct setting
value.
Specify the correct setting
value.
Specify the correct setting
value.
Specify the correct setting
value.
Specify the correct mode.
Specify the channel number
correctly in the range of 1h
to fh.
The specified channel
number is not supported in
the specified function.
Specify the correct mode.
Specify the correct mode.
GPF-6320 Help for Windows
(Continued)
Error Code
IFUCNT_ERROR_INVALID_LOAD
Value
Description
C0001014h The specified load mode
(-1073737708) is invalid.
Comments/Solutions
Specify the correct mode.
IFUCNT_ERROR_INVALID_LATCH
C0001015h The specified latch mode
(-1073737707) is invalid.
IFUCNT_ERROR_INVALID_CLOCK
C0001016h The
specified
(-1073737706) setting is invalid.
IFUCNT_ERROR_INVALID_TYPE
C0001017h The specified count type
(-1073737705) is invalid.
Specify the correct type.
IFUCNT_ERROR_INVALID_DIVISOR
C0001018h The specified divisor is
(-1073737704) invalid.
Specify the correct value.
IFUCNT_ERROR_INVALID_PWIDE
C0001019h The specified pulse width
(-1073737703) is invalid.
Specify the correct value.
IFUCNT_ERROR_INVALID_LOGIC
C000101ah The specified logic
(-1073737702) setting is invalid.
Specify the correct setting.
IFUCNT_ERROR_INVALID_OUTB
C000101bh The output setting of
(-1073737701) OUTB is invalid.
Specify the correct value.
IFUCNT_ERROR_INVALID_CYCLE
C000101ch The cycle setting is
(-1073737700) invalid.
Specify the correct value.
IFUCNT_ERROR_INVALID_HPULSE
C000101dh The high-pulse width is
(-1073737699) invalid.
Specify the correct value.
IFUCNT_ERROR_INVALID_TRG_
START
IFUCNT_ERROR_INVALID_TRG_
STOP
IFUCNT_ERROR_INVALID_TRG_
CHANNEL
IFUCNT_ERROR_INVALID_TRG_
MODE
IFUCNT_ERROR_INVALID_CMP_
CHANNEL
IFUCNT_ERROR_INVALID_CMP_
OUTA
C000101eh The start-trigger setting is
(-1073737698) invalid.
Specify the correct setting.
C000101fh The stop-trigger setting is
(-1073737697) invalid.
Specify the correct setting.
C0001020h The trigger channel is
(-1073737696) invalid.
Specify the correct channel.
C0001021h The trigger mode is
(-1073737695) invalid.
Specify the correct trigger
mode.
Specify the correct channel.
Specify the correct mode.
clock Specify the correct setting.
C0001022h The comparison counter
(-1073737694) channel is invalid.
C0001023h The matching detection
(-1073737693) setting of OUTA is
Specify the correct setting.
invalid.
IFUCNT_ERROR_INVALID_CMP_
OUTB
C0001024h The matching detection
(-1073737692) setting of OUTB is
IFUCNT_ERROR_INVALID_FILTER
C0001025h The digital filter is invalid.
(-1073737691)
IFUCNT_ERROR_INVALID_
COUNTER
IFUCNT_ERROR_INVALID_CMP_
SELECT
IFUCNT_ERROR_INVALID_
COMPARATOR
C0001026h The counter setting is
(-1073737690) invalid.
IFUCNT_ERROR_INVALID_
BUFFER_SIZE
C0001029h The setting value for the
(-1073737687) comparison counter B is
Specify the correct setting.
invalid.
Specify the correct digital
filter.
Specify the correct setting.
C0001027h The comparison counter is
(-1073737689) invalid.
Specify the correct counter.
C0001028h The setting value for the
(-1073737688) comparison counter A is
Specify the correct value.
invalid.
invalid.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
245
Specify the correct value.
GPF-6320 Help for Windows
(Continued)
Error Code
IFUCNT_ERROR_INVALID_DATA_
NUM
IFUCNT_ERROR_INVALID_
COMMAND
IFUCNT_ERROR_INVALID_OUT_
ENABLE
IFUCNT_ERROR_INVALID_DO
IFUCNT_ERROR_INVALID_MASK
IFUCNT_ERROR_NO_DATA
IFUCNT_ERROR_NO_DMAMEMORY
IFUCNT_ERROR_FAILED_MEMMAP
Value
C000102ah
(-1073737686)
C000102bh
(-1073737685)
C000102ch
(-1073737684)
C000102dh
(-1073737683)
C000102eh
(-1073737682)
C0001030h
(-1073737680)
C0001032h
(-1073737678)
C0001033h
(-1073737677)
Description
The number of acquired
sampling data is invalid.
The counter control
command is invalid.
The general purpose
output setting is invalid.
The specified digital
output value is invalid.
The interrupt mask
setting is invalid.
No retrievable data exist.
Comments/Solutions
Specify the correct setting.
The specified number of
samplings
Internal buffer mappings
fails
Check the internal buffer
size by IFUCNTMEM.exe.
The internal process fails
because of some factors
Copyright 2004, 2014 Interface Corporation. All rights reserved.
246
Specify the correct setting.
Specify the correct setting.
Specify the correct value.
Specify the correct setting.
-
GPF-6320 Help for Windows
5.4.2 Return Value for High-Speed Counter
Error Code
IFHSCNT_ERROR_SUCCESS
IFHSCNT_ERROR_NOT_DEVICE
Value
Description
0 The process was
successfully
completed.
C0000001h The current driver
(-1073741823) cannot be used.
IFHSCNT_ERROR_NOT_OPEN
C0000002h The driver cannot be
(-1073741822) opened.
IFHSCNT_ERROR_INVALID_
HANDLE
C0000003h The device handle is
(-1073741821) invalid.
IFHSCNT_ERROR_ALREADY_
OPEN
IFHSCNT_ERROR_NOT_
SUPPORTED
C0000004h The specified device
(-1073741820) cannot be opened
because it has already
been opened by
another process.
C0000009h The specified function
(-1073741815) is not supported.
IFHSCNT_ERROR_INVALID_
PARAMETER
IFHSCNT_ERROR_NULL_
POINTER
IFHSCNT_ERROR_INVALID_
CHANNEL
C0000010h
(-1073741808)
C0001000h
(-1073737728)
C0001001h
(-1073737727)
IFHSCNT_ERROR_INVALID_
RESET_MODE
IFHSCNT_ERROR_INVALID_
COUNT_MODE
IFHSCNT_ERROR_INVALID_
MASK
IFHSCNT_ERROR_INVALID_
COMMAND
C0001002h
(-1073737726)
C0001003h
(-1073737725)
C0001004h
(-1073737724)
C0001005h
(-1073737723)
The specified
parameters are invalid.
Specified NULL
pointer.
The specified channel
number is invalid.
The specified reset
mode is invalid.
The specified count
mode is invalid.
The interrupt mask
setting is invalid.
The counter control
command is invalid.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
247
Comments/Solutions
Connect the device
correctly and confirm to
display it on the device
manager.
Errors occurred while
the system opens the
device.
Use the device handle
obtained by the
HScntOpen function.
The device used by
another process cannot
be accessed.
The function is not
available because the
device does not support.
Specify correct values.
Secure the correct
address.
Specify the channel
number correctly in the
range of 1h to Fh.
The specified channel
number is not supported
to the specified function.
Specify the correct
setting value.
Specify the correct
setting value.
Specify the correct
setting value.
Specify the correct
setting value.
GPF-6320 Help for Windows
Chapter 6
Sample Programs
6.1 Sample Programs
This product provides sample program files for C++, Visual Basic, and Delphi. You can find four files in the
samples folder under the destination folder specified at the installation. This product does not contain the
executable files of the sample programs. You need to build the programs before running them.
Visual C++
1. Start Visual C++ (Visual Studio).
2. Select File > Open Workspace.
3. Open the projectfile, *.dsp.
4. Build the project file.
5. Run the executable file, *.exe.
Visual Basic
1. Start Visual Basic.
2. Open the project file, *.vbp.
3. Build the project file.
4. Run the executable file, *exe.
Delphi
1. Start Delphi.
2. Open the project file, *.dpr.
3. Build the project file.
4. Run the executable file, *.exe.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
248
GPF-6320 Help for Windows
The following table shows the sample programs.
Sample Program
UcntPulseCount
UcntFreqAvg
UcntCycle
UcntPhaseDiff
UcntTimer
Description
This sample program performs the basic pulse counter by using the pulse
counter mode.
This sample program performs the frequency meter of various input pulses
by using the average frequency meter mode.
This sample program performs the cycle meter (High/Low pulse width) of
input pulse by using the cycle meter mode.
This sample program meters the pulse width difference of input pulse from
A-phase and B-phase with pulse width difference meter mode.
This sample program performs timer count with the timer mode.
This sample program performs devisor output of input pulse with divider
mode.
UcntPulseGenerator This sample program performs the pulse output by using the pulse
generator mode.
UcntSampling
This sample program samples the counter value.
HScntPulseCount
This sample program performs the count by using high-speed counter.
EncoderPulseCount This sample program counts phase-shifted pulse of encoder output.
UcntFreqDivider
PulseDutySampling
This sample program samples the duty cycle of input pulse.
SinglePulseCount
This sample program counts the single-phase pulse.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
249
GPF-6320 Help for Windows
Chapter 7
Utilities
7.1 Operation Test Utility Program (IFUcntCounter)
1. Click the Start button, point to Programs, point to Interface GPF-6320, and then click IFUcntCounter.
2. The Open New Device dialog box will appear.
3. Select the device to diagnose, and then click OK.
4. If the device is successfully opened, the following windows will appear.
Note: Every channel can be controled in a different panel. (Arrangement of panel can be changed freely.)
Delete un used channel panel by clicking Exit on the panel or uncheck the checkbox of Displayed
Channel on the main menu.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
250
GPF-6320 Help for Windows
<Main Window>
To close the current device, click Close the Device on the Device menu. It is possible to start the new device.
To terminate this program, click Exit.
<Counter Operating Panels>
These counter control panels can control by switching to the seven operation modes for each channel. Each
operation mode can be changed the tab of the panel upper part. The current status condition is displayed on
the Counter Status. You can confirm the input status of each pin and counter status regardless of the counter
start or stop. pulse count mode with direction: single-edge evaluation
“Signal-phase pulse count mode with direction: signal-edge evaluation”.
- Pulse Counter Mode
The pulse counter mode can select the count mode and displayed format on the panel. You can select the
decimal number or hexadecimal number on the Form. This default setting of Counter Mode is Single-phase
1. To confiture anther mode, click Setting on the menu.
2. To start the count, click Start. The counter value is displayed on the black panel.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
251
GPF-6320 Help for Windows
- Average Frequency Meter Mode
The average frequency meter mode can select the base clock and displayed unit on the panel. The default
setting is 1 s on the Base Clock (Frequency, Measuring Period).
1. To start the frequency meter, click Start. The value is displayed on the black panel.
2. To configure detailed setting, click Setting on the menu. If you use that, Custom is selected on the Base
Clock (Frequency, Measuring Period).
- Cycle Meter Mode
The cycle meter mode can select the base clock and displayed unit on the panel. The default setting is that all
frequancy is measured.
To configure detailed setting, click Setting on the menu. If you use that, Custom is selected on the
Base Clock (Cycle Measurement, Clock Accuracy).
Copyright 2004, 2014 Interface Corporation. All rights reserved.
252
GPF-6320 Help for Windows
- Phase-Shifted Pulse Width Meter Mode
The phase-shifted pulse width meter mode can select the base clock and displayed unit on the panel. The
default setting is chosen the phase-shifted pulse width meter.
To configure detailed setting, click Setting on the menu. If you use that, Custom is selected on the
Base Clock (Phase-Shifted Pulse Width Measurement, Clock Accuracy).
- Timer Mode
The timer mode can select the count cycle and displayed format on the panel.
1. To start this mode, click Start.
2. To configure detailed setting, click Setting on the menu. If you use that, Custom is selected on the
Base Clock (Count Cycle).
Copyright 2004, 2014 Interface Corporation. All rights reserved.
253
GPF-6320 Help for Windows
- Divider Mode
The divider mode can select the divider cycle and displayed format on the panel.
1. You can select the divider value and logic as follows:
divider value: 1/2, 1/3, 1/4, 1/5, or 1/10
logic: positive or negative
2. To start this mode, click Start.
3. To configure detailed setting, click Setting on the menu. If you use that, Custom is selected on the
Divider Value (High-Pulse Width/All Cycle Width).
- Pulse Generator Mode
The pulse generator mode can select the basic frequency, and displayed format on the panel.
1. To start the pulse output, click Start. (The duty ratio of the output pulse is fixed at 50%.)
2. To configure detailed setting or output from OUTB, click Setting on the menu.
After configuration, Custom is selected on the Multiplier (Frequency Magnification).
The current output frequency is displayed on the black panel.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
254
GPF-6320 Help for Windows
- Detailed Setting Panel
The following figure shows the detailed setting panel of the pulse count mode.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
255
GPF-6320 Help for Windows
7.2 CardBus ID Configuration Utility Program
This utility program can configure the CardBus ID number. The ID number on each Interface CardBus card is
is used to uniquely identify each card, in case multiple Interface CardBus cards of the same type are installed in
the same system. This ID number for CardBus card is the same meaning as the rotary switch number for
PCI/CompactPCI modules. Therefore, the CardBus ID number is appeared as the rotary switch number
(RSW1) on the diagnostic program or device manager.
7.2.1 Configuring the ID Number
1. After installing the driver software, click the Start button and point to Settings, and then click
Control Panel.
2. Double-click Interface CardBus ID Utilitty, and then the CardBus ID Utility dialog box will appear.
Item
Description
Bus (hex)
Bus number in hexadecimal
Dev (hex)
Device number in hexadecimal
Func (hex)
Function number in hexadecimal
Board type
Model
ID Number (hex)
CardBus ID number in hexadecimal
3. Select a card that you want to set the ID number. Then, another CardBus ID Utility dialog box will appear.
Notes:
- Selectable ID number is in the range of 0h to Fh.
- To recognize the card which changed the ID number, remove the card and insert it or restart the
computer.
- To identify each card, we recommend to put a sticker with the ID number on the card.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
256
GPF-6320 Help for Windows
7.3 Memory Size Configuration Utility
* This utility program is for 64-bit environment.
7.3.1 Starting the Utility Program
1. Click the Start button, point to Programs, point to Interface GPF-6320, and then click
IFUcntMem to start the Memory Size Configuration Unitily.
2. The following dialog box will appear.
7.3.2 Selecting a Device
1. Select a device to configure at the Device combo box in the Memory size configuration.
2. After selecting a device, the currently allocated buffer size of each channel is displayed at Allocated size.
7.3.3 Configuring the Memory Size
1. Enter the allocated buffer size for each channle in hexadecimal at Allocated size.
2. Click OK.
Example:
Sampling up to 20,000 data (32 bit counter, status information included)
The data size per sampling is 32 bits (4 bytes) and status information (4 bytes ), a total of 8 bytes.
When the number of sampling is 20000, the memory size is found as follows.
20000 x 8 = 160000 (byte)
And the setting value is 27100 in hexadecimal.
If the configuration fails, an error message, “Failed to configure allocated memory size.”, appears.
To configure multiple devices, repeat the procedure 2 and 3.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
257
GPF-6320 Help for Windows
7.3.4 Configuring the Memory Size
After completion of the configuration, click Close button.
A message, “Restart Windows to reflect the settings.”, appears.
Click OK to close the application.
To reflect the change in memory size, you need to restart the operating system. After the operating system
restatrts, the allocated memory size is displayed in the Memory Size Configuration Utility dialog box.
!
Caution
Depending on computer environment, the specified size of physical memory
may not be allocated. Allocate suitable size of memory space by yourself.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
258
GPF-6320 Help for Windows
Chapter 8
How to Use .NET
8.1 Overview
This chapter explains how to use the GPF-6320 for .NET.
The following table shows supported languages.
Microsoft Visual C++ .NET 2002, .NET 2003, 2005, 2008, 2010
Supported Languages
Microsoft Visual C# .NET 2002, .NET 2003, 2005, 2008, 2010
Microsoft Visual Basic .NET 2002, .NET 2003, 2005, 2008, 2010
- Any editions (Standard, Professional, Enterprise) or versions of the languages described in the table above are
supported unless otherwise noted.
8.2 Class Library
This product includes the source files of the class library. Creating the class library from the source files makes
it easier to define DLL functions.
The IFCUCNT/IFCHSCNT classes are difinitions for x86. To create a new application, use the difinition for the
IFCUCNT_ANY class/ IFCHSCNT_ANY class (applicable to x86 and x64 ).
8.2.1 Creating the Class Library
To call DLL functions on .NET, you need to prepare class library first.
Visual C# .NET
1. Start Visual Studio.
2. Open the followning project file.
<installation destination> \interface\GPF6320\samples\CS_NET\IFCUCNT\IFCUCNT.csproj
<installation destination> \interface\GPF6320\samples\CS_NET\IFCHSCNT\IFCHSCNT.csproj
After building the project file, IFCUCNT.dll and IFCHSCNT.dll are created in the bin folder.
Visual Basic .NET
1. Start Visual Studio.
2. Open the followning project file.
<installation destination> \interface\GPF6320\samples\VB_NET\IFCUCNT\IFCUCNT.vbproj
<installation destination> \interface\GPF6320\samples\VB_NET\ IFCHCNT\IFCHSCNT.vbproj
After building the project file, IFCUCNT.dll and IFCHSCNT.dll created in the bin folder.
*For C++ CLR project, create class library for Visual C# .NET or Visual Basic .NET by the above
procedures.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
259
GPF-6320 Help for Windows
8.2.2 Adding Class Library Reference
Visual C# .NET and Visual Basic .NET
1. Start Visual Studio.
2. Select Project > Add Reference.
3. Click the Browse button.
4. Specify the class library DLL to refer.
<installation destination>\interface\GPF6320\samples\CS_NET\IFCUCNT\bin\Release\ifcucnt.dll
<installation destination> \interface\GPF6320\samples\VB_NET\IFCUCNT\bin\Release\ifcucnt.dll
<installation destination>\interface\GPF6320\samples\CS_NET\IFCHSCNT\bin\Release\ifchscnt.dll
<installation destination>\interface\GPF6320\samples\VB_NET\IFCHSCNT\bin\Release\ifchscnt.dll
5. The DLL file will be displayed in Selected Components.
6. Click OK.
7. Add the namespace of InterfaceCorpDllWrap as below at the header of your source file to call the
DLL functions.
Visual C# .NET
using InterfaceCorpDllWrap;
Visual Basic .NET
Imports InterfaceCorpDllWrap
Visual C++ CLR Project
using namespace InterfaceCorpDllWrap
* Add class library for Visual C# or Visual Basic.NET.
8.3 Notes
8.3.1 Variables called by reference
Each funcion is unmanaged function. Memory is deallocated or moved at a certain timing by garbage
collection. Therefore, gap occurs between pointer in functions and variable pointer in appication and memory
may be corrupted. When calling manage objects by reference, prevent them from being collected with the
GCHandle structure.
8.3.2 Structure
LayoutKind.Sequential is specified to the Structlayout class option.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
260
GPF-6320 Help for Windows
Chapter 9
Sample Programs for .NET
This chapter describes the outline of sample programs prepared for each .NET language.
9.1 Execution Procedure
The GPF-6320 has sample programs for Visual C# and Visual Basic .NET. Each program is created with the
following.
• Microsoft Visual C# .NET 2003
• Microsoft Visual Basic .NET 2003
This sample programs are created by referring to the project in the class library.
Execution procedure
Executable files of the sample programs are not included with this product.
Compile the source code and create executable file to start.
Visual C# .NET
1. Start Visual C# .NET.
2. On the File menu, click Open Solution.
3. Open the solution file, * csproj.
4. Build the solution file.
5. Run the executable file, *.exe.
Visual Basic .NET
1. Start Visual Basic.
2. On the File menu, click Open Solution.
3. Open the solution file, * vbproj.
4. Build the solution file.
5. Run the executable file, *.exe.
Visual C++ .NET
1. Start Visual C++ (Visual Studio).
2. Select File > Open > Project.
3. Open the projectfile, *. vcproj.
4. Build the project file.
5. Run the executable file, *.exe.
Note : The class library will be automatically built at the same time as opening the solution files.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
261
GPF-6320 Help for Windows
9.2 List of Sample Programs
The outline of each sample program is the following.
Sample Program
Description
This
sample
proram
is
the
class
library
source code for multi-function counter.
IFCUCNT
The necessarry processing to use API function in “ifucnt. dll” by .NET is
described.
IFCHSCNT
This sample program is the class library source code for multi-function
counter.
The necessary processing to use API function in “ifucnt. dll” by .NET is
described.
This sample program performs the pulse count by using the pulse counter
UcntPulseCount
mode. It samples by using the internal clock latch.
HScntPulseCount
This sample program counts using high-speed counter.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
262
GPF-6320 Help for Windows
Chapter 10
Terms of Use
10.1 Limited Warranty
Interface Corporation does not warrant uninterrupted or error-free operations of the source programs included in this
document. The entire risks as to the quality or arising out of use or performance of the program, if any, remains with
you.
Interface believes that information contained in the document is accurate. The document is carefully reviewed for
technical accuracy. Interface reserves the right to make changes to subsequent editions of this document without prior
notice to holders of this edition. Interface is not liable for any damages arising out of or related to this document or
the information contained in it.
Charts and tables contained in this document are only for illustration purposes and may vary depending upon a user's
specific application.
10.2 Copyrights and Intellectual Property Rights
Interface Corporation owns all titles and intellectual property rights in and to the products. The products include
the software, audio/visual content such as images, texts, or pictures.
10.3 Warning Regarding Medical and Clinical Use of Our Products
Our products are not designed for components intended to ensure a level of reliability suitable for use under
conditions that might cause serious injury or death.
Our products are not designed with components and testing instrument intended to ensure a level of reliability
suitable for use in treatment and diagnosis of human.
Applications of our products involving medical or clinical treatment can create a potential for accidental injury
caused by product failure, or by errors on the part of the user or application engineer.
10.4 Prohibition of Reproduction
No part of this document may be reproduced or changed in any form without the prior consent of Interface
Corporation.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
263
GPF-6320 Help for Windows
10.5 Limitation of Liability
Interface Corporation will not be liable for any special, incidental, indirect or consequential damages
whatsoever even if Interface Corporation or any reseller could foresee the possibility of damages.
Users shall assume any subsequent risks whatsoever resulting from such as using and installing this product.
Interface Corporation shall not be liable for any incidental or consequential damages, including damages or
other costs resulting from defects which might be contained in the product, product supply delay or product
failure.
Customer's right to recover damages caused by fault or negligence on the part of Interface Corporation shall be
limited exclusively to product replacement.
This product is designed under Japanese domestic specifications. Interface Corporation is not responsible for
the use of this product outside Japan. We do not offer any maintenance service or technical support abroad.
Interface Corporation is not liable for any damage arising from the included document or information.
10.6 Trademark
Products and company names are trademarks, registered trademarks, or servicemarks of their respective owners.
Copyright 2004, 2014 Interface Corporation. All rights reserved.
264