LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

c to labview

I have converted the following code from C to Labview, it does not seem to be giving me the same results. Anyone knows whats wrong?
Download All
0 Kudos
Message 1 of 5
(4,238 Views)
Well, for one thing you're shifting in the wrong direction. As the help for the "Logical Shift" says:
"If y is greater than 0, the function shifts x left y bits (from least significant to most significant bit) and inserts zeros in the low-order bits. If y is less than 0, the function shifts x right y bits (from most significant to least significant bit) and inserts zeros in the high-order bits"
Thus, to shift right you need negative values.

Also, the constant of "20" is not the same as "0x20", which is the hex value of 20, which is decimal 32 (a space character). To specify a numeric constant in hex values, right-click on the constant and select "Format and Precision". Select "Hexadecimal" from the listbox. You should also change to the "Appearance" tab and check the box "Show Radix". This will display a little "x" inside the left border to indicate it's a value in hex.

Also, it seems you're assuming the frequency is entered in MHz, since you're dividing by 2.8, whereas the C code was dividing by 2.8e6, so it was assuming the frequency was in Hz.
0 Kudos
Message 2 of 5
(4,216 Views)

Thanks for your help. One more thing to verify I am doing the right thing. About the frequencies you are right I am using Mhz while on the other program we used Hz. I have updated the Vi with your recommendations and I have attached the code. Does it look right to you?

 

0 Kudos
Message 3 of 5
(4,196 Views)


@bob.k wrote:

Thanks for your help. One more thing to verify I am doing the right thing. About the frequencies you are right I am using Mhz while on the other program we used Hz. I have updated the Vi with your recommendations and I have attached the code. Does it look right to you?


It's a bit cheap to have someone who gave you so good advice to try to get to review your software for you. I mean what does it cost to verify practically that the software does what it should do and simply post a

Thanks a lot your suggestions helped me make this work!

After all you are the one supposed to know what the software should do and are in the prime spot to be able to test that.

Rolf Kalbermatter

Message Edited by rolfk on 10-10-2007 07:55 AM

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(4,175 Views)
Well, you made the changes, but other than that, I don't really know how to answer the question "Does it look right to you". If you're referring to the actual changes you made, well for one thing you don't need to use the negate operation. Just change the constant values from, say, 16 to -16. (Though as a side note, you've made it into our Rube Goldberg Code thread with that.) If you're asking about coding style, the wires can be straightened out, but you can read the LabVIEW Style Guide (available with the LabVIEW documentation) for that. If you're asking does it do the same thing as the C code, well, I don't know since I haven't looked at the C code in detail, but you can easily get expected output for certain inputs out of the C code and see if the VI gives you the same thing. Since you can run the C code you're the one who can best do that.
0 Kudos
Message 5 of 5
(4,128 Views)