Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP ! simple program to generate sqaure wave using VB6

I wrote a program to generate sqaure wave in DAQ PCI-6259 using VB6. There is no error to the program, but no signal found in the ocillator. What is the problem?
 
here is my code:
 
Private Sub Command1_Click()
    Dim channel As String
    Dim minVoltage, maxVoltage As Double
    Dim samplesPerChannelPerWrite As Long
    Dim sampleRate As Double
    Dim sampleMode As Long
   
    Dim temp As Long
   
   
    ' Get values from UI controls
    channel = "Dev1/ao0"
    minVoltage = -10
    maxVoltage = 10
    samplesPerChannelPerWrite = 100
    sampleRate = 1000
   
    ' Configure the task
    temp = DAQmxCreateTask("", taskhandle)
    temp = DAQmxCreateAOVoltageChan(taskhandle, channel, "", minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts, vbNullString)
    temp = DAQmxCfgSampClkTiming(taskhandle, "", sampleRate, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, samplesPerChannelPerWrite)
   
    temp = DAQmxWriteAnalogF64(taskhandle, samplesPerChannelPerWrite, False, -1, DAQmx_Val_GroupByScanNumber, waveform(0), samplesPerChannelPerWrite, vbNullString)
   
    ' Start the DAQmx Task
    DAQmxStartTask (taskhandle)
   
End Sub
 
Private Sub Command2_Click()
DAQmxClearTask (taskhandle)
End Sub
 
Private Sub Form_Load()
analog_signal
End Sub
0 Kudos
Message 1 of 2
(7,145 Views)

Hi,

If this is all of your code, then you seem to be missing the section where you generate your array of values to create the square wave. If that has been generated, how so? Either way, check out the ContGenVoltWfmIntClk example that installs with VB support. It's a great place to get started -

C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Analog Out\Generate Voltage\Cont Gen Volt Wfm-Int Clk

 Let us know if this doesn't work for you.

Andrew S

0 Kudos
Message 2 of 2
(7,129 Views)