Shop OBEX P1 Docs P2 Docs Learn Events
DS2760 doubt — Parallax Forums

DS2760 doubt

jabezsdavidjabezsdavid Posts: 11
edited 2010-07-22 02:56 in Accessories
when I compile this temperature program, I am to get output as out of range. I deleted some lines from the program which I got it DS2760 thermocouple kit. could some one tell what went wrong in this program given below.

'
[noparse][[/noparse] Initialization ]

Check_Device:

OWOUT OW, %0001, [noparse][[/noparse]ReadNet]
OWIN OW, %0010, [noparse][[/noparse]SPSTR 8]

GET idx, char
IF (char<>$30)THEN
DEBUG "No DS2760 found."
STOP
ENDIF

'
[noparse][[/noparse] Program Code ]

Main:
DO
GOSUB Read_TC_Volts
GOSUB Read_CJ_Temp

READ(tmpCJ * 2),cjComp

IF sign THEN

IF (tCuV < cjComp) THEN
cjComp = cjComp - tCuV
ELSE
cjComp = 0
ENDIF
ELSE
cjComp = cjComp + tCuV
ENDIF

LOOKUP type, [noparse][[/noparse]1023, 1023, 400], tblHi
GOSUB TC_Lookup
tempF = tempC * 9 / 5 + 32

IF (error = 0) THEN
DEBUG CRSRXY, 0, 7,
"Temp °C..... ", SDEC tempC, CLREOL
DEBUG CRSRXY, 0, 8,
"Temp °F..... ", SDEC tempF, CLREOL
ELSE
DEBUG CRSRXY, 0, 7,
"Temp °C..... Out of Range", CLREOL
DEBUG CRSRXY, 0, 8,
"Temp °F..... Out of Range", CLREOL
ENDIF

PAUSE 1000
LOOP
END

Read_Vin:
OWOUT OW, %0001, [noparse][[/noparse]SkipNet, RdReg, $0C]
OWIN OW, %0010, [noparse][[/noparse]vIn.BYTE1, vIn.BYTE0]
IF (vIn.BIT15) THEN
vIn = 0
ELSE
vIn = vIn >> 5 */ $4E1
ENDIF
RETURN

Read_TC_Volts:
OWOUT OW, %0001, [noparse][[/noparse]SkipNet, RdReg, $0E]
OWIN OW, %0010, [noparse][[/noparse]tCuV.BYTE1, tCuV.BYTE0]
sign = tCuV.BIT15
tCuV = tCuV >> 3
IF sign THEN
tCuV = tCuV | $F000
ENDIF
tCuV = ABS tCuV */ 4000
RETURN

Read_CJ_Temp:
OWOUT OW, %0001, [noparse][[/noparse]SkipNet, RdReg, $18]
OWIN OW, %0010, [noparse][[/noparse]tmpCJ.BYTE1, tmpCJ.BYTE0]
IF (tmpCJ.BIT15) THEN
tmpCJ = 0
ELSE
tmpCJ = tmpCJ.HIGHBYTE
ENDIF
RETURN

TC_Lookup:
tblLo = 0
tempC = 22

READ (tblHi * 2), Word testVal
IF (cjComp > testVal) THEN
error = 1
ELSE
DO
eePntr = (tblLo + tblHi) / 2
READ (eePntr * 2), Word testVal

IF (cjComp = testVal) THEN
EXIT
ELSEIF (cjComp < testVal) THEN
tblHi = eePntr
ELSE
tblLo = eePntr
ENDIF

IF ((tblHi - tblLo) < 2) THEN
eePntr = tblLo
EXIT
ENDIF
LOOP
tempC = eePntr
ENDIF
RETURN

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-07-07 02:12
    David,

    one thing that will help forum members help you is for you to place your code between two "code tags". They look like this except you need to take out the spaces

    [noparse][[/noparse] code ]

    [noparse][[/noparse] / code ]

      That way the indentation
         of your code
           will be preserved
    
    
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-07-07 18:19
    Actually, I would recommend anything more than a code segment be attached rather than pasted in the message. The DS2760 program is complex enough, but trying to chase it down on a forum post...nonetheless there is very little code there and the original code is multi-bank.

    What happens when you run the demo code without making modifications and making sure all slots get loaded?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-07-08 17:03
    With such a large program maybe it would be better to explain in what way you are modifying the code instead of forum members having to do a line-by-line comparison. When modifying this complex and large of a program it helps to understand what every line in the original program is doing so that way you know what you can safely remove and what you cannot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • jabezsdavidjabezsdavid Posts: 11
    edited 2010-07-11 14:58
    I just deleted menu lines from the program. after I delete this part , I get the output has out of range. could you explain these line in the program. since I need to use SEROUT instead of DEBUG.

    Menu:
    DEBUG CLS,
    "===============================", CR,
    " DS2760 Thermocouple Interface ", CR,
    "===============================", CR,
    CR,
    "Select TC Type (1 - 3)", CR,
    CR,
    "(1) K - Chromel/Alumel", CR,
    "(2) J - Iron/Constantan", CR,
    "(3) T - Copper/Constantan", CR,
    CR,
    ">>> "

    DEBUGIN DEC1 type
    IF (type < 1) OR (type > 3) THEN Menu
    DEBUG CRSRXY, 0, 3, CLRDN
    STORE type

    Show_SN:
    DEBUG CRSRXY, 0, 4, "Device SN... "
    FOR idx = 0 TO 7
    GET idx, char
    DEBUG HEX2 char
    NEXT

    Show_Type:
    DEBUG CRSRXY, 0, 6, "TC Type..... "
    LOOKUP (type - 1), [noparse][[/noparse]"KJT"], char
    DEBUG char
  • ridharidha Posts: 1
    edited 2010-07-22 02:56
    i want made a projetc with ds 2760 ,but in the datasheet with basic stamp ,I have try with AVR but can't run really. is it wrong, and why made project ds 2760 and in for avr/atmega
Sign In or Register to comment.