07-20-2010 02:23 PM
Hi,
I'm a new user on labview and i have a problem with saving data from a signal to an excel spreadsheet.
I already have something that works, but doesn't work very well my .vi goes in attachment.
I also want to put another column with the elapsed time linked to the sample rate... every time i change the sample rate, the intervals between the elapsed time changes too, i dont know how to do this and i would be very appreciated if anyone could take a look at my .vi and see if there's a better and simple way to save data to excel.
i also have other problem but don't know if this is the right place to put it, i have a control to change the sample rate on my application, but when i open the saved data on the excel the number of values saved doesn't seem to match the sample rate, for example, i put 1000 hz for sampling rate, but only 200 values are stored...
any idea?
Hope anyone can help me.
07-20-2010 08:54 PM
Where is your sample rate ever defined? The only thing that determines the rate is how fast your while loop executes and the Emant300 Read Analog.VI (not attached) executes.
You have some odd program constructs in there. Why multiply by 1?
Why are you taking a scalar value in your case structure, building it into a 1-D array (which means it is a 1-element array), then ROTATING the array (I would believe rotating a 1-element array is going to give you the same array) before formatting to a string and writing it out?
07-21-2010 12:45 PM
This program was build by a collegue of mine last year and as i don't understand much of labview i didn't notice that. i already made a few changes in the application.
The sampling rate is defined where it says "taxa de aquisição", i don't know if this works as you say, that it only changes how fast is the loop, when i change the sampling rate i get a higher frequency in the graph, but when i open the spreadsheet i only see a few values, for example, i define the sample rate as 1000 Hz but i only get 200 or so recorded values when i should get for a 5 second interval, 5000 values.
07-21-2010 12:47 PM
This program was build by a collegue of mine last year and as i don't understand much of labview i didn't notice that. i already made a few changes in the application.
The sampling rate is defined where it says "taxa de aquisição", i don't know if this works as you say, that it only changes how fast is the loop, when i change the sampling rate i get a higher frequency in the graph, but when i open the spreadsheet i only see a few values, for example, i define the sample rate as 1000 Hz but i only get 200 or so recorded values when i should get for a 5 second interval, 5000 values.
I send in attachment the strain lib i think this is where i went to get the Emant300 Read Analog.VI....
thanks for your help
07-21-2010 02:03 PM
That "taxa" control may define sampe rate of the "emant" instrument, but is has absolutely no control over the while loop. The while loop runs as fast as it can, but ultimately the timing of the control loop is dependent on how fast it can get back a piece of data from the Analog Read VI of the instrument driver, and also how fast it can write the data out to the file.
Since the communication is serial, and you are trying to get data 1 point at a time, I don't know if you can really expect to get 1000 data points through the serial port in a second. Actually I really doubt it. Assuming your baud rate is 9600, that means about 960 bytes per second. If each data point is only 1 byte (meaning one of 256 possible values), at the fastest you'd get 960 data points a second. But in reality, each data point probably consists of several bytes.
You'd have to see if your driver can send through data faster and in larger packets to be able to try to log at a rate as fast as 1000 points per second.
07-21-2010 02:47 PM
The problem is that i have done a few tests and i used a sample rate of 500Hz and in my excel spreadsheet it only appear 200 or so values for a test of 10 seconds or more when it should be more...
07-21-2010 03:10 PM
Are you sure you are even using the correct read function? No matter what you set the sample rate to, you are taking only a single reading. The hardware would have to take multiple readings for any sort of sample rate to apply. There is the function called EMANT300 Read Analog 16 bit Waveform that would perhaps reflect your selected sample rate.
If you were using NI DAQ functions, the equivalent would be 1Ch 1Samp and that switches you to software timing. The hardware timing gets disabled.
07-21-2010 03:31 PM
I think so, because this .Vi was an adaptation of the .Vi that the Emant company provides for the users... my collegue just made some changes in the formula that calculates the strain...
07-21-2010 03:41 PM
@Nuno_Gonçalves wrote:
I think so, because this .Vi was an adaptation of the .Vi that the Emant company provides for the users... my collegue just made some changes in the formula that calculates the strain...
You really need to think again.
That VI may have worked for your colleague if all he was interested in was getting one data point at a time. But that isn't the right VI for you if you are trying to read all of the data points that the instrument is acquiring.
07-21-2010 03:45 PM
A single examples does not mean that there is not different ways to do things. If you stick with this, then I think you need to accept that you will not acquire any faster.
Remove the file write function and see how fast your loop iterates. That will be your maximum sample rate with this program. Then, use the function I mentioned and look at the waveform datatype it creates. There is a dt value and this will tell you the time between samples when you use this mode. Let us know if the the dt then reflects the sample rate you have entered.