Trial and error led me to this code after my description just below. It works just like I need it to but there has to be a better way. The formula provided is this:Seems simple, right? Not for me.....Code:0.125*(M1*256+M2-0x0FA0)

So if M1=15 and M2=160 the result is 0. Both are byte variables so a rollover from M2 will increase M1 by 1. Increasing this number will provide a positive number and decreasing it will provide a negative number. In addition to the difficulty I was having with the formula, I had to account for formatting on my screen so triple digit numbers needed to be formatted differently than double digit numbers. Any comments are appreciated!

B1=256

B2=4000

MULT=125

G3T and G4T are byte sized variables

If someone comes up with a one-line code I'm going to slit my wrists.....Code:SELECT CASE G3T CASE 15 SELECT CASE G4T CASE IS < 160 DUMMY =MULT*((G3T*B1)+(G4T+B2)) MG2_NM = DIV32 100 MG2_NM=10000-MG2_NM IF MG2_NM > 999 THEN LCDOUT $FE, POS4-1,"-",DEC MG2_NM/10,".",DEC MG2_NM DIG 0 ELSE LCDOUT $FE, POS4-1,"-",DEC MG2_NM/10,".",DEC MG2_NM DIG 0," " ENDIF CASE IS >= 160 MG2_NM=(G4T*125)-20000 IF MG2_NM > 9999 THEN LCDOUT $FE,POS4-1," ",DEC MG2_NM/100,".",DEC MG2_NM DIG 0 ELSE LCDOUT $FE,POS4-1," ",DEC MG2_NM/100,".",DEC MG2_NM DIG 0," " ENDIF END SELECT CASE IS < 15 DUMMY =MULT*((G3T*B1)+(G4T+B2))' GOOD FOR NEGATIVE NM, INCLUDING ZERO MG2_NM = DIV32 100 MG2_NM=10000-MG2_NM IF MG2_NM > 999 THEN LCDOUT $FE, POS4-1,"-",DEC MG2_NM/10,".",DEC MG2_NM DIG 0 ELSE LCDOUT $FE, POS4-1,"-",DEC MG2_NM/10,".",DEC MG2_NM DIG 0," " ENDIF CASE ELSE DUMMY = MULT*((G3T*B1)+(G4T-B2)) MG2_NM = DIV32 100 IF MG2_NM > 999 THEN LCDOUT $FE,POS4-1," ",DEC MG2_NM/10,".",DEC MG2_NM//10 ELSE LCDOUT $FE,POS4-1," ",DEC MG2_NM/10,".",DEC MG2_NM//10," " ENDIF END SELECT

I have another issue that I'm having difficulty solving. I'm viewing data that comes at a very fast rate. The number is very jumpy because it changes quickly. I know I can average it but if I average say 5 measurements, it would seem good for those five measurements but when compared with the next five measurements I would think the number would still appear jumpy. What is a good way to make a measurement look smooth? It looks like the data is sent about 90 times a second.

## Bookmarks