Searching \ for 'how to compare number - (DS1624)' 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=how+compare+number
Search entire site for: 'how to compare number - (DS1624)'.

Truncated match.
PICList Thread
'how to compare number - (DS1624)'
1998\10\01@150049 by lurdinha

flavicon
face
Hi All,

       i'm working with the sensor of temperature DS1624 (I2C),
it me return 2 bytes MSB=data integer and LSB=data decimal, how to
compare this data with one table of temperature range, or where find
routines of this type.

Ex.:  the data sensor is:  18,5


       my table:  15,2 to 16,9
                  17,0 to 19,6  item is true (on range of 18,5)
                  19,7 to 22,2


thanks,

Mauro Costa Sollar

1998\10\02@064135 by Caisson

flavicon
face
> Van: Mauro Costa Sollar <spam_OUTlurdinhaTakeThisOuTspamnewagetel.com.br>
> Aan: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
> Onderwerp: how to compare number  -   (DS1624)
> Datum: donderdag 1 oktober 1998 21:02
>
> Hi All,
>
>         i'm working with the sensor of temperature DS1624 (I2C),
> it me return 2 bytes MSB=data integer and LSB=data decimal, how to
> compare this data with one table of temperature range, or where find
> routines of this type.
>
> Ex.:  the data sensor is:  18,5
>
>
>         my table:  15,2 to 16,9
>                    17,0 to 19,6  item is true (on range of 18,5)
>                    19,7 to 22,2

Regard your data as ONE 16-bit number.  For example 18.5 equals 0x1205.
That should make life easier. :-)

You could (maybe) compress your measurement to a one-byte number.  The six
upper bits to create a range of 64 degrees (-20 to +44 for example) with
the low two bits to create a resolution of 1/4 degree.

Comparing with table-data is nothing more than retrieving data from a table
and than compare :

 clrf Index
TableLoop:
 call GetTableByte
 subwf ValueH,W
 btfsc STATUS,C
 goto Higher
 call GetTableByte
 subwf ValueL,W
 btfss STATUS,C
 goto TableLoop

Higher:
 {Do anything}
 ret

GetTableByte:
  movf Index,W
  incf Index
  addwf PCL
  db {lowest value - High-byte},  {lowest value - Low-byte}
  db  ...
  db {Highest value - High-byte},  {Highest value - Low-byte}
  db 0xFF,0xFF  ; Table terminator

Greetz,
 Rudy Wieser

1998\10\03@022458 by Michael Hagberg

flavicon
face
if i read it correctly you want to know this.

if (17.0 <= x ) and ( x <= 19.6 ) then TRUE else FALSE

   movf    MSB,w
   sublw    .16        ; 16 - MSB = ?
   btfsc    status,c
   goto    return_false    ; MSB is 16 or less

   movf    MSB,w
   sublw    .19        ; 19 - MSB
   btfss    status,c
   goto    return_false    ; MSB it greater than 19
   btfss    status,z
   goto    return_true

   movf    LSB,w
   sublw    .6        ; 6 - LSB
   btfss    status,c
   goto    return_false
   goto    return_true

this code is not debugged (and assume it's buggy) but will give you an idea
of how to start.

michael

You may leave the list at any time by writing "SIGNOFF PICLIST" in the
   body of a message to LISTSERVspamKILLspamMITVMA.MIT.EDU.

{Original Message removed}

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