Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I generate a single pulse in a digital output (not a PFI) without using the counter.

Can someone help me to generate a single pulse in a digital output (not a PFI) of the PCI6251 board without using its counters?
0 Kudos
Message 1 of 12
(5,060 Views)
What kind of pulse width are you looking for and how accurately do you need to control pulse width?
0 Kudos
Message 2 of 12
(5,040 Views)
The pulse width must be 80ms +/-  1%.
0 Kudos
Message 3 of 12
(5,038 Views)
Using software timing, you won't be able to count on hitting your target pulse time within 1% (less than a msec in this case).  You would have to use "correleated DIO" with one of the lines from port 0.
 
This type of hardware-timed DO task cannot generate its own sample clock however -- it needs to borrow one from another task or from an external source.  What other tasks are running on your multifunction board in this app?  Maybe you can borrow one of their clocks...
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 12
(5,026 Views)
Kevin is right about software timing.  I think I would consider creating a task to output a digital 1D array or waveform and let the task use a clock in the DAQ hardware.  How critical is the timing of when the pulse starts/happens?
0 Kudos
Message 5 of 12
(5,019 Views)

Hi Centerbolt

I already created a task to output a digital 1D array or waveform, but the pulse do not appeared in the terminal.  Could you see some problem in the attached code bellow?

Public Function GFUNC_booCreateDOPulse() As Boolean

    Dim LlngTaskHandle As Long 

    Dim LbytSamples(0 to 80 * 3 - 1) As Byte

    Dim LlngSamplesCounter As Long 
    Dim LlngSignalLevel As Long 
    Dim LlngDummy As Long

   
On Error GoTo GFUNC_booCreateDOPulseErr

   GFUNC_booCreateDOPulse = False

   ' Create the sample data (80 samples in low level + 80 samples in high level + 80 samples in low level)

   LlngSignalLevel = 0

  For LlngSamplesCounter = 0 To (80 * 3) - 1
                                            
      ' Invert the polarity each 80 samples                 
     If  (LlngSamplesCounter Mod 80 = 0) Then
                        
         If (LlngSignalLevel = 0) Then
                            
            LlngSignalLevel = 1
                                
       Else
                            
           LlngSignalLevel = 0
                            
        End If
                        
    End If
                    
    LbytSamples(LlngSamplesCounter) = LlngSignalLevel
                    
  Next LlngSamplesCounter

   ' Create a task
        
   If (DAQmxCreateTask("", LlngTaskHandle) >= 0) Then
        
      ' Create the digital output channel
        
      If (DAQmxCreateDOChan(LlngTaskHandle, "/Dev1/P0.3", "", DAQmx_Val_ChanForAllLines) >= 0) Then
                            
        ' Create the timming: sample rate 1000S/s,  # Samples = 3 * 80 

         If (DAQmxCfgSampClkTiming(LlngTaskHandle, "20MHzTimebase", 1000, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_FiniteSamps, 80 * 3)>= 0) Then
                                       
            ' Write the SAMPLES

             If (DAQmxWriteDigitalLines(LlngTaskHandle, LlngPulseWidth * 3, True, 3, DAQmx_Val_GroupByScanNumber, LbytSamples(0), LlngDummy, ByVal 0) >= 0) Then
                    
                 If ( DAQmxWaitUntilTaskDone(LlngTaskHandle, 3) >= 0) Then
                 
                      If (DAQmxClearTask(LlngTaskHandle) >= 0) Then

                             ' End of pulse generation
   

0 Kudos
Message 6 of 12
(4,992 Views)
Sorry, I don't program using text based entry.  Perhaps someone with experience can look at your code and find the problem. 
0 Kudos
Message 7 of 12
(4,980 Views)
I'd venture that the problem is in the line containing:
DAQmxCfgSampClkTiming(LlngTaskHandle, "20MHzTimebase", ...
Digital tasks can't derive their sample clocks directly from any of the onboard clocks.  They can only borrow from another task or some external signal. Possible sources on an M-series board are the the sample clock from an AI or AO task, the output from a counter pulse train task. or a PFI pin that is externally wired to a TTL frequency source.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 8 of 12
(4,971 Views)
Hi NDBorrego,

"/Dev1/P0.3" isn't a valid DAQmx physical channel string, so DAQmxCreateDOChan is probably returning an error which your program isn't reporting. DAQmx terminals start with a leading slash but DAQmx physical channels do not, and the software uses "port0/line3" to represent P0.3. Try "Dev1/port0/line3" instead.

"/Dev1/20MHzTimebase" may sort of work as a DO sample clock but it exceeds the board's DIO specifications because its frequency is 20 MHz. For the clocked DIO on M Series, the rate parameter to DAQmxCfgSampClkTiming tells DAQmx what frequency the clock is running at. By passing 1000 to DAQmxCfgSampClkTiming you are telling DAQmx that the 20 MHz timebase is running at 1000 Hz (which it is not). I think that DAQmx will error if you set the sample clock source to 20MHzTimebase and you set the sample clock rate to anything other than 20000000.

If you want a DIO sample clock that doesn't consume a general purpose counter, you can create a continuous CO pulse train task on the physical channel "Dev1/freqout" and then specify "/Dev1/FrequencyOutput" for your DO sample clock. The frequency output counter is a very limited 4-bit counter that can only generate continuous pulse trains, but it's useful as a DIO sample clock.

Brad

Message Edited by Brad K on 10-26-2007 07:29 PM

---
Brad Keryan
NI R&D
0 Kudos
Message 9 of 12
(4,963 Views)
Minor correction to my last post: the error check I mentioned (when SampClk.src== 20MHzTimebase and SampClk.Rate != 20000000) only happens for AI. With AO or DIO, I get an underflow error as soon as I start the task, not "Sample Clock Rate must match the frequency of the internal timebase specified as the Sample Clock Source".

Brad
---
Brad Keryan
NI R&D
0 Kudos
Message 10 of 12
(4,956 Views)