02-28-2007 01:22 AM
02-28-2007 03:08 AM
03-01-2007 12:51 AM
Hi Bong
I'm back in the office, so here are the answers:
1. Well, time elapsed is updating, but it's always the same value: 50ms, which is the same as the time constant I want the loop to wait after each iteration. Additionally, this calculated values is averaged as well, so you don't see any changing value in general.
2. Of course the lower case structure handles different cases, but it depends on the size of the buffer arrays. During the 10 first iterations of the loop, the buffer arrays are smaller than 10 elements, so the case "0..9, Default" is executed. Afterwards it is the other Frame (10..). I strongly assume you started the vi and turned the highlighting mode on after a moment. Turn the highlighting mode on and start the vi after this - you should see what I mean.
3. The purpose of buffering the data and calculating the mean valus is this: Firstly, I can have a higher iteration rate. Secondly, if I have a value very different to the others, the difference is decreased. So you kind of "break" peaks.
If you have more questions, don't hesitate to ask.
Thomas
03-02-2007 12:32 AM
03-02-2007 01:04 AM
Hi Bong
Firstly, my VI is not intended to be the final version. It just could be a possible solution which may be optimized.
To comment your points:
1. If you measure data you never get an exact value. It will always jump (the raw value) due to A/D conversion
2. As the data is buffered, it takes at least 0.5sec (10 cycles with 50ms) to empty the buffer, but as long as there is data measured, the buffer can not be emptied.
3. Did you really have a look at the vi? If you just follow the wire from the control backwards you will come to the Mean.vi - so it obviously must be averaged. As I do not know what kind of data you get, I just used the dial to simulate an angle value in degrees. So the dial has a range from 0 - 360°.
Now the answers to your follow up questions:
1. The time difference between the measurements is calculated. In general this value should be 50ms, but as you never know if this rate is fixed, I calculate the time difference between each reading of the dial value. To make this more precise, the dial control and the current time ms should be placed in a simple sequence, to make sure that there is no time delay between reading the dial and the current time.
2. -
3. If you read data in the loop, the you have faster reading. In general, you can be more precise. Just an example: If you measure the rpm of a motor and it is setup to have its maximum speed after one second, you have a different number of values depending on the iteration speed of the loop. If you have 250ms per cycly, you would just get 4 values. With 50ms you get 20 values.
The negative values indicate the rotation direction, so if I was you, I would not get rid of it.
As I said at the beginning of my post, this vi should just help you to find a solution and I just can recommend to debug my vi, so that you understand how it works. Basically there is nothing difficult about it - some data buffering and some calculations.
Thomas
p.s.: don't worry about the questions - that's ok (as long as you do not just give 1 star ratings ;))
03-04-2007 06:16 PM
Hi Mr Thomas,
Thanks again for the reply.
When I first received your VI i test it immediately here in my table together with the compass. At one glance i thought it makes sense. It is calculating distance travelled and speed. So, i move on and test it on the actual machine to get rid of magnetic errors. And it looks fine too. But I guess buffering I need to understand more to know how the VI is really working. I will continue to study your VI and will make correction or improvement (if any) if needed.
Thanks a lot for everything. You have been very helpful.
Best regards,
bong
03-05-2007 12:19 AM
Hi Bong
Maybe this helps: The "buffering" you could also call moving average.
03-05-2007 12:48 AM