VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX" Begin VB.Form mainform Caption = "dac sample" ClientHeight = 5445 ClientLeft = 60 ClientTop = 345 ClientWidth = 6705 LinkTopic = "Form1" ScaleHeight = 5445 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 = 1455 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 = 840 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 = 2640 TabIndex = 14 Top = 4200 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 = 480 TabIndex = 13 Top = 4200 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 = 1695 Left = 4800 TabIndex = 9 Top = 2985 Width = 1695 Begin VB.OptionButton chbutton Caption = "All Channels" Height = 195 Index = 6 Left = 120 TabIndex = 23 Top = 1410 Width = 1455 End Begin VB.OptionButton chbutton Caption = "Channel 5" Height = 195 Index = 5 Left = 120 TabIndex = 22 Top = 1210 Width = 1335 End Begin VB.OptionButton chbutton Caption = "Channel 4" Height = 195 Index = 4 Left = 120 TabIndex = 21 Top = 1020 Width = 1215 End Begin VB.OptionButton chbutton Caption = "Channel 3" Height = 195 Index = 3 Left = 120 TabIndex = 20 Top = 820 Width = 1335 End Begin VB.OptionButton chbutton Caption = "Channel 2" 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 = 430 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 = 1815 Left = 4800 TabIndex = 3 Top = 1080 Width = 1695 Begin VB.OptionButton rangebutton Caption = "4-20 mA" Height = 195 Index = 6 Left = 120 TabIndex = 25 Top = 1510 Width = 1215 End Begin VB.OptionButton rangebutton Caption = "1-5 mA" Height = 195 Index = 5 Left = 120 TabIndex = 24 Top = 1300 Width = 1095 End Begin VB.OptionButton rangebutton Caption = "0-10 VDC" Height = 195 Index = 4 Left = 120 TabIndex = 8 Top = 1090 Width = 1455 End Begin VB.OptionButton rangebutton Caption = "0-5 VDC" Height = 195 Index = 3 Left = 120 TabIndex = 7 Top = 890 Width = 1095 End Begin VB.OptionButton rangebutton Caption = "+/-10 VDC" Height = 195 Index = 2 Left = 120 TabIndex = 6 Top = 680 Width = 1215 End Begin VB.OptionButton rangebutton Caption = "+/-5 VDC" Height = 195 Index = 1 Left = 120 TabIndex = 5 Top = 450 Width = 1215 End Begin VB.OptionButton rangebutton Caption = "+/-2.5 VDC" Height = 195 Index = 0 Left = 120 TabIndex = 4 Top = 240 Width = 1335 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 = 650 Left = 4800 TabIndex = 0 Top = 360 Width = 1695 Begin VB.TextBox ISAEdit Height = 285 Left = 720 TabIndex = 1 Text = "300" Top = 220 Width = 855 End Begin VB.Label Label1 Caption = "hex" Height = 255 Left = 240 TabIndex = 2 Top = 250 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) For i = 0 To 6 If chbutton(i).value = True Then maxch = i End If Next i End Sub Private Function ConvertForOutput(v As Long) As Long Dim i As Integer v = v If maxch < 6 Then Call OutPort(base + (maxch * 2), v) 'write to DAC Else For i = 0 To maxch - 1 Call OutPort(base + (i * 2), v) '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 Dim outval As Integer outval = &H800 temp = "" 'print output onscreen as binary For i = 0 To 11 If (n And (outval)) = 0 Then temp = temp + "0" Else temp = temp + "1" End If outval = outval / 2 Next i 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(5).value = True Or rangebutton(6).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 = 6 rangebutton(0).value = True chbutton(0).value = True 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 = 5 offset = 2.5 ElseIf rangebutton(1).value = True Then span = 10 offset = 5 ElseIf rangebutton(2).value = True Then span = 20 offset = 10 ElseIf rangebutton(3).value = True Then span = 5 offset = 0 ElseIf rangebutton(4).value = True Then span = 10 offset = 0 ElseIf rangebutton(5).value = True Then span = 4 offset = -1 ElseIf rangebutton(6).value = True Then span = 16 offset = -4 Else span = 5 offset = 2.5 End If UpdateDAC End Sub Private Sub Value_Scroll() CurVal = value.value UpdateDAC End Sub