09-14-2010 02:23 AM - edited 09-14-2010 02:25 AM
Hi,
I have this data which is in the format of 16 bit. Now i need to convert it to a 14bit(0-13) twos complement. bit 14 and 15 will be some flag clear status. The data will be in 14 bit 2s complement HEX.
For eg. 0x0001 = 1 LSB, 0x0000 = 0 LSB and 0x3FFF = -1 LSB.
How can i implement this? Please advise. Thank you.
09-14-2010 02:47 AM
Hi,
I assume in 14Bits:
0x1FFF is the maximal positive value.
0x3FFF is -1
Is right for you ?
May be a way:
try all your operations in 16bits,
At the end, compare if > 0x7FFF (or if 16bits sign bit is set),
if true, make a right shift register of 2bits. This will convert your value in 14Bits digit.
if false, make a logical AND with 0x1FFF.
Best regards
Nicolas
09-14-2010 06:08 PM
see attached file
09-15-2010 12:11 AM
Hi Kate,
Is it possible to change I16 to a DBL? What are the things that i need to change? This is because i will have floating numbers.
09-15-2010 12:15 AM
Hi nferry,
you are right, the MSB of the 14bits will be the sign. No wonder i don't get the correct result because i looked at it the wrong way. I manage to get the desired result already. Thank you.
09-15-2010 01:39 AM
Hi all,
problem solved. Because i need to scale to by 0.05 first. for e.g. my reading is 10.55, then i need to scale by 0.05 which gives me 211 which will not have the floating number problem. Thank you to everyone!
09-16-2010 01:48 AM
Hi all,
I am trying to do a separate part on read via RS232 so i tried one of the solution in this forum for the read part. I found that in the data that i am sending in the string, there is a 16bits 0 that is infront of each data. May i know if this is correct in rs232 communication or that i have done things wrongly in my attached vi. Please advise. Thank you.