Shop OBEX P1 Docs P2 Docs Learn Events
Problem with DS1620 — Parallax Forums

Problem with DS1620

useruser Posts: 3
edited 2009-09-17 20:07 in General Discussion
My 68HC11 project is complete, but when show the temperature on the LCD it always show 28.5 oC, or in BCD – 00111001. I don’t know why. I read the code couple of times to make sure that I didn’t make something wrong. Can somebody help me.

This code I took from here: http://www.emicros.com/ds1620.htm and modify it little because it was showing 0 oC

This is fragments of the code:


RSTTEMP equ %00100000
I_O equ %00001000
SCLK equ %00010000




ReadTemperature:
ldx #REGBLK
bset DDRD,x %00111000
bclr PortD,x SCLK
bset PortD,x RSTTEMP
ldaa #$AA

ldab #8
ZS:
bclr PortD,x I_O
lsra
bcc NS
bset PortD,x I_O
NS:
bset PortD,x SCLK
nop
nop
nop
bclr PortD,x SCLK
decb
bne ZS

clr TempLSB
clr TempMSB
bclr DDRD,x I_O
ldab #8
JJ:
nop
nop
nop
bset PortD,x SCLK
clc
brclr PortD,x I_O HJ
sec
HJ:
ror TempLSB
bclr PortD,x SCLK
decb
bne JJ

bset PortD,x SCLK
brclr PortD,x I_O AD
ldaa #1
staa TempMSB

AD:
bclr PortD,x SCLK
bset DDRD,x I_O
bclr PortD,x RSTTEMP
ldab TempLSB
rts




BCD2STR:
psha
anda #$0F
oraa #$30
staa 1,x
pula
asra
asra
asra
asra
anda #$0F
oraa #$30
staa 0,x
rts




ldaa Str2+1
cmpa LastSecond
beq NoNewTemp
staa LastSecond
jsr ReadTemperature
lsrb
bcc Set00
ldaa #'5'
bra Set05
Set00:
ldaa #'0'
Set05:
staa Str2+12

clra
tba
ldx #Str2+9
jsr BCD2STR
clrb
ldab TempMSB
cmpb #$1
bne NoNewTemp
ldaa #'-'
staa Str2+8

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-09-15 20:30
    Uh.... what makes you think it's appropriate to ask for 68HC11 help in an SX forum? Google is your friend; use it to find 68HC11 resources on the Internet.
  • useruser Posts: 3
    edited 2009-09-16 06:00
    Because I asked in couple of other forums and search in Internet - no solution. Nobody say that can help me.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-16 13:58
    We can't help you with your 68H11 code. If you had a question about how the DS1620 works, we could point you to documentation and sample code for any of Parallax's microcontrollers and try to answer your question in terms of a Parallax microcontroller, but not the 68H11.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-09-16 16:19
    user said...
    Because I asked in couple of other forums and search in Internet - no solution. Nobody say that can help me.

    The next time you're craving Chinese food try ordering it from Mexican restaurant and see how they respond.

    As Mike points out, if your question is about the DS1620 then fine, but you seem to want code for a processor that is not supported on this forum. The 68HC11 is very popular with the Seattle Robotics Society, you might give them a try.
  • useruser Posts: 3
    edited 2009-09-17 15:14
    I solved the problem by putting this code in the initialization:

    ldx #REGBLK
    bset DDRD,x %00111000
    bclr PortD,x SCLK
    bset PortD,x RSTTEMP
    ldaa #$EE

    ldab #8
    ZS1:
    bclr PortD,x I_O
    lsra
    bcc NS1
    bset PortD,x I_O
    NS:
    bset PortD,x SCLK
    nop
    nop
    nop
    bclr PortD,x SCLK
    decb
    bne ZS1


    When I done this I begin to get different readings such as 3=, 2> and so on.

    So I put this code for the convertion from BCD to degrees, showing on LCD:

    clra
    ldx #10
    idiv
    orab #$30
    stab str2+10
    xgdx
    ldx #10
    idiv
    orab #$30
    stab str2+9


    When I put it I begin to get from 40oC to 65-70oC, but without any marks or unknown symbols.

    I'm surprised of this reading, because the temperature on the corpus of the device is not more than 25-27oC, even colder.

    Is there an error in the code for the conversion?
    Can somebody tell me better method, because I don't know other?
  • mikedivmikediv Posts: 825
    edited 2009-09-17 20:07
    Wow, OK. User I belong to the "hc11@yahoogroups.com" Ask them this is a site dedicated to the HC11 I use it all the time and its a very good resource.
    Your question will be emailed to all the members and someone always tries to help.
Sign In or Register to comment.