The raw temperature on Arduino library is computed like this:

int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) |
scratchPad[TEMP_LSB];

Is used a signed word.

Look at examples, I think library support also negative temperatures.
The temperature is computed later, in another procedure and a sign is
detected...

For an unique sensor on wire:
procedure s_temp_18B20(byte out inches, byte out fraction, bit out
signed)
procedure s_temp_18B20_CRC(byte out inches, byte out fraction, bit out
signed) is

For multiple sensors:
procedure temp_18B20(byte out inches, byte out fraction, bit out
signed) is
procedure temp_18B20_CRC(byte out inches, byte out fraction, bit out
signed) is


Vasi

On Dec 13, 2:17 pm, vasile surducan <[email protected]> wrote:
> On Mon, Dec 13, 2010 at 2:14 PM, funlw65(Vasi) <[email protected]> wrote:
> > Thank you for solution. You mean, JAL is more efficient than
> > assembler?
>
> Jal is a dream. Use words only.[?]
>
> > I really need to find some time to learn assembler. I did once for
> > Z80, but I had the required book... don't have it anymore...
>
> > On Dec 13, 2:04 pm, vasile surducan <[email protected]> wrote:
> > > if sign == high then           ; negative temperatures
> > >         assembler
> > >         comf    t_lsb,f         ;complement all two bytes
> > >         comf    t_msb,f
>
> > >         incf    t_lsb,f         ;inc. low byte always
> > >         skpnz                   ;skip if no carry to higher bytes
> > >         incf    t_msb,f         ;carry to next byte
> > >         end assembler
> > >  end if
>
> > > Maybe you translate this in jal, as word is producing too long code...
>
> > > Vasile
>
> > > On Mon, Dec 13, 2010 at 1:57 PM, funlw65(Vasi) <[email protected]>
> > wrote:
> > > > Then, I believe you are right. I will see on Arduino library how they
> > > > do it... if there is not another source...
>
> > > > Vasi.
>
> > > > On Dec 13, 1:51 pm, vasile surducan <[email protected]> wrote:
> > > > > OK, apai nu cred c-o sa mearga...because you didn't computed the
> > two's
> > > > > complement for negative temperature display.
>
> > > > > Vasile
>
> > > > > On Mon, Dec 13, 2010 at 1:46 PM, funlw65(Vasi) <[email protected]>
> > > > wrote:
> > > > > > Hi Vasile,
>
> > > > > > Not tested it yet but I will! do it tomorrow - pentru ca azi mai am
> > de
> > > > > > taiat niste lemne cu drujba :-D
>
> > > > > > On Dec 13, 9:12 am, vasile surducan <[email protected]> wrote:
> > > > > > > Hi Vasi,
>
> > > > > > > I'm just curious, this library works Ok with negative
> > temperatures
> > > > too?
>
> > > > > > > thx,
> > > > > > > Vasile
>
> > > > > > > On Wed, Aug 18, 2010 at 2:42 PM, vasi vasi <[email protected]>
> > > > wrote:
> > > > > > > > We don't have yet a 1wire library and I needed it for a DS18B20
> > > > > > temperature
> > > > > > > > sensor. But I found one written by Vasile and adapted by Jean
> > > > > > Marchaudon,
> > > > > > > > included in Bert van Dam package. Is there a reason why not
> > > > including
> > > > > > it in
> > > > > > > > Jallib? For a DS18B20 library, I did one (not really
> > necessarily)
> > > > > > looking at
> > > > > > > > And-Tech.pl samples for their EvB 4.3 board and at Bert
> > library,
> > > > > > > > ds1822_1_wire.jal. Now, I have working examples [?] but lots of
> > > > > > warnings.
> > > > > > > > Here is also a "disabled" sensor config.range and resolution
> > > > function ,
> > > > > > not
> > > > > > > > tested - needs advices from experts.  All functions which start
> > > > with
> > > > > > "s_"
> > > > > > > > are for a unique device on bus - others require the ID for
> > access a
> > > > > > sensor
> > > > > > > > on multiple sensors on bus.
> > > > > > > > First example (thermometer.jal and an image included) is
> > reading a
> > > > > > unique
> > > > > > > > device on 1wire bus and the second is reading the device on a
> > > > multi.
> > > > > > sensor
> > > > > > > > bus, using the ID discovered in first example.
> > > > > > > > Maybe is useful in taking some decisions about this (new and
> > > > general
> > > > > > > > libraries, samples, etc...)
> > > > > > > > --
> > > > > > > > Vasi
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > Groups
> > > > > > > > "jallib" group.
> > > > > > > > To post to this group, send email to [email protected].
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > [email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > <jallib%[email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > > > <jallib%[email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > <jallib%[email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > > > > > .
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/jallib?hl=en.
>
> > > > > > >  330.png
> > > > > > > < 1KViewDownload
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "jallib" group.
> > > > > > To post to this group, send email to [email protected].
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > <jallib%[email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/jallib?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "jallib" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<jallib%[email protected]>
> > <jallib%[email protected]<jallib%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/jallib?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "jallib" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<jallib%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/jallib?hl=en.
>
>
>
>  329.png
> < 1KViewDownload

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to