03-17-2010 08:53 AM
03-17-2010 09:43 AM
Hey Ray, I tryed your example here
but when I use for loop with index enable it don't work because create a 3D array
and if I use with disable index, it aways give me the index of 0.
Thanks
03-17-2010 10:14 AM
I didn't realize you were working with 8 channels. That should be okay. I would have done the code a little differently.
Can you post your code?
03-17-2010 10:33 AM
Hey Ray.R, is something like that
I only did it comparing 0 and 4, the next will be the same if it works!
But my problem is, when I use enable indexing I receive an error because I'm trying to read a 3D array, and when I disable auto-indexing I always receive 0 at result!
Thanks
03-17-2010 12:21 PM
I see the problem.
In your example, simply remove the For Loop.
However, before I do that, do you mean to say that you have 8 channels, but you are only interested in two of them?
If so, then try removing the For Loop.. , especially since you only have 1 iteration.
From what I understand when reading your post and looking at the code, you are looking for a value going positive when it crosses the x-axis. I had the sample data going the other way (going negative). If that is the case, then you want to change the numeric constantfrom 2.5 to -2.5 and change all the minus to plus. Otherwise, yes 0 is where they both meet the condition and it will say that they are equal.
If you are monitoring 8 channels, I can improve my example.
03-17-2010 12:38 PM - edited 03-17-2010 12:42 PM
Ray R, I'm monitoring 8 channels but i'm using 2 channels to compare!
Like I will compare Vr with Ir, Vs with Is, Vt with It and Vtn with In
so if I only make more 3 cases using the correct index, don't work?
or if you can, improve to 8 channels so I will take a look!
I didn't understand why you use 2,5 and a minus in the beggining, could you explain me a little better this?
And, yes I need know when the value goes to positive, so please change your code, because I tryed here but it don't work x(
03-17-2010 02:38 PM
The -2.5 is to have negative values initially.
I will do the example for 8 channels during my next break.
03-17-2010 04:06 PM - edited 03-17-2010 04:12 PM
See the code snippet below: The portion on the left represents the signals (8 ch) that you are acquiring. Or have acquired or read from a file, etc.
Since you are only interested in 2 of the 8 channels, I left the code to the right similar to the original example. However, I included two controls to select the channels, one for Voltage and the other for current. I wanted to have fun with various levels, so I placed a random number generator for this example. Run it a few times, and you will see how it behaves under different circumstances, such as the signal never crossing the threshold. Since you mentionned that it crosses the x-axis, which is amplitude = 0, then I left the comparison as GE 0. Otherwise, you can change the logic to accommodate different threshold values. You will/may have to include logic to deal with the situation when they both cross the x-axis at the same time.
Enjoy..
03-18-2010 06:35 AM - edited 03-18-2010 06:38 AM
Well Ray. R,
I connect the first multiply ( 1 x random number ) at frequency, and the (5 x random number ) at amplitude, but why sometimes I'm geting index -1? In my opinion index 0 would be the first one, no?
Maybe I connect something wrong =x
And could you explain me why this "-2,5" ??
I didn't understand it yet!
Thanks
03-18-2010 07:59 AM
You're not doing anything wrong..
-1 means that it did not find any values crossing the x-axis. I wanted the example to show what happens if: as time goes to infinity, the values goes to zero, meaning it gets really close but never reaches it. If your values do not exhibit this, then you will never see -1. In the example, the "-1" case represents having signals (waveform, etc) that never have amplitude values above zero.
Why -2.5? Simple. You mentionned that the signals start off being negative, and increase to positive values, so I am forcing the starting values to be below zero (below x-axis), in other words the starting numbers are negative.
You can add a waveform graph to the example to see what the signals look like and what they are doing. If you want to avoid the "-1" case from happening in the example, you have 2 choices: 1) change the amplitude value to a constant instead of random, or.. 2) include a minimum range for the amplitude (ie > 2.5) so that the signal does cross the x-axis.
But remember, this is just an example, it is not the values that you will be dealing with.