|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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! Last edited by kamocat : 21-08-2008 at 18:03. |
|
#2
|
||||
|
||||
|
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! Last edited by kamocat : 21-08-2008 at 18:10. Reason: another error was realized |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
||||||
|
||||||
|
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. Last edited by Joe Ross : 21-08-2008 at 18:18. |
|
#5
|
||||
|
||||
|
Re: Variable rollover with Labview (suggestions?)
Quote:
I'll consider that, and see what I can do without too much hinderance to modification. |
|
#6
|
|||
|
|||
|
Re: Variable rollover with Labview (suggestions?)
Quote:
|
|
#7
|
||||
|
||||
|
Re: Variable rollover with Labview (suggestions?)
Quote:
|
|
#8
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with CMUcam & LABView | Daniel_H | LabView and Data Acquisition | 1 | 30-01-2006 12:07 |
| Problem with freezing frames in LabVIEW | pdc | LabView and Data Acquisition | 2 | 26-01-2006 01:34 |
| Problems tracking with CMUCam2 in LabVIEW | PhilBot | LabView and Data Acquisition | 5 | 17-01-2006 20:42 |
| Need help with 255 Variable | Joseph F | Programming | 18 | 26-02-2002 14:49 |