PDA

View Full Version : Combination from binary bit to Hexdecimal



Ann_BBO
10-19-2009, 02:01 AM
Hi All,

I have a question about the binary to hex problem in excel sheet. For the file structure, please see the attached excel file.

Column B is the hex value with 2 Bytes format. (e.g. 0xFFFF) regarding to combination of Column G. The setting value in column G base on the Column E (bits offset) and Column F (bit size). This is the default value. All these values take as references.

Example:
Column .......B .............E ................F ..............G
Description Value ......Bit offset...Bit size...Default value
.......................0xC034...0 .................4 ............0x0004
......................................4................. 8 ............0x0003
......................................12.............. .3.............0x0004
......................................15................ 1 ...........0x0001

Explanation of Combination of “0xC034” is
15 11 7 3
1100 0000 0011 0100

Now, Column C is the new changed value and Column H are the “Changed value” (hex format) regarding to combination of G and H. If H column has a new value, ignore the “Default value”. Combination of G and H will create the new value in column C.


Example:
Column .......B........... C......... E............... F........... G..................... H
Description Value.. .New ....Bit offset Bit size Default value Changed
.......................0xC034..0xB031.0.............. 4............ 0x0004............. 0x0001
...................................................4.............. 8............ 0x0003
...................................................12............ 3............. 0x0004 ............0x0003
...................................................15............ 1.............. 0x0001

Explanation of Combination of “0xB031”
15 11 7 3
1011 0000 0011 0001

Another problem is the Bit size checking. Since the Column H value are fixed by Column F (Bit size). If the actual bit size of “Changed value” is bigger than Bit size setting.

Example:
Column ........F............H
Description Bit size Changed
.......................3.............0x0008
Since 0x0008 has more than 3 address bits (i.e. 1000 b) is larger than 3 bit size.
Give the warning and no update on "Changed Value".

Thanks,
Ann
2009-10-19

Bob Phillips
10-19-2009, 03:34 AM
I have a question about the binary to hex problem in excel sheet. For the file structure, please see the attached excel file.

Column B is the hex value with 2 Bytes format. (e.g. 0xFFFF) regarding to combination of Column G. The setting value in column G base on the Column E (bits offset) and Column F (bit size). This is the default value. All these values take as references.

Example:
Column .......B .............E ................F ..............G
Description Value ......Bit offset...Bit size...Default value
.......................0xC034...0 .................4 ............0x0004
......................................4................. 8 ............0x0003
......................................12.............. .3.............0x0004
......................................15................ 1 ...........0x0001

Explanation of Combination of “0xC034” is
15 11 7 3

Where does 15 11 7 3 come from?


1100 0000 0011 0100

15 11 7 3 is 1111 1011 0111 0011 not 1100 0000 0011 0100


Now, Column C is the new changed value and Column H are the “Changed value” (hex format) regarding to combination of G and H. If H column has a new value, ignore the “Default value”. Combination of G and H will create the new value in column C.

You want something to happen when the user changes column C?

Ann_BBO
10-19-2009, 03:50 AM
Hi xld,

"15 11 7 3" is the address bit. I am going to explain how to form 0xC034 value.
(i.e. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) <-- Total 16 bit size
= 1100 0000 0011 0100 <-- (i.e. 0xC034 in binary format.)

I want something change when column H is changed. Column C value is combined from Changed value (if no value in column H, use column G.)

Sorry for my misleading.

See the attached excel files will be more clearly understanding.

Thanks,
Ann

Bob Phillips
10-19-2009, 04:00 AM
I think I can see that you mean 15 0 3 4 not 15 11 7 3 which equates to C034 and closer (but not exactly) to the binary layout you gave, but I still have no idea how 15 0 3 4 is arrived at.

And no, the file doesn't make it any clearer for me, AND you have nasty merged cells which always make life harder.

Ann_BBO
10-19-2009, 09:59 AM
Hi xld,

Thanks for your reply. Let me to explain how to form the value "0xC034".

Example:
Column .......B ..................E ............ F ..............G
Description Value ..............Bit offset...Bit size...Default value
.......................0xC034......0 ............4 ............0x0004
......................................4..............8 ............0x0003
......................................12............3.............0x0004
......................................15............1 ...........0x0001

"Bit offset' is the starting address bit where "Bit size" is the offset address bit inclusive with "Bit offset". For example, "Bit offset"=0 and "Bit size"=4 means it has "3rd 2nd 1st 0th" total 4 address bit start from 0th address bit (binary form). Default value = 0x0004 (hex format) is fulfill the bit size requirement since the binary of "0x0004" is "0100 b" which has 3 address bit and smaller than 4 bit size.

Again, if "Bit offset" = 12 and "Bit size" = 3. It means the address bits has "14th 13th 12th" total 3 address bit. If the default value = "0x0004". Since "0x0004" has the 3 address bit which is "0100 b" and fulfill the bit size reqirement. However, if this value are set to "0x0008". It will be wrong sicne "0x0008" has the 4 address bit which is "1000 b" bigger than bit size.

Finally, "Bit offset" = 15 and "Bit size" = 1 means that it only have the "15th" a 1 address bit. Therefore, user will only input "0x0001" or "0x0000" as the address bit is 1 in binary form.

Combine "15th 14th 13th 12th" value, we have "1100 b" binary form. Therefore, it is "C" in hexdecimal or "15".

I hope that it can help you to understanding.

Thanks,
Ann

Ann_BBO
10-20-2009, 02:20 AM
Hi xld,

Do you understand my explanation? Let me know if you have any questions. Thanks

Best Regards,
Ann