VERSION 5.00 Begin VB.Form Form1 BorderStyle = 3 'Fixed Dialog Caption = "Isolated Input/Digital Output Test/Sample" ClientHeight = 4530 ClientLeft = 45 ClientTop = 330 ClientWidth = 6150 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 4530 ScaleWidth = 6150 ShowInTaskbar = 0 'False StartUpPosition = 2 'CenterScreen Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1000 Left = 2640 Top = 4080 End Begin VB.Frame Frame1 Caption = "Status" Height = 1695 Left = 120 TabIndex = 10 Top = 2280 Width = 5895 Begin VB.TextBox Memo1 Height = 1335 Left = 120 Locked = -1 'True MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 11 Top = 240 Width = 5655 End End Begin VB.CommandButton ExitButton Caption = "E&xit" Height = 375 Left = 4320 TabIndex = 9 Top = 4080 Width = 1575 End Begin VB.CommandButton PerformButton Caption = "Perform I/O" Height = 375 Left = 240 TabIndex = 2 Top = 4080 Width = 1455 End Begin VB.Label OptoIn Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "00000000" Height = 255 Left = 3960 TabIndex = 8 Top = 1920 Width = 1215 End Begin VB.Label RelayRead Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "00000000" Height = 255 Left = 2400 TabIndex = 7 Top = 1920 Width = 1215 End Begin VB.Label RelayOut Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "00000000" Height = 255 Left = 840 TabIndex = 6 Top = 1920 Width = 1215 End Begin VB.Label Label5 AutoSize = -1 'True Caption = "Opto Input" Height = 195 Left = 4200 TabIndex = 5 Top = 1680 Width = 750 End Begin VB.Label Label4 AutoSize = -1 'True Caption = "Relay Readback" Height = 195 Left = 2400 TabIndex = 4 Top = 1680 Width = 1200 End Begin VB.Label Label3 AutoSize = -1 'True Caption = "Relay Output" Height = 195 Left = 960 TabIndex = 3 Top = 1680 Width = 930 End Begin VB.Label CardName AutoSize = -1 'True Caption = "Card Name" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 300 Left = 240 TabIndex = 1 Top = 840 Width = 1200 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "Windows Sample" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 1560 TabIndex = 0 Top = 120 Width = 2520 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Rem This sample now uses the AIOWDM.bas VB module included in this project Rem Calls to OutPortB() InPortB() have been changed to RelOutPortB() RelInPortB() Rem They now use CardNum = 0, and address "Offset" instead of just "Address" Rem This app will write output to A and also read its value as input, It also reads Input on B Rem It only supports a single card installed in the system Public Status As Integer Public NumCards As Long Public Cardnum As Integer Public Offset As Long Dim Ports(4) As Long Public RunFlag As Boolean Public Address As Long Public MyIndex As Integer Dim MyValues(2) As Integer Public Msg As String Private Sub AddressLabel_Click() End Sub Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() Memo1.Text = "This sample will sequentially turn on all bits of the relay input and sequentially turn them off. Each time it sets a new bit, both the relay output and the relay input are read and the data is displayed. This demonstrates how to read and write to the relays and how to use the readback function of the board." + Chr(13) + Chr(10) Memo1.SelStart = 32768 'This is still an absolute port address value writen to the driver to test for card and error return 0xAA55 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 Dim found As Boolean Dim DeviceID As Long Dim Base As Long Dim NameSize As Long Dim Name As String Dim i As Integer NumCards = 0 Cardnum = 0 DeviceID = 0 NameSize = 256 found = False RunFlag = True 'Make sure theres at least one card in the system NumCards = GetNumCards() If (NumCards = 0) Then GoTo NoCards 'Samples are for only one card get the device ID Status = QueryCardInfo(i, DeviceID, Base, NameSize, Name) RunFlag = True Select Case DeviceID Case &HF00& CardName.Caption = "PCI-IIRO-8 Digital Input/Relay Output Card" found = True Case &HF08& CardName.Caption = "PCI-IIRO-16 Digital Input/Relay Output Card" found = True Case &HDC8& CardName.Caption = "PCI-IDIO-16 Solid-State Input/Output Card" found = True Case &HF02& CardName.Caption = "PCIe-IIRO-8 Digital Input/Relay Output Card" found = True Case &HF09& CardName.Caption = "PCIe-IIRO-16 Digital Input/Relay Output Card" found = True End Select NoCards: If Not found Then CardName.Caption = "No Card Found In Registry": Memo1.Text = "No Card Found In Registry." + vbCrLf + _ "This may mean an ISA IIRO-8 is installed, no card is installed, or that NTioPCI.SYS is not installed." + vbCrLf + _ "If you have an ISA IIRO-8 card installed, you may continue running the sample by entering the card's Base Address in the edit box above and continuing as normal." + vbCrLf + _ "If you have a PCI card installed, please make sure you have run PCIFind.EXE." Memo1.SelStart = 32768: RunFlag = False End If If RunFlag Then Offset = 0 ' One board at offset 0 End If End Sub Private Sub PerformButton_Click() If Not RunFlag Then Offset = 0 ' One board at offset 0 End If If Timer1.Enabled Then Timer1.Enabled = False: PerformButton.Caption = "Perform I/O" Else Timer1.Enabled = True: PerformButton.Caption = "Stop I/O" End If End Sub Private Sub Timer1_Timer() Dim j As Integer MyValues(0) = 2 ^ MyIndex Call RelOutPortB(Cardnum, Offset, MyValues(0)) MyValues(1) = RelInPortB(Cardnum, Offset) MyValues(2) = RelInPortB(Cardnum, Offset + 1) MyIndex = MyIndex + 1 MyIndex = MyIndex Mod 8 Msg = "" For j = 7 To 0 Step -1 If (MyValues(0) And (2 ^ j)) > 0 Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next RelayOut.Caption = Msg Msg = "" For j = 7 To 0 Step -1 If (MyValues(1) And (2 ^ j)) > 0 Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next RelayRead.Caption = Msg Msg = "" For j = 7 To 0 Step -1 If (MyValues(2) And (2 ^ j)) > 0 Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next OptoIn.Caption = Msg End Sub