12F508 and Dallas 1820 not working


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: 12F508 and Dallas 1820 not working

    Are you really sure of your OWIN parameters ???

    I'm not !!!

    Alain
    Last edited by Acetronics2; - 10th February 2012 at 15:23.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: 12F508 and Dallas 1820 not working

    Sorry... TRISGPIO = %00000010

  3. #3
    Join Date
    Feb 2012
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: 12F508 and Dallas 1820 not working

    Quote Originally Posted by Acetronics View Post
    Are you really sure of your OWIN parameters ???

    I'm not !!!

    Alain
    Thank you. I am fairly new with Picbasic, but all that code is directly copied from rentron.com Picbasic sample page. Only changed the DS1820 ID. I again double checked the ID and the code. I have a check board with a suitable program and an LCD. I just plug in any DS18x20 and can I see immediately the ID and CRC-code. By the way, my english may not be good. I am from Finland.


    See the original code at Rentron:

    http://www.rentron.com/PicBasic/one-wire2.htm

    and find Temp_1 label.

    The code works exteremely well with my other programs with 16F87xx Pics. I also changed my sample code a bit and used GPIO.2 as data pin. Datasheet says "General Purpose IO-pin", just like PortC-pins on 16F87xx. But this tiny chip is against me. I have also tested another 12F508 without success. Maybe I have to give up

  4. #4
    Join Date
    Feb 2012
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: 12F508 and Dallas 1820 not working

    Oh sh*t!!!

    I had forgotten to connect a pull-up resistor to data pin, and that was the reason for non workin code. I am sorry, that I have caused trouble. The following works. Data pin is now back to GP1 (GPIO.1)



    Code:
    '****************************************************************
    '*  Name    : 12F508thermostat.BAS                                          *
    '*  Author  : AN OLD FINNISHMAN                    *
    '*  Notice  :                                    *
    '*            :                                 *
    '*  Date    : 02/12/2012                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                    *
    '*          :                                                   *
    '****************************************************************
    
    ' CHIP: PIC 12F508
    ' A simple program to read DS1820 (18S20) and depending on the temperature
    ' to drive a led (and/or a solit state relay to drive an 
    ' electric heater).
    ' ID for the sensor and a CRC value is here:
    ' $10,$B2,$AD,$D8,$00,$08,$00,$26
    ' replace it with yours
    ' USE INTERNAL OSCILLATOR (INTRC) 
    
    ' connect a led via 470 ohm resistor to GP0
    ' connect a 4k7 pull-up resistor to data pin GP1
    
    
    Define osc 4
    
    led var GPIO.0
    
    
    Tempa Var Word            ' Temperature storage
    Stat var bit
    
    DQ    Var    GPIO.1            ' One-wire data pin
    
    TRISIO =000010
    GPIO =000000
    
    'led on for a second to see if code runnig
    
            High led 
            PAUSE 1000
            low led
    
    pauseus 100
    
    Temp_1:
        
        OWOUT DQ, 1, [$55,$10,$B2,$AD,$D8,$00,$08,$00,$26,$44]
    W1:
        OWIN DQ, 4, [Stat]' Check for still busy converting
        IF Stat = 0 THEN W1' Still busy?, then loop
        OWOUT DQ, 1,[$55,$10,$B2,$AD,$D8,$00,$08,$00,$26,$BE]
        OWIN DQ, 2, [Tempa.LOWbyte,Tempa.HIGHBYTE]' Read two bytes, then end communications
        
    ' replace upper and lower limits with your own
    ' variable Tempa is 2 times the temperature in degrees C
        
    If Tempa >= 41 then low led ' if temp >= 20,5 (upper limit)
    If Tempa <= 40 then High led ' if temp <= 20 (lower limit)
    
    PAUSE 1000
    
    Goto Temp_1
    Last edited by Picprogman; - 10th February 2012 at 17:18.

Members who have read this thread : 0

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