Recording of Temperature Control Readings (Packet Structure & Decoding)

Discussion in 'The Projects Forum' started by aac52, Sep 6, 2015.

  1. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    I've recorded some packets from a device which uses two lines to send them; clock, and data.

    The device is a temperature controller, and these are the output packets being sent to the dual 7-segment temperature display controller.

    Been scratching my head for a while now, but can't seem to see anything obvious that relates the data I have to their "true" values.

    Each packet consists of 7 bytes, and only the 5th byte changes.

    Below are all of the temperature packets in HEX.

    Code (Text):
    1. FF 7F 3E FE DA FF 3E // 16
    2. FF 7F 3E FE 1A FF 3E // 17
    3. FF 7F 3E FE EA FF 3E // 18
    4. FF 7F 3E FE 2A FF 3E // 19
    5. FF 7F 3E FE 4A FF 3E // 20
    6. FF 7F 3E FE 8A FF 3E // 21
    7. FF 7F 3E FE F2 FF 3E // 22
    8. FF 7F 3E FE 32 FF 3E // 23
    9. FF 7F 3E FE 52 FF 3E // 24
    10. FF 7F 3E FE 92 FF 3E // 25
    11. FF 7F 3E FE 62 FF 3E // 26
    12. FF 7F 3E FE A2 FF 3E // 27
    13. FF 7F 3E FE C2 FF 3E // 28
    The "true" values are at the end of each line, after the "//".

    Below is the binary representation of just the 5th byte from each packet.

    Code (Text):
    1. 1101 1010 // 16
    2. 0001 1010 // 17
    3. 1110 1010 // 18
    4. 0010 1010 // 19
    5. 0100 1010 // 20
    6. 1000 1010 // 21
    7. 1111 0010 // 22
    8. 0011 0010 // 23
    9. 0101 0010 // 24
    10. 1001 0010 // 25
    11. 0110 0010 // 26
    12. 1010 0010 // 27
    13. 1100 0010 // 28
    There must be some kind of reasonable way to determine the temperature from the packet without the need for a look-up table, but I just can't figure it out!

    Any help would be greatly appreciated.
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    There is a pattern. If you read the bits of the 5th byte from right to left and ignore the left-most bit then the values are in a descending sequence.
     
    aac52 likes this.
  3. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    So obvious now... I knew it couldn't be that obscure, but when you've been looking at those 1's and 0's for a day, things start looking a bit odd.

    Thanks so much for the help!
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    Ah, that's the ticket! I had a suspicion that the values were read right to left. Dropping the last bit was the piece I was missing.

    Here is a C function to map the decoded values to the "true" results. Note that '*_in' is the decoded values and correspondingly '*_out' is the "true" values.

    Code (C):
    1. long map(long x, long in_min, long in_max, long out_min, long out_max)
    2. {
    3.   return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    4. }
    5.  
     
  5. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    By my reckoning the left-most bit is a parity bit.
     
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,652
    766
    Sorry Alec,

    Can you work out in detail just any two of them? You said "descending".

    Not my best day today.

    /EDIT

    Now I understand: I was trying to match your process with the decimal numbers on the right as provided by the OP which I conclude, are not correct. That's why.

    Checked again the three bottom ones: 35, 34 and finally 33. Descending.

    Gracias.

    EDIT/
     
    Last edited: Sep 6, 2015
  7. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Hi Agustin.
    Consider the first two values in the table showing the 5th byte.
    Ignoring the left-most (parity) bit and reading bits from right to left, true value 16 reads as 0101 101 whereas true value 17 reads as 0101 100, i.e. is one less.
     
  8. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    It does indeed, seems to be odd parity
     
  9. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    The "true" values at the end are what the temperature read out on a display is for that packet.

    So what I mean is that when the first packet is sent, the reading on the temperature display is 16 degrees, and so on.

    I guess my original question may have been a little ambiguous, and I was trying to find the pattern, rather than specifically relating the packets to the "true" value, since when you have the pattern, in this case descending by one each time, it is easy to offset the packet values to get the true value.

    There is actually more to this problem than I originally posted, and given the interest and lightning quick responses I'll definitely be updating this thread with the progress I make.

    I have been using a logic analyser to read the data, but am now working on writing some code to read the values using an Arduino. Seems to be a little more difficult than anticipated though, since when I plug the clock and data lines from the temperature controller into the Arduino input pins, the temperature controller is not happy at all...
     
  10. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,652
    766
    OK AAC,

    So, the values after // are "actually displayed values". I feel better now. I was trying to match them straight...! :(

    The point then is to find how the algorithm (or is it a hardware display decoder) comes to those displayed ones.
     
  11. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,652
    766
    Hola again AAC,

    What is the maximum temperature that the display is supposed to show?

    Thinking in loud voice: values as per Alec's sequence, (45 to 33), deducted from 61 give (16 to 28). Maybe there is a way there. (Yes you said offset).
     
  12. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    16 to 28 is the full range that the display shows, or at least, those are the maximum values this temperature controller allows the temperature to be set at.
     
  13. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    Found out the issue I was having.

    I was assuming that the temperature control unit was sending clock pulses and data, but when I disconnected the display I could not pick up any packets on the Arduino.

    I set up my logic analyser to output one of the packets I recorded earlier, and it was registering fine on the Arduino so I assumed my code was okay. Decided to do a bit more probing and it turns out the display unit actually sends the clock pulses, which ironically makes the code easier for me since I can just request data whenever I want it.
     
  14. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    Do you know what the values corresponding the the largest an smallest input value? Decoded, not encoded. Thus "1101 1010" decodes to decimal 87.

    With those maximum and minumum values and their corresponding display values, the equation for the display value given any input was posted in post #4.
     
  15. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,652
    766
    Not C conversant myself but thanks djf
     
Loading...