Hi,
I don't get it.... $18 and $7F is 24 and 127 respectively. Putting these in the formula should result in "real life values" ranging from -100 to 50 representing the current in amperes, correct?
((0*128)+0-2048) / 20.48 = -100 OK
((24*128)+127-2048) / 20.48 = 56 ??
Next question is what you're going to do with the values? If you're displaying them to a human then it makes sense to scale them properly but of you're continuing to do massage the numbers it doesn't matter what "units" they are in.
Anyway, how about:In the above, if BD[4]=3 and BD[5]=90 the correct result is -76.855 and the code displays -76.85. If BD[4]=19 and BD[5]=89 the correct result is 23.096 and the code displays 23.09. Is that close enough?Code:Result var WORD Sign VAR BIT Result = (BD[4] * 128) + BD[5] - 2048 Sign = Result.15 Result = ABS Result Result = Result * 2500 Result = DIV32 512 If Sign = 1 Then LCDOUT $FE, 1, "-", #RESULT/100, ".", DEC2 RESULT//100 ELSE LCDOUT $FE, 1, #RESULT/100, ".", DEC2 RESULT//100 ENDIF
/Henrik.





Bookmarks