LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Circular In Range check

Solved!
Go to solution

Hi folks,

 

It looks like you are pretty much got there thanks to Nathan's fine work. I found this a difficult but fun problem. I know this is not ideal but I wanted to float the idea of using this function to create two arrays that you could logical AND to check for overlap.

 

This is the function

 

 

Now there are some issues here in my code. Span will create ranges of length 1,3,5 ... so that needs to be better defined for even number spans. I know I am a bit late and probably not perfect to your needs. However I did the work and I thought might as well share it just in case it sparks furher ideas for the topic.

 

cheers

 

David

Message Edited by David Crawford on 04-08-2010 10:55 PM
Download All
Message 11 of 20
(1,388 Views)

nathand wrote:

elset191 wrote:

That doesn't quite work.  At least one case I have checked is when one range is completely within the other.  For example, (87,8) and (85,2) should remain 8 span (and center 87), but the method you described gives 7.  It's not always off by one, (87,8) and (87,2) gives 5, for instance.


Good point; I should have tested more thoroughly before suggesting that.  This has been a fascinating way to be unproductive for a few hours today, and if I'm ever looking for a programming puzzle for someone maybe I'll suggest this.  It may not be the most efficient implementation but I'm pretty sure the code below does what you need.  If I missed another case let me know.

 


That's just about the same solution I had previously, so I guess I'll stick with it.  Thanks for taking the time to explore my problem.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 12 of 20
(1,338 Views)

elset191 wrote:

nathand wrote:

elset191 wrote:

That doesn't quite work.  At least one case I have checked is when one range is completely within the other.  For example, (87,8) and (85,2) should remain 8 span (and center 87), but the method you described gives 7.  It's not always off by one, (87,8) and (87,2) gives 5, for instance.


Good point; I should have tested more thoroughly before suggesting that.  This has been a fascinating way to be unproductive for a few hours today, and if I'm ever looking for a programming puzzle for someone maybe I'll suggest this.  It may not be the most efficient implementation but I'm pretty sure the code below does what you need.  If I missed another case let me know.

 


That's just about the same solution I had previously, so I guess I'll stick with it.  Thanks for taking the time to explore my problem.

The only modification I made was to replace the select part with a mod.  Thanks again.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 13 of 20
(1,327 Views)

Further testing exposed an error in the super-range code.  (250,8) and (2,8) returns a center of 128 and span of 256.

 

This case fails in my original code too.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 14 of 20
(1,311 Views)

Hi Elset,

 

I had a go at your problem and have posted below. I think i get what you are trying to do but not 100% sure:

 

Circular range check.png

 

Am i correct in saying that the new span will be between the overlapped highest point to lowest point, and the new centre the value in the centre of these 2 points? This VI does that. One thing that i noticed whilst playing around with it is that if this is what you are after you may get funny results. For some circumstances the Overlapped Maximum and minimum points will have an uneven span, say 13. This will mean the centre value will not be an absolute value but be n + 0.5. I would assume that this will not be what you are after but this is what you'll get as you cannot control how the 2 ranges overlap.

 

Hope this has helped. If i have misunderstood give me more details and i will have another go for you.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 15 of 20
(1,276 Views)

Hey Lucither,

 

So far it seems to do exactly what I need.  So far it has passed all the test cases that have given me trouble throughout the different iterations.  I'll continue to try and break it though.  

 

 Also, I've cleaned it up, removing a lot of selects and case structures

 

The main In Range Check VI

inRange.png

 

The Get Span and Center VI.  (The subvi just does the plus and minus of span/2)

Get Span and Center_BD.png

 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 16 of 20
(1,252 Views)

Hi Else

 

Im not sure that you can use the Max Min vi to correctly sort the range1 and range2. If you do what you have done then it will return a cluster containing the 2 highest values and 1 containing the lowest. For it to work correctly though the correct span has to be kept with its own center. This could cause them to change. for example, if you have range 1 = centre:100, span:0 and range2 = centre:87, span:3. it will return a range of 100:0 and 87:3, this will give you incorrect readings when trying to calculate the new centre and span. you need to sort the ranges by order of just the centres but keep the spans with there original centres.

 

Glad its working so far though

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 17 of 20
(1,243 Views)

Lucither wrote:

Hi Else

 

Im not sure that you can use the Max Min vi to correctly sort the range1 and range2. If you do what you have done then it will return a cluster containing the 2 highest values and 1 containing the lowest. For it to work correctly though the correct span has to be kept with its own center. This could cause them to change. for example, if you have range 1 = centre:100, span:0 and range2 = centre:87, span:3. it will return a range of 100:0 and 87:3, this will give you incorrect readings when trying to calculate the new centre and span. you need to sort the ranges by order of just the centres but keep the spans with there original centres.

 

Glad its working so far though


Change the comparison mode on the Max & Min from Compare Elements to Compare Aggregates and it works correctly.  This way it compares the first element.  (then if it is equal it will look at the second, and so on)
Message Edited by elset191 on 04-13-2010 11:00 AM
--
Tim Elsey
Certified LabVIEW Architect
Message 18 of 20
(1,240 Views)

Hi Else,

 

Yeah, your right, just tested. Have never used that mode before. Have learnt something new, thanks.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 19 of 20
(1,235 Views)

elset191 wrote:

Change the comparison mode on the Max & Min from Compare Elements to Compare Aggregates and it works correctly.  This way it compares just the first element I believe.


It compares the first element, and if they're equal, then it compares the second element (and then the third, etc).  This is the same way that Sort 1D Array works when passed an array of clusters, and it is a very useful technique to know for sorting by criteria in order of preference (arrange your cluster so that the most important element is first, the next most second). 

0 Kudos
Message 20 of 20
(1,234 Views)