07-24-2012 04:09 AM
Hi,
I tried a lot and read a lot but I still getting this error massage:
NON-FATAL RUN-TIME ERROR: "malloctest.c", line 198, col 25, thread id 0x00001764: Function DAQmxWriteDigitalU32: (return value == -200292 [0xfffcf19c]). Some or all of the samples to write could not be written to the buffer yet. More space will free up as samples currently in the buffer are generated. To wait for more space to become available, use a longer write timeout. To make the space available sooner, increase the sample rate. Property: DAQmx_Write_RelativeTo Corresponding Value: DAQmx_Val_CurrWritePos Property: DAQmx_Write_Offset Corresponding Value: 0 Task Name: out Status Code: -200292
I tried all those suggestions but I still getting the same error.
What is my mistake? Do I have to create a own Task for SampClkTiming? By the way I am using USB 6221 and I am trying to have two silmutaneous DO Signals.
array has a size of 60 elements. array=[data1,data2]
DAQmxCreateTask ("out", &task);
DAQmxCreateDOChan (task, "Dev1/port0/line0", "", DAQmx_Val_ChanPerLine);
DAQmxCreateDOChan (task, "Dev1/port0/line1", "", DAQmx_Val_ChanPerLine);
DAQmxCfgSampClkTiming (task, "/Dev1/PFI0", 30, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 60);
DAQmxWriteDigitalU32(task, 30, 0, 10.0, DAQmx_Val_GroupByChannel, array, &written, NULL);
DAQmxStartTask (task);
while(loop)
{
ProcessSystemEvents();
if(loop==1)
{
DAQmxWriteDigitalU32 (task, 30, 0, 10.0, DAQmx_Val_GroupByChannel, array, NULL, NULL);
ProcessSystemEvents();
}
}
Solved! Go to Solution.
07-24-2012 08:24 AM
Hello Leee, as you can see in the help for the function, DAQmxCfgSampClkTiming expects either a channel name in Source parameter or NULL (or OnboardClock, which is the same). In the first case you must provide the clock signal at the stated input terminal; in the latter one the board operates with its own internal clock. Since you stated to use PFI0 as the source, you must provide the clock signal, or the timeout is the very expected error you may receive.
Additionally, have you read my answer to your other thread? It is the very same question, so it's better you continue with the original thread instead of opening more and more times the same topic.
07-24-2012 09:25 AM
Hi,
how do I provide a clock signal?
//DAQmxCreateCOPulseChanFreq (CLK, "Dev1/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 1000000, 0.5);
//DAQmxCfgImplicitTiming (CLK, DAQmx_Val_ContSamps, 30);
//DAQmxCfgDigEdgeStartTrig (CLK, "/Dev1/PFI0", DAQmx_Val_Rising);
I tried using Onboardclock but I recieved:
NON-FATAL RUN-TIME ERROR: "malloctest.c", line 175, col 14, thread id 0x00000470: 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
07-24-2012 10:02 AM
Simply put NULL in Source parameter and do nothing else: DAQmx will automatically configure the internal clock for this task.
07-24-2012 10:07 AM
I did but still receiving the same error
07-24-2012 10:08 AM
NON-FATAL RUN-TIME ERROR: "malloctest.c", line 176, col 14, thread id 0x00000758: Function DAQmxWriteDigitalU32: (return value == -200303 [0xfffcf191]). External sample clock source must be specified for this application. Task Name: _unnamedTask<0> Status Code: -200303
07-24-2012 10:20 AM
What if you specify a input terminal and provide a square wave clock? Try not to use a counter from the same board: some tasks may conflict in internal resource usage and generate errors.
Have you other input / output tasks running at the same time?
Unfortunately I haven't a daq board at the moment in my hand so I cannot test it other than on simulated devices.
07-24-2012 10:29 AM
could you give my an example link and by the way are there any other methods to have silmutaneous Do signals instead of using just one task. I would like to change them on the fly.
07-25-2012 08:21 AM
This is my new code:
DAQmxCreateTask ("", &task);
DAQmxCreateTask ("CLK", &CLK);
DAQmxCreateTask ("AI", &AI);
DAQmxCreateAIVoltageChan (AI, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, -5.0, 5.0, DAQmx_Val_Volts, "");
DAQmxCfgSampClkTiming (AI, "OnboardClock", 100000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 10);
DAQmxCreateDOChan (task, "Dev1/port0/line0", "", DAQmx_Val_ChanPerLine);
DAQmxCreateDOChan (task, "Dev1/port0/line1", "", DAQmx_Val_ChanPerLine);
//DAQmxSetWriteAttribute (task, DAQmx_Write_RegenMode, DAQmx_Val_AllowRegen);
DAQmxCfgSampClkTiming (task, "/Dev1/ai/SampleClock", 10, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);
DAQmxWriteDigitalU32 (task, 30, 0, 10.0, DAQmx_Val_GroupByChannel, array, &written, NULL);
DAQmxStartTask (AI);
DAQmxStartTask (task);
DAQmxWriteDigitalU32 (task, 30, 0, 10.0, DAQmx_Val_GroupByChannel, array, NULL, NULL);
Rate in SampClkTiming of "AI" sets my frequency. The other values what are there for? Because I changed them and my output didn't change.
How do I create a dynamic output. Using "DAQmxSetWriteAttribute"? Are there any examples?
greeting
07-25-2012 10:37 AM
It's not clear to me whether your configuration is safe or not.
On the first DAQmxCfgSampClkTiming you configure an analog acquisition at 100 kHz, continuous acquisition. The last parameter, 10, is used in this case for internal dimensioning of the buffer. You may have errors if you do not read fast enough from this task (samples overridden before being read or similar error) unless there is a implicit minimum size for the buffer that saves this situation.
On the second line, you specify the use of the same clock for digital output: I never used such a configuration so I don't know whether it is intended as external or internal clock. In both cases, the DO should happen at the same 100 kHz rate.
So the question is: are you effectively using the analog acquisition or it is used only for timing? It should not be necessary to define another task only for timing the DO, but if you need to use it you should configure the application so that you do not receive errors in AI task, especially if this configuration must be sustained for a long time.
If your intention is to sincronize the tasks, you could try another way: set one task to start when the other one starts. This should permit to have different rates for the tasks and guarantee the sync.