VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx" Begin VB.Form mainform Caption = "da02a sample" ClientHeight = 4365 ClientLeft = 60 ClientTop = 345 ClientWidth = 6705 LinkTopic = "Form1" ScaleHeight = 4365 ScaleWidth = 6705 StartUpPosition = 3 'Windows Default Begin VB.Frame outframe Caption = "Output Value" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1215 Left = 120 TabIndex = 17 Top = 2400 Width = 4575 Begin ComctlLib.Slider value Height = 375 Left = 120 TabIndex = 19 Top = 240 Visible = 0 'False Width = 4215 _ExtentX = 7435 _ExtentY = 661 _Version = 327682 LargeChange = 16 Max = 4095 End Begin VB.Label LOutput Height = 375 Left = 120 TabIndex = 18 Top = 720 Visible = 0 'False Width = 4335 End End Begin VB.Frame Frame1 Caption = "How to use this program" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1935 Left = 120 TabIndex = 15 Top = 360 Width = 4575 Begin VB.Label Label2 Caption = $"main.frx":0000 Height = 1455 Left = 120 TabIndex = 16 Top = 360 Width = 4095 End End Begin VB.CommandButton ExitButton Caption = "Exit Program" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4800 TabIndex = 14 Top = 3720 Width = 1695 End Begin VB.CommandButton InitButton Caption = "Initialize" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 3000 TabIndex = 13 Top = 3720 Width = 1695 End Begin VB.Frame ChannelFrame Caption = "Output 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 = 975 Left = 4800 TabIndex = 9 Top = 2640 Width = 1695 Begin VB.OptionButton ChButton Caption = "All Channels" Height = 195 Index = 2 Left = 120 TabIndex = 12 Top = 630 Width = 1335 End Begin VB.OptionButton ChButton Caption = "Channel 1" Height = 195 Index = 1 Left = 120 TabIndex = 11 Top = 440 Width = 1095 End Begin VB.OptionButton ChButton Caption = "Channel 0" Height = 195 Index = 0 Left = 120 TabIndex = 10 Top = 240 Width = 1215 End End Begin VB.Frame OutputFrame Caption = "Output Range" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1335 Left = 4800 TabIndex = 3 Top = 1200 Width = 1695 Begin VB.OptionButton RangeButton Caption = "4-20 mA" Height = 195 Index = 4 Left = 120 TabIndex = 8 Top = 1050 Width = 1455 End Begin VB.OptionButton RangeButton Caption = "0-10 VDC" Height = 195 Index = 3 Left = 120 TabIndex = 7 Top = 850 Width = 1095 End Begin VB.OptionButton RangeButton Caption = "0-5 VDC" Height = 195 Index = 2 Left = 120 TabIndex = 6 Top = 650 Width = 1215 End Begin VB.OptionButton RangeButton Caption = "+/-10 VDC" Height = 195 Index = 1 Left = 120 TabIndex = 5 Top = 450 Width = 1215 End Begin VB.OptionButton RangeButton Caption = "+/-5 VDC" Height = 195 Index = 0 Left = 120 TabIndex = 4 Top = 240 Width = 1095 End End Begin VB.Frame ISAFrame Caption = "Base Address" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 4800 TabIndex = 0 Top = 360 Width = 1695 Begin VB.TextBox ISAEdit Height = 285 Left = 720 TabIndex = 1 Text = "300" Top = 320 Width = 855 End Begin VB.Label Label1 Caption = "hex" Height = 255 Left = 240 TabIndex = 2 Top = 360 Width = 495 End End End Attribute VB_Name = "mainform" 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 Long) As Integer Dim base As Long Dim span As Double Dim offset As Double Dim maxch As Integer Dim channel As Long Dim CurVal As Long Private Sub ChButton_Click(Index As Integer) If ChButton(0).value = True Then maxch = 0 ElseIf ChButton(1).value = True Then maxch = 1 ElseIf ChButton(2).value = True Then maxch = 2 Else maxch = 2 End If End Sub Private Function ConvertForOutput(v As Long) As Long Dim i As Integer v = v If maxch < 2 Then Call OutPort(base + (maxch * 2), v * 16) 'write to DAC Else For i = 0 To maxch - 1 Call OutPort(base + (i * 2) + 4, v * 16) 'write to DAC Next i End If ConvertForOutput = v End Function Private Function IntToBin(n As Integer) As String Dim temp As String Dim i As Integer Dim f As Double temp = "" 'print output onscreen as binary If (n And (&H800)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H400)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H200)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H100)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H80)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H40)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H20)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H10)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H8)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H4)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H2)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If If (n And (&H1)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If temp = temp + "xxxx" f = ((n) * span / 4096 - offset) 'convert to volts mystring = Str(f) mystring2 = Str(n) temp = temp + " hex " + Hex(mystring2) + " " + mystring 'print binary, hex, volts onscreen If RangeButton(4).value = True Then IntToBin = temp + " mA" Else IntToBin = temp + " Volts" End If End Function Private Sub UpdateDAC() LOutput.Caption = IntToBin(ConvertForOutput(CurVal)) 'write output on screen End Sub Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() maxch = 2 RangeButton(0).value = True ChButton(0).value = True 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 InitButton_Click() value.Visible = True 'make slider bar visible LOutput.Visible = True base = "&h" + ISAEdit.Text 'set base address If base < &H100 Or base >= &H3FF Then 'check if base is okay Beep End If End Sub Private Sub RangeButton_Click(Index As Integer) If RangeButton(0).value = True Then 'set offset and span for output range span = -10 offset = -5 ElseIf RangeButton(1).value = True Then span = -20 offset = -10 ElseIf RangeButton(2).value = True Then span = 5 offset = 0 ElseIf RangeButton(3).value = True Then span = 10 offset = 0 ElseIf RangeButton(4).value = True Then span = 16 offset = -4 Else span = -30 offset = -5 End If UpdateDAC End Sub Private Sub Value_Scroll() CurVal = value.value UpdateDAC End Sub