Shop OBEX P1 Docs P2 Docs Learn Events
Ds1620 — Parallax Forums

Ds1620

jc3IIIjc3III Posts: 21
edited 2012-02-12 20:00 in BASIC Stamp
why does the Applied Sensor book use the number 2 to configure the DS1620 to continuous conversion with CPU. The book says that it is mode 2. On the data sheet 02h(2) writes low temp. value into TL register. EEh(238) initiates temp conversion, AAh(170), 0Ch(12) Writes configuration data to configuration register. I would like to know why are they using the number 2. It doesn't seem to match up with the DS1620 data sheet.

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-05-04 10:33
    Please do not ask the same question in two different forums (Here and in there in general discussion)--forum rules.

    The answer is that some of the DS1620 commands have two parts, , the command itself, and the parameter. The sequence from Applied Sensors is
    SHIFTOUT 15, 14, LSBFIRST, [12,2] ' Command to set DS1620 configuration 2.
    

    The command is 12 (configure), and the parameter is 2 (continuous conversion with CPU).

    As a command, 2 has a different meaning (set low threshold).
  • jc3IIIjc3III Posts: 21
    edited 2011-05-05 14:08
    I understand that, but for my project at school, I need to confirm where it came from besides the Applied Sensor book. I don't see where on the data sheet that it explains it.
  • FranklinFranklin Posts: 4,747
    edited 2011-05-05 15:08
    I understand that, but for my project at school, I need to confirm where it came from besides the Applied Sensor book. I don't see where on the data sheet that it explains it.
    Page 5 (config register)
    Page 12 (write configuration)
  • jc3IIIjc3III Posts: 21
    edited 2011-05-05 20:53
    I've read it up and down. I still don't see it. I looked on page 5 and 12. Page 12 doesn't even talk about writing configuration. Page 5 doesn't bring up 2 either.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2011-05-05 21:41
    Reference:
    http://datasheets.maxim-ic.com/en/ds/DS1620.pdf

    See 'CONFIGURATION/STATUS REGISTER' on page 5
    Also 'OPERATION IN STAND-ALONE MODE' on page 6

    jc3III,

    This reference doesn't specifically bring up 2 either, but the binary placement of the 'CPU bit' in the configuration status register is in position 2
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-05 21:45
    It probably depends on the datasheet you're looking at. This one discusses writing configuration on pages 7-9. The format of the config register is discussed on page 5.
  • jc3IIIjc3III Posts: 21
    edited 2011-05-07 08:10
    What is connected to the DS1620's T-com pin and can anyone describe how the function block diagram works? Thank you for your help so far.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2011-05-07 21:16
    jc3III,

    "What is connected to the DS1620's T-com pin" - Nothing is connected if you don't use the alarm outputs.

    TLOW and THIGH are alarm thresholds that you can set via the Write TH [01h] and the Write TL [02h].

    TCOM is an alarm output that basically OR's TLOW an THIGH.... if either alarm has been tripped, so is the output of TCOM.
  • jc3IIIjc3III Posts: 21
    edited 2011-05-08 22:50
    what is it connected to if you the alarm outputs
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2011-05-08 23:46
    Google is your friend... "DS1620 application note"

    http://www.maxim-ic.com/app-notes/index.mvp/id/67

    basically, you can connect anything that's TTL compatible to the outputs.
  • KievlaninKievlanin Posts: 55
    edited 2012-02-08 19:49
    To continue my learning of PBASIC:

    I am now trying to learn how to use a DS1620
    Using it with BS1

    I was trying to figure myself how to set a new temperatures to thermostat mode.
    For example 25*C on High & 19*C on Low.
    Anyone can help me?
    I think I can't figure out how to "Shout" 9 bits of temperature number. I understand there is a W(n) memory slot must be used.
    Anyway, any suggestions?

    Here is the program for BS1 from Volts & nuts:

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
     
    ' Program Listing 2.1: DS1620.BAS
    ' This program interfaces the DS1620 Digital Thermometer to the
    ' BASIC Stamp. Input and output subroutines can be combined to
    ' set the '1620 for thermometer or thermostat operation, read
    ' or write nonvolatile temperature setpoints and configuration
    ' data.
    ' ===================== Define Pins and Variables ================
    SYMBOL DQp = PIN2 ' Data I/O pin.
    SYMBOL DQn = 2 ' Data I/O pin _number_.
    SYMBOL CLKn = 1 ' Clock pin number.
    SYMBOL RSTn = 0 ' Reset pin number.
    SYMBOL DSout = W0 ' Use bit-addressable byte for DS1620 output.
    SYMBOL DSin = W0 ' " " " word " " input.
    SYMBOL clocks = B2 ' Counter for clock pulses.
    ' ===================== Define DS1620 Constants ===================
    ' >>> Constants for configuring the DS1620
    SYMBOL Rconfig = $AC ' Protocol for 'Read Configuration.'
    SYMBOL Wconfig = $0C ' Protocol for 'Write Configuration.'
    SYMBOL CPU = %10 ' Config bit: serial thermometer mode.
    SYMBOL NoCPU = %00 ' Config bit: standalone thermostat mode.
    SYMBOL OneShot = %01 ' Config bit: one conversion per start request.
    SYMBOL Cont = %00 ' Config bit: continuous conversions after start.
    ' >>> Constants for serial thermometer applications.
    SYMBOL StartC = $EE ' Protocol for 'Start Conversion.'
    SYMBOL StopC = $22 ' Protocol for 'Stop Conversion.'
    SYMBOL Rtemp = $AA ' Protocol for 'Read Temperature.'
    ' >>> Constants for programming thermostat functions.
    SYMBOL RhiT = $A1 ' Protocol for 'Read High-Temperature Setting.'
    SYMBOL WhiT = $01 ' Protocol for 'Write High-Temperature Setting.'
    SYMBOL RloT = $A2 ' Protocol for 'Read Low-Temperature Setting.'
    SYMBOL WloT = $02 ' Protocol for 'Write Low-Temperature Setting.'
    ' ===================== Begin Program ============================
    ' Start by setting initial conditions of I/O lines.
    LOW RSTn ' Deactivate the DS1620 for now.
    HIGH CLKn ' Initially high as shown in DS specs.
    PAUSE 100 ' Wait a bit for things to settle down.
    ' Now configure the DS1620 for thermometer operation. The
    ' configuration register is nonvolatile EEPROM. You only need to
    ' configure the DS1620 once. It will retain those configuration
    ' settings until you change them--even with power removed. To
    ' conserve Stamp program memory, you can preconfigure the DS1620,
    ' then remove the configuration code from your final program.
    ' (You'll still need to issue a start-conversion command, though.)
    LET DSout=Wconfig ' Put write-config command into output byte.
    GOSUB Shout ' And send it to the DS1620.
    LET DSout=CPU+Cont ' Configure as thermometer, continuous conversion.
    GOSUB Shout ' Send to DS1620.
    LOW RSTn ' Deactivate '1620.
    PAUSE 50 ' Wait 50ms for EEPROM programming cycle.
    LET DSout=StartC ' Now, start the conversions by
    GOSUB Shout ' sending the start protocol to DS1620.
    LOW RSTn ' Deactivate '1620.
    ' The loop below continuously reads the latest temperature data from
    ' the DS1620. The '1620 performs one temperature conversion per second.
    ' If you read it more frequently than that, you'll get the result
    ' of the most recent conversion. The '1620 data is a 9-bit number
    ' in units of 0.5 deg. C. See the ConverTemp subroutine below.
    Again:
    PAUSE 1000 ' Wait 1 second for conversion to finish.
    LET DSout=Rtemp ' Send the read-temperature opcode.
    GOSUB Shout
    GOSUB Shin ' Get the data.
    LOW RSTn ' Deactivate the DS1620.
    GOSUB ConverTemp ' Convert the temperature reading to absolute.
    GOSUB DisplayF ' Display in degrees F.
    GOSUB DisplayC ' Display in degrees C.
    GOTO Again
    ' ===================== DS1620 I/O Subroutines ==================
    ' Subroutine: Shout
    ' Shift bits out to the DS1620. Sends the lower 8 bits stored in
    ' DSout (w0). Note that Shout activates the DS1620, since all trans-
    ' actions begin with the Stamp sending a protocol (command). It does
    ' not deactivate the DS1620, though, since many transactions either
    ' send additional data, or receive data after the initial protocol.
    ' Note that Shout destroys the contents of DSout in the process of
    ' shifting it. If you need to save this value, copy it to another
    ' register.
    Shout:
    HIGH RSTn ' Activate DS1620.
    OUTPUT DQn ' Set to output to send data to DS1620.
    FOR clocks = 1 TO 8 ' Send 8 data bits.
    LOW CLKn ' Data is valid on rising edge of clock.
    LET DQp = BIT0 ' Set up the data bit.
    HIGH CLKn ' Raise clock.
    LET DSout=DSout/2 ' Shift next data bit into position.
    NEXT ' If less than 8 bits sent, loop.
    RETURN ' Else return.
    ' Subroutine: Shin
    ' Shift bits in from the DS1620. Reads 9 bits into the lsbs of DSin
    ' (w0). Shin is written to get 9 bits because the DS1620's temperature
    ' readings are 9 bits long. If you use Shin to read the configuration
    ' register, just ignore the 9th bit. Note that DSin overlaps with DSout.
    ' If you need to save the value shifted in, copy it to another register
    ' before the next Shout.
    Shin:
    INPUT DQn ' Get ready for input from DQ.
    FOR clocks = 1 TO 9 ' Receive 9 data bits.
    LET DSin = DSin/2 ' Shift input right.
    LOW CLKn ' DQ is valid after falling edge of clock.
    LET BIT8 = DQp ' Get the data bit.
    HIGH CLKn ' Raise the clock.
    NEXT ' If less than 9 bits received, loop.
    RETURN ' Else return.
    ' ================= Data Conversion/Display Subroutines ===============
    ' Subroutine: ConverTemp
    ' The DS1620 has a range of -55 to +125 degrees C in increments of 1/2
    ' degree. It's awkward to work with negative numbers in the Stamp's
    ' positive-integer math, so I've made up a temperature scale called
    ' DSabs (DS1620 absolute scale) that ranges from 0 (-55 C) to 360(+125 C).
    ' Internally, your program can do its math in DSabs, then convert to
    ' degrees F or C for display.
    ConverTemp:
    IF BIT8 = 0 THEN skip ' If temp > 0 skip "sign extension" routine
    LET W0 = W0 | $FE00 ' Make bits 9 through 15 all 1s to make a
    ' 16-bit two's complement number.
    skip:
    LET W0 = W0 + 110 ' Add 110 to reading and return.
    RETURN
    ' Subroutine: DisplayF
    ' Convert the temperature in DSabs to degrees F and display on the
    ' PC screen using debug.
    DisplayF:
    LET W1 = W0*9/10 ' Convert to degrees F relative to -67.
    IF W1 < 67 THEN subzF ' Handle negative numbers.
    LET W1 = W1-67
    DEBUG #w1, " F",CR
    RETURN
    subzF:
    LET W1 = 67-W1 ' Calculate degrees below 0.
    DEBUG "-",#w1," F",CR ' Display with minus sign.
    RETURN
    ' Subroutine: DisplayC
    ' Convert the temperature in DSabs to degrees C and display on the
    ' PC screen using debug.
    DisplayC:
    LET W1 = W0/2 ' Convert to degrees C relative to -55.
    IF W1 < 55 THEN subzC ' Handle negative numbers.
    LET W1 = W1-55
    DEBUG #w1, " C",CR
    RETURN
    subzC:
    LET W1 = 55-W1 ' Calculate degrees below 0.
    DEBUG "-",#w1," C",CR ' Display with minus sign.
    RETURN 
    
    
    
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-09 11:05
    That is a program by Scott Edwards from the BS1 application notes. Good stuff.

    You would need to modify the Shout routine to send either 8 or 9 bits. I'm pretty rusty on the BS1, but I'd start by making the number of bits sent be a variable. To set the thresholds, you send the command, 8 bits, and then the desired threshold value, 9 bits, then set the RSTn line back low to complete the command.
    SYMBOL nBits = B3 ' number of bits to send ' ...
    
    
    '' and the shout routine:
    Shout9:          ' call this for sending 9 bits
    LET nBits = 9
    GOTO Shouts
    Shout:
    LET nBits = 8    ' call this as usual for commands
    Shouts: HIGH RSTn ' Activate DS1620. OUTPUT DQn ' Set to output to send data to DS1620. FOR clocks = 1 TO nBits ' Send nBits data bits. LOW CLKn ' Data is valid on rising edge of clock. LET DQp = BIT0 ' Set up the data bit. HIGH CLKn ' Raise clock. LET DSout=DSout/2 ' Shift next data bit into position. NEXT ' If less than 8 bits sent, loop. RETURN ' Else return.
    
  • KievlaninKievlanin Posts: 55
    edited 2012-02-09 17:32
    Well,
    Tracy, I need to set-up a high limit of (for example 22 degree C
    I need to set up as:
    SYMBOL HighTemp = B3
    LET B3 = 22

    Then I need to Shout this into DS1620 right after code (Write TH) High Temperature limit.
    This is were I am losing something.
    I am going to read more about.

    Anyway, I did not get it yet...
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-09 19:12
    To get a threshold of 22, you have to enter a value of 44. Temperature times 2. So a value of 44 would be 22.0 °C and 45 is 22.5 °C and so on. Also, it is DSout = 44, not B3=44. The data you want to send is held in variable DSout, which is an alias name for w0, the first word in the BS1 memory. It has to be that way for the shout subroutine.

    Make B3=8, for sending the command (%00000001 for upper threshold and %00000010 for lower threshold), and B3=9 for nine bits to send the threshold value. The DS1620 requires 9 bits for the threshold value, and the 9th bit is the sign bit.

    Here is the sequence to set the upper threshold to 22 °C using my program mods:
    RSTn starts low.
    B3=8 and DSout=1, call shout.
    B3=9 with DSout=44, call shout.
    set RSTn high to finish the command.

    I have applicable info but using the Stamp 2 on this page:
    http://www.emesystems.com/OL2d1620.htm#thermostat
  • KievlaninKievlanin Posts: 55
    edited 2012-02-10 18:14
    The original program using W0 register.
    Why can't we use the same to send comands?

    I do not know what I am doing wrong...
    I was trying to use your code, nothing worked.

    I will post my modifications I made to the program.
    
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
     
    ' Program Listing 2.1: DS1620.BAS
    ' This program interfaces the DS1620 Digital Thermometer to the
    ' BASIC Stamp. Input and output subroutines can be combined to
    ' set the '1620 for thermometer or thermostat operation, read
    ' or write nonvolatile temperature setpoints and configuration
    ' data.
    ' ===================== Define Pins and Variables ================
    SYMBOL DQp = PIN2 ' Data I/O pin.
    SYMBOL DQn = 2 ' Data I/O pin _number_.
    SYMBOL CLKn = 1 ' Clock pin number.
    SYMBOL RSTn = 0 ' Reset pin number.
    SYMBOL DSout = W0 ' Use bit-addressable byte for DS1620 output.
    SYMBOL DSin = W0 ' " " " word " " input.
    SYMBOL clocks = B2 ' Counter for clock pulses.
    ' ===================== Define DS1620 Constants ===================
    ' >>> Constants for configuring the DS1620
    SYMBOL Rconfig = $AC ' Protocol for 'Read Configuration.'
    SYMBOL Wconfig = $0C ' Protocol for 'Write Configuration.'
    SYMBOL CPU = %10 ' Config bit: serial thermometer mode.
    SYMBOL NoCPU = %00 ' Config bit: standalone thermostat mode.
    SYMBOL OneShot = %01 ' Config bit: one conversion per start request.
    SYMBOL Cont = %00 ' Config bit: continuous conversions after start.
    ' >>> Constants for serial thermometer applications.
    SYMBOL StartC = $EE ' Protocol for 'Start Conversion.'
    SYMBOL StopC = $22 ' Protocol for 'Stop Conversion.'
    SYMBOL Rtemp = $AA ' Protocol for 'Read Temperature.'
    ' >>> Constants for programming thermostat functions.
    SYMBOL RhiT = $A1 ' Protocol for 'Read High-Temperature Setting.'
    SYMBOL WhiT = $01 ' Protocol for 'Write High-Temperature Setting.'
    SYMBOL WhiTemp = $16 'High temperature limit
    SYMBOL RloT = $A2 ' Protocol for 'Read Low-Temperature Setting.'
    SYMBOL WloT = $02 ' Protocol for 'Write Low-Temperature Setting.'
    ' ===================== Begin Program ============================
    ' Start by setting initial conditions of I/O lines.
    LOW RSTn ' Deactivate the DS1620 for now.
    HIGH CLKn ' Initially high as shown in DS specs.
    PAUSE 100 ' Wait a bit for things to settle down.
    ' Now configure the DS1620 for thermometer operation. The
    ' configuration register is nonvolatile EEPROM. You only need to
    ' configure the DS1620 once. It will retain those configuration
    ' settings until you change them--even with power removed. To
    ' conserve Stamp program memory, you can preconfigure the DS1620,
    ' then remove the configuration code from your final program.
    ' (You'll still need to issue a start-conversion command, though.)
    '=== Original Code Saved below ----------
    'LET DSout=Wconfig ' Put write-config command into output byte.
    'GOSUB Shout ' And send it to the DS1620.
    'LET DSout=CPU+Cont ' Configure as thermometer, continuous conversion.
    'GOSUB Shout ' Send to DS1620.
    'LOW RSTn ' Deactivate '1620.
    'PAUSE 50 ' Wait 50ms for EEPROM programming cycle.
    '=== Original Code Saved above ----------
    
    LET DSout=Wconfig ' Put write-config command into output byte.
    GOSUB Shout ' And send it to the DS1620.
    LET DSout=NoCPU' Configure as stand alone thermostat
    GOSUB Shout ' Send to DS1620.
    LET DSout=Whit 'Send high temperature limit
    GOSUB Shout
    LET DSout=WhiTemp 'Send high temperature limit
    GOSUB Shout9bit
    LOW RSTn ' Deactivate '1620.
    PAUSE 50 ' Wait 50ms for EEPROM programming cycle.
    
    'LET B3 = 8
    'LET DSout = 1
    'GOSUB Shout
    'LET B3 = 9
    'LET DSout = 44
    'GOSUB Shout
    'LOW RSTn ' Deactivate the DS1620.
     
    'LET DSout=StartC ' Now, start the conversions by
    'GOSUB Shout ' sending the start protocol to DS1620.
    'LOW RSTn ' Deactivate '1620.
    ' The loop below continuously reads the latest temperature data from
    ' the DS1620. The '1620 performs one temperature conversion per second.
    ' If you read it more frequently than that, you'll get the result
    ' of the most recent conversion. The '1620 data is a 9-bit number
    ' in units of 0.5 deg. C. See the ConverTemp subroutine below.
    '=== Original Code Saved below ----------
    'Again:
    'PAUSE 1000 ' Wait 1 second for conversion to finish.
    'LET DSout=Rtemp ' Send the read-temperature opcode.
    'GOSUB Shout
    'GOSUB Shin ' Get the data.
    'LOW RSTn ' Deactivate the DS1620.
    'GOSUB ConverTemp ' Convert the temperature reading to absolute.
    'DEBUG "Current Temperature", CR
    'GOSUB DisplayF ' Display in degrees F.
    'GOSUB DisplayC ' Display in degrees C.
    'DEBUG "==========", CR
    '=== Original Code Saved above ----------
    Again:
    PAUSE 1000 ' Wait 1 second for conversion to finish.
    LET DSout=RhiT
    GOSUB Shout
    GOSUB Shin ' Get the data.
    LOW RSTn ' Deactivate the DS1620.
    GOSUB ConverTemp ' Convert the temperature reading to absolute.
    DEBUG "Thermostat High Temperature Limit", CR
    GOSUB DisplayF ' Display in degrees F.
    GOSUB DisplayC ' Display in degrees C.
    PAUSE 2000
    DEBUG CLS
    GOTO Again
     
    ' ===================== DS1620 I/O Subroutines ==================
    ' =====================         Shout's        ==================
    ' Subroutine: Shout
    ' Shift bits out to the DS1620. Sends the lower 8 bits stored in
    ' DSout (w0). Note that Shout activates the DS1620, since all trans-
    ' actions begin with the Stamp sending a protocol (command). It does
    ' not deactivate the DS1620, though, since many transactions either
    ' send additional data, or receive data after the initial protocol.
    ' Note that Shout destroys the contents of DSout in the process of
    ' shifting it. If you need to save this value, copy it to another
    ' register.
    Shout:
    HIGH RSTn ' Activate DS1620.
    OUTPUT DQn ' Set to output to send data to DS1620.
      FOR clocks = 1 TO 8 ' Send 8 data bits.
        LOW CLKn ' Data is valid on rising edge of clock.
        LET DQp = BIT0 ' Set up the data bit.
        HIGH CLKn ' Raise clock.
        LET DSout=DSout/2 ' Shift next data bit into position.
      NEXT ' If less than 8 bits sent, loop.
    RETURN ' Else return.
    Shout9bit:
    HIGH RSTn ' Activate DS1620.
    OUTPUT DQn ' Set to output to send data to DS1620.
      FOR clocks = 1 TO 9 ' Send 9 data bits.
        LOW CLKn ' Data is valid on rising edge of clock.
        LET DQp = BIT0 ' Set up the data bit.
        HIGH CLKn ' Raise clock.
        LET DSout=DSout/2 ' Shift next data bit into position.
      NEXT ' If less than 8 bits sent, loop.
    RETURN ' Else return.
     
    
    ' Subroutine: Shin
    ' Shift bits in from the DS1620. Reads 9 bits into the lsbs of DSin
    ' (w0). Shin is written to get 9 bits because the DS1620's temperature
    ' readings are 9 bits long. If you use Shin to read the configuration
    ' register, just ignore the 9th bit. Note that DSin overlaps with DSout.
    ' If you need to save the value shifted in, copy it to another register
    ' before the next Shout.
    Shin:
    INPUT DQn ' Get ready for input from DQ.
    FOR clocks = 1 TO 9 ' Receive 9 data bits.
    LET DSin = DSin/2 ' Shift input right.
    LOW CLKn ' DQ is valid after falling edge of clock.
    LET BIT8 = DQp ' Get the data bit.
    HIGH CLKn ' Raise the clock.
    NEXT ' If less than 9 bits received, loop.
    RETURN ' Else return.
    ' ================= Data Conversion/Display Subroutines ===============
    ' Subroutine: ConverTemp
    ' The DS1620 has a range of -55 to +125 degrees C in increments of 1/2
    ' degree. It's awkward to work with negative numbers in the Stamp's
    ' positive-integer math, so I've made up a temperature scale called
    ' DSabs (DS1620 absolute scale) that ranges from 0 (-55 C) to 360(+125 C).
    ' Internally, your program can do its math in DSabs, then convert to
    ' degrees F or C for display.
    ConverTemp:
    IF BIT8 = 0 THEN skip ' If temp > 0 skip "sign extension" routine
    LET W0 = W0 | $FE00 ' Make bits 9 through 15 all 1s to make a
    ' 16-bit two's complement number.
    skip:
    LET W0 = W0 + 110 ' Add 110 to reading and return.
    RETURN
    ' Subroutine: DisplayF
    ' Convert the temperature in DSabs to degrees F and display on the
    ' PC screen using debug.
    DisplayF:
    LET W1 = W0*9/10 ' Convert to degrees F relative to -67.
    IF W1 < 67 THEN subzF ' Handle negative numbers.
    LET W1 = W1-67
    DEBUG #w1, " F",CR
    RETURN
    subzF:
    LET W1 = 67-W1 ' Calculate degrees below 0.
    DEBUG "-",#w1," F",CR ' Display with minus sign.
    RETURN
    ' Subroutine: DisplayC
    ' Convert the temperature in DSabs to degrees C and display on the
    ' PC screen using debug.
    DisplayC:
    LET W1 = W0/2 ' Convert to degrees C relative to -55.
    IF W1 < 55 THEN subzC ' Handle negative numbers.
    LET W1 = W1-55
    DEBUG #w1, " C",CR
    RETURN
    subzC:
    LET W1 = 55-W1 ' Calculate degrees below 0.
    DEBUG "-",#w1," C",CR ' Display with minus sign.
    RETURN
    
    
    
  • KievlaninKievlanin Posts: 55
    edited 2012-02-10 18:30
    Shout9:
    HIGH RSTn                                   ' Activate DS1620.
    OUTPUT DQn                              ' Set to output to send data to DS1620.
    FOR clocks = 1 TO 9                  ' Send 9 data bits.
    LOW CLKn                                  ' Data is valid on rising edge of clock.
    LET DQp = BIT0                         ' Set up the data bit.
    HIGH CLKn                                 ' Raise clock.
    LET DSout=DSout/2                  ' Shift next data bit into position.
    NEXT                                           ' If less than 9 bits sent, loop.
    RETURN                                     ' Else return. 
    


    Look at the above code
    Remember, both DSout and DSin are using W0 register.
  • KievlaninKievlanin Posts: 55
    edited 2012-02-10 18:34
    Temperature DS 1620 Original.bs1


    Original flie above. For anyone who wish to play with. (For BS1)
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-11 10:22
    It needs to have the RSTn sequence after the configuration command, and before the threshold commands. The RSTn sequence delimits the commands.
    [SIZE=1]LET DSout=Wconfig ' Put write-config command into output byte.
    GOSUB Shout ' And send it to the DS1620.
    LET DSout=NoCPU' Configure as stand alone thermostat
    GOSUB Shout ' Send to DS1620.
    [COLOR=#020FC0]LOW RSTn ' Deactivate '1620.
    PAUSE 50 ' Wait 50ms for EEPROM programming cycle.
    [/COLOR]LET DSout=Whit 'Send high temperature limit
    GOSUB Shout
    LET DSout=WhiTemp 'Send high temperature limit
    GOSUB Shout9bit
    LOW RSTn ' Deactivate '1620.
    PAUSE 50 ' Wait 50ms for EEPROM programming cycle.[/SIZE]
    
  • KievlaninKievlanin Posts: 55
    edited 2012-02-11 11:24
    OK, I made it working.
    After bunch of trial and error.
    It is now works prefect.
    However, I had to break program into two. (There is a limit on GOSUB (16))
    First will write desired High & Low limits.
    Second program will read & display in DEBUG Terminal: High, Low, Curent Temperatures.

    I think the main trick is at the top of both programs.
    Look how I formatted temperature codes
    High limit is 22C
    Low limit is 19C

    I would like to see your comments on both programs modifications I made.

    And of cource big thanks to Scott Edwards!
    W/out his help all of this may never be possible.
    Temperature Write DS 1620 revB.bs1
    Temperature Read DS 1620 revC.bs1


    On the pictures you will see Green & Red LED.
    Green will go on when T=>22C
    Red will go on when T<=19C
    IMG_5184.JPG
    IMG_5183.JPG
    IMG_5185.JPG
  • Paul RomskyPaul Romsky Posts: 66
    edited 2012-02-12 05:17
    Sorry about the late reply,

    I will take a look today. I will get back to you later.

    I don't check my Parallax mail every day. Send me an e-mail to get a hold of me faster. romsk22@gmail.com.

    Paul
  • Paul RomskyPaul Romsky Posts: 66
    edited 2012-02-12 20:00
    Kievlanin,

    I could only read the code because I do not have a DS1620. I didn't make any modifications to the code, however, I did "beautify" the code so it is eaiser to read.

    Whenever I grab someone else's code, I usually have to throw in a LOT of WHITESPACE and INDENT the loops and conditionals. Notice how I added some comments based only on what I was able to determine from the code.

    I suggest that you do the same (especially when you are learning a new device). Look at the code that I attached below. Notice how this is the same code, but now it is broken down into logical functions and is just a little bit "cleaner". Trust me, if you do this to every piece of code you view (or write) you WILL find mistakes and bugs faster, learn what another's code is doing quicker, and last but not least, make the code easy to read for the next reader.

    Keep up the good work.

    Paul
Sign In or Register to comment.