![]() |
Forum Index : Microcontroller and PC projects : Voltage data stream disassembly.
Author | Message | ||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
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 Edited 2020-11-04 19:07 by retepsnikrep Gen1 Honda Insights. |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
Forgive me if I'm missing the point.. but if I convert Hex to Dec and plot I get: ![]() Ignoring the first and last points as they look definitely non linear (clipping at the highest voltage) --- you get a perfect linear relationship between V and your Hex (now in Dec) measures... Have I missed the point? Nim Entropy is not what it used to be |
||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
That's great if it's a simple linear relationship. Sometimes you just need someone on the outside to chip in. You can get stuck in a loop staring at data and i'm useless with Excel. 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 your 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 Gen1 Honda Insights. |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
![]() Always a fan of fresh eyes. Out of pure nosiness - what's your application? N Entropy is not what it used to be |
||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
Motor control.. ![]() Gen1 Honda Insights. |
||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
The values in the graph and formula look suspiciously like 127 or 128 am I missing something obvious with the conversion? Is it really decimal points maths on the voltage value to generate the hex? Gen1 Honda Insights. |
||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
This is another idea.. Output numbers = (Vin-10)*126 (could be more like 128 as it is then a left shift operation) So 100V - 10 = 90 * 128 = 11520 = $2D00 We had $2C30 for 100V in the table but that's not miles off and resolution won't be much better than a volt at best. Gen1 Honda Insights. |
||||
retepsnikrep![]() Senior Member ![]() Joined: 31/12/2007 Location: United KingdomPosts: 134 |
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 and ignore the lower nibble 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? Gen1 Honda Insights. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Go back to the first answer give. Convert the 16 bit HEX numbers into decimal. Lets call that 'reading' Volts = int(reading/126 + 10.8) Ignoring the first and last readings, that is close enough for me. I have tweaked the values to allow for rounding to whole volt values. Jim VK7JH MMedit |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |