LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time elapsed not keeping correct time/Hz problem

I am writing a program to measure voltages. The program should run as such(in this order):

 

1. Ask where to save data where to save data (only once)

2. Wait until "Start Scan" is pressed

3. Take the scan for inputed seconds at inputed Hz

4. Save the results in Excel file

5. Go back to 2

 

This all works, just not well. The first time I run the program, it runs for the correct amount of time. However, after one full "cycle" (the second time step two is executed) when you press the Start Scan, it runs for somewhere around half the time it should. Any ideas on this?

 

The Second problem is with the Hz the data is sampled. I understand that since I am reading three channels it is slower than what is should be, but it is still nowhere near where it should be. I am using a DAQ USB 6009 which can run up to 30kHz if I remember correctly. But when I run it at 100Hz for ten seconds, it would make sense to get maybe 333 data points, however, I get somewhere around 460. I know that the Hz doesn't really line up with real seconds, but what do I need to do to make this work in a more rational way? What limits the actual Hz this is taken at?

 

Feel free to answer either of these questions. Thanks

 

 

 

0 Kudos
Message 1 of 7
(2,903 Views)

Reset the "elapsed time" express VI when the iteration is zero. (wire an "equal zero" between the [i] of the while loop and the reset terminal).

 

(If you don't do this, the time will be measured from the last time it reset, i.e. after the last iteration of the prevoious execution of the loop).

 

While you're at it, get rid of some of the beginner code, e.g. the CPU hogging empty polling loop. Look into a state machine architecture instead. Also, with proper wiring, none of your sequence frames are needed. They just clutter the diagram. What's up with the wire going out of frame 1 and entering back into frame 2 of the big flat sequence. There is probably a shorter way ;).

Also don't operate on paths as strings. Can you explain the meaningless gymnastics with the .xls extension??

Message Edited by altenbach on 11-29-2009 01:20 AM
Message 2 of 7
(2,892 Views)
You should also be aware that the Write to Spreadsheet File does not produce an Excel file. It is a poorly named VI that we have been dealing with for almost 20 years. It produces a delimited text file that you can open with Excel. If you absolutely have to have an Excel workbook then you need to use ActiveX to create workbooks. See the examples that ship with LabVIEW as well as the Excel thread for more information. (Please note that the Excel thread is just a repository of links - do not ask questions on how to do something in that thread.)
0 Kudos
Message 3 of 7
(2,875 Views)

Yeah I have never really had a use for this program (LabVIEW) before so it is totally strange to me. So from what I am hearing you think it is best for me to rewrite this program. I guess I will try the state architecture like you suggested. The program I had attached before was sort of a combination of many smaller programs I found on these forums so yeah it probably doesn't make the most amount of sense.

When I do rewrite this, I guess I would like to know two things. What is the fastest way to get the data from three channels (I bet the Express package isn't the best way) and how would you suggest saving the data?

0 Kudos
Message 4 of 7
(2,870 Views)

Hi R Redford,

 

The DAQ Assistant is probably going to be the quickest and easiest way to get data from your hardware, however, the DAQ Assistant is a configuration utility and lacks much of the flexibility you can get from using the DAQmx VIs. If you want to learn how to program with the DAQmx VIs, you can start with the example programs at Help >> Find Examples within LabVIEW.   When the Example Finder opens, double click Hardware Input and Output >> DAQmx >> Analog Measurement >> Voltage >> Cont Acq&Graph - Write Data to FIle (TDMS).vi.  This will show you how to write data to a file using the DAQmx VIs.

Regards,
Jim Schwartz
Message 5 of 7
(2,830 Views)
The examples that show the DAQmx 9.0 feature of logging to disk are all called "TDMS Streaming - ..."  These examples show the easiest and fastest way to log data to disk.  Just by calling the DAQmx Configure Logging VI, data will be logged to disk every time you call DAQmx Read.
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 6 of 7
(2,818 Views)

I have taken altenbach's advice and switched to state arch as well as tried to switch to a producer and consumer setup on the advice of a friend. However, I don't think that this is fast enough. I guess my problem is that I am trying to read from three channels so I am not sure if I can ever get this program to run at the labeled max speed of the DAQ. (All of this wiring is in the "Start Scan" frame of the arch) Is there a better way to maximize the speed at which the data is taken.I know someone else suggested ditching the Express VI for taking voltage and jus setting it up manually. For my applicaiton is that something that needs to be done?

Also, I am sure there is a better way to wire the things I already have and any specific advice on that would be appreciated.

0 Kudos
Message 7 of 7
(2,639 Views)