05-14-2012 06:43 PM
What I have is a VI that measures pressure continuously from a cDAQ 9237 and records to a file. I react on that feedback data to open/close 4 solenoids as required with a cDAQ 9481. I have an early version showing the data path below. I display the data realtime to a waveform chart. I'm sure its just some settings, but I have not figured it out yet. Does anyone know why my chart looks like this?
05-14-2012 08:45 PM
Post your .vi so we can see how your Express VI's are configured.
05-14-2012 08:48 PM
Sorry about that.
05-14-2012 09:00 PM
One thing is that your DAQ assistant is set to read N samples. That means it waits to read N samples, then returns them. Then you proceed further to process the data and send it to a file. Your waveform is continuing, but you aren't collecting samples during that time. Then when you get back around to the DAQ assistant, then it starts collecting the N samples again. Anything that happened in between calls of the DAQ assistant are loss.
The longer your code takes to run, the longer the gaps will be. So writing data to the file takes time. Or having a wait in the time delay VI. You may want to consider using a producer/consumer architecture to send the data to a separate while loop by way of queues to save the data to the file.
The horizontal lines are odd. I don't know if it is a visual defect on plotting, or something else.
05-14-2012 09:32 PM
Hello Ravens, thanks for the response.
Interestingly, I had attempted to read continuously before and received errors while compiling the express vi. I dont recall the error, but NI tech support suggested to use the N samples with my cDAQ 9237. I just tried again, and was able to compile with continuous samples for the first time. I can not explain that. Obviously, the chart appears better in this configuration. I think I will need to play with the Samples to Read and Rates now, as it tends to hang after a few seconds with buffer errors now. I would like to read the sensor relatively fast for the control but not write all the data; maybe down sample somehow. I have not seen the horizontal lines in this configuration yet.
I agree that this code will not collect samples between calls of the DAQ assistant... and is not very clean to begin with. Its my first round at a controls program and state machine as well. I appreciate any and all critiques at this point.
I am unaware of the producer/consumer architecture you mention. I do have concerns with data loss during any holds, so I will look into this.