01-19-2011 07:36 AM
Hi,
Is there some counter function in labview 2009?
What I need is to count how many times I enter in a Case loop, when I reach a certain value (that I set) it should start from zero again. I need it to creat some kind of delay. I have two case loops, one inside the other and I want the external loop to run 5 times before I enter the inner loop, once I run the inner loop the outer loop should run 5 times again and so on.
It´s something simple and useful but I can´t find anything that does what I need.
Solved! Go to Solution.
01-19-2011 08:06 AM
Hi ManuP,
you can store the value in a shiftregister. Add only "1" if you are in the correct case.
Mike
01-19-2011 09:00 AM
That´s right it works, thank you. I thoguth there was an event counter or something like that.
One more question, I´m using the Circular Buffer VI and the help says that I can´t use two buffers of the same data type at once. If I want to do that I have to save multiple versions of the same circular buffer with different names. What exactly does it mean?
01-19-2011 10:19 AM
ManuP,
It means that if you want 2 seperate buffers that hold different data you will have to rename the vi to do this. If the vi has the same name then everytime you add data you will be adding it to the same buffer. For example Say you wanted to store 2 lots of data, A's and B's. You will need 2 buffers, Buffer A and Buffer B. If you only had one buffer (Buffer A) then all data, A's and B's would go there. You will have to rename the vi for each buffer you require. You can have multiple copies of each buffer in your code, but all A's should use Buffer A and all B's should use buffer B etc...... (Now im confused!
)
Rgs,
Lucither.
01-19-2011 01:33 PM
I know it should be like you say, but the 2 buffers I'm using have different names and still they work as one.
To rename them I right-clicked on the circular buffer's icon, enter properties and changed the name of one of them. I think that's the only way to rename it, right?
When I plot the data of the two buffers using two different graphs I can notice that all I have is concatenated data of the two sensors in one single buffer.
01-19-2011 01:54 PM
Here is an image to show you what I'm talking about.
I store the data in the buffers in packets of 40 samples each, wich represents 200ms of signal. Then I wait until I've stored 5 packets in each buffer (so I can see 1 second of the signal being sampled). After that I read 200 samples (40 samples x 5 packets) from each buffer and plot them.
In the image: the noise should be shown only in the graph called "ED1 Grafico", and the other graph should show a flat signal. But as you can see the noise and the flat signal are shown in both graphs, which tells me that I only have one buffer.
01-19-2011 07:37 PM
ManuP,
There are 2 ways i would do it. If i never had the program open i would go to the folder that contains the vi, copy it and rename it. Leaving both copies in the folder.
If i had the program open, i would open the vi, from that vi i would go to Save As. It will then ask you how you want to save. I would choose Copy- Open additional copy, then save it with a different name. You will then have both of the versions open.
Another thing i would do once i have 2 copies would be to either slightly modify the icon (Maybe have a small A in the corner of one and a B in the other) or place the 2 copies in seperate wrapper vi's, again making the icons different. This would be purely to make it harder to accidentally use the wrong buffer in your code somewhere. Will also make it easier to understand for someone else reading your code or even yourself in years to come.
At the moment all you are changing is the label. All instances will still be the same vi.
Just out of interest where did you obtain the circular buffer?
Rgs,
Lucither
01-20-2011 08:20 AM
Hi Lucither, thanks for your answer.
I was sure that it would work, but I tried saving it both ways and neither of them worked.
If I open the folder and copy the VI with a different name, then when I look for it on the palette I see a white icon with a big question mark and it doesn´t work.
If I open the VI and go to save as->copy->open additional copy I am able to save it ,but it is saved in the Instance VIs folder and I don't have access to that folder from the palette.
Besides there is a Circular Buffer.lvlib file that I can´t modify and I think that file should be updated too.
Well I´m kind of lost now, the VI´s help puts it so simple but I just don't get it.
.
I downloaded the Circular buffer VI from http://zone.ni.com/devzone/cda/tut/p/id/7188.
01-20-2011 09:42 AM
ManuP,
I just downloaded it and tried myself and your right, is not easy. I played around for a while, i actually changed the vi in the instances folder rather then the polymorphic version. I got it too run but never managed to get the buffer to output data, from the information about the buffer size it was returning it did also seems as though the buffers where being shared. Im literally on my way to bed now so will have a look again tomorrow.
Out of interest what type of buffer do you need, what data are you storing. The reason i ask is because i have just had a look at the circular buffer BD and at first glance it seems over-complicated and poorly written. I have a circular buffer routine that may better suit you. Let me know the specs for your buffer as i may have a better option for you.
Rgs,
Lucither.
01-20-2011 12:08 PM
Thanks Lucither, now I feel less stupid for not being able to copy and rename a VI.![]()
I'm using three XBees modules, two of them sample analog data and send it to the third module, which is connected to the pc, in packets of 40 samples each. My program opens a COM port and analyzes the string of data and detects which module is sending the samples. The ADC in the modules has 10bit resolution so the program type casts every two bytes into a word values and stores it in two buffers. Then it plots the samples of each module using two waveform graphs.