VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 6330 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 6330 StartUpPosition = 3 'Windows Default Begin VB.CommandButton beginBTN Caption = "&Begin" Height = 375 Left = 2040 TabIndex = 2 Top = 1440 Width = 1455 End Begin VB.TextBox addrEDIT Height = 285 Left = 4560 TabIndex = 0 Text = "Text1" Top = 840 Width = 855 End Begin VB.Label infoLBL Caption = "Label2" Height = 975 Left = 240 TabIndex = 3 Top = 1920 Width = 5775 End Begin VB.Label Label1 Caption = "Enter the Base address in HEX and click BEGIN to start" Height = 255 Left = 240 TabIndex = 1 Top = 840 Width = 4095 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim BASE As Long Private Sub CtrMode(cntr As Byte, mode As Byte) Dim ctrl As Byte ctrl = (cntr * (2 ^ 6)) Or &H30 Or (mode * (2 ^ 1)) OutPortB BASE + 3, ctrl End Sub Private Sub LoadCtr(C As Long, Val As Long) OutPortB BASE + C, Val And &HFF OutPortB BASE + C, ((Val And &HFF00) / 256) And &HFF End Sub Private Function POW(x As Double, y As Long) As Double Dim count As Integer Dim total As Double total = x For count = 2 To y total = total * x Next count POW = total End Function Private Sub beginBTN_Click() Dim BUFFER(30000) As Long Dim count As Long If beginBTN.Caption = "&Begin" Then beginBTN.Caption = "STOP" BASE = "&h" + addrEDIT.Text '***************************************************** '** This for loop will fill the buffer with the following '** three wave forms and rescales them to have the same period: '** 1) sin(x^2) from x = -3.3 to 3.3 '** 2) cos(x^2) from x = -3.0 to 3.0 '** 3) sin(x^2) * cos (x^2) from x = -1.9 to 1.9 '***************************************************** For count = 0 To 9999 BUFFER(count * 3) = Sin(POW(-3.3 + (0.00066 * count), 2)) * 2047# + 2048# BUFFER(count * 3) = BUFFER(count * 3) And &HFFF BUFFER(count * 3 + 1) = Cos(POW(-3# + (0.0006 * count), 2)) * 2047# + 2048# BUFFER(count * 3 + 1) = BUFFER(count * 3 + 1) And &HFFF BUFFER(count * 3 + 2) = Sin(POW(-1.9 + (0.00038 * count), 2)) * Cos(POW(-1.9 + (0.00038 * count), 2)) * 2047# + 2048# BUFFER(count * 3 + 2) = BUFFER(count * 3 + 2) And &HFFF BUFFER(count * 3 + 2) = BUFFER(count * 3 + 2) Or &H2000 Next count BUFFER(29999) = BUFFER(29999) Or &H1000 'this is the end of the stream and the card needs to loop OutPortB BASE + &H1A, 0 'we will only be writing to the first 30k addresses 'so we get to leave bit 16 of the SRAM addr at 0 For count = 0 To 29999 OutPort BASE + &H18, (count * 2) 'set the address we are going to write to OutPort BASE + &H1C, BUFFER(count) 'write the value for that address Next count CtrMode 1, 2 'set counter 1 to mode 2 CtrMode 2, 2 'set counter 2 to mode 2 LoadCtr 1, 5 'load counter 1 to 5 ticks LoadCtr 2, 10 'load counter 2 to 10 ticks OutPortB BASE + &H10, &H41 'tell the card to start and enable the 'ARB Else OutPortB BASE + &H10, 0 'tell the card to stop beginBTN.Caption = "&Begin" End If End Sub Private Sub Form_Load() addrEDIT.Text = "300" infoLBL.Caption = "This program will output three wave forms from the 104-DA12-8." + vbCrLf infoLBL.Caption = infoLBL.Caption + "The wave forms will be output on DACS 0 - 2." + vbCrLf infoLBL.Caption = infoLBL.Caption + "The wave forms will stop when the user clicks stop or exits the program" End Sub Private Sub Form_Unload(Cancel As Integer) OutPortB BASE + &H10, 0 'tell the card to stop End Sub