03-22-2019 07:03 AM
Hi
i have attached sample code and screenshot.first i configured each control for how much maximum bit i want to write.again i converted that decimal value into hexadecimal integer string for each control.again all bit i combined to make single hexadecimal frame(this should be 29 bit).now i want to pass these string in to U-32 bit indicator.but U-32 bit indicator not showing exact same value like frame.some MSB bit is missing.so please tell me where is the fault.
03-22-2019 08:52 AM
You are making mistakes on how you are merging numbers into hexadecimal digits.
Your first 12 bits you are converting into 3 hexadecimal characters. That is fine since hex character can handle 4 bits.
Then for bits 12 and 13, you are converting the bits to a hex character. which means they are either 0 or 1. So you are throwing off all data and the place values.
It is almost like saying the number 3 consists of 3 1's and thus writing it as 111.
What you need to do is use the bit shifting functions in the numeric data manipulation palette and using the AND function to combine the individual pieces into a single 32 bit value. You shouldn't be playing with string functions because it just doesn't work the way you are trying to force it to work.
03-22-2019 08:56 AM - edited 03-22-2019 08:58 AM
Hi rishijha,
why don't you follow my suggestions - and why did it take so long to provide an example?
(You could also achieve the same as RavensFan suggested: using AND, multiply and add functions. This is basic bit stuffing!)
03-22-2019 11:13 PM
Hi,
Your first 12 bits you are converting into 3 hexadecimal characters. That is fine since hex character can handle 4 bits.
so if my number is combination of 4bit 8bit and 12bit like that then i can use same what i have followed programming.
What you need to do is use the bit shifting functions in the numeric data manipulation palette and using the AND function to combine the individual pieces into a single 32 bit
can u share some example??
03-23-2019 12:03 AM - edited 03-23-2019 12:05 AM
@Risuraj wrote:What you need to do is use the bit shifting functions in the numeric data manipulation palette and using the AND function to combine the individual pieces into a single 32 bit
can u share some example??
Well, you would mask with AND (In case there are stray bits outside the valid range), shift accordingly, and merge with OR.
Here is a simple example, see if it makes sense (assuming the input is an array, but you can always build one if needed ;)):
03-23-2019 02:50 PM
The above solution is the most generic and can be adapted more easily to new scenarios because only one simple array of counts needs to be changed. If performance is absolutely essential, you can of course pre-compute the masks and shifts (e.g. using the above code ;)) and do as follows:
03-23-2019 02:56 PM - edited 03-23-2019 03:34 PM
And if you can somehow guarantee that the input is clean and there are no stray bits outside the valid range for each input value, you can even omit the masking. Masking was just for safety, but always a good idea. 😄