Searching \ for 'SUBSTRACTION OF TWO 16BIT INTEGERS' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=substraction+two
Search entire site for: 'SUBSTRACTION OF TWO 16BIT INTEGERS'.

Truncated match.
PICList Thread
'Substraction of two 16bit integers'
1998\04\06@183357 by marcel

picon face
Hello i am receiving 12 bit data into two registers the next time
I get data i want to now how much it differs from the first data.

Any body with suggestions thanks in advance


marcel   Electronic workshop Scope

Amsterdam

spam_OUTmarbelTakeThisOuTspamxs4all.nl

1998\04\08@115030 by marcel

picon face
  Tanks for the reply's on this matter
the thing is what i wand to do is more complicated
I am reading 12 bit of data from an potentiometer when it is in the
middle
it should give something like 0x0800  "hex"
when i turn left it decreases and when i turn right it increases
The maximum increment should be no more than 0x3f  and the maximum
decrement must not cross 0x40 within one reading if so i have to
increment or decrement
with these maximums or less until i reach the last readout.

I hope i am more clear on what i want to do

I can get the data msb first in the registers datahi and datalo but
the LTC1286 allows also to read LSB first

Example   first readout  could be  x0800  the next  0x0870
the different is 70 positive is bigger than 0x3f so i add 0x3f to
previous readout
and compare again with the last readout witch can have changed in this
example
i assume not so 0x870 sub 0x83f is 0x31 witch is less than 0x3f  and the

process stops
until a new readout appears

I don't understand what is the meaning msb stored at lower adress at the

moment i am
trying simulating this in MacPic



 Storage1      equ   0x10
 Storage2      equ   0x11
 Storage3      equ   0x12
 Storage4      equ   0x13
 TmpReg1     equ   0x14
 TmpReg2     equ   0x15
 datahi           equ   0x16
 datalo           equ   0x17




  movlw         0x01         ;
  movwf        datalo       ;
  movwf        Storage1     ;
  movlw         0x80         ;
  movwf        datahi       ;
  movwf        Storage2     ;
  clrf             TmpReg1      ;
  clrf             TmpReg2      ;

start

 ; movwf       Storage1
 ; movwf       TmpReg1

  movf            datahi,W
  subwf          Storage2,W
  movwf         TmpReg2
  btfss             STATUS,Z
  decf              TmpReg1,F
  movf             datalo,W
  subwf           TmpReg1,F
 ; incf               datalo

  goto              start

As i already  sad    thanks  for all the reply's on this matter


Marcel   Electronic  Workshop Scope

Amsterdam .

1998\04\08@131750 by Jon Baker

flavicon
picon face
>The maximum increment should be no more than 0x3f  and the maximum
>decrement must not cross 0x40 within one reading if so i have to
>increment or decrement
>with these maximums or less until i reach the last readout.
>
>I hope i am more clear on what i want to do


So what you want is a damped reading, so no matter how fast someone turns
the Pot, the rate of change is always with in given limits?

1998\04\08@195742 by Ron Kreymborg

flavicon
face
Still not crystal clear Marcel. Are you saying that:

1. Take a reading and compare to previous.

2. If the new reading has increased by more than 0x3f, add 0x3f to the old
reading and compare it again with the new reading. Continue until the
difference is less than 0x3f. The result then becomes the old or
previous reading. Loop to 1.

3. Similar to 2 for the decrease case only use 0x40.

Ron

On Wed, 8 Apr 1998, marcel wrote:

{Quote hidden}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ron Kreymborg                   Computer Systems Manager
Monash University               CRC for Southern Hemisphere Meteorology
Wellington Road
Clayton, VIC 3168               Phone     : 061-3-9905-9671
Australia                       Fax       : 061-3-9905-9689
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...