07-11-2012 12:42 PM
I AM TRYING TO WRITE A PROGRAM THAT USES A SINGLE ANALOG INPUT CHANNEL OF THE USB-6008. I WANT TO CONTINUOUSLY READ THE VOLTAGE FOR 60 SECONDS. I WANT TO COMPARE ANY ONE VOLTAGE TO THE PREVIOUS VOLTAGE OF THAT SAME CHANNEL, ESSENTIALLY TO GET THE MAX VOLTAGE OF THE GIVEN TIME FRAME AND THEN GET A FINAL VOLTAGE READING. THE OUTPUT OF THE VI IS A DBL. I ONLY WANT TO EXPORT THE TWO VOLTAGES TO EXCEL. TO SAVE TIME I KNOW HOW TO DO THE EXPORT. CAN SOMEONE HELP ME OUT WITH THIS ONE.
Solved! Go to Solution.
07-11-2012 01:03 PM
STOP SCREAMING AT US.
This seems fairly simple. What have you done so far? Please upload your code.
07-11-2012 01:22 PM
Sorry about the screaming it is a habit....all of our documents have to be typed in all caps. Here is the attachment, hopefully it uploaded.
07-11-2012 01:47 PM
The VI needs a shift register wired to the Max & Min function. The current value would be the y input and the x input is the shift register from the left. The max value gets wired to the shift register on the right. Don't forget to initialize it. The output of the shift register is the max you would write and wiring the value of the DAQmx Read out of the loop will give you the last reading.
Your wait of 45 seconds makes no sense since you said you wanted to read continuously. You also said you wanted to read for 60 seconds and all of that logic is missing. A simple Elapsed Time function is all that you need.
07-11-2012 01:53 PM
Thanks I will give that a try.
07-13-2012 07:01 AM
I ended up building a comparison circuit using the get time function to get the timing because I couldn't get the elapsed time vi to work the way I thought it should. I also tried adding shift registers etc. I then started getting the error code
(Error -200279 occurred at DAQmx Read (Analog 1D Wfm NChan NSamp).vi:9) Possible reason(s):
Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: RelativeTo
Corresponding Value: Current Read Position
Property: Offset
Corresponding Value: 0
I tried rewiring everything using the daqmx timing vi., I tried using the daqmx assistant, I also tried adjusting the sample rate and time out functions, and of course I tried modifying the code as you said, Unless I missed something, which is very possible. I will upload just that portion of the circuit.
07-13-2012 07:18 AM - edited 07-13-2012 07:18 AM
07-13-2012 08:39 AM
I do apologize...I am still a novice using this software. I did however go back and look at Dennis' suggestions and studied it some more and realized I had completely misinterpreted what he was saying. The good thing is that it works now, increasing the number of samples took care of the error code. The only thing I still don't get is the elapsed time vi. That would save me a lot of time in the future if I could get it to operate. Is there any way I could get someone to upload an example of very simple elapsed time vi.
Thanks for all your help.
Bobby
07-13-2012 09:39 AM
Your first example had a single sample read. To use the elapsed time function, all you had to do was wire the Time Has Elapsed Output to the termination terminal.
Your second does not do what you asked for - take samples for 60 seconds. The timeout of 60 is not at all the same thing. Please read the help. If you want to read multiple samples at the same time, set the sample rate and then set the number of samples to read to be the same. Basic arithmetic says that will give you 60 seconds worth of samples. No loop required.
07-13-2012 10:45 AM
Got it! Thank you all. I was trying to way over complicate things, overanalyzing. But thanks again.