How to isolate 10 bits from word variable?


Closed Thread
Results 1 to 7 of 7
  1. #1

    Question How to isolate 10 bits from word variable?

    Hello All: Could someone explain how to isolate just the 10 Most significant bits from a word variable?.

    Example:%1111111100000000 (16 bit word read from device)


    I would like to get this:

    My10Bits=%1111111100 (10 bits actual data)


    I am using PicBasic-Pro 2.50
    Thanks in advance
    Bob C.

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    A word consits of a high byte and a low byte. (see manual)
    There is also a shift (right) possibility in PBP. (>>)
    Only you have to copy the lsb of the high byte to the msb of the low byte after every shift.

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Also try, as suggested by Mat

    My16Bits = %1111111100000000
    My10Bits=My16Bits >> 6 ; lose the lower 6 bits (same as divide by 64)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4


    Did you find this post helpful? Yes | No

    Default Thanks Matt

    Thank you for your response:

    The problem I'm having is joining the entire Highbyte of the Word variable with the 2 MSB's of the Lowbyte to form my 10 Bits.

    I know I need to concatenate the bits together,but I am getting a bit frustrated by this...If you or anyone else can show me the coding syntax for this operation I would appreciate it.

    The concatenated bits will be placed in a word variable .

    Down and out
    Bob C.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Unhappy Rtfm !!!

    Pfouuuuuh !!!

    A is a Byte - Lower Part of THE 16bits value VAL
    B is a Byte - Higher Part ....

    VAL.Lowbyte = A
    VAL.Highbyte = B

    That'a All ...

    and VAL >> 6 is What you look for.

    Final point.


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6


    Did you find this post helpful? Yes | No

    Smile Thanks Everyone!

    I now understand the process!!!....ACE-I honestly RTFM but I guess I just was not understanding.

    In your honor Ace I have declared RTFM as a Word variable and will use it my program


    Again,thanks for helping me out gentleman!!

    Bob C

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


    Did you find this post helpful? Yes | No

    Default

    some may have learn from this RTFM expression

    http://www.rtfm.com/

    Some also did come cofee cup

    Steve

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

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  4. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 1

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