BCD conversion


Closed Thread
Results 1 to 10 of 10

Thread: BCD conversion

Hybrid View

  1. #1
    Macgman2000's Avatar
    Macgman2000 Guest

    Question BCD conversion

    Hello All,

    I have 3 bytes that represent a value 122880 . The problem is that the 3bytes are backwards in bit order.......

    regular binary 122880 = (msb) 00000001 11100000 00000000

    My buffer reads 122880 = (lsb) 00000000 00000111 10000000

    How do I take the 3bytes that are backwards in bit order and convert it to BCD or to something I can throw up on an LCD.

    Best Regards,
    Nick

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it's sounds familiar...
    http://www.picbasic.co.uk/forum/show...=reverse+order

    regular binary 122880 = (msb) 00000001 11100000 00000000

    My buffer reads 122880 = (lsb) 00000000 00000111 10000000
    How do you get those bytes??? let's say by serial com... why not... it's possible
    Code:
    b0 var byte
    b1 var byte
    b2 var byte
    w1 var byte
    w0 var word
    
    hserin [b0,b1,b2]
    w1=b2 rev 8
    w0.highbyte=b1 rev 8
    w0.lowbyte=b0 rev 8
    hserout [bin8 w1,bin16 w0]
    now i leave you with the pleasure of doing some math and use modifiers like DEC, DIG and all the others.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Just curious. If you're shifting in data LSB first, and this results in your data
    being backwards, what happens if you shift in your data MSB first?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i had this idea... but since we don't know how and where it come from...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Bruce & Steve,

    I guess Nick is receiving the bits from an external Master talking:
    "Chinese Protocol"

    See here for reference
    Last edited by NavMicroSystems; - 1st August 2005 at 22:06.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Nick,

    how are you getting on with the project?
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. A/D conversion problem in 18F2520, 2523, 2550 etc.
    By selimkara in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 10th March 2008, 16:26
  3. Rotary BCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 03:04
  4. Strange A/D conversion...
    By Christos_K in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th June 2005, 01:35
  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