04-10-2013 06:16 AM
Hi again,
In attachment you can find the very latest edition. ( I made an expansion of the original program but it's not really relevant for my questions)
Only Events 'Start' and 'SAVE' are important for now I think.
The questions that remain are the following:
1) If I just run the program and collect the data, everything works fine. However, if I press 'SAVE', the created matlab file has 2 columns ( force and acceleration) but each column only holds about 12 values ( of which the last 6 values are even zero's). Normally both of the columns should contain 60,000 values..
2) The x-axis of the charts on the first 'page' is set from 0 to 1. However, if I start the program the x-axis automatically changes to from 3448436383 to 3448436391. I think this should be solved using a chart property node which resets the 'time history' of a chart, but I don't know if something like that exists and what exactly it is...
3) I tried to implement the Circular buffer into LV 8.5 by following the steps: http://forums.ni.com/t5/LabVIEW/Circular-Buffer-implementation-for-LabVIEW-8-5/td-p/971762
If I download the file on the forum and I open the 'circular buffer.vi' I get to choose between more than 30 circular buffers. How do I know which one to pick? And how exactly do I implement them in my vi? I can open the buffers but then a new vi pops up. Should I just copy and paste the whole vi into my own vi or should I use it as a subVI ( and how do I do this)?
Also where should I place the Circular buffer and what should I use as input/output? I've read about Circular buffers on the LabVIEW website so I think I understand how they 'operate'. But I still don't have a clue how I can use them in my vi.
PS: I'm very sorry for the spaghetti code. I know I have to clean it up and I'll do it whenever the program works 🙂
PS2: If you would change anything and post your changes below, could you please post them in the LabVIEW 8.5 format? I'm running version 8.5 on my laptop.
Thank you! 🙂
Best regards,
Dries
04-12-2013 05:35 AM
Hello,
To answer your questions in order:
1) I don't see any reason to use a MATLAB Script Node for saving.
You can also see by the coercion dot (red dot) that your waveform data is converted to double data.
Please try to use a native save to file function to perform these actions.
If you want to use the Write To Measurement File express VI, then you can just directly use it in the save event case;
One of the things I don't understand in your code is how you implemented a part of Acquisition Loop.
Over here you need to take alook at how you build your arrays.
If you modify it like in the attachment then you should have the data as described in attachment.
Please note that this is neither the most efficient nor easiest way to this.
It is a way with the least change to the current code.
2) This is caused because you are using the t0 from the waveform as a reference point.
I assume that this t0 (part of the waveform cluster) is equal to 3448436383.
Can you verify this at your side?
3) Let me put the question differently: Which ones have you tried and what were the results?
About the spagetti code side I can give you one tip: waiting until you're finished to clean up your code will make it take longer to finish the code. 🙂
If you clean up your code while programming, then you will automatically see where certain errors are rising from.
04-12-2013 07:46 AM
Hi Thierry,
To answer your questions:
1) We use Matlab for further analysis of our measurements. Therefore it's useful to save as a .mat file instead of using the Write to Measurement File express vi.
If I get this right, I have to use the 'append waveforms vi' instead of the 'build array vi'? If I do so, will the 'save to a .mat file' work?
2) Yes, that is correct. Is there anyway I can reset this t0 after every 'start-stop'?
3) I haven't got any results yet as I have no clue how to use the circular buffer. I open the Circular buffer ( 1D Wfm with attributes) and insert it into my vi. The first problem which occurs is: Where to place the buffer?
Should it be placed after the 'Trigger and Gate vi', but still in the 'True / False' case structure? Should I then connect the data in with the output of the Trigger and Gate vi and the data out with the input of the Index Array vi?
I suppose the 'operation' should be defined as 'Write'? But I don't see how I can connect the amount of presamples and the trigger value with this buffer. ( To be honest I don't even know how to reach them).
I'm pretty sure that I'm doing some important things totally wrong and that if I would do them the right way all would become clear to me 🙂
But since I don't know what I'm doing wrong I hope you can help me finding out.
Thanks for the tip, I will clear up my program before I add any more features to it 🙂
Best regards,
Dries
04-12-2013 11:00 AM
Hello Dries,
1) That information about the .mat file is indeed important and I don't remember it being mentioned here before (I can of course also be wrong about this 🙂 )
The problem was a bit more complex:
Just using a Build Array function (X times) with waveforms (like youd did) created an array of X waveforms.
And this was not what you were looking for.
You wanted to have 2 waveforms of full measurement length at the end and not X times 2 waveforms.
The most important question about the .mat files is as follows:
What do you want to save to it?
Please show me an example of how your stored data should look like.
2) Yes, by changing the t0 value of both the waveforms
3) Ok, one quick question. Do you really fully understand the concept behind circular buffers, because if you would then these questions should not pop up.
I think I already mentioned this before, but here I go:
The circular buffer should not be placed after the "trigger and gate" VI.
You should use it in a VI (that you create yourself) to make your own "trigger and gate" VI.
Do you have any idea on how you could do this? You can say it in your own words.
The reason I'm asking you this is because I want you to fully understand what you're programming and not just blindly give you a solution (that is not understood)
04-13-2013 04:50 AM
Hi again,
1) In attachment you'll find an example of the resulted .mat file I wish to become.
In the first column all the measured Force values are listed. In the second column all the measured Acceleration values are listed.
The length of the list depends on the amount of measured values ( in my program around 60k).
2) Can I just click on the x-axis and change the t0 value to 0? If I do so and I run the program again the t0 value automatically changes back the the large value.
3) I've read the info of the Circular Buffer on the NI website ( http://www.ni.com/white-paper/7188/en). Or isn't that NI webpage the right one for me? I'm not too sure I understand what the Circular Buffer is all capable of: I know it's a sort of array with a fixed length and when the end of the array is reached it automatically starts to read/write back from the front but I'm pretty sure there is so much more it can be used for. However I haven't got a clue about how it can help me creating my own 'trigger and gate' vi...
I've also tried to search for video's of curcular buffers but they didn't make me any wiser...
Thank you again for your time,
Best regards,
Dries
04-16-2013 11:42 AM
1) To save to .mat files from inside LabVIEW you could also use these VI's:
http://digital.ni.com/public.nsf/allkb/FBA2EAE2AB27BDEA862575D900724BDD?OpenDocument
2) As long as you are using waveforms and writing those to your front panel each write will try to force the timing info of the waveform.
If we would store our data in simple doubles, then this problem would be more easily avoidable.
3) The circular buffer on itself is capable to buffer something and that's it.
What my idea would be is to embed this circular buffer into a Functional Global Variable (Do you now this).
This Functional would add the trigger and gate functionality to the circular buffer.
It would also allow you to dynamically initialize the array in which the buffered data will be stored.
The trick here is that you have to check the read data and track at which point in you circular buffer your trigger is seen.
If you know this, then you can easily add some logic to the functional global variable that makes you only acquire for a certain amount of time/elements.
Do you understand what I'm trying to say here?
04-16-2013 03:33 PM
Hi,
1) I tried to open the .vi but it's made for LabVIEW versions 8.6 or higher and we are still working with 8.5. Is there any other way I can get a version for 8.5?
Also, could you tell me what are the advantages of this vi? ( Why is the way I did it not a good way?)
If I work with this Dataplugin, do I first have to save to a .TDMS file and then the vi can convert this .TDMS into a .mat file? Or how does this specific vi works?
2) I'm afraid this is not possible since the main goal of the vi is not only to save to a .mat file and do some calculations with the results, but also to display the measured values "in realtime" in a graphic ( chart).
3) I've read the explanation of the Functional Global Variable on the NI forums ( https://decibel.ni.com/content/docs/DOC-2143). I have found an example for LabVIEW 8.5 ( http://forums.ni.com/t5/LabVIEW/Functional-Globals-in-LV-8-5/td-p/1477104)
I think my knowledge of LabVIEW might not be enough to understand where you're going to. But nevertheless I'm eager to learn about how to make this work 🙂
Thank you in advance.
Best regards,
Dries
04-17-2013 02:44 AM
1)To see how it works you should use it. I did a quick conversion over here.
To convert VI's in the future, you can go to this specific part of the forum:
http://forums.ni.com/t5/Version-Conversion/bd-p/VersionConversion
The previous way (in your example code) you connected aan array of waveforms to a 2D Array of doubles.
These datatypes are totally different so this is were it went wrong.
Of course you could also write your own VI that converts from waveform to 2D array of doubles.
2) You can still display your data (even if your using 2D Data istead of waveforms) and save it.
Why do you think one of them would exclude the other?
3) Where are you stuck?
04-17-2013 06:38 AM
Hi again,
1) Do I have to download a DataPlugin before I can use the program? If I try to run the program I get the error:
Error -2553 occurred at Write Data
Possible reason(s):
LabVIEW: The object refnum is invalid. The node that returned this refnum might have encountered an error and did not return a valid refnum. The storage this refnum refers to might have closed before the call executed.
I filt in the storage location and I think the sine wave vi will provide the data to save. But how about the dataplugin?
2) I thought I already stored the data in a 2D array first before sending it to the charts? Or isn't this what I did? 🙂
3) Pretty much in the beginning 🙂 I read about both the circulair buffer and the Functional Global Variable but I don't really have an idea about how I can create a vi which embeds this circular buffer into a Functional Global Variable. Is the example in the link posted in my previous post a good example of a FGV?
Thank you.
Best regards,
Dries
04-29-2013 06:38 AM
Hello Dries,
I have been out of office the last week (vacation without internet), so only now I'm able to contact you back.
Is the status still the same at this moment of have you made any further progress?