On Sun, Jan 16, 2011 at 12:38 AM, Joep Suijs <[email protected]> wrote:
> Hi,
>
> I'm still puzzled, since small delays don't work for me either. And I do
> work the third (vdd) line. When the conversion is running and I read the
> device, the reported temperature is 85 degrees. So I have to wait for 800ms
> - one way or the other - after conversion before I can get a valid reading.
> I can't think of a reason why it does work for you, Vasi. Unless it has to
> do with slightly different devices?!?
>
If we talk about 18B20, then all devices are the same except if are not all
set on 12 bit resolution. Until the first conversion is not complete you
should read 0. However you will read the last conversion (even you are
performing the last+1 conversion), so usually you need NO delay there.
That's the way I'm doing with a two colour 7 seg multiplexed display:
procedure match_temperature_read (byte in sensor,
byte in colour,
byte out t_total,
bit out signn) is
sensor_present = _1w_reset -- start temp conversion
_1w_writebyte(0xCC) -- Skip ROM
_1w_writebyte(0x44) -- Convert T command to all devices
; _1w_waitconv -- Conversion delay, THIS ONE IS NOT NECESSARY
_1w_reset
match_rom ( sensor ) -- match to one sensor ID
_1w_writebyte(0xBE) -- and Read ScratchPad of that sensor
t_lsb = _1w_readbyte
t_msb = _1w_readbyte
var volatile bit sign at t_msb : 7
signn = sign
if sign == high then ; negative temperatures
assembler
comf t_lsb,f ;Complement all 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
; for DS18B20, is different for DS18S20!
dec = t_lsb & 0x0F
units = t_lsb & 0xF0
units = units >> 4
if dec == 0 then decimal = 0
elsif dec == 1 then decimal = 0;06 ; rounded to the first decimal
elsif dec == 2 then decimal = 1;12
elsif dec == 3 then decimal = 2;18
elsif dec == 4 then decimal = 2;25
elsif dec == 5 then decimal = 3;31
elsif dec == 6 then decimal = 4;37
elsif dec == 7 then decimal = 4;43
elsif dec == 8 then decimal = 5;50
elsif dec == 9 then decimal = 5;56
elsif dec == 10 then decimal = 6;62
elsif dec == 11 then decimal = 7;68
elsif dec == 12 then decimal = 7;75
elsif dec == 13 then decimal = 8;81
elsif dec == 14 then decimal = 9;87
elsif dec == 15 then decimal = 9;93
end if
if t_msb == 0 then temperature = units
elsif t_msb == 1 then temperature = 16 + units
elsif t_msb == 2 then temperature = 32 + units
elsif t_msb == 3 then temperature = 48 + units
elsif t_msb == 4 then temperature = 64 + units
elsif t_msb == 5 then temperature = 80 + units
elsif t_msb == 6 then temperature = 96 + units
elsif t_msb == 7 then temperature = 112 + units
end if
var byte T11, T12, T13, tmp1a
const byte C100 = 100, c10 = 10
T11 = temperature / c100
tmp1a = temperature % c100
T12 = tmp1a / c10
T13 = tmp1a % c10
t_total = temperature
if sensor_present == 0 then
if colour == red then
------------------------
if signn == high then
digit_display ( 1,0,0,0,0,0,0,0); show digit1
portB = seven_from_digit ( 27 )& mask ; minus
delay_10uS ( red )
digit_display ( 0,0,0,0,0,0,0,0)
end if
if T12 > 0 then
digit_display ( 0,1,0,0,0,0,0,0)
portB = seven_from_digit ( T12 )& mask
delay_10uS ( red )
end if
digit_display ( 0,0,1,0,0,0,0,0)
portB = seven_from_digit ( T13 )& mask
delay_10uS ( red )
digit_display ( 0,0,0,1,0,0,0,0)
portB = seven_from_digit ( decimal )& mask
delay_10uS ( red )
digit_display ( 0,0,0,0,0,0,0,0)
elsif colour == green then
-------------------------------
if signn == high then
digit_display ( 0,0,0,0,1,0,0,0); show digit1
portB = seven_from_digit ( 27 )& mask ; minus
delay_10uS ( green )
digit_display ( 0,0,0,0,0,0,0,0)
end if
if T12 > 0 then
digit_display ( 0,0,0,0,0,1,0,0)
portB = seven_from_digit ( T12 )& mask
delay_10uS ( green )
end if
digit_display ( 0,0,0,0,0,0,1,0)
portB = seven_from_digit ( T13 )& mask
delay_10uS ( green )
digit_display ( 0,0,0,0,0,0,0,1)
portB = seven_from_digit ( decimal )& mask
delay_10uS ( green )
digit_display ( 0,0,0,0,0,0,0,0)
end if
-------------------------
else
error_open (colour) ; no DS18B20 is present on the bus
end if
end procedure
Vasile
> The test file and libraries need some cleanup but should work okay if you
> have one device on the bus. If you create a jal program that includes one of
> the board files and then the test file, you should have a working
> program. The program prints the temperature and rom id to the serial
> port. I'd apprecieate to hear your findings in general and more specific on
> a device in parasite mode since I did not try that yet.
>
> Joep
>
> 2011/1/16 Serdar K. <[email protected]>
>
> Hi, i think the delay routine is for charging/powering the circuit from
>> one-wire bus, which only contains one data+vdd and one ground pin. If you
>> power the sensor IC with a seperate Vdd line, the delay time could be less,
>> and not as much critical, but i can not tell if this is the case, because
>> the schematics link on this thread didn't work for me...
>>
>> If this can be without the power line and with no or less delay, this
>> would be very nice.
>>
>> Greetings,
>> Serdar
>>
>> 2011/1/15 Joep Suijs <[email protected]>
>>
>>> 2011/1/15 vasile surducan <[email protected]>:
>>> >
>>> >
>>> > On Sat, Jan 15, 2011 at 1:21 AM, vasile surducan <[email protected]>
>>> > wrote:
>>> >> even when display on a 7 segment? and display is multiplexed...
>>> >> Vasile
>>>
>>> I don't see why not. If the display routine requires strict timing
>>> like with multiplexing, the design of your program should be
>>> accordingly. I'm not sure if the seven segment display accepts ascii
>>> (an requirement for format.jal), but you can make this if you need it.
>>> Of course, you can add additional constaints so it won't work with
>>> generic libraries. You have to do specific optimisations in JAL or
>>> revert to assembler.
>>>
>>> Joep
>>>
>>> --
>>>
>>> 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.
>>>
>>>
>>
>>
>> --
>> *Serdar KIZILTOPRAK
>> Intelligence **Technology Systems
>> [email protected]
>> http://www.its3k.com
>> +90(216) 518 15 00*
>> **
>>
>>
>> <https://mail.google.com/mail/html/compose/static_files/blank_quirks.html#12d8de55314f6b3c_>
>> <https://mail.google.com/mail/html/compose/static_files/blank_quirks.html#12d8de55314f6b3c_>
>>
>> <https://mail.google.com/mail/html/compose/static_files/blank_quirks.html#12d8de55314f6b3c_>
>>
>> <https://mail.google.com/mail/html/compose/static_files/blank_quirks.html#12d8de55314f6b3c_>
>>
>> --
>> 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.
>>
>
> --
> 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.
>
--
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.