Herunterladen Inhalt Inhalt Diese Seite drucken

JÄGER ADwin-Gold II Handbuch Seite 138

Vorschau ausblenden Andere Handbücher für ADwin-Gold II:
Inhaltsverzeichnis

Werbung

Zähler
Cnt_Sync_Latch
132
Beispiel
Rem Wählen Sie das passende Include für ADbasic / TiCoBasic
#Include
ADwinGoldII.inc'für ADbasic
Rem #Include GoldIITiCo.inc für TiCoBasic
frequency
#Define
Dim
time, edges, oldpw,
Dim
vr,
pw
As Long
Init:
Processdelay
=
3000000
Cnt_Enable(0)
Cnt_Mode(1,00000000b)
Cnt_Clear(0001b)
Cnt_Enable(0101h)
Cnt_Sync_Latch(0001b)
oldvr
=
Cnt_Read_Int_Register
oldpw
=
Cnt_Read_Int_Register
frequency
=
0
Event:
REM latch values of counter 1 (V/R and PWM)
Cnt_Sync_Latch(0001b)
vr
= Cnt_Read_Int_Register(1,6)
edges
=
Abs(vr
- oldvr)
If
(edges
<> 0)
pw
= Cnt_Read_Int_Register(1,8)
time
=
pw
-
oldpw
Rem frequency: 100000000=timer frequency
frequency
=
edges*100000000/time
oldcnt
=
cnt
oldpw
=
pw
EndIf
Par_1
oldvr
As Long
'100Hz with T11 processor
'counters off
'mode: clock/dir
'clear counter 1
'enable counters V/R 1 and PWM 1
'latch counter 1 (V/R and PWM)
(1,6)
'V/R counter 1
(1,8)
'PWM counter 1
'value of clock/dir counter
'number of edges between events
Then
'positive edges latch 1
'calculate timebase
'store VR counter value
'store PW counter value
ADwin
ADwin-Gold II, Handbuch Dez. 2018

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis