Pro II: Digitale Ein-/Ausgänge
P2_Comp_Init
146
Beispiel
#Include
ADwinPro_All.inc
#Define
module
2
Dim
Bit_Ch_0,
Bit_Ch_0_1
Init:
P2_Comp_Init(module,1,3)
Rem Set thresholds: channel group 1 to 0V, channel group 2 to 10V
P2_Comp_Set(module,1,Volt2Digits(0.0))
P2_Comp_Set(module,2,Volt2Digits(10.0))
Rem Set thresholds in volts directly
'P2_Comp_Set_Voltage(module, 1, 0.0)
'P2_Comp_Set_Voltage(module, 1, 10.0)
Rem Set filter to length 200 ns
P2_Comp_Filter_Init(module, 10)
Event:
Rem check comparator bits
Par_1
= P2_Digin_Long(module)
Rem channel 1
Bit_Ch_0
=
Par_1
And
Rem free hysteresis determined by channels 0, 1
Bit_Ch_0_1
= Shift_Right(Par_1,16)
If
(Bit_Ch_0
= 1)
Rem channel 0 > 0 V
Else
'
(Bit_Ch_0 = 0)
Rem channel 0 < 0 V
EndIf
If
(Bit_Ch_0_1
= 1)
Rem both channels 0, 1 > 10 V
Else
'
(Bit_Ch_0_1 = 0)
Rem both channels 0, 1 < 0 V
EndIf
Function
Volt2Digits(volt)
Volt2Digits
=
volt
EndFunction
As Long
'set channels 0..3 to hold 200µs
1b
'threshold of channel 0
And
Then
Then
As Long
*
(65536
/ 60) +
32768
ADwin-Pro II Software, Handbuch Apr. 2021
ADwin
1