07-26-2012 07:42 AM
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
07-26-2012 08:04 AM
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
07-26-2012 08:05 AM
DAQmxCfgSampClkTiming (WALSHPWMOUPUT, "OnboardClock", 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, samplesize*8);
DAQmxWriteDigitalU32 (WALSHPWMOUPUT, samplesize, 0, 10.0, DAQmx_Val_GroupByChannel, data, &written, 0);
07-26-2012 08:07 AM
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);
07-26-2012 03:01 PM - edited 07-26-2012 03:02 PM
I'm not sure about OnBoardClock, but NULL is surely different from "NULL":
I suppose the same applies to OnBoardClock.
Try again without quotes...
07-27-2012 02:39 AM
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);
07-27-2012 03:01 AM
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.
07-27-2012 05:52 AM
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 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