Counters
Cnt_Clear
ADwin
112
ADwin-Gold II
, Manual February 2013
Example
Rem Please select the appropriate include for ADbasic /
TiCoBasic
#Include
ADwinGoldII.inc
'for ADbasic
Rem #Include GoldIITiCo.inc 'for TiCoB
as
ic
Dim
old_1
,
new_1
As
Long
Dim
old_2
,
new_2
As
Long
Init:
old_1
=
0
'initialize
old_2
=
0
Cnt_SE_Diff
(
0011b
)
'counters 1+2 diff. (3+4 single
'ended
)
Rem Counter 1: Mode clock-direction
,
enable CLR input
Cnt_Mode
(
1
,
10000b
)
Cnt_Mode
(
2
,
0
)
'Set all counters to external
'clock
Cnt_Clear
(
11b
)
'reset counters 1+2 to 0
Rem start counters 1+2, stop counters 3+4 and PWM1-4
Cnt_Enable
(
11b
)
Event:
Cnt_Latch
(
11b
)
'latch both counters 1+2
new_1
=
Cnt_Read_Latch
(
1
)
'read latch A of counter 1 and
new_2
=
Cnt_Read_Latch
(
2
)
' latch A of counter 2.
Par_1
=
new_1
-
old_1
'caluclate the difference (f =
'impulses/time)
Par_2
=
new_2
-
old_2
' -"-
old_1
=
new_1
'Save new counter values
old_2
=
new_2
' -"-