how to convert thermometer code to binary one ?

Discussion in 'Programmer's Corner' started by raika.sorena, Oct 23, 2013.

  1. raika.sorena

    Thread Starter New Member

    Oct 23, 2013
    2
    0
    Hi every one
    i want to convert a thermometer code with 119 bit to binary one in SIMULINK Matlab
    how i can do it?
    is there any block ?
    or
    how can i do it with a code ?
    is there any formula to convert thermometer code to binary ?
    please help me ASAP.

    best regards
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    What is a thermometer code?
     
  3. WBahn

    Moderator

    Mar 31, 2012
    17,788
    4,808
    It's basically a unary code (sorta) in which the value is equal to the number of leading bits of the same type (or one more than the value if 0 is a valid value). So you've got

    Value Encoding
    0 10
    1 110
    2 1110
    3 11110
    ..
    12 11111111111110
    ..


    @OP:

    There are several ways to approach this, depending on what your requirements and resources are. Are the bits coming in serially? Are they available in a vector all at once?
     
    JohnInTX likes this.
  4. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    If there is always 119 bits per sample, you can just get the average number of 1 bits per 119 bits to get an accurate reading. No counting or segmentation is needed, just real time averaging.
     
Loading...