07-21-2016 06:14 AM
Hello,
I have a problem with writing some values to a analog output. You can see the code in the following.
So my problem is, when I call the function PostHolding(0.004), I put some values in a array and at the end of this function I write the array into the device buffer for the analog output.
The call is this: DAQmxErrChk(DAQmxWriteAnalogF64 (taskHandle, (PostHoldingTime*SampleRate), 0, 10.0, DAQmx_Val_GroupByScanNumber, PostHoldingArray, NULL,NULL));
I checked the array and the number of values for each channel and there is everything ok.
So now I come to the for loop and the if clause (array has the right values). With generatePatter() I generate a pattern, this is a global one. The return value shows me how many values are in the pattern. When I call now DAQmxErrChk(DAQmxWriteAnalogF64 (taskHandle, (newPointer-g_Pointer), 0, 10.0, DAQmx_Val_GroupByScanNumber, g_TotalPattern, NULL,NULL)); it should write my new pattern likewise into the device buffer. When I start the task I should see the first array from the PostHolding function and then the second array from the second function. And here is the problem I always see the array from the PostHolding function but not the second from the generatePattern(). I don't know where the failure is.
I have the same problem, when I call the PostHolding function (green in the picture) after the generatePatter() call. Here I see the signal from the generatePatter() function but not the signal from the PostHolding function.
I hope someone can help me?
Best Regards
Solved! Go to Solution.
07-21-2016 08:25 AM - edited 07-21-2016 08:25 AM
I forgot the following. You can see it here.
Best regards
07-26-2016 03:39 AM
Hi Fasching_K,
unfortunately it's not possible to write into the device buffer twice before you start the DAQmx Task. Because the DAQmxWriteAnalogF64 allocates the whole Device Buffer with one call.
So there are two options you can pursue.
1. Write your second Array into the device buffer after you've started the task
2. Combine the two arrays beforehand and write it into the buffer afterwards
Kind regards
Thomas
07-27-2016 12:52 AM - edited 07-27-2016 12:53 AM
Hello,
thank you for your answer. I found the failure already. When you create a channel you must say how many samples the channels gets. I forgot to calculate the additional samples to my first sample size.
DAQmxCfgSampClkTiming (taskHandle, "", SampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, Samples);
Best regards