Jump to content

Conversion and Calculations in LabView


MUSA

Recommended Posts

Hello every one.

I want to do the following procedure in LabView, and I shall be thanks full if some one can help me to do that . I am new user of LabView.

Steps:

I am receiving a two byte data in LabView from the hardware I am using (the data is the input voltage to the board). I want to

1. Switch the positions of the data bytes and then convert the decimal value in these two bytes in to hexadecimal value individually.

2. Then add these two hexadecimal values and convert it in to decimal again as shown in example below.

3. The decimal value I will get i will want to divide that value with the number "8241.5" and after that the answer I will get I want to plot that floating number into the graph.<br style=""> <br style="">

<b style="">I want to do the following steps in the LabView<br style=""> <br style=""> </b>

Example:

Step 1:

(The actual data i received).

byte [0] = 251

byte [1] = 202

Step 2:

I want to switch these two bytes as

byte [0] = 202

byte [1] = 251

Step 3:

then convert each byte into the hexadecimal individually.

byte [0] = 202 = 0xCA

byte [1] = 251 = 0XFB

Step 4:

Combine these two hexadecimal values and convert it into the decimal again

CAFB = 51963

Step 5:

Divide this value from the decimal number "8241.5"

51963/8241.5 = 6.3

Step 6:

in the last step plot this number “6.3” in to the graph as a voltage. I mean how can I draw this voltage of 6.3 in a graph. I shall be very thanks full if some one can make this VI for me or guide me how to make this in LabView.

Best Regards.

Link to comment

Hi MUSA

Have a go at searching the palettes for the following functions in order to solve your problem.

Cheers

-JG

There is a much more straight forward method if he is only interested in the numeric aspect of the conversions. The whole thing can be done numerically without the need to convert the numbers to strings.

post-4959-126167210998_thumb.png

Link to comment

There is a much more straight forward method if he is only interested in the numeric aspect of the conversions. The whole thing can be done numerically without the need to convert the numbers to strings.

Very nice, but not what he asked for :P

Maybe he has to log the hex string???

Link to comment

...well... in that case:

post-9667-126167394444_thumb.png

;)

My first though was to use the join numbers but for some reason I had a mental block when I actually whipped up the example and used the shift and the add VIs.

However the main reason I posted the alternative solution was that the OP may not have been aware it could be done without all the string conversions. Unless required for something specific his procedure required lots of extra work to accomplish a very simple task.

Link to comment
However the main reason I posted the alternative solution was that the OP may not have been aware it could be done without all the string conversions. Unless required for something specific his procedure required lots of extra work to accomplish a very simple task.

Yes, yours was a much better solution - mine officially sucks :)

I didn't even think down that path - just followed the steps!!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.