In the absence of a method of posting an Excel spreadsheet, here is a list of the code used. This may or may not work as shown using Google Sheets (or any other spreadsheet). If not, the spreadsheet likely has a function similar but with slightly different implementation.
I had a bunch of PIDS and MTH’s to create formula from. This really simplified the process. Plus it eliminated “I did it wrong errors”.
Implement the equations in Excel as shown and it should work as mine does. There may be better, easier or more efficient ways to perform the task of parsing the MTH data for the equations …. but this works. For that matter, it could be built into the Torque application so that you’d enter the MTH data and Torque parsed it for you…Ian?
Inputs:
D7 = RXF value (example: 032180000000 )
D8 = RXD value (example: 2810 )
D9 = MTH Value (example: 00070064FE70 )
Create the following cells:
CELL FORMULA
F7 =MID(E7,5,1)
F8 =MID(E8,1,2)
G8 =MID(E8,3,2)
F9 =MID(E9,1,4)
G9 =MID(E9,5,4)
F10 =HEX2DEC(F9)
G10 =HEX2DEC(G9)
J6 “EQUATION—>”
K6 =CONCATENATE(“((“,K8,”*”,K10,”/”,K7,”)”)
K7 =IF(F7=”4″,100,IF(F7=”8″,10,1))
K8 =IF(G8=”10″,”((A*256)+B)”,”A”)
I9 =MID(H9,1,1)
J10 =IF(OR(I9=”F”, I9=”E”, I9=”D”, I9=”C”, I9=”B”,I9= “A”, I9=”9″, I9= “8”),”-“,””)
K10 =CONCATENATE(“(“,F10,”/”,G10, “)”,H11,”)”)
H9 =MID(E9,9,4)
H10 =MOD(HEX2DEC(H9)+2^15,2^16)-2^15
H11 =TEXT(H10,”+#,###;-#,###;+0″)
The final equation is located in Cell K6
Note:
Let’s say your equation looks like this: (A*(100/255)+0)/1)
Looking at the part that looks like: +0)/1)
In math equation terms:
+0 adds nothing to the value and
/1 does nothing to the value
As such, both can be eliminated (or left in … your option) from the equation so that it looks like this:
(A*(100/255))
They are there because I did not complicate the tool to automatically eliminate them.
Note also that extra parenthesis pairs can also be eliminated (optional). If the parenthesis don’t balance, balance as needed
———————–
If you are copying text from elsewhere and it looks like this:
TXD: 07E021D9
RXF: 032180000000
RXD: 2810
MTH: 00070064FE70
NAM: TFT
Paste into C23, C24, C25, C26, C27 respectively.
The following formulas will parse out the data from the text automatically from C23, C24, C25, C26, C27. Then you can COPY and PASTE SPECIAL – PASTE_VALUES into the above cells D7, D8, D9. Or set D7:=E23, D8: =E24, D9: =E25 to get the data automatically from E23,E24, E25)
Note: The ID and Value need not be typed into cells and are shown for reference only. When I created this post, some of the formatting was lost and makes the following a bit harder to read. The first line shows the ID, the 2nd line shows the value and they alternate from there. Dashes were added to trick the forum tool to help with spacing.
Address____Formula _______________________ID_______Value
D23 =MID(C23,1,FIND(“:”,C23,1)) _________ TXD:
E23 =TRIM(MID(C23,1+FIND(“:”,C23,1),30)) _____________ 07E021D9
D24 =MID(C24,1,FIND(“:”,C24,1)) _________ RXF:
E24 =TRIM(MID(C24,1+FIND(“:”,C24,1),30)) _____________ 032180000000
D25 =MID(C25,1,FIND(“:”,C25,1)) _________ RXD:
E25 =TRIM(MID(C25,1+FIND(“:”,C25,1),30)) _____________ 2810
D26 =MID(C26,1,FIND(“:”,C26,1)) _________ MTH:
E26 =TRIM(MID(C26,1+FIND(“:”,C26,1),30)) _____________ 00070064FE70
D27 =MID(C27,1,FIND(“:”,C27,1)) _________ NAM:
E27 =TRIM(MID(C27,1+FIND(“:”,C27,1),30)) _____________ TFT
|