Anyone can explain this code please? (Read temperature with DS1620 +pic 16F628)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2014
    Posts
    2

    Post Anyone can explain this code please? (Read temperature with DS1620 +pic 16F628)

    I have this code (DS1620 with PIC 16F628), and was trying to understand how works, but i dont know whats means the variables.

    Anyone can explain me this code??



    Code:
    include "Modedefs.bas
    DEFINE OSC = 4
    VRCON = 0
    TRISA= %00000000
    TRISB = % 00000000
    CFGW CON $0C
    CPUCN CON $02
    START CON $EE
    GETT CON $AA
    STH CON $01
    STL CON $02
    
    DST var PortB.0
    CLK Var PortB.1
    RST var PortB.2
    SER var PortB.3
    Temp var byte
    GCel var byte
    
    gosub Init
    GoSUB SetHL
    gosub LetGo
    
    e_go:
    gosub Lee_T
    GCel = Temp /2
    serout ser,N2400,[GCel]
    pause 250
    goto e_go
    end
    
    Init:
    High RST
    shiftout DST,CLK,LSBFIRST,[CFGW,CPUCN]
    low RST
    pause 10
    return
    
    LetGo
    high RST
    shiftout DST,CLK,LSBFIRST,[START]
    low RST
    pause 10
    return
    
    Lee_T:
    high RST
    shiftout DST,CLK,LSBFIRST,[GetT]
    shiftin DST,CLK,LSBPRE,[Temp]
    low RST
    return
    
    SetHL:
    high RST
    shiftout DST,CLK,LSBFIRST,[SHL,48\9]
    low RST
    pause 10
    high RST
    shiftout DST,CLK,LSBFIRST,[STL,34\9]
    low RST
    pause 10
    return
    Thanks!!

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Anyone can explain this code please? (Read temperature with DS1620 +pic 16F628)

    You'll find everything you're looking for in the DS 1620 datasheet ...

    see here for commented code snippets ...
    http://cornerstonerobotics.org/curri...hermometer.pdf
    http://cornerstonerobotics.org/picba...em_control.php
    http://melabs.com/samples/LABX1-16F887/temp3x.htm

    Alain
    Last edited by Acetronics2; - 10th November 2014 at 17:54.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Anyone can explain this code please? (Read temperature with DS1620 +pic 16F628)

    A variable is a space in memory which you have given a name to and declared it's size, or it is a register, port etc . . . which you have given an alias to.
    When you post "found code" it is usually helpful to post a link to where you found it too.
    Code:
    DST var PortB.0 'most likely DQ pin 1 of ds1620
    CLK Var PortB.1 'pin 2 of ds1620
    RST var PortB.2 'pin 3 " "  " "
    SER var PortB.3 'pin user is sending information to serial display
    Temp var byte   'store rew received data
    GCel var byte   'var to store temp/2
    http://datasheets.maximintegrated.com/en/ds/DS1620.pdf
    Last edited by Archangel; - 10th November 2014 at 18:39.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Anyone can explain this code please? (Read temperature with DS1620 +pic 16F628)

    Code:
    CFGW CON $0C
    CPUCN CON $02
    START CON $EE
    GETT CON $AA
    STH CON $01
    STL CON $02

    Those variables ( which are constants !!! ) are custom names for the DS1620 command codes and internal DS1620 registers ...

    sooo simple !!! ( with the datasheet - once more - )
    ************************************************** ***********************
    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. Timer code examples for PIC 16F628
    By Tastature in forum mel PIC BASIC
    Replies: 6
    Last Post: - 22nd November 2013, 02:47
  2. Crashing 16F628 Code
    By hhaplant in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th March 2012, 09:40
  3. read temperature
    By breeno in forum General
    Replies: 16
    Last Post: - 6th October 2010, 12:55
  4. DS1620 temperature sensor in high resolution mode
    By crodan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th March 2007, 04:03
  5. read temperature sensor
    By breeno in forum General
    Replies: 5
    Last Post: - 10th January 2005, 06:04

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