Binary to BCD conversion


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Binary to BCD conversion

    Thanks for your reply. I am a little confused though, does this convert to ASCII rather than BCD?
    I think I misunderstood the question, I thought BCD was a way of expressing a binary value as ASCII characters. So for example a byte would become two ASCII chars, a word 4 ASCII chars etc.
    George

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Binary to BCD conversion

    John, If you limit the accumulated value to say 5 digits as in a word (65535 max) then you can use it without LONG's. I use this method to display MPH with 3 decimal places on a terminal thru a serial port by adding:

    TX_BYTES(TX_OUTPUT) = $30 + VALUE DIG JUNK 'Turn decimal value into ASCII
    Dave Purola,
    N8NTA
    EN82fn

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Binary to BCD conversion

    Dave,

    Interesting approach, seems like I got too bogged down in shifting and adding multiple times rather than using the more obvious arithmetic capabilities of PICBASIC.

    George,

    Thanks for the hint on conversion to ASCII, I'm sure it will come in useful at some stage.
    For info, BCD represents the decimal digits 0-9 using a nibble of data. With BCD only the states 0-9 are valid. 0xA to 0xF are forbidden. Its used for seven segment displays, real time clock modules, etc.

Similar Threads

  1. Trouble Reading Binary or BCD from a GPS
    By gavo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th August 2011, 18:27
  2. Nice tutorial on BCD to Binary
    By lerameur in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th December 2010, 18:21
  3. PIC16F628 - Convert Binary to BCD?
    By steng in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th March 2009, 08:17
  4. BCD conversion
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th October 2005, 19:24
  5. HEX to BCD conversion
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd February 2005, 14:39

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts