03-20-2018 03:35 PM
Hello,
My goal is to update my analog output & digital output and then read my analog input in a Timed While Loop with the period being 10ms. The problem seems to be that if I make my buffer to big then I am getting "old data" that will then feed back into my PID. If I make it too small then it errors out after running for a few seconds.
Attached is my setup code.
Hardware
CDAQ-9132
NI-9264 AO
NI-9224 AI
NI-9474 DO
LV2016
Thanks,
Tony
03-21-2018 01:08 PM
Hi Tony,
How quickly are you acquiring the data, and how quickly are you reading it? Are you familiar with producer/consumer loops? This article will walk you through getting started with it. I recommend separating the consumer and producer functionality into separate while loops.
Let me know how that works for you!
03-21-2018 03:15 PM
Tim,
I am using a producer/consumer loop. The producer is running at 10ms and the consumer has no loop timer. The producer does the PID control at 10ms and only puts information in the queue every 50ms (or every 5 loops). My consumer loop runs varies from 5ms-30ms.
So I think I figured out my problem, this morning after dream about it last night lol. On the Read VI I changed it to read N_Sample N_Channels Waveform, I think before I was only reading 1 Sample N_Channels. I also changed the sample rate to 150Hz, Continuous and 2 samples on the timing VI.
Now when the producer loops I get either one or two samples of data but I just coheres it from a Waveform to a Double Array. This seem to be working very consistently.
VR,
Tony