VERSION 5.00 Begin VB.Form Sample0Form Caption = "104-AIM-32 Sample 0" ClientHeight = 6735 ClientLeft = 4620 ClientTop = 4995 ClientWidth = 9495 LinkTopic = "Form1" ScaleHeight = 449 ScaleMode = 3 'Pixel ScaleWidth = 633 StartUpPosition = 2 'CenterScreen Begin VB.Timer TestTimer Enabled = 0 'False Interval = 500 Left = 5760 Top = 2040 End Begin VB.CommandButton ExitButton Caption = "E&xit" Height = 375 Left = 8400 TabIndex = 82 Top = 2040 Width = 975 End Begin VB.TextBox Text1 Height = 4095 Left = 5520 Locked = -1 'True MultiLine = -1 'True TabIndex = 81 Text = "Sample0Form.frx":0000 Top = 2520 Width = 3855 End Begin VB.Frame EndGroup Caption = "S.E./Diff." Height = 855 Left = 7920 TabIndex = 78 Top = 1080 Width = 1455 Begin VB.OptionButton EndOption Caption = "Differential" Height = 195 Index = 1 Left = 90 TabIndex = 80 Top = 510 Width = 1215 End Begin VB.OptionButton EndOption Caption = "Single Ended" Height = 255 Index = 0 Left = 90 TabIndex = 79 Top = 240 Value = -1 'True Width = 1335 End End Begin VB.Frame GainBox Caption = "Gain" Height = 855 Left = 7920 TabIndex = 76 Top = 120 Width = 1455 Begin VB.ComboBox GainComboBox Height = 315 ItemData = "Sample0Form.frx":011A Left = 240 List = "Sample0Form.frx":0130 TabIndex = 77 Text = "0.5" Top = 360 Width = 975 End End Begin VB.Frame Frame1 Caption = "Address for 104-AIM-32" Height = 855 Left = 5520 TabIndex = 73 Top = 1080 Width = 2175 Begin VB.TextBox AIM32Edit Height = 315 Left = 720 TabIndex = 74 Text = "320" Top = 360 Width = 1215 End Begin VB.Label Hex2Label Caption = "Hex:" Height = 315 Left = 360 TabIndex = 75 Top = 360 Width = 330 End End Begin VB.Frame AddrBox Caption = "Address for 104 Card" Height = 855 Left = 5520 TabIndex = 70 Top = 120 Width = 2175 Begin VB.TextBox BaseEdit Height = 315 Left = 720 TabIndex = 72 Text = "300" Top = 360 Width = 1215 End Begin VB.Label HexLabel Caption = "Hex:" Height = 315 Left = 360 TabIndex = 71 Top = 360 Width = 330 End End Begin VB.CommandButton StartButton Caption = "&Start" Height = 375 Left = 7200 TabIndex = 69 Top = 2040 Width = 975 End Begin VB.Frame ChannelBox Caption = "Output" Height = 6495 Left = 120 TabIndex = 0 Top = 120 Width = 5295 Begin VB.Label VoltsLabels Height = 225 Index = 31 Left = 3840 TabIndex = 68 Top = 6120 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 30 Left = 3840 TabIndex = 67 Top = 5760 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 29 Left = 3840 TabIndex = 66 Top = 5400 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 28 Left = 3840 TabIndex = 65 Top = 5040 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 27 Left = 3840 TabIndex = 64 Top = 4680 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 26 Left = 3840 TabIndex = 63 Top = 4320 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 25 Left = 3840 TabIndex = 62 Top = 3960 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 24 Left = 3840 TabIndex = 61 Top = 3600 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 23 Left = 3840 TabIndex = 60 Top = 3240 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 22 Left = 3840 TabIndex = 59 Top = 2880 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 21 Left = 3840 TabIndex = 58 Top = 2520 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 20 Left = 3840 TabIndex = 57 Top = 2160 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 19 Left = 3840 TabIndex = 56 Top = 1800 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 18 Left = 3840 TabIndex = 55 Top = 1440 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 17 Left = 3840 TabIndex = 54 Top = 1080 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 16 Left = 3840 TabIndex = 53 Top = 720 Width = 1155 End Begin VB.Label Volts2Label Alignment = 2 'Center Caption = "Volts" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 195 Left = 3840 TabIndex = 52 Top = 360 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 31" Height = 225 Index = 31 Left = 2640 TabIndex = 51 Top = 6120 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 30" Height = 225 Index = 30 Left = 2640 TabIndex = 50 Top = 5760 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 29" Height = 225 Index = 29 Left = 2640 TabIndex = 49 Top = 5400 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 28" Height = 225 Index = 28 Left = 2640 TabIndex = 48 Top = 5040 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 27" Height = 225 Index = 27 Left = 2640 TabIndex = 47 Top = 4680 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 26" Height = 225 Index = 26 Left = 2640 TabIndex = 46 Top = 4320 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 25" Height = 225 Index = 25 Left = 2640 TabIndex = 45 Top = 3960 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 24" Height = 225 Index = 24 Left = 2640 TabIndex = 44 Top = 3600 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 23" Height = 225 Index = 23 Left = 2640 TabIndex = 43 Top = 3240 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 22" Height = 225 Index = 22 Left = 2640 TabIndex = 42 Top = 2880 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 21" Height = 225 Index = 21 Left = 2640 TabIndex = 41 Top = 2520 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 20" Height = 225 Index = 20 Left = 2640 TabIndex = 40 Top = 2160 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 19" Height = 225 Index = 19 Left = 2640 TabIndex = 39 Top = 1800 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 18" Height = 225 Index = 18 Left = 2640 TabIndex = 38 Top = 1440 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 17" Height = 225 Index = 17 Left = 2640 TabIndex = 37 Top = 1080 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 16" Height = 225 Index = 16 Left = 2640 TabIndex = 36 Top = 720 Width = 1155 End Begin VB.Label Channel2Label Caption = "Channel" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 195 Left = 2640 TabIndex = 35 Top = 360 Width = 705 End Begin VB.Label VoltsLabels Height = 225 Index = 15 Left = 1320 TabIndex = 34 Top = 6120 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 14 Left = 1320 TabIndex = 33 Top = 5760 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 13 Left = 1320 TabIndex = 32 Top = 5400 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 12 Left = 1320 TabIndex = 31 Top = 5040 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 11 Left = 1320 TabIndex = 30 Top = 4680 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 10 Left = 1320 TabIndex = 29 Top = 4320 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 9 Left = 1320 TabIndex = 28 Top = 3960 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 8 Left = 1320 TabIndex = 27 Top = 3600 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 7 Left = 1320 TabIndex = 26 Top = 3240 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 6 Left = 1320 TabIndex = 25 Top = 2880 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 5 Left = 1320 TabIndex = 24 Top = 2520 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 4 Left = 1320 TabIndex = 23 Top = 2160 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 3 Left = 1320 TabIndex = 22 Top = 1800 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 2 Left = 1320 TabIndex = 21 Top = 1440 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 1 Left = 1320 TabIndex = 20 Top = 1080 Width = 1155 End Begin VB.Label VoltsLabels Height = 225 Index = 0 Left = 1320 TabIndex = 19 Top = 720 Width = 1155 End Begin VB.Label VoltsLabel Alignment = 2 'Center Caption = "Volts" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 195 Left = 1320 TabIndex = 18 Top = 360 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 15" Height = 225 Index = 15 Left = 120 TabIndex = 17 Top = 6120 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 14" Height = 225 Index = 14 Left = 120 TabIndex = 16 Top = 5760 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 13" Height = 225 Index = 13 Left = 120 TabIndex = 15 Top = 5400 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 12" Height = 225 Index = 12 Left = 120 TabIndex = 14 Top = 5040 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 11" Height = 225 Index = 11 Left = 120 TabIndex = 13 Top = 4680 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 10" Height = 225 Index = 10 Left = 120 TabIndex = 12 Top = 4320 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 9" Height = 225 Index = 9 Left = 120 TabIndex = 11 Top = 3960 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 8" Height = 225 Index = 8 Left = 120 TabIndex = 10 Top = 3600 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 7" Height = 225 Index = 7 Left = 120 TabIndex = 9 Top = 3240 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 6" Height = 225 Index = 6 Left = 120 TabIndex = 8 Top = 2880 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 5" Height = 225 Index = 5 Left = 120 TabIndex = 7 Top = 2520 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 4" Height = 225 Index = 4 Left = 120 TabIndex = 6 Top = 2160 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 3" Height = 225 Index = 3 Left = 120 TabIndex = 5 Top = 1800 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 2" Height = 225 Index = 2 Left = 120 TabIndex = 4 Top = 1440 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 1" Height = 225 Index = 1 Left = 120 TabIndex = 3 Top = 1080 Width = 1155 End Begin VB.Label ChannelLabels Caption = "Channel 0" Height = 225 Index = 0 Left = 120 TabIndex = 2 Top = 720 Width = 1155 End Begin VB.Label ChannelLabel Caption = "Channel" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 195 Left = 120 TabIndex = 1 Top = 360 Width = 705 End End End Attribute VB_Name = "Sample0Form" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Function InPortB Lib "ACCES32.dll" Alias "VBInPortB" (ByVal Port As Long) As Integer Private Declare Function InPort Lib "ACCES32.dll" Alias "VBInPort" (ByVal Port As Long) As Integer Private Declare Function OutPortB Lib "ACCES32.dll" Alias "VBOutPortB" (ByVal Port As Long, ByVal Value As Byte) As Integer Private Declare Function OutPort Lib "ACCES32.dll" Alias "VBOutPort" (ByVal Port As Long, ByVal Value As Byte) As Integer Public BaseAddress As Long Public AIM32Addr As Long Public CalSpace As Long Public Ended As Long Public Range As Long Public Mode As Long Public Gain As Double Public EEPROMReady As Boolean Private Sub EndOption_Click(Index As Integer) Dim i As Integer If Index = 0 Then Ended = 1 Channel2Label.Visible = True Volts2Label.Visible = True For i = 16 To 31 ChannelLabels(i).Visible = True VoltsLabels(i).Visible = True Next i ElseIf Index = 1 Then Ended = 0 Channel2Label.Visible = False Volts2Label.Visible = False For i = 16 To 31 ChannelLabels(i).Visible = False VoltsLabels(i).Visible = False Next i End If Call OutPortB(AIM32Addr + 1, Ended + CalSpace + &H10) End Sub Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() CalSpace = 0 Ended = 1 Range = 0 Mode = 0 Gain = 0.5 EEPROMReady = False If (InPortB(&H61) = &HAA55) Then Call MsgBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", 0, "Warning") End If End Sub Private Sub GainComboBox_Click() Gain = GainComboBox.Text If Gain = 0.5 Then Range = &H0 ElseIf Gain = 1 Then Range = &H20 ElseIf Gain = 2 Then Range = &H40 ElseIf Gain = 50 Then Range = &H60 ElseIf Gain = 100 Then Range = &H80 ElseIf Gain = 200 Then Range = &HA0 End If End Sub Private Sub StartButton_Click() If TestTimer.Enabled = True Then TestTimer.Enabled = False StartButton.Caption = "Start Test" BaseEdit.Enabled = True AIM32Edit.Enabled = True Else StartButton.Caption = "Abort Test" BaseEdit.Enabled = False AIM32Edit.Enabled = False BaseAddress = "&H" + BaseEdit.Text AIM32Addr = "&H" + AIM32Edit.Text Call OutPort(AIM32Addr + 1, &H10 + Ended + CalSpace) TestTimer.Enabled = True End If ' end else End Sub Private Sub TestTimer_Timer() Dim chan As Integer Dim counts As Integer Dim MaxChannels As Integer Dim timeout As Long Dim volts As Double If Ended = 0 Then MaxChannels = 16 Else MaxChannels = 32 End If For chan = 0 To MaxChannels - 1 timeout = 65535 Call OutPortB(AIM32Addr, chan + Range) ' write AIM-32 channel Do While (CheckForBusy(AIM32Addr + 1) And (timeout > 0)) timeout = timeout - 1 Loop timeout = 65535 Call OutPortB(BaseAddress + 2, 0) ' write channel Do While (Not (CheckForEOC(BaseAddress)) And (timeout > 0)) timeout = timeout - 1 Loop If (timeout = 0) Then VoltsLabels(chan).Caption = "A/D Timeout" Else counts = InPort(BaseAddress + 2) volts = ((counts And &HFFF) * (5# / Gain)) / 4096# VoltsLabels(chan).Caption = Format(volts, "##.########") End If ' end else Next chan ' end for chan End Sub Private Function CheckForEOC(ByVal Address As Integer) As Boolean Dim EOCCheck As Byte EOCCheck = InPortB(Address) CheckForEOC = ((EOCCheck And &H80) = &H80) End Function ' end CheckForEOC Private Function CheckForBusy(Address As Integer) As Boolean Dim BusyCheck As Byte BusyCheck = InPortB(Address) CheckForBusy = ((BusyCheck And &H40) = &H40) End Function