VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4305 ClientLeft = 60 ClientTop = 450 ClientWidth = 12690 LinkTopic = "Form1" ScaleHeight = 4305 ScaleWidth = 12690 StartUpPosition = 3 'Windows Default Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1000 Left = 0 Top = 0 End Begin VB.CommandButton Command1 Caption = "Start" Height = 375 Left = 5520 TabIndex = 28 Top = 3600 Width = 1575 End Begin VB.TextBox freqEdit Height = 285 Index = 12 Left = 11280 TabIndex = 15 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 11 Left = 10440 TabIndex = 14 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 10 Left = 9600 TabIndex = 13 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 9 Left = 8760 TabIndex = 12 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 8 Left = 7920 TabIndex = 11 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 7 Left = 7080 TabIndex = 10 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 6 Left = 6240 TabIndex = 9 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 5 Left = 5400 TabIndex = 8 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 4 Left = 4560 TabIndex = 7 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 3 Left = 3720 TabIndex = 6 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 2 Left = 2880 TabIndex = 5 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 1 Left = 2040 TabIndex = 4 Text = "Text1" Top = 1200 Width = 735 End Begin VB.TextBox freqEdit Height = 285 Index = 0 Left = 1200 TabIndex = 3 Text = "Text1" Top = 1200 Width = 735 End Begin VB.Label Label15 Caption = "12" Height = 255 Left = 11520 TabIndex = 27 Top = 720 Width = 255 End Begin VB.Label Label14 Caption = "11" Height = 255 Left = 10680 TabIndex = 26 Top = 720 Width = 255 End Begin VB.Label Label13 Caption = "10" Height = 255 Left = 9840 TabIndex = 25 Top = 720 Width = 255 End Begin VB.Label Label12 Caption = "9" Height = 255 Left = 9000 TabIndex = 24 Top = 720 Width = 135 End Begin VB.Label Label11 Caption = "8" Height = 255 Left = 8160 TabIndex = 23 Top = 720 Width = 135 End Begin VB.Label Label10 Caption = "7" Height = 255 Left = 7320 TabIndex = 22 Top = 720 Width = 135 End Begin VB.Label Label9 Caption = "6" Height = 255 Left = 6480 TabIndex = 21 Top = 720 Width = 135 End Begin VB.Label Label8 Caption = "5" Height = 255 Left = 5640 TabIndex = 20 Top = 720 Width = 135 End Begin VB.Label Label7 Caption = "4" Height = 255 Left = 4800 TabIndex = 19 Top = 720 Width = 135 End Begin VB.Label Label6 Caption = "3" Height = 255 Left = 3960 TabIndex = 18 Top = 720 Width = 135 End Begin VB.Label Label5 Caption = "2" Height = 255 Left = 3120 TabIndex = 17 Top = 720 Width = 135 End Begin VB.Label Label4 Caption = "1" Height = 255 Left = 2280 TabIndex = 16 Top = 720 Width = 135 End Begin VB.Label Label3 Caption = "0" Height = 255 Left = 1440 TabIndex = 2 Top = 720 Width = 135 End Begin VB.Label Label2 Caption = "Frequency" Height = 255 Left = 120 TabIndex = 1 Top = 1200 Width = 855 End Begin VB.Label Label1 Caption = "Counter" Height = 255 Left = 360 TabIndex = 0 Top = 720 Width = 615 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Public DeviceIndex As Long Public DetectOK As Boolean Private Sub Command1_Click() Dim count As Integer 'set counter 13 low so it will not be gating the other counters yet CTR_8254Mode DeviceIndex, 0, 13, 0 CTR_8254Mode DeviceIndex, 0, 14, 0 For count = 0 To 12 CTR_8254ModeLoad DeviceIndex, 0, count, 2, -1 Next count 'we are putting counters 13 and 14 together to create 1 ' 32 bit counter. Loading them with 10,000 and 1,000 gives ' a total divisor of 10,000,000 and a frequency of 1 Hz ' this results in a known gate signal of .5 seconds CTR_8254ModeLoad DeviceIndex, 0, 13, 3, 10000 CTR_8254ModeLoad DeviceIndex, 0, 14, 2, 1000 CTR_8254SelectGate DeviceIndex, 13 Timer1.Enabled = True End Sub Private Sub Form_Load() Dim OutMask As Byte Dim I As Integer Dim Status As Long DeviceIndex = diOnly Status = CTR_8254Mode(DeviceIndex, 0, 0, 0) If Status <> 0 Then Call DetectForm.Show(vbModal, Me) If DetectOK = False Then Unload Me Exit Sub End If End If End Sub Private Sub Timer1_Timer() Dim values(15) As Integer Dim count As Integer Dim Status As Long Dim temp As Long values(15) = 1 CTR_8254ReadLatched DeviceIndex, values(0) If values(15) <> 0 Then 'if the last one is 0 there is no new data to grab 'The screwed up math inside this for loop is because VB sucks 'and doesn't have unsigned types For count = 0 To 12 temp = values(count) temp = temp And &HFFFF& freqEdit(count).Text = (65535 - temp) / 0.5 Next count End If End Sub