Shop OBEX P1 Docs P2 Docs Learn Events
max 7219 and ds1620 as stand alone thermostat — Parallax Forums

max 7219 and ds1620 as stand alone thermostat

aj_ax24aj_ax24 Posts: 16
edited 2005-04-12 04:09 in BASIC Stamp
Im a new user and ordered the kit for the ds1620 and can't really understand anything it is saying.· I get some of the routines and when i tried to download the program from the software it came with the only temp it shows is 0 f and 32 C.· Also considering if i can get the temp to work right i was wanting to display digitaly on the max7219 in real time.· I went to the web site called put your data in lights using an led display chip, and it was giving me code for the bs1 and the variables wern't written wright.
If you could give me a hint of the code for the ds1620 and then shiftout to max7219 it would really be appreciated.· i really liked doing the projects in·whats a microcontroller book and was looking into the industrial controles book but i am getting frustrated with this code thing.· I am more of a hard ware guy myself.· Well if you guys could give some feed back that would be so great.· Thanks for your time and look forword to getting this figured out.·

AJ

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-10 01:38
    ·· You can find code examples for both the MAX7219 and the DS1620 in our Stampworks manual.· This is available as a free download in PDF format from our website.· Please see the Books section.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • aj_ax24aj_ax24 Posts: 16
    edited 2005-04-10 04:44
    Hey thanks ken that was so helpfull.· I guess i need some break down of the code and what it means.· I should be able to work this out great.· Thanks again

    aaron
  • KenMKenM Posts: 657
    edited 2005-04-10 15:14
    aj_ax24 said...

    ·I guess i need some break down of the code and what it means.

    Is there a specific section of code that needs more explanation? If so don't hesitate to ask.

    However, I am going out of town today and will not have access to email until Wednesday.
  • aj_ax24aj_ax24 Posts: 16
    edited 2005-04-11 00:44
    Hey here is my code for the temp of the ds1620. Can anyone help out with how i can put the temp from debug to display on the three digit LED with dp? I have been trying but can't seem to get anything out. thanks


    DQ CON 2 ' Pin 2 <=> DQ.
    CLKT CON 1 ' Pin 1 => CLK.
    RST CON 0 ' Pin 0 => RST (high = active).


    DSdata VAR Word ' Word variable to hold 9-bit data.
    Sign VAR DSdata.BIT8 ' Sign bit of raw temperature data.
    T_sign VAR Bit ' Saved sign bit for converted temperature.

    ' ===================== Define DS1620 Constants ===================
    ' >>> Constants for configuring the DS1620

    Rconfig CON $AC ' Protocol for 'Read Configuration.'
    Wconfig CON $0C ' Protocol for 'Write Configuration.'
    CPU CON %10 ' Config bit: serial thermometer mode.
    NoCPU CON %00 ' Config bit: standalone thermostat mode.
    OneShot CON %01 ' Config bit: one conversion per start request.
    Cont CON %00 ' Config bit: continuous conversions after start.
    ' >>> Constants for serial thermometer applications.

    StartC CON $EE ' Protocol for 'Start Conversion.'
    StopC CON $22 ' Protocol for 'Stop Conversion.'
    Rtemp CON $AA ' Protocol for 'Read Temperature.'
    ' >>> Constants for programming thermostat functions.

    RhiT CON $A1 ' Protocol for 'Read High-Temperature Setting.'
    WhiT CON $01 ' Protocol for 'Write High-Temperature Setting.'
    RloT CON $A2 ' Protocol for 'Read Low-Temperature Setting.'
    WloT CON $02 ' Protocol for 'Write Low-Temperature Setting.'

    ' ===================== Begin Program ============================

    Begin:
    LOW RST ' Deactivate '1620 for now.
    HIGH CLK ' Put clock in starting state.
    PAUSE 100 ' Let things settle down a moment.
    HIGH RST ' Activate the '1620 and set it for continuous..
    SHIFTOUT DQ,CLKT,LSBFIRST,[noparse][[/noparse]Wconfig,NoCPU+Cont] ' ..temp conversions.
    LOW RST ' Done--deactivate.
    PAUSE 50 ' Wait for the EEPROM to self-program.
    HIGH RST ' Now activate it again and..
    SHIFTOUT DQ,CLKT,LSBFIRST,[noparse][[/noparse]StartC] ' Send start-conversion protocol.
    LOW RST ' Done--deactivate.

    ' The loop below continuously reads the latest temperature from
    ' the DS1620.

    again:
    PAUSE 1000 ' Wait a second between readings.
    HIGH RST ' Activate the '1620.
    SHIFTOUT DQ,CLKT,LSBFIRST,[noparse][[/noparse]Rtemp] ' Request to read temperature.
    SHIFTIN DQ,CLKT,LSBPRE,[noparse][[/noparse]DSdata\9] ' Get the temperature reading.
    LOW RST
    'SHOW THAT SHIFTIN COMMAND RECIEVED

    PAUSE 500 'DATA AND PROGRAM IS WORKING
    T_sign = Sign ' Save the sign bit of the reading.
    DSdata = DSdata/2 ' Scale reading to whole degrees C.
    IF T_sign = 0 THEN no_neg1
    DSdata = DSdata | $FF00 ' Extend sign bits for negative temps.

    no_neg1:
    'DEBUG SDEC DSdata," degrees C",CR ' Show signed temperature in C.
    DSdata = (DSdata */ $01CC) ' Multiply by 1.8.
    IF T_sign = 0 THEN no_neg2 ' If negative, extend sign bits.
    DSdata = DSdata | $FF00

    no_neg2:
    DSdata = DSdata + 32 ' Complete the conversion.
    DEBUG SDEC DSdata," degrees F",CR ' Show signed temperature in F.


    ' =========================================================================
    '
    ' File......MAX7219
    ' Purpose...Test the use of shift out to control a MAX7219
    ' Author....Ken Mathis
    ' E-mail....
    ' Started...5/31/04
    ' Updated...
    '
    '
    ' =========================================================================


    '
    [noparse][[/noparse] Program Description ]
    'The program will test the operation of shiftout command to control a MAX7219
    'IC that will multiplex 8 seven segment displays

    '
    [noparse][[/noparse] Revision History ]


    '
    [noparse][[/noparse] I/O Definitions ]
    '0 sets pin as input
    'button PIN 0 makes the word button = pin 0
    'DIRS = $0000 'pins 1 2 3 output,all other pins outputs
    DOUT PIN 7 'pin 1 of stamp to pin 1 of 7219
    Load PIN 6 'pin 2 of stamp to pin 12 of 7219
    CLK PIN 5 'pin 3 of stamp to pin 13 of 7219





    '
    [noparse][[/noparse] Variables ]
    Dig0 VAR Word
    DIG1 VAR Word
    Dig2 VAR Word
    Value VAR Nib
    AJ VAR Nib

    '
    [noparse][[/noparse] EEPROM Data ]


    '
    [noparse][[/noparse] Initialization ]

    Dig0 = $0100
    Dig1 = $0200
    Dig2 = $0300
    Value = 0
    AJ = 0

    '
    [noparse][[/noparse] Program Code ]
    Begin1:
    GOSUB DecodeMode
    GOSUB ShutDownMode
    GOSUB ScanLimit
    GOSUB Intensity


    continue:
    Dig0 = Dig0 | Value
    Dig1 = Dig1 | Value
    Dig2 = Dig2 | Value
    Value = Sign
    'first digit least significant
    SHIFTIN DQ,CLKT,LSBPRE,[noparse][[/noparse]DSdata\9]
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]Dig0\16]
    HIGH Load
    PAUSE 40


    'second digit
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]Dig1\16]
    HIGH Load
    PAUSE 40

    'third digit
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]Dig2\16]
    HIGH Load
    PAUSE 40




    '
    [noparse][[/noparse] Subroutines ]
    'Decode mode for no decoding to BCD
    'Least sig nibble:
    '0 = no decode
    '1 = decode digit 0
    'F = decode digits 0-3
    'FF = decode digits 0-7
    DecodeMode:
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]$090F\16]
    HIGH Load
    RETURN

    'Set shutdown mode so device is active
    ShutDownMode:
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]$0C01\16]
    HIGH Load
    RETURN


    'Set scan limit mode for three digits
    ScanLimit:
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]$0B02\16]
    HIGH Load
    RETURN

    'Set intensity of LEdDs
    'LSNibble 0 = min intensity and F = max intensity
    Intensity:
    LOW Load
    SHIFTOUT DOUT, CLK, MSBFIRST,[noparse][[/noparse]$0A05\16]
    HIGH Load
    RETURN
  • steve_bsteve_b Posts: 1,563
    edited 2005-04-11 17:03
    I got too dizzy reading all that.
    Maybe play with each device exclusively first!
    I've been playing with the DS1620 this w/e with intentions of timestamping the temps with the DS1320. But first I had to play with both to get an idea how I could do this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • aj_ax24aj_ax24 Posts: 16
    edited 2005-04-12 04:09
    Ok sorry about the code overload.· the first part of the code is the basic DS1620 code for reading temp.· Next ken let me see his code for the max7219 and i used it to make some of my own.· All i needed was to get the 7219 to display the digital read out of the temp.· So after some close examination of Kens code I figured out how to display three digits of realtime code from the 1620.· it was a simple matter of making a variable = to the digital value of the temp.· then i used a few if then; if else statements to cover the spectrum.· I don't however know how to use the DS1620 as a stand alone thermostat so i am just using it as a temp and programming the BS2 for the
    IF temp·> #< #·then
    goto cool·down

    and so on.· below is some code for the·different set points of tempspans i want·but if someone know how to use the DS1620 as a thermostat i could use a darlington pair to drive the circuits i want to run on Thigh and TLow.

    thanks

    AJ

    Code:
    IF IND = 0000·Then
    GOTO Code
    ELSEIF·IND = 0001 Then
    GOTO·tempspan70To75
    ELSEIF IND = 0010 Then
    GOTO·tempspan65To70
    ELSEIF IND = 0011 Then
    GOTO tempspan60To65
    ELSIF IND = 0100 Then
    GOTO tempspan55To60
    ELSIF IND > 0101 Then
    GOTO Code
    ENDIF

    All that just for set peramiters·in conjuction with a·dip switche for a thermostat.· So if anyone can help in using the DS1620 it would be much appreciated
Sign In or Register to comment.