Bonjour Voila j'expose mon problème

j'ai donc le projet d'un ascensur avec une carte Velleman K8055

J'ai donc tout un code qui fonctionne correctement il me manque juste une partie
Ou une petite modification à faire

Voici mon problème j'ai donc des Command (4) qui sont indexée

le moteur de l'ascenseur est actioné avec 2 sorties de la carte ( setdigitalchannel(1) ) qui met la sortie 1 a 1 ( puis partie de puissance )
donc il y a deux sortie sortie 1 Monté sortie 2 descendre

Il faudrait avec le code que quand j'appuie sur la commande 1 il sache que l'ascensur doit monté jusqu'a ce que une checkbox soit coché ( check box qui correspond a l'étage )
et que quand je suis a deux il sache ( quand j'appuie sur la command ) 3 par ex qu'il doit monté ( donc que la sortie 1 doit etre a 1 )
jusqu'a ce que la check box 3 soit cochée

voici donc mon code

______________________________ __

VERSION 5.00
Begin VB.Form Form3
Caption = "Form1"
ClientHeight = 2895
ClientLeft = 60
ClientTop = 390
ClientWidth = 8340
LinkTopic = "Form1"
ScaleHeight = 2895
ScaleWidth = 8340
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer2
Interval = 50
Left = 3480
Top = 720
End
Begin VB.Timer Timer1
Interval = 50
Left = 6000
Top = 720
End
Begin VB.Frame Frame6
Caption = "Inputs"
Height = 735
Left = 3840
TabIndex = 15
Top = 0
Width = 2595
Begin VB.CheckBox Check2
Caption = "1"
Height = 255
Index = 0
Left = 240
TabIndex = 20
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "2"
Height = 255
Index = 1
Left = 720
TabIndex = 19
Top = 300
Width = 375
End
Begin VB.CheckBox Check2
Caption = "3"
Height = 255
Index = 2
Left = 1080
TabIndex = 18
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "4"
Height = 255
Index = 3
Left = 1560
TabIndex = 17
Top = 300
Width = 495
End
Begin VB.CheckBox Check2
Caption = "5"
Height = 255
Index = 4
Left = 2040
TabIndex = 16
Top = 300
Width = 435
End
End
Begin VB.CommandButton Command
Caption = "Command(4)"
Height = 735
Index = 4
Left = 7200
TabIndex = 14
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(3)"
Height = 735
Index = 3
Left = 7200
TabIndex = 13
Top = 1440
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(2)"
Height = 735
Index = 2
Left = 7200
TabIndex = 12
Top = 720
Width = 1095
End
Begin VB.CommandButton Command
Caption = "Command(1)"
Height = 735
Index = 1
Left = 7200
TabIndex = 11
Top = 0
Width = 1095
End
Begin VB.Frame Frame7
Caption = "Outputs"
Height = 735
Left = 0
TabIndex = 2
Top = 0
Width = 3555
Begin VB.CheckBox Check3
Caption = "1"
Height = 255
Index = 0
Left = 120
TabIndex = 10
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "2"
Height = 255
Index = 1
Left = 540
TabIndex = 9
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "3"
Height = 255
Index = 2
Left = 960
TabIndex = 8
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "4"
Height = 255
Index = 3
Left = 1380
TabIndex = 7
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "5"
Height = 255
Index = 4
Left = 1800
TabIndex = 6
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "6"
Height = 255
Index = 5
Left = 2220
TabIndex = 5
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "7"
Height = 255
Index = 6
Left = 2640
TabIndex = 4
Top = 300
Width = 375
End
Begin VB.CheckBox Check3
Caption = "8"
Height = 255
Index = 7
Left = 3060
TabIndex = 3
Top = 300
Width = 375
End
End
Begin VB.CommandButton connect
Caption = "test connect"
Height = 615
Left = 0
TabIndex = 0
Top = 960
Width = 1215
End
Begin VB.Shape Shape
Height = 735
Index = 4
Left = 6480
Top = 2160
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 3
Left = 6480
Top = 1440
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 2
Left = 6480
Top = 720
Width = 735
End
Begin VB.Shape Shape
Height = 735
Index = 1
Left = 6480
Top = 0
Width = 735
End
Begin VB.Label Label1
Caption = "---"
Height = 255
Left = 0
TabIndex = 1
Top = 1800
Width = 1935
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'
Dim DoNothing As Boolean '<- je vois pas à quoi il sert, il ne change jamais
'Dim n As Integer '<- pas la peine de le déclarer 2 fois
'
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal cardaddress As Long) As Long
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
'
'
Private Sub Check3_Click(index As Integer)
Dim i As Long
Dim n As Long
n = 0
For i = 0 To 7
n = n + Check3(i).Value * (2 ^ i) '<-- pas très propre d'utiliser un booléen...
Next
If Not DoNothing Then WriteAllDigital n
End Sub
'
'
Private Sub Command_Click(index As Integer) '<- commencent à 1
ClearAllDigital
Call carte(index)
'If Command(Index).Value Then ... '<-- pourquoi tester la valeur du bouton?!
Call ChangeAscenseur(index)
End Sub


