scusami hai ragione...questo è quello che progettato con VB 6
Option Explicit
Dim DoNothing As Boolean
Dim n As Integer
Dim CardAddress As Long
Private Declare Function OpenDevice Lib "k8061.dll" () As Long
Private Declare Sub CloseDevices Lib "k8061.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long) As Long
Private Declare Function PowerGood Lib "k8061.dll" (ByVal CardAddress As Long) As Boolean
Private Declare Function Connected Lib "k8061.dll" (ByVal CardAddress As Long) As Boolean
Private Declare Sub ReadVersion Lib "k8061.dll" (ByVal CardAddress As Long, Buffer As Long)
Private Declare Sub ReadAllAnalog Lib "k8061.dll" (ByVal CardAddress As Long, Buffer As Long)
Private Declare Sub OutputAnalogChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub OutputAllAnalog Lib "k8061.dll" (ByVal CardAddress As Long, Buffer As Long)
Private Declare Sub ClearAnalogChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib "k8061.dll" (ByVal CardAddress As Long)
Private Declare Sub ClearAllAnalog Lib "k8061.dll" (ByVal CardAddress As Long)
Private Declare Sub SetAnalogChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub OutputAllDigital Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib "k8061.dll" (ByVal CardAddress As Long)
Private Declare Sub SetDigitalChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib "k8061.dll" (ByVal CardAddress As Long)
Private Declare Function ReadDigitalChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib "k8061.dll" (ByVal CardAddress As Long) As Long
Private Declare Sub OutputPWM Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Data 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)
Next
If Not DoNothing Then OutputAllDigital CardAddress, n
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then Timer2.Enabled = True Else Timer2.Enabled = False
End Sub
Private Sub ClearAllAnalog1_Click()
Dim i As Long
ClearAllAnalog CardAddress
For i = 0 To 7
VScroll1(i).Value = 0
Label3(i) = 0
Next i
End Sub
Private Sub Command1_Click()
Dim Info(0 To 51) As Long
Dim i As Long
ReadVersion CardAddress, Info(0)
Label7.Caption = ""
For i = 0 To 49
Label7.Caption = Label7.Caption + Chr(Info(i))
Next i
End Sub
Private Sub Connect_Click()
Dim h As Long
h = OpenDevice
Select Case h
Case 0, 1, 2, 3, 4, 5, 6, 7
Label1.Caption = "Card " + Str(h) + " connected"
Option1(h).Enabled = True
Option1(h).Value = True
Timer1.Enabled = True
Case -2
Label1.Caption = "Card not found"
Case -1
Label1.Caption = "All cards opened"
End Select
End Sub
Private Sub Form_Initialize()
DoNothing = False
n = 7
End Sub
Private Sub Form_Terminate()
CloseDevices
End Sub
Private Sub Option1_Click(Index As Integer)
CardAddress = Index
End Sub
Private Sub SetAllAnalog1_Click()
Dim i As Long
SetAllAnalog CardAddress
For i = 0 To 7
VScroll1(i).Value = 255
Label3(i) = 255
Next i
End Sub
Private Sub SetAllDig_Click()
Dim i As Long
DoNothing = True
For i = 0 To 7
Check3(i).Value = 1
Next
DoNothing = False
SetAllDigital CardAddress
End Sub
Private Sub ClearAllDig_Click()
Dim i As Long
DoNothing = True
For i = 0 To 7
Check3(i).Value = 0
Next
DoNothing = False
ClearAllDigital CardAddress
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim i As Long
Dim Buffer(0 To 7) As Long
If PowerGood(CardAddress) Then
Label2.Caption = "CPU OK"
Label2.ForeColor = &H8000&
Else
Label2.Caption = "CPU FAIL"
Label2.ForeColor = &HFF&
End If
If Connected(CardAddress) Then
Label6.Caption = "USB Connected"
Label6.ForeColor = &H8000&
Else
Label6.Caption = "USB Disconnected"
Label6.ForeColor = &HFF&
Label1.Caption = "Card disconnected"
End If
i = ReadAllDigital(CardAddress)
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
Check2(5).Value = (i And 32) / 32
Check2(6).Value = (i And 64) / 64
Check2(7).Value = (i And 128) / 128
ReadAllAnalog CardAddress, Buffer(0)
For i = 0 To 7
If Buffer(i) < 0 Then Buffer(i) = 0
If Buffer(i) > 1023 Then Buffer(i) = 1023
VScroll2(i).Value = Buffer(i)
Label4(i).Caption = Buffer(i)
Next i
Timer1.Enabled = True
End Sub
Private Sub Timer2_Timer()
Check3(n).Value = 0
n = n + 1
If n = 8 Then n = 0
Check3(n).Value = 1
End Sub
Private Sub VScroll1_Change(Index As Integer)
Label3(Index).Caption = VScroll1(Index).Value
OutputAnalogChannel CardAddress, Index + 1, VScroll1(Index).Value
End Sub
Private Sub VScroll3_Change()
OutputPWM CardAddress, VScroll3.Value
Label5.Caption = VScroll3.Value
End Sub
ora il problema è inserire un altro VScroll che ha come funzione quella d'indicare la tensione dell'alimentatore stabilizzato.L'esercitazione consiste nel far accendere i led con tensioni diverse(da 0V a 10 V max).la tensione deve essere indirizzata su l'ingressi.
con tensione compresa tra 0V e 1V il primo led deve accendersi,ma se la tensione è maggiore di 1V non deve accendersi,se la tensione è compresa tra 1V e 2V deve accendersi il 2° led ma se è minore di 1V e maggiore di 2V no e cosi' via per tutti i gli altri led.
come posso fare????