LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sampclktiming??? How to use??

Solved!
Go to solution

Hi,

 

I tried just to use DAQmxSamplClkTiming with the Onboard Clock to set my Output frequence of my DO Signals. But I received an error like my software couldn't find the path or something like that. So I tried to set an AI Clock to sample my DO Signal.

My Understanding is:

 

I set the AI Clock to 100KHz. This is my maximum. Then I set another clock to control my output frequency. How does the clock and timing stuff actually works? I think didn't get it correct. Could you explain it to me and pls don't give me a link to an example.

 

thanks

0 Kudos
Message 11 of 18
(1,264 Views)

 NON-FATAL RUN-TIME ERROR:   "Digital_Output.c", line 395, col 13, thread id 0x00001400:   Function DAQmxWriteDigitalU32: (return value == -89120 [0xfffea3e0]). Source terminal to be routed could not be found on the device.  Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names. Property: DAQmx_SampClk_Src Property: DAQmx_SampClk_ActiveEdge Source Device: Dev1 Source Terminal: OnboardClock  Task Name: _unnamedTask<0>  Status Code: -89120

0 Kudos
Message 12 of 18
(1,260 Views)

DAQmxCfgSampClkTiming (WALSHPWMOUPUT, "OnboardClock", 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, samplesize*8);
        
            DAQmxWriteDigitalU32 (WALSHPWMOUPUT, samplesize, 0, 10.0, DAQmx_Val_GroupByChannel, data, &written, 0);

0 Kudos
Message 13 of 18
(1,259 Views)

 NON-FATAL RUN-TIME ERROR:   "Digital_Output.c", line 395, col 13, thread id 0x00000B64:   Function DAQmxWriteDigitalU32: (return value == -89120 [0xfffea3e0]). Source terminal to be routed could not be found on the device.  Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names. Property: DAQmx_SampClk_Src Property: DAQmx_SampClk_ActiveEdge Source Device: Dev1 Source Terminal: NULL  Task Name: _unnamedTask<0>  Status Code: -89120

 

 

DAQmxCfgSampClkTiming (WALSHPWMOUPUT, "NULL", 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, samplesize*8);
        
            DAQmxWriteDigitalU32 (WALSHPWMOUPUT, samplesize, 0, 10.0, DAQmx_Val_GroupByChannel, data, &written, 0);

0 Kudos
Message 14 of 18
(1,258 Views)

I'm not sure about OnBoardClock, but NULL is surely different from "NULL":

 

  • NULL is a macro that is translated to a nul value
  • "NULL" is a string that in this case is intrepreted as a channel name, which of course does not exist

I suppose the same applies to OnBoardClock.

Try again without quotes... Smiley Wink



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 15 of 18
(1,249 Views)

I did try without strings but I still receive an error. This is my error:

 

 NON-FATAL RUN-TIME ERROR:   "Digital_Output.c", line 401, col 13, thread id 0x00000ED0:   Function DAQmxWriteDigitalU32: (return value == -200303 [0xfffcf191]). External sample clock source must be specified for this application. Task Name: _unnamedTask<0>  Status Code: -200303

I tried with Counter Pulse Frequency with "Dev1/freqout" and set my Sampling Clock Timing of my Signal to "Dev1/PF14" is this a correct way to do it?

 

            DAQmxCreateTask ("", &Timerfre);
            DAQmxCreateCOPulseChanFreq (Timerfre, "Dev1/freqout", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 10000, 0.5);
            DAQmxCfgImplicitTiming (Timerfre, DAQmx_Val_ContSamps, samplesize);
            DAQmxStartTask(Timerfre);


            DAQmxCreateTask ("", &WALSHPWMOUPUT);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line0", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line1", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line2", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line3", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line4", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line5", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line6", "", DAQmx_Val_ChanPerLine);
            DAQmxCreateDOChan (WALSHPWMOUPUT, "Dev1/port0/line7", "", DAQmx_Val_ChanPerLine);
            DAQmxCfgSampClkTiming (WALSHPWMOUPUT, "/Dev1/PFI14", 1000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, samplesize);
            DAQmxWriteDigitalU32 (WALSHPWMOUPUT, samplesize, 0, 10.0, DAQmx_Val_GroupByChannel, data, &written, 0);
            DAQmxStartTask(WALSHPWMOUPUT);
            DAQmxWriteDigitalU32 (WALSHPWMOUPUT, samplesize, 0, 10.0, DAQmx_Val_GroupByChannel, data, NULL, NULL);

0 Kudos
Message 16 of 18
(1,241 Views)

I am not sure about my Understanding of Clock and Timing. I try to exlpain it.

I need a rate to read my data into the hardware buffer. The size of my buffer depends on number of channels and samples. For example 8 Channels with each 300 samples. Thus my buffer has to be 8*300 big. Then my device has a rate to output my signal. We are talking about cont Samps. I create a Pulse Frequency Channel with 10kHz and I create a SaplingClock depends on the Pulse Frequency Channel. I read my samples with 10kHz into my buffer and output my signal with 10KHz as well. Why do I need the samplingclock.

What is exactly timing? a time unit?

 

On my Device USB 6221 I have 2 Counter/Timer with 80MHz Inputfrequency. What is this Input Frequency? At my DIOs I can software and hardware timing with each 1 MHz. My AI has 250 ks/s and can't sample silmutaneously. My AO has 833ks/s.

 

My Project is to have 8 AI and 8 DO output. DO depends on those 8 AI. Thus I have to sample my 8 AI silmutaneously which is not possible with my device. So I have to use multiplexing method.

I need a Clock for my 8 different AI and a Clock for my 8 different DO but I have to sychronize them and maybe I have to shift my AI sample due to delay of Signal.

 

 

0 Kudos
Message 17 of 18
(1,237 Views)

Hello Leee, as I already told you I do not have a board like yours to eprform tests nor I can simulate the USB board in Max, I can only create a simulated PCI-6221 board.

 

I tried to setup a process like you have done receiving the same errors as you, additionally I tried running some examples found on NI site both in CVI and LabVIEW with the same results, so it appears that to run DO generation you need to apply an external clock.

 

If this is true, you can go 2 ways:

 

  • If your DO and your AI have the same speed, you can use the AI sample clock as you have already tried as a clock for DO task
  • Alternatively, you can try using a counter to generate the clock and either route it internally or wire it on the connector to he appropriate PFI to use for DO

 

If you want to sincronize AI and DO with different sampling rate, your could build up a pattern for digital ouput that has several samples with the same value (e.g. if the rate of AI it twice the rate of DO, creating a DO buffer with all samples doubled will produce an output of the desired frequency).

 

Regarding the second scenario, I suggest you start by running some example for counter frequency generation and trim it to fit your needs; once this step is completed, you can add the DO generation using that signal as clock source. Going through DO generation examples that come with CVI and DAQmx can also give you some clue as to how to address this matter. You can simplify your code for example using a channel for the entire port: individual lines are driven according to the bit pattern of the variable you write to the task.

 

Regarding analog reading, it's true that your board is not a simultanoeus sampling one, but the timing difference between channels is very low and in the majority of applications you do not need to shift measurements to compensate



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 18 of 18
(1,229 Views)