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
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?
1 Attachment(s)
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
Attachment 8963
Hope this helps
Re: How is this data being formed from the values given?
Thanks for that very interesting..
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
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
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.
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, :confused: 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?
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
Re: How is this data being formed from the values given?
Thanks I think I have it now..