'
'
Private Sub connect_Click()
Dim cardaddress As Long
Dim h As Long
cardaddress = 0
h = OpenDevice(cardaddress)

Select Case h
Case 0, 1, 2, 3
Label1.Caption = "card" + Str(h) + " connected"

Case -1
Label1.Caption = "Card " + Str(cardaddress) + " not found"
End Select
End Sub
Private Sub Form_Load()

Dim cardaddress As Long
Dim h As Long
cardaddress = 0
h = OpenDevice(cardaddress)

Select Case h
Case 0, 1, 2, 3
Label1.Caption = "card" + Str(h) + " connected"

Case -1
Label1.Caption = "Card " + Str(cardaddress) + " not found"
End Select
End Sub


'
'
Private Sub test_Click()
Form2.Show
Unload Form1 ' oubien Unload Me '<- parfois plus simple pour se relire
End Sub
'
'
Private Sub ChangeAscenseur(Etage As Integer)
Dim i As Integer
Shape(Etage).FillStyle = 0
For i = 1 To 4
If i <> Etage Then Shape(i).FillStyle = 1
Next i

End Sub

Private Sub carte(test As Integer)
ClearAllDigital
Dim i As Integer

For i = 1 To 4
If i <> test Then SetDigitalChannel i
Next i



End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
Frame1.Caption = Check2.Value
End Sub

Private Sub Label2_Click()

Check2 = Label2.Caption
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim i As Long


i = ReadAllDigital
Check2(0).Value = (i And 1)
Check2(1).Value = (i And 2) / 2
Check2(2).Value = (i And 4) / 4
Check2(3).Value = (i And 8) / 8
Check2(4).Value = (i And 16) / 16


Timer1.Enabled = True

Dim bloop As Byte, bchecked As Byte


If Check2(0).Value = 1 Then bchecked = bchecked + 1


If Not bchecked = 0 Then
For bloop = 1 To 4
Command(bloop).Visible = True
Next
End If

If bchecked = 0 Then
For bloop = 1 To 4
Command(bloop).Visible = False
Next
End If

End Sub

Private Sub Timer2_Timer()

Dim bloop As Byte, bchecked As Byte


If Check2(0).Value = 1 Then bchecked = bchecked + 1


If Not bchecked = 0 Then
For bloop = 1 To 4

Frame7.Visible = True
Next
End If

If bchecked = 0 Then
For bloop = 1 To 4

Frame7.Visible = False
Next

End If

End Sub

______________________________ ____________

il y a des shape pour savoir l'étage ou je me trouve ... il se colorie en noir quand j'appuie sur le bouton

alors voici le lien pour le shéma


http://img221.imageshack.us/img221/6943/shema7bn.jpg

Bon sa c'est le normal je Voici le shéma ou j'ai entouré les entrées

http://img162.imageshack.us/img162/6753/shema1of.jpg

ce que je t'ai entouré correspond au check box 1 à 5 ( il y a 5V entre les entrées et le GND une fois que le GND est relier a une des entré la check Box qui correspond à l'entrée ce met a 1 )

Donc la 1ere entrée est relier Au Gnd et doit rester à 1 cela signifie que les portes des étages sont fermée.

Les autres check box doivent se cocher en fonction des étages (4) etages ... une fois la check box cochée les sorties de la carte doivent s'arreter

Moi ce qu'il me faudrait c'est que les commandes sachent si je dois monté ou descendre

ex j'appuie sur le bouton 4 l'asscenseur est au 1 il sait qu'il doit monté jusqu'a ce que la check box 4 se coche

l'ascenseur est au 3 je le veux au 2 il sait qu'il doit descendre et s'arreter quand la check box 2 va se coché



donc les sorties de la carte velleman 1 sortie Pour faire monté l'ascenseur

2 eme sortie pour faire descendre l'ascenseur

Pour sa j'utilise Un ULN

l'uln comporte un Clamp ou je met 5V entre le GND et le Clamp (com )
ce qui permet une carte de puissance d'actioner un moteur



Voici le shéma ou sont les entrées et les sorties

http://img78.imageshack.us/img78/2867/shema5fr.jpg


si qq'un connait une solution

Merci d'avance