VERSION 5.00 Begin VB.Form MainForm Caption = "USB-DIO-32 Sample" ClientHeight = 8055 ClientLeft = 3480 ClientTop = 4815 ClientWidth = 9855 LinkTopic = "Form1" ScaleHeight = 537 ScaleMode = 3 'Pixel ScaleWidth = 657 StartUpPosition = 2 'CenterScreen Begin VB.CommandButton Command2 Caption = "USB" Enabled = 0 'False Height = 615 Left = 240 TabIndex = 56 Top = 3960 Width = 1215 End Begin VB.CommandButton Command1 BackColor = &H00000000& Caption = "LED" Enabled = 0 'False Height = 375 Left = 240 Style = 1 'Graphical TabIndex = 55 Top = 3120 Width = 735 End Begin VB.CheckBox OutButton Caption = "Output Port C Group 1" Height = 375 Index = 5 Left = 360 Style = 1 'Graphical TabIndex = 38 Top = 1080 Width = 2895 End Begin VB.CheckBox OutButton Caption = "Output Port B Group 1" Height = 375 Index = 4 Left = 3360 Style = 1 'Graphical TabIndex = 37 Top = 1080 Width = 2895 End Begin VB.CheckBox TristateButton Caption = "Tristate All" Height = 375 Left = 3600 Style = 1 'Graphical TabIndex = 4 Top = 3960 Width = 2775 End Begin VB.CheckBox OutButton Caption = "Output Port A Group 1" Height = 375 Index = 3 Left = 6360 Style = 1 'Graphical TabIndex = 3 Top = 1080 Width = 2895 End Begin VB.CheckBox OutButton Caption = "Output Port C Group 0" Height = 375 Index = 2 Left = 6840 Style = 1 'Graphical TabIndex = 2 Top = 6840 Width = 2895 End Begin VB.CheckBox OutButton Caption = "Output Port B Group 0" Height = 375 Index = 1 Left = 3840 Style = 1 'Graphical TabIndex = 1 Top = 6840 Width = 2895 End Begin VB.CheckBox OutButton Caption = "Output Port A Group 0" Height = 375 Index = 0 Left = 840 Style = 1 'Graphical TabIndex = 0 Top = 6840 Width = 2895 End Begin VB.Timer ReadTime Enabled = 0 'False Interval = 1 Left = 720 Top = 0 End Begin VB.Label Label19 Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "+5V" Height = 255 Left = 360 TabIndex = 66 Top = 7200 Width = 375 End Begin VB.Label Label18 Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "+5V" Height = 255 Left = 9360 TabIndex = 65 Top = 960 Width = 375 End Begin VB.Label Label14 Alignment = 2 'Center Caption = "Pin 49" Height = 255 Left = 240 TabIndex = 63 Top = 6960 Width = 615 End Begin VB.Image LowLevel Enabled = 0 'False Height = 360 Left = 0 Picture = "MainForm.frx":0000 Top = 0 Visible = 0 'False Width = 360 End Begin VB.Image HighLevel Enabled = 0 'False Height = 360 Left = 360 Picture = "MainForm.frx":04CE Top = 0 Visible = 0 'False Width = 360 End Begin VB.Label Label12 Alignment = 2 'Center Caption = "Pins 1 to 15 odd" Height = 255 Left = 360 TabIndex = 62 Top = 120 Width = 2895 End Begin VB.Label Label11 Alignment = 2 'Center Caption = "Pins 17 to 31 odd" Height = 255 Left = 3360 TabIndex = 61 Top = 120 Width = 2895 End Begin VB.Label Label10 Alignment = 2 'Center Caption = "Pins 33 to 47 odd" Height = 255 Left = 6360 TabIndex = 60 Top = 120 Width = 2895 End Begin VB.Label Label9 Alignment = 2 'Center Caption = "Pins 47 to 33 odd" Height = 255 Left = 840 TabIndex = 59 Top = 6600 Width = 2895 End Begin VB.Label Label8 Alignment = 2 'Center Caption = "Pins 31 to 17 odd" Height = 255 Left = 3840 TabIndex = 58 Top = 6600 Width = 2895 End Begin VB.Label Label7 Alignment = 2 'Center Caption = "Pins 15 to 1 odd" Height = 255 Left = 6840 TabIndex = 57 Top = 6600 Width = 2895 End Begin VB.Image LevelImage Height = 375 Index = 47 Left = 360 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 46 Left = 720 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 45 Left = 1080 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 44 Left = 1440 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 43 Left = 1800 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 42 Left = 2160 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 41 Left = 2520 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 40 Left = 2880 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 39 Left = 3360 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 38 Left = 3720 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 37 Left = 4080 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 36 Left = 4440 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 35 Left = 4800 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 34 Left = 5160 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 33 Left = 5520 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 32 Left = 5880 Top = 600 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "0" Height = 195 Index = 15 Left = 2880 TabIndex = 54 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "1" Height = 195 Index = 14 Left = 2520 TabIndex = 53 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "2" Height = 195 Index = 13 Left = 2160 TabIndex = 52 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "3" Height = 195 Index = 12 Left = 1800 TabIndex = 51 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "4" Height = 195 Index = 11 Left = 1440 TabIndex = 50 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "5" Height = 195 Index = 10 Left = 1080 TabIndex = 49 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "6" Height = 195 Index = 9 Left = 720 TabIndex = 48 Top = 360 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "7" Height = 195 Index = 8 Left = 360 TabIndex = 47 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "0" Height = 195 Index = 15 Left = 5880 TabIndex = 46 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "1" Height = 195 Index = 14 Left = 5520 TabIndex = 45 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "2" Height = 195 Index = 13 Left = 5160 TabIndex = 44 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "3" Height = 195 Index = 12 Left = 4800 TabIndex = 43 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "4" Height = 195 Index = 11 Left = 4440 TabIndex = 42 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "5" Height = 195 Index = 10 Left = 4080 TabIndex = 41 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "6" Height = 195 Index = 9 Left = 3720 TabIndex = 40 Top = 360 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "7" Height = 195 Index = 8 Left = 3360 TabIndex = 39 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "7" Height = 195 Index = 7 Left = 6360 TabIndex = 36 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "6" Height = 195 Index = 6 Left = 6720 TabIndex = 35 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "5" Height = 195 Index = 5 Left = 7080 TabIndex = 34 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "4" Height = 195 Index = 4 Left = 7440 TabIndex = 33 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "3" Height = 195 Index = 3 Left = 7800 TabIndex = 32 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "2" Height = 195 Index = 2 Left = 8160 TabIndex = 31 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "1" Height = 195 Index = 1 Left = 8520 TabIndex = 30 Top = 360 Width = 375 End Begin VB.Label BitLabelD Alignment = 2 'Center Caption = "0" Height = 195 Index = 0 Left = 8880 TabIndex = 29 Top = 360 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "7" Height = 195 Index = 7 Left = 6840 TabIndex = 28 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "6" Height = 195 Index = 6 Left = 7200 TabIndex = 27 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "5" Height = 195 Index = 5 Left = 7560 TabIndex = 26 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "4" Height = 195 Index = 4 Left = 7920 TabIndex = 25 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "3" Height = 195 Index = 3 Left = 8280 TabIndex = 24 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "2" Height = 195 Index = 2 Left = 8640 TabIndex = 23 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "1" Height = 195 Index = 1 Left = 9000 TabIndex = 22 Top = 7800 Width = 375 End Begin VB.Label BitLabelC Alignment = 2 'Center Caption = "0" Height = 195 Index = 0 Left = 9360 TabIndex = 21 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "7" Height = 195 Index = 7 Left = 3840 TabIndex = 20 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "6" Height = 195 Index = 6 Left = 4200 TabIndex = 19 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "5" Height = 195 Index = 5 Left = 4560 TabIndex = 18 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "4" Height = 195 Index = 4 Left = 4920 TabIndex = 17 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "3" Height = 195 Index = 3 Left = 5280 TabIndex = 16 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "2" Height = 195 Index = 2 Left = 5640 TabIndex = 15 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "1" Height = 195 Index = 1 Left = 6000 TabIndex = 14 Top = 7800 Width = 375 End Begin VB.Label BitLabelB Alignment = 2 'Center Caption = "0" Height = 195 Index = 0 Left = 6360 TabIndex = 13 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "7" Height = 195 Index = 7 Left = 840 TabIndex = 12 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "6" Height = 195 Index = 6 Left = 1200 TabIndex = 11 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "5" Height = 195 Index = 5 Left = 1560 TabIndex = 10 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "4" Height = 195 Index = 4 Left = 1920 TabIndex = 9 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "3" Height = 195 Index = 3 Left = 2280 TabIndex = 8 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "2" Height = 195 Index = 2 Left = 2640 TabIndex = 7 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "1" Height = 195 Index = 1 Left = 3000 TabIndex = 6 Top = 7800 Width = 375 End Begin VB.Label BitLabelA Alignment = 2 'Center Caption = "0" Height = 195 Index = 0 Left = 3360 TabIndex = 5 Top = 7800 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 31 Left = 6360 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 30 Left = 6720 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 29 Left = 7080 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 28 Left = 7440 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 27 Left = 7800 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 26 Left = 8160 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 25 Left = 8520 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 24 Left = 8880 Top = 600 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 23 Left = 6840 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 22 Left = 7200 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 21 Left = 7560 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 20 Left = 7920 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 19 Left = 8280 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 18 Left = 8640 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 17 Left = 9000 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 16 Left = 9360 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 15 Left = 3840 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 14 Left = 4200 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 13 Left = 4560 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 12 Left = 4920 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 11 Left = 5280 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 10 Left = 5640 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 9 Left = 6000 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 8 Left = 6360 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 7 Left = 840 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 6 Left = 1200 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 5 Left = 1560 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 4 Left = 1920 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 3 Left = 2280 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 2 Left = 2640 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 1 Left = 3000 Top = 7320 Width = 375 End Begin VB.Image LevelImage Height = 375 Index = 0 Left = 3360 Top = 7320 Width = 375 End Begin VB.Label Label16 Alignment = 2 'Center Caption = "Pin 49" Height = 255 Left = 9240 TabIndex = 64 Top = 720 Width = 615 End End Attribute VB_Name = "MainForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Public DeviceIndex As Long Dim DIOData(0 To 5) As Byte Dim DoUpdate As Boolean Public DetectOK As Boolean Private Function FormatFreq(Freq As Double) As String If Freq >= 1000000 Then FormatFreq = Format$(Freq / 1000000, "0.0MHz") ElseIf Freq >= 10000 Then FormatFreq = Format$(Freq / 1000, "0.0KHz") ElseIf Freq >= 1000 Then FormatFreq = Format$(Freq / 1000, "0.0KHz") ElseIf Freq >= 10 Then FormatFreq = Format$(Freq, "0.00Hz") ElseIf Freq >= 1 Then FormatFreq = Format$(Freq, "0.00Hz") Else FormatFreq = Format$(Freq, "0.00Hz") End If End Function Private Sub Form_Load() Dim OutMask As Integer Dim I As Integer Dim Status As Long DeviceIndex = diOnly For I = 0 To 5 DIOData(I) = &HFF Next OutMask = &H0 Status = DIO_Configure(DeviceIndex, False, OutMask, DIOData(0)) If Status <> ERROR_SUCCESS Then Call DetectForm.Show(vbModal, Me) If DetectOK = False Then Unload Me Exit Sub End If End If DoUpdate = True ReadTime.Enabled = True End Sub Private Sub Form_Unload(Cancel As Integer) ReadTime.Enabled = False End Sub Private Sub LevelImage_Click(Index As Integer) Dim NewValue As Boolean Dim BitIndex As Integer, ByteIndex As Integer BitIndex = Index Mod 8 ByteIndex = Index \ 8 DIOData(ByteIndex) = DIOData(ByteIndex) Xor (2 ^ BitIndex) 'Toggle bit NewValue = (DIOData(ByteIndex) And (2 ^ BitIndex)) <> 0 'Get bit value Call DIO_Write1(DeviceIndex, Index, NewValue) DoUpdate = True End Sub Private Sub OutButton_Click(Index As Integer) Dim I As Integer Dim OutMask As Integer Dim TristateChecked As Boolean OutMask = &H0 For I = 0 To 5 If OutButton(I).Value = 1 Then OutMask = OutMask Or (2 ^ I) End If Next I TristateChecked = (TristateButton.Value = 1) Call DIO_Configure(DeviceIndex, TristateChecked, OutMask, DIOData(0)) DoUpdate = True End Sub Private Sub ReadTime_Timer() Dim BitI As Integer, ByteI As Integer Dim oDIOData(0 To 5) As Byte Dim Changes(0 To 5) As Byte For ByteI = 0 To 5 oDIOData(ByteI) = DIOData(ByteI) Next Call DIO_ReadAll(DeviceIndex, DIOData(0)) If DoUpdate Then For ByteI = 0 To 5 Changes(ByteI) = &HFF Next DoUpdate = False Else For ByteI = 0 To 5 Changes(ByteI) = DIOData(ByteI) Xor oDIOData(ByteI) Next End If For ByteI = 0 To 5 For BitI = 0 To 7 If (Changes(ByteI) And (2 ^ BitI)) <> 0 Then If (DIOData(ByteI) And (2 ^ BitI)) <> 0 Then LevelImage(ByteI * 8 + BitI).Picture = HighLevel.Picture Else LevelImage(ByteI * 8 + BitI).Picture = LowLevel.Picture End If 'DIOData End If 'Changes Next BitI Next ByteI End Sub Private Sub TristateButton_Click() Dim I As Integer Dim OutMask As Integer Dim TristateChecked As Boolean OutMask = &H0 For I = 0 To 5 If OutButton(I).Value = 1 Then OutMask = OutMask Or (2 ^ I) End If Next I TristateChecked = (TristateButton.Value = 1) Call DIO_Configure(DeviceIndex, TristateChecked, OutMask, DIOData(0)) End Sub