ADwin-Gold II
, Manual February 2013
113
Counters
Cnt_Enable
ADwin
Cnt_Enable
Cnt_Enable
disables or enables the counters set by
pattern
, to count inco-
ming impulses.
Syntax
#Include
ADwinGoldII.inc / GoldIITiCo.inc
Cnt_Enable
(
pattern
)
Parameters
Notes
Standard counters and PWM counters run separately.
See also
,
,
,
,
,
Valid for
Gold II-CNT
Example
Rem Ple
as
e select the appropriate include for ADbasic /
TiCoBasic
#Include
ADwinGoldII.inc
'for ADbasic
Rem #Include GoldIITiCo.inc 'for TiCoBasic
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
' -"-
T11 TiCo
pattern
Bit pattern.
Bit = 0: stop counter.
Bit = 1: enable counter.
LONG
Bit no.
31…
9
11
10
9
8
7…4
3
2
1
0
C o u n t e r
no.
–
PW
4
PW
3
PW
2
PW
1
–
VR4 VR3 VR2 VR1