LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem by writting into the device buffer

Solved!
Go to solution

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

0 Kudos
Message 1 of 4
(3,463 Views)

I forgot the following. You can see it here.

 

Best regards

 

 

0 Kudos
Message 2 of 4
(3,457 Views)

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

Kind Regards,

Thomas Gimpel
Application Engineer Intern
National Instruments
0 Kudos
Message 3 of 4
(3,409 Views)
Solution
Accepted by topic author Fasching_K

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

0 Kudos
Message 4 of 4
(3,401 Views)