AC Drive China Forum
Forum » PLC - Programmable Logic Controller » Hexadecimal
Topics: Hexadecimal on PLC - Programmable Logic Controller
#1
Start by
Brian Jones
10-26-2013 09:15 AM

Hexadecimal

I am stumped. I had a question on my pre-test that looks like this convert binary
101010111110 into Hexadecimal. Came up with a really long number. 17592186044416 and then I was going to try and put that number into ABCDEF. It does not work that way. Can someone explain where I went wrong??
10-26-2013 11:52 AM
Top #2
Brian Jones
10-26-2013 11:52 AM
Do you use base 2 or base 16 when converting?? I will try Base 2 tomorrow..
10-26-2013 02:45 PM
Top #3
Dean Lefebvre
10-26-2013 02:45 PM
Binary, base 2 = 101010111110
hexadecimal, base 16 = 0xABE
decimal base, 10 = 2750.

The first four bits 1010 = A
The second four bits 1011 = B
The third four bits 1110 = E
10-26-2013 04:59 PM
Top #4
Dean Lefebvre
10-26-2013 04:59 PM
third four digits = 1110 = E hex = 14 decimal
28 decimal would be 1C or 11100 binary
i.e. 1 hex = 0001 = 1 x 16^1 = 16 decimal
C hex = 1100 = 12 x 16^0 = 12 decimal

16 decimal + 12 decimal = 28 decimal

0000 = 0 = 0
0001 = 1 = 1
0010 = 2 = 2
0011 = 3 = 3
0100 = 4 = 4
0101 = 5 = 5
0110 = 6 = 6
0111 = 7 = 7
1000 = 8 = 8
1001 = 9 = 9
1010 = A = 10
1011 = B = 11
1100 = C = 12
1101 = D = 13
1110 = E = 14
1111 = F = 15
10-26-2013 07:46 PM
Top #5
Brian Jones
10-26-2013 07:46 PM
Dean, I found I did the math wrong. I have it!. Thank you for your input!
10-26-2013 10:06 PM
Top #6
Wojciech GOMOLKA
10-26-2013 10:06 PM
Dear Brian and Dean,
Are you sure? 1C hex represents a word. But a word can be written in Big Endian or Little Endian mode. So if it's Big Endian 0x1C is exactly 28, but in Little Endian mode 1C become 193 decimal. But that is another philosophical topic of industrial computing.
10-27-2013 12:07 AM
Top #7
Dean Lefebvre
10-27-2013 12:07 AM
Good point,

I think the way it should be written is with the most significant bit first. The Endianess concept just developed to get around some hardware limitations.
10-27-2013 02:54 AM
Top #8
Jeffrey T. Johannessen, MBA
10-27-2013 02:54 AM
Endian only matters when you store the data in memory. When you are converting from binary to hex, you tak it 4 bits at a time. Right most is the LSB, left is the MSB.
Reply to Thread