06-05-2007 11:40 AM
06-05-2007 12:10 PM - edited 06-05-2007 12:10 PM
Message Edited by Stradis on 06-05-2007 01:11 PM
06-05-2007 12:54 PM
06-05-2007 01:21 PM
06-05-2007 01:32 PM - edited 06-05-2007 01:32 PM

Message Edited by altenbach on 06-05-2007 11:32 AM
06-05-2007 01:42 PM - edited 06-05-2007 01:42 PM
@hotmail wrote:
See attached and please give me feedbacks on this.
This code is very silly. There is no reason in the world to use a local variable here, because you will end up with a race condition. Most likely, the local variable read will occur way before the upper loop has finished, and you'll get the sum of some unpredictable random intermediary result.
It is also useless to place the indicators for quotient and remaider outside the loop. You won't see any variation. E.g the "remainder" indicator only receives data after the loop has finished, and since the loop does not finish until the remainder is zero, you'll get zero in 100% of the cases. 😉
Since you have a 1 second delay (maybe for debugging?) All indicators belong inside the loop. Once the code is debugged, all these indicators and the delay can be removed.
Also, you initialize your array with the wrong representation. Don't mix orange and blue for no good reason. RIght-click the array constant and to "representation...DBL".
Message Edited by altenbach on 06-05-2007 11:44 AM
06-05-2007 02:18 PM
06-05-2007 02:55 PM - edited 06-05-2007 02:55 PM
@hotmail wrote:
The 'remainder & quotient' function rounds off the values which is exactly what I want. Now I want to take the values the ones the shift register arrayed and sum them up. Now this sum should not include the last computation that resulted in a 0 or 0.5. For this particular example the sum should yield (1x2^2)+ (0x2^1)+(0x2^0)=4 not 12 (The first '1' in the 1100 is ignored). Its giving me 12 instead of 4, do I need to fudge with the while loop??
So, what result do you actually want? Why all that song and dance if all you want is an unsigned integer that has the highest set bit zeroed out?? 🙂
Since boolean operations work bitwise on integers, maybe the following is a possible solution? Basically, it finds the highest set bit and zeroes it, keeping the rest intact. Please modify to your exact requirements (e.g. integer representation, currently U8). There are may other ways to do this, but this should getr you going.
An input of 12 will result in an output of 4.

Message Edited by altenbach on 06-05-2007 12:56 PM
06-08-2007 11:42 AM
Thank you all for your help and feedback. Yes, I am new to Labview and yes there are many ways you can do what I am trying to do and maybe the way I'm doing it is silly...but... part of the learning process 'ey.
Okay...maybe I should have explained the whole purpose of why I wanted to sum up consecutive results. The whole purpose is to manually convert numbers to single precision floating points (http://en.wikipedia.org/wiki/Single_precision). See the finalized vi that I have attached. Well, not quite finalized because it only converted integers (-ve and +ve) and it doesnt do fraction. I was able to create a vi to do fractions but I cannot post it at this time.
The VI attached does the conversion in two different ways. One is using the built in Single Precision conversion funciton and the other is by step by step manual calculation. You may notice the conversions for the 0 and 1 are different for each type of conversion. This is because of the calculation methodoloy used.
Alntenback- your method is simple and straight forward...thanks. ![]()
Thanks
06-08-2007 12:06 PM - edited 06-08-2007 12:06 PM

Message Edited by altenbach on 06-08-2007 10:07 AM