LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6008 LABVIEW 8.2. SINGLE CHANNEL INPUT VOLTAGE WITH DBL OUTPUT COMPARISON

Solved!
Go to solution

 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.

0 Kudos
Message 1 of 10
(2,914 Views)

STOP SCREAMING AT US.

 

This seems fairly simple. What have you done so far? Please upload your code.

0 Kudos
Message 2 of 10
(2,913 Views)

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.

0 Kudos
Message 3 of 10
(2,907 Views)
Solution
Accepted by topic author BWMPDINC

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.

Message 4 of 10
(2,899 Views)

Thanks I will give that a try.

0 Kudos
Message 5 of 10
(2,896 Views)

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.

0 Kudos
Message 6 of 10
(2,876 Views)

Hi BWM,

 

- you need to read more samples per iteration to avoid buffer overflow!

 

Also you should read again what Dennis told you about wiring that MinMax function, it seems you missed some points...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 10
(2,870 Views)

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

0 Kudos
Message 8 of 10
(2,860 Views)

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.

Message 9 of 10
(2,855 Views)

Got it! Thank you all. I was trying to way over complicate things, overanalyzing. But thanks again.

0 Kudos
Message 10 of 10
(2,850 Views)