How is this data being formed from the values given?


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

    Default How is this data being formed from the values given?

    I have a device that accepts volts and squirts out two bytes of data shown below which represent the volts. I sent some accurate volt tests into it and got the following.

    How are they getting those numbers from the volts and vice versa?

    I have played around with various highbyte and low byte ideas and can get near but not near enough. Multiplying the first byte, adding the second etc etc.

    I can get near at 50V but then it's wildly out at others..

    0V * = $0000
    10V *= $0010
    20V *= $0500
    30V *= $0970
    40V *= $0E70
    50V *= $1360 *If we just take the decimal of this = 4960, it could be right..
    60V *= $1860
    70V *= $1D60
    80V *= $2250
    90V *= $2740
    100V= $2C30 However the decimal of this 11312 is off by miles.
    110V= $3130
    120V= $3620
    130V= $3B10
    140V= $4000
    150V= $4470
    160V= $4970
    170V= $4E72
    180V= $5352
    190V= $5862
    200V= $5B52

    If we can't find the formula/logic they are using perhaps it is a look up table and i could plot these points on a graph to reproduce it in excel?

    THere could be a flag bit in the data when it goes to 170V and above.. That errant 2 on the end maybe!

    The data it outputs is unlikely to be super accurate but it would certainly be within a couple of volts.

    In the past in a similar device the data was in a single byte which was doubled to give the voltage. So $32 = 50 decimal = 100V

    This is more recent and probably more accurate.

    Grateful for any ideas or thoughts? *Thanks
    Last edited by retepsnikrep; - 4th November 2020 at 10:08.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    It looks like the voltage is in the high byte and the high nibble of the low (second) byte.

    The lower nibble of the low (second) byte is probably flags.

    So simplifying my formula slightly and converting say 100V into the hex =

    (100 x 126) - 1286 = 11314 = $2C32

    Then AND $F0 to mask out the lower nibble or the low byte gives $2C30


    The values in the formula look suspiciously like 127 or 128 am I missing something obvious with the conversion?

    Is it really maths as shown on the voltage value to generate the hex?

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    After a little analyses, this is what I got

    Output numbers = (Vin-10)*126 (could be more like 128 as it is then a left shift operation)
    So, converting into a table, this is what I see
    Name:  Screenshot from 2020-11-05 08-16-12.png
Views: 377
Size:  62.4 KB

    Hope this helps

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Thanks for that very interesting..

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    there's few things the arduino community have not hacked into if its at all possible
    a google search for "arduino & 'my secret unmentionable device' " might yield some results
    Warning I'm not a teacher

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Hi, Peter

    I suggest you to try :

    count = ( 1001 x Voltage - 9891 ) / 8

    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 " !!!
    *****************************************

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Thanks again for the ideas. Alain what makes yours special/sneaky?

    I note that in my original table the 3rd character of the hex words 100V = $2C30 (3) in this case is never a letter A,B,C,D,E,F
    Either I got lucky with my samples or something else is happening.

    I was wondering if we are seeing the output from a 12bit ADC 4096 packed into those twelve bits.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Sorry I'm still a bit stuck.

    Looking at this again lets assume my voltage data is being encoded into a 3 digit hex humber. (12 bits)? or is it a raw 10 bit non justified ADC result I am seeing?

    Lets take 100V as an example $2C3 = 707

    The position 3 is never > 7 and varies between 0 and 7 as the voltage rises and falls.

    That feels significant, so what is going on?

    150V for example = $447 = 1095

    Grateful for any other ideas.

    Or alternatively how can I prevent anything other than 0-7 appearing in the result?

  9. #9
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Hi Peter

    Let us walk through this as per what I suggested

    (100V-10)*126 = 11340 = $2C4C
    (150V-10)*126 = 17640 = $44E8

    Now suppose we drop the last nibble( divide by 16), you get $24C and $44E which is pretty close to the numbers you're seeing. So, the error must be in the formula being an approximation.

    Hope this makes it easier for you to solve the issue

    Regards

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: How is this data being formed from the values given?

    Thanks I think I have it now..

Similar Threads

  1. need eeprom to save values
    By queenidog in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 10th July 2014, 01:16
  2. linear data memory & large data arrays
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th June 2011, 00:21
  3. Port Values
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd January 2007, 21:44
  4. t in POT, c's values
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th August 2006, 00:30
  5. Numeric Values
    By Armando Herjim in forum General
    Replies: 8
    Last Post: - 28th June 2006, 02:54

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