je souhaiterai utiliser la carte VM 167 avec 16 contacts
mais lors de la programation je ne peux les utiliser que 4 par 4
est il possible d’utiliser les 16 contacts comme sur a documentations (velleman.eu/downloads/0/mod … 167_fr.pdf) page 8
I will wish to use the VM167 card with 16 contacts
but when programing I use them only 4 by 4
it is possible to use the 16-pin like a documentation ( velleman.eu/downloads/0/mod … 167_fr.pdf ) Page 8
voila mon programme
Option Explicit
Private Declare Function OpenDevices Lib “vm167.dll” () As Long
Private Declare Sub CloseDevices Lib “vm167.dll” ()
Private Declare Sub InOutMode Lib “vm167.dll” (ByVal CardAddress As Long, ByVal HighNibble As Long, ByVal LowNibble As Long)
Private Declare Function ReadAnalogChannel Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib “vm167.dll” (ByVal CardAddress As Long, ByRef Buffer As Long)
Private Declare Sub OutputAllDigital Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib “vm167.dll” (ByVal CardAddress As Long)
Private Declare Sub SetDigitalChannel Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib “vm167.dll” (ByVal CardAddress As Long)
Private Declare Function ReadDigitalChannel Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib “vm167.dll” (ByVal CardAddress As Long) As Long
Private Declare Function ReadCounter Lib “vm167.dll” (ByVal CardAddress As Long) As Long
Private Declare Sub ResetCounter Lib “vm167.dll” (ByVal CardAddress As Long)
Private Declare Sub SetPWM Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Channel As Long, ByVal Data As Long, ByVal Freq As Long)
Private Declare Sub OutputAllPWM Lib “vm167.dll” (ByVal CardAddress As Long, ByVal Data1 As Long, ByVal Data2 As Long)
Private Declare Function VersionDLL Lib “vm167.dll” () As Long
Private Declare Function VersionFirmware Lib “vm167.dll” (ByVal CardAddress As Long) As Long
Private Declare Function Connected Lib “vm167.dll” () As Long
Private Declare Sub ReadBackPWMOut Lib “vm167.dll” (ByVal CardAddress As Long, ByRef Buffer As Long)
Private Declare Function ReadBackInOutMode Lib “vm167.dll” (ByVal CardAddress As Long) As Long
Private Declare Function SetTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Dim n As Long
Dim Data(0 To 4) As Long
Dim CardAddress As Long
Dim Cards As Long
Dim flag
Dim cible
Dim cible1
Dim cible2
Dim cible3
Dim cible4
Dim tps1
Dim tps2
Dim tps3
Dim tps4
Dim tps_fin
Sub Button3_Click()
If flag = 0 Then
TimerSeconds = 0.05 ’ the timer interval is now 1 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
cible = 0
cible1 = 0
cible2 = 0
cible3 = 0
cible4 = 0
tps1 = 0
tps2 = 0
tps3 = 0
tps4 = 0
tps_fin = 0
Range(“B2:R3”).Select
Selection.ClearContents
Range("G1").Select
flag = 1
End If
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
Dim i As Long
Dim Digi As Long
'InOutMode CardAddress, 1, 0
'OutputAllDigital CardAddress, 15
'SetDigitalChannel CardAddress, 2
If cible = 0 Then tps1 = tps1 + TimerSeconds
If cible = 1 Then tps2 = tps2 + TimerSeconds
If cible = 2 Then tps3 = tps3 + TimerSeconds
If cible = 4 Then tps4 = tps4 + TimerSeconds
If cible = 8 Then tps1 = tps1 + TimerSeconds
If cible = 16 Then tps2 = tps2 + TimerSeconds
If cible = 32 Then tps3 = tps3 + TimerSeconds
If cible = 64 Then tps4 = tps4 + TimerSeconds
If cible = 128 Then tps1 = tps1 + TimerSeconds
If cible = 256 Then tps2 = tps2 + TimerSeconds
If cible = 512 Then tps3 = tps3 + TimerSeconds
If cible = 1024 Then tps4 = tps4 + TimerSeconds
If cible = 2048 Then tps1 = tps1 + TimerSeconds
If cible = 4096 Then tps2 = tps2 + TimerSeconds
If cible = 8192 Then tps3 = tps3 + TimerSeconds
If cible = 16384 Then tps4 = tps4 + TimerSeconds
If cible > 0 Then tps_fin = tps_fin + TimerSeconds
If (ActiveSheet.Cells(10, 2) = 1 And (cible = 0 Or cible = 8 Or cible = 128 Or cible = 2048)) Then
If cible = 0 Then
cible = 1
ActiveSheet.Cells(2, 2) = 1
ActiveSheet.Cells(3, 2) = 0
End If
If cible = 8 Then
cible = 16
ActiveSheet.Cells(2, 6) = 1
ActiveSheet.Cells(3, 6) = tps1
End If
If cible = 128 Then
cible = 256
ActiveSheet.Cells(2, 10) = 1
ActiveSheet.Cells(3, 10) = tps1
End If
If cible = 2048 Then
cible = 4096
ActiveSheet.Cells(2, 14) = 1
ActiveSheet.Cells(3, 14) = tps1
End If
ActiveSheet.Cells(10, 2) = 0
tps1 = 0
End If
If (ActiveSheet.Cells(10, 3) = 1 And (cible = 1 Or cible = 16 Or cible = 256 Or cible = 4096)) Then
If cible = 1 Then
cible = 2
ActiveSheet.Cells(2, 3) = 1
ActiveSheet.Cells(3, 3) = tps2
End If
If cible = 16 Then
cible = 32
ActiveSheet.Cells(2, 7) = 1
ActiveSheet.Cells(3, 7) = tps2
End If
If cible = 256 Then
cible = 512
ActiveSheet.Cells(2, 11) = 1
ActiveSheet.Cells(3, 11) = tps2
End If
If cible = 4096 Then
cible = 8192
ActiveSheet.Cells(2, 15) = 1
ActiveSheet.Cells(3, 15) = tps2
End If
ActiveSheet.Cells(10, 3) = 0
tps2 = 0
End If
If (ActiveSheet.Cells(10, 4) = 1 And (cible = 2 Or cible = 32 Or cible = 512 Or cible = 8192)) Then
If cible = 2 Then
cible = 4
ActiveSheet.Cells(2, 4) = 1
ActiveSheet.Cells(3, 4) = tps3
End If
If cible = 32 Then
cible = 64
ActiveSheet.Cells(2, 8) = 1
ActiveSheet.Cells(3, 8) = tps3
End If
If cible = 512 Then
cible = 1024
ActiveSheet.Cells(2, 12) = 1
ActiveSheet.Cells(3, 12) = tps3
End If
If cible = 8192 Then
cible = 16384
ActiveSheet.Cells(2, 16) = 1
ActiveSheet.Cells(3, 16) = tps3
End If
ActiveSheet.Cells(10, 4) = 0
tps3 = 0
End If
If (ActiveSheet.Cells(10, 5) = 1 And (cible = 4 Or cible = 64 Or cible = 1024 Or cible = 16384)) Then
If cible = 4 Then
cible = 8
ActiveSheet.Cells(2, 5) = 1
ActiveSheet.Cells(3, 5) = tps4
End If
If cible = 64 Then
cible = 128
ActiveSheet.Cells(2, 9) = 1
ActiveSheet.Cells(3, 9) = tps4
End If
If cible = 1024 Then
cible = 2048
ActiveSheet.Cells(2, 13) = 1
ActiveSheet.Cells(3, 13) = tps4
End If
If cible = 16384 Then
cible = 32768
ActiveSheet.Cells(2, 17) = 1
ActiveSheet.Cells(3, 17) = tps4
End If
ActiveSheet.Cells(10, 5) = 0
tps4 = 0
End If
If cible = 32768 Then Button4_Click
End Sub
Sub Button4_Click()
KillTimer 0&, TimerID
'CloseDevices
'ClearAllDigital CardAddress
ActiveSheet.Cells(3, 18) = tps_fin
flag = 0