Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/29/05 23:19
Read: times


 
#96256 - Still Confused
Responding to: ???'s previous message
Ivan Azuara said:
Yeah, i make a mistake with the question, i get 8 bits and i whant to convert that 8 bit number in 2 bytes decimal.

You mean you want to convert the 8-bit number to two ASCII-coded characters.

ASCII is a 7-bit code, usually held in a byte with the top bit zero.
So, each byte of ASCII code represents a single character - such as '6' or '4' or 'A'

if i get 1000000 i whant to send to the serial port 64

1000000 in binary = 100 in Octal = 40 in Hex = 64 in Decimal = LXIV in Roman Numerals

See: http://www.8052.com/forum/read.phtml?id=67434
and: http://www.8052.com/forum/read.phtml?id=65390

So, if you want to send the ASCII-coded representations to the serial port, you would need to send:
  • For the binary representation: An ASCII-coded '1' character, followed by six ASCII-coded '0' characters - a total of seven characters, therefore requiring seven bytes.

  • For the octal representation: An ASCII-coded '1' character, followed by two ASCII-coded '0' characters - a total of three characters, therefore requiring three bytes.

  • For the hex representation: An ASCII-coded '4' character, followed by an ASCII-coded '0' character - a total of two characters, therefore requiring two bytes.

  • For the decimal representation: An ASCII-coded '6' character, followed by an ASCII-coded '4' character - a total of two characters, therefore requiring two bytes.

  • For the Roman representation: An ASCII-coded 'L' character, followed by an ASCII-coded 'X' character, followed by an ASCII-coded 'I' character, followed by an ASCII-coded 'V' character - a total of four characters, therefore requiring four bytes.

    Are you getting the idea...?

    if the value is 01000011 i get 2 bytes 43 that is the Hex value

    No.
    Each Hex digit represents four bits - so 43 hex is just one byte.

    However, if you want to represent this by sending ASCII-coded characters over the serial port, you need two characters - a '4' followed by a '3'
    Since each ASCII code for a character requires a byte, that means two bytes.

    You can look-up the byte values of the ASCII codes for '4' and '3' in an ASCII table - see the link elsewhere.


    Of course, all of this is just a restatement of http://www.8052.com/forum/read.phtml?id=94478 - have you read it yet?


  • List of 14 messages in thread
    TopicAuthorDate
    ASCII TO DECIMAL            01/01/70 00:00      
       re: ascii to decimal            01/01/70 00:00      
       DS1620 - ASCII???            01/01/70 00:00      
          9 bits            01/01/70 00:00      
             So not ASCII, then!            01/01/70 00:00      
       The Othe way around            01/01/70 00:00      
          Not ASCII            01/01/70 00:00      
             Still Confused            01/01/70 00:00      
                i whant to do this            01/01/70 00:00      
                   Re-read Neil's post!            01/01/70 00:00      
                   It was discused al least..... a lot but:            01/01/70 00:00      
                      You only forgot ...            01/01/70 00:00      
                      For Ivan            01/01/70 00:00      
       resource            01/01/70 00:00      

    Back to Subject List