Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI 6534 sampling clock rate change and sinusoidal wave generation (Visual Basic)

Hello,

 

I have been trying to develope a program that acquires a data array for a sinusoidal function then output it into an oscilloscope.

 

I was successful on creating waves for certain amount of time,

but I was unsuccessful when trying to create the wave for more than couple milliseconds off the memory.

 

I could think of changing the sampling clock rate for the PCI 6534 card to lower clock rates such that

each datapoint would register in a longer period of time, but I was unsuccessful in this procedure.

 

I've read some other forums and it seems that I should be using a "DIG_BLOCK_PG_CONFIG" command somewhere.  

 

The following is the code for it without the PG_CONFIG.

 --------------------


    iDevice% = 1
    iGroup% = 1
    iGroupSize% = 4         'Configuring all ports in one group for output
    iPort% = 0
    iDir% = 1
    iSignal% = 3            'assigns burst handshking
    iEdge% = 0
    iReqPol% = 0
    iAckPol% = 0
    iAckDelayTime% = 7     ' 50 ns PCLK period
    ulRemaining& = 1
    iIgnoreWarning% = 1
    lTimeout& = 180

    '     This sets a timeout limit (#Sec * 18ticks/Sec) so that if there is
    '     something wrong, the program won't hang.
 
    iStatus% = Timeout_Config(iDevice%, lTimeout&)

    iRetVal% = NIDAQErrorHandler(iStatus%, "Timeout_Config", iIgnoreWarning%)
           
    If (iStatus% = 0) Then
           
        ' Configure group of ports as output, with handshaking.

        iStatus% = DIG_Grp_Config(iDevice%, iGroup%, iGroupSize%, iPort%, iDir%)

        iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Grp_Config", iIgnoreWarning%)

 

        ' Configure group handshaking parameters for burst, active high request
        '  and active high acknowledge (REQ1 needs to be tied to +5V) with delay.

        iStatus% = DIG_Grp_Mode(iDevice%, iGroup%, iSignal%, iEdge%, iReqPol%, iAckPol%, iAckDelayTime%)

        iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Grp_Mode", iIgnoreWarning%)

 

        ' Setup the device for internal clock, PCLK1

        iStatus% = Set_DAQ_Device_Info(iDevice%, ND_CLOCK_REVERSE_MODE_GR1, ND_ON)

        iRetVal% = NIDAQErrorHandler(iStatus%, " Set_DAQ_Device_Info ", iIgnoreWarning%)

        If (iStatus% = 0) Then
       
            'Send out all waveform samples (TOTAL_SAMPLES) plus two counter reset command plus one stop writing-to-memory command
            iStatus% = DIG_Block_Out(iDevice%, iGroup%, Data_Array(0), Number)

            iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Block_Out", iIgnoreWarning%)

            While ((ulRemaining& <> 0) And (iStatus% = 0))

                iStatus% = DIG_Block_Check(iDevice%, iGroup%, ulRemaining&)

                DoEvents

            Wend
           
            iRetVal% = NIDAQErrorHandler(iStatus%, "DIG_Block_Check", iIgnoreWarning%)
           
            ' CLEANUP - Don't check for errors on purpose.

            ' Clear the block operation.

            iStatus% = DIG_Block_Clear(iDevice%, iGroup%)
           
            'Call PrintText(formMain.txtStatusBox, "Channel " + Str$(Loading_Channel + 1) + " Memory has been loaded! ")
           
        Else

            Call PrintText(formMain.txtStatusBox, "Error loading memory! ")

        End If
       
        ' Unconfigure group.
 
        iStatus% = DIG_Grp_Config(iDevice%, iGroup%, 0, 0, 0)
      
    End If

    ' Disable timeouts.

    iStatus% = Timeout_Config(iDevice%, -1)

    'CurrentPortC = Data_Array(Number - 1)
    'CurrentPortD = Data_Array(Number - 1)
 

 

--------------------- 

 

 

If someone could please help with a solution for this problem, it would be awesome.

 

Thanks,

John

 

0 Kudos
Message 1 of 5
(3,656 Views)

John,

 

Could you clarify for me exactly what you are trying to do with your Visual Basic code. I understand that you are acquiring a digital array. I am then guessing you are doing some manipulation to the data, then output that digital array to an oscilloscope. Is your question with how to set a slower acquisition time with the PCI 6534? Or are you trying to set the output rate of your digital out to a lower value so that the values will stay on the port longer giving you more time to acquire them with the scope? 

 

The "DIG_BLOCK_PG_CONFIG" will change the pulse width of the clock on REQ line, so I am not sure if that would help you or not. 

 

Any clarification you could give would help me understand your application better.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 5
(3,631 Views)

John,

 

I would also like to Add to what Aaron mentioned above.  If you are just starting your application, I would recommend switching to DAQmx.  It is easier to program with and you will run into less problems when operating with multi-core computers.

 

Jesse O. | National Instruments R&D
0 Kudos
Message 3 of 5
(3,627 Views)

Aaron, thank you for the hand!

 

Right now, I'm just trying to make one sine wave consisting of an arbitrary number of data points to be longer than it is before.

The problem I have right now lies within the memory, where I don't have enough data points...

(mainly the fact that I cannot port a set of points that correspond to one full second, since I'm running on 20MHz sampling clock.)

 

So I would like to have an idea to start how to make something like 10000 data points correspond to 1.0 second, rather than something like 0.5 millisecond.

(0.5 millisecond being 20MHz for each, 10000 data points.)

 

Other than this, I would say that my program is just a simple sine-wave generator.

It first creates an array containing the sine wave data

This is stored into the onboard memory, then ported out to the oscilloscope.

 

Thanks for any help! 😃

 

 

 

Jesse, I will take your advice and use DAQmx in the future.

Right now, the program that my coworkers coded is in visual basic, and I have no choice but to get helped in visual basic!

 

Thank you guys for your concerns,

best wishes for the new year.

 

-John

0 Kudos
Message 4 of 5
(3,614 Views)

John,

 

When we suggest switching to DAQmx we are just suggesting using the DAQmx driver in addition to your VB Code. The DAQmx driver has support for Visual Basic and will make your controlling of the card much easier. I linked a web page that gives some examples for writing VB with the DAQmx driver. You will still be able to program in VB but this will just make it easier. The examples will shed some light on how to control the clock rate of your output. 

 

NI-DAQmx Examples for Visual Basic 6.0

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 5 of 5
(3,598 Views)