The DS1820 Wait time mystery ...


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614

    Lightbulb The DS1820 Wait time mystery ...

    Hi,

    Finally ... I got it !!!

    The famous waiting loop

    Code:
    While DQ : WEND
    never loops !!!

    You comment it ... the reading continues to work as it ... Strange ???


    NO,

    In fact, you ask for the conversion ... and read the scratch pad.

    Two different things : you'll read the same value on the scratchpad UNTIL the end of conversion ... overwrites the scratchpad.

    Asking for a new conversion while previous still running do not disturb the chip at all ... it ignores the command !!!

    so, no waiting required ... but it's not "real time measurement"

    How to be sure what you read is the result of the last demand ???

    You must ASK the device for "still busy" by sending it a short LOW "request pulse" ... and then you have 15 µs for reading the bus ... NO MORE !!!


    Externally ... the bus is released as soon as the convert command has been sent ... so you must send request pulses as long as the chip answer is NOT "0".

    see :

    Code:
    '*****************************************************************************
    ' Check for still busy converting 
    '*****************************************************************************
    
    waitloop:
     
    	 LOW DQ              ' Pulls the bus LOW 
    	 INPUT DQ            ' Releases the bus and prepare reading
    
    	IF NOT DQ THEN    ' If bus kept low 
    	
    	 PORTC.4 = 1        ' Show it
    
    	 GOTO Waitloop     ' Go on asking device state
    	 
    	ENDIF
    	
    	PORTC.4 = 0         ' clear marker
    Here ... what's printed is what you have asked for ... not previous readings ...

    This one Works fine too

    Code:
    waitloop:
     
    OWIn DQ, 4, [Busy] ' Check for still busy converting
    
    If Busy = 0 Then 
    
     PORTC.4 = 1
     GOTO waitloop
     
    ENDIF
    
    PortC.4 = 0
    Alain
    Last edited by Acetronics2; - 20th February 2009 at 17:45.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. DS1820 display with 7-seg 4 digits
    By chai98a in forum Code Examples
    Replies: 12
    Last Post: - 10th April 2008, 13:12
  4. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  5. DS1820 again
    By paxmowa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th January 2006, 14:49

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts