01-30-2017 03:44 PM
Hey guys,
Still relatively new to labview but have run into a problem which I am pretty sure is a simple one. Ive got a VI here which takes two inputs from two enums (one containing the information X,Y and Z and the other containing A+B and A-B)
I want to mask off the bits coming out of the compound arithmetic and extract the axis and operation (represented as 0,1 or 2)
So if I choose Y and A-B, the axis will show 1 and 1
If i chose X and A+B the axis will show 0 and 0
If i chose Z and A+B the axis will show 2 and 0
if that makes sense. I know its something simple but I cant see it - Any help would be greatly appreciated.
Thanks!
Solved! Go to Solution.
01-30-2017 03:58 PM - edited 01-30-2017 04:01 PM
I'm not certain what you are trying to do, but I believe you issue is you aren't shifting the bits back. After the AND with 0b110000 you should logical shift back -4.
Why do you need to do this in the first place? If you what to combine two pieces of information into a single type, use the Bundle, or Bundle by Name making it into a cluster that can be more easily passed around and unbundled.
Oh and your Enums Axis and Operation can have their representation changed to a U8 so you don't need the conversion. Right click the control and go to Representation >> U8
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-30-2017 04:15 PM
Yep, just got this now haha. I shifted it back by -4 and the operation works as 0 1 or 2 (yay!) but now when i typecast it back to its original ENUM style, it only comes up as X or Z. (as in 0 = X, 1 = Z, 2 = Z) which is really confusing. Would anyone happen to know why this is?
Thanks!
Muri.
01-30-2017 05:06 PM
You really should type def your enums. That could be part of your problem.
You also do not need to use the AND for the axis representation. The logic shift will remove the lower bits for you.
01-30-2017 05:16 PM
Thanks for your help guys!
Changing the axis to a type-def does not solve my problem unfortunately. Must just be a little bug or something? Ill get some colleagues to check over my code to see that I havent missed anything - Unless you guys can see something?
Thanks again!
01-30-2017 05:37 PM
Just figured it out guys - since the value coming out of the and gate was an 8 bit and the input into the typecast is 16 bit, there was some weird conversion problem and the program seemed to forget the middle bit. Can be fixed by either changing the axis representation or by adding a U16 converter after the AND gate.
Thanks all for the help!!