Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Variable rollover with Labview (suggestions?) (http://www.chiefdelphi.com/forums/showthread.php?t=68909)

kamocat 21-08-2008 17:08

Variable rollover with Labview (suggestions?)
 
I'm looking for a better way (if there is one) of making a number roll over at a specified value, with Labview. What I have come up with so far is this:



If you don't have the boolean symbols memorized, what it does is determine whether a value is closer to the rollover limit or the highest possible number, and places it where it should have been back within the range. (of course, it only does this when the number is out of range)
The challenge here is that the number may change at an inconstant rate (you can add or subtract values much greater than 1). The problem with this solution is that it doesn't actually tell which way a value has rolled over, and thus could pose some problems if the increment is quite large. Also, it must be in a feedback loop to work for more than one rollover.
Please post your suggestions! I don't mind if you post them as VIs, but other people might appreciate your using pictures.

Thanks!

kamocat 21-08-2008 17:56

Re: Variable rollover with Labview (suggestions?)
 
I suppose this one would work too, but this one requires that the rollover value be no more than half the maximum value of a 16-bit unsigned word. Also, because it gets so close to actual U16 rollover, there's a chance that the value will truly roll over without being caught at the desired value. (To make sure this is a feasible challenge, I'm going with the assumption that there will be no jump in value greater that half the rollover limit).



Again, for those that might not be familar with all the symbols, that division thing with the R and the IQ is a quotient function. It gives the quotient IQ and the remainder R. The triangles with the ? T F on them are boolean selectors; it selects the value wired to T or F according to the boolean input (the ? symbol). Lastly, that green arrow there is a feedback node; it holds a value until the next call. This one happens to be green (boolean).
And I believe you can figure the rest out.

Thanks again!

EricVanWyk 21-08-2008 18:00

Re: Variable rollover with Labview (suggestions?)
 
I'm having a little trouble following exactly what you are trying to accomplish: could you provide example inputs and what you want as an output?

I've included a few options, all assume that rollover is 100.

Which of the following behaviors is correct?
1) 112 becomes 12
2) 112 becomes 100


Another interpretation: You have a variable x, and you are incrementing or decrementing by dx. You want output to "latch" to either extreme if you would otherwise roll.
x=98, dx=5, output = 100
x=98, dx=70, output = 100
x=3, dx=-5, output = 0

Perhaps pulling dx into your function would make it easier, as you can use it's sign without having to guess.
Also, would it help to temporarily use a 32bit int to avoid overflow, and then truncate back down?

Joe Ross 21-08-2008 18:10

Re: Variable rollover with Labview (suggestions?)
 
You can right click on the addition icon, choose properties, go to the output configuration tab, and change the representation to U16. This will automatically wrap the values at U16 (or whatever other data type you want). It should simplify some of your VI, by not having to worry about the max U16 value.

It would be a lot easier to work with if you posted your vi, rather then just a picture.

kamocat 21-08-2008 19:27

Re: Variable rollover with Labview (suggestions?)
 
Quote:

Originally Posted by EricVanWyk (Post 762418)
I'm having a little trouble following exactly what you are trying to accomplish: could you provide example inputs and what you want as an output?

I've included a few options, all assume that rollover is 100.

Which of the following behaviors is correct?
1) 112 becomes 12
2) 112 becomes 100

That's the trouble. I want it to roll in both directions. Say I'm working with degrees, so I have the rollover set to 360. I need it to reset back to zero when it turns past 359, but I also need it to go to 359 when it goes past zero if it's turning the other direction.

Quote:

Originally Posted by EricVanWyk (Post 762418)
Perhaps pulling dx into your function would make it easier, as you can use it's sign without having to guess.
Also, would it help to temporarily use a 32bit int to avoid overflow, and then truncate back down?

I'll consider that, and see what I can do without too much hinderance to modification.

EricVanWyk 21-08-2008 20:53

Re: Variable rollover with Labview (suggestions?)
 
Quote:

Originally Posted by kamocat (Post 762422)
That's the trouble. I want it to roll in both directions. Say I'm working with degrees, so I have the rollover set to 360. I need it to reset back to zero when it turns past 359, but I also need it to go to 359 when it goes past zero if it's turning the other direction.


I'll consider that, and see what I can do without too much hinderance to modification.

It sounds like you might be looking for the "modulus" operator. I'm not a LabView expert, but I did find this in my googling - http://forums.lavag.org/Computing-mo...w-7-t8550.html

kamocat 21-08-2008 21:21

Re: Variable rollover with Labview (suggestions?)
 
Quote:

Originally Posted by EricVanWyk (Post 762424)
It sounds like you might be looking for the "modulus" operator. I'm not a LabView expert, but I did find this in my googling - http://forums.lavag.org/Computing-mo...w-7-t8550.html

Thanks, but no. All I want is an artificial rollover. The modulus operator was just another way of getting it done

Greg McKaskle 22-08-2008 08:30

Re: Variable rollover with Labview (suggestions?)
 
There are many ways of doing this.

I'd start along Eric's lines of asking more questions. The easiest way to detect overflow is before the operation that causes it. Before adding or subtracting the delta, determine if dX is greater than the boundary it is approaching. If so, do some wrapping code.

Key operators that may be handy are the "Integer Division", which performs the modulus operation, giving IQ and R. There is also the "In Range and Coerce" node.

Have fun.
Greg McKaskle


All times are GMT -5. The time now is 08:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi