
The sample displays the count value and status of the number of channels you want.
This sample program must use with "Usual
Counter" device.
Please refer "Counter
Type Specification" to verify the model number of your device.
When you use "High-performance Counter" device, it would be better to use "High-performance Counter Sample".
Sample specification |
* This is the initial value of the sample program. |
Program name |
./Counter/counter/counter |
Counter Operation Mode |
2 Phase, 1X |
Clear mode |
Asynchronous Clear |
Counter direction |
Up Count |
Z phase mode |
Not Used |
Z phase logic |
Negative |
Digital filter |
Not Used (0) |
It would be help to refer "Flowchart for Counter function".
1. Specify the desired program name, run the program, then it will wait
for you to enter a device name.
Please specify the device name that was set in
the Configuration Tool.
Notify
the device driver of the start of use for the specified device.
For example, if you specify the device name
as [CNT000], the execution result of CntInit will be displayed as shown
below.
After that, the CUI(Character User Interface) menu
will be displayed.
For CntInit, please refer to [Init and Exit Processing].
2. Counter Operation Mode Setting
For Counter Operation Mode Setting, please refer to [Counter Operation Mode Setting].
- From the CUI menu, select [(1).Set] to specify the counter
operation mode.
When you select [(1).Set], it will wait for you
to enter the number of channels to be used, as shown below.

- When entering the number of channels, it will wait for you to set the Z phase mode.

- When specifying the command in Z phase mode setting, CntSetZMode
will be executed.
For example, when you specify [(1).Not Use] as
the command, the execution result of CntSetZMode will be displayed as
shown below.
After that, it will wait for you to set the Z phase
logic.

- When specifying the command in Z phase logic setting,
CntSetZLogic will be executed.
For example, when you specify [(2).Negative Logic]
as the command, the execution result of CntSetZLogic will be displayed
as shown below.
After that, it will wait for you to set the external
signal source.

- When specifying the command in external signal source
setting, CntSelectChannelSignal will be executed.
The available external signal sources depend on
the device you are using.
For details, please refer to the function specification
of CntSelectChannelSignal.
For example, when you specify [(1).Photo Coupler]
as the command, the execution result of CntSelectChannelSignal will be
displayed as shown below.
After that, it will wait for you to set the count
direction.

- When specifying the command in count direction setting,
CntSetCountDirection will be executed.
For example, when you specify [(2).UP Count] as
the command, the execution result of CntSetCountDirection will be displayed
as shown below.
After that, it will wait for you to set the digital
filter coefficient.

- When specifying the command
in digital filter coefficient setting, CntSetDigitalFilter will be executed.
For example, when you specify 0 as the command,
the execution result of CntSetDigitalFilter will be displayed as shown
below.
After that, it will wait for you to set the operation
mode.

- When specifying the command in operation mode setting,
CntSetOperationMode will be executed.
For example, when you specify [(2).2-phase input],
[(1).1X], [(1).Async Clear] in order, the execution result of CntSetOperationMode
will be displayed as shown below.
After that, the CUI menu will be displayed again,
and it will wait for you to specify the command.

3. Count Start
For Counter Operation, please refer to [Counter Operation].
- From the CUI menu, select [(2).CntStartCount] to start
counting.
When you select [(2).CntStartCount], the execution
result of CntStartCount will be displayed as shown below.
After that, the CUI menu will be displayed again,
and it will wait for you to specify the command.

4. Get Count Value
For Counter Operation, please refer to [Counter Operation].
- From the CUI menu, select [(3).CntReadCount] to get the
current count value.
When you select [(3).CntReadCount], the execution
result of CntReadCount will be displayed as shown below.
After that, the CUI menu will be displayed again,
and it will wait for you to specify the command.

5. Count Stop
For Counter Operation, please refer to [Counter Operation].
- From the CUI menu, select [(6).CntStopCount] to stop counting.
When you select [(6).CntStopCount], the execution
result of CntStopCount will be displayed as shown below.
After that, the CUI menu will be displayed again,
and it will wait for you to specify the command.

6. Program Exit
- From the CUI menu, select [(q).Exit] to exit the sample program.