Shop OBEX P1 Docs P2 Docs Learn Events
1wire DS2760 > SX28 — Parallax Forums

1wire DS2760 > SX28

T ChapT Chap Posts: 4,223
edited 2006-11-21 16:35 in General Discussion
I am looking for an easy solution to get the DS2760 Temp into a computer via serial port. Is the SX able to read the chip and convert to F or C, then allow the computer to read it? I am looking through the 1wire file in the SX software, trying to decide how to start. t looks doable, just wanted to make sure. If a code exists somewhere already for the Parallax thermocoupler kit please let me know. I have the Stamp version, but it looks like a ton of work to convert it.

The idea in mind is to program the SX to locate the 1wire device, read it's temp value every second, and output the temp value for every readTemp. I don't see a need for the SX to get info back from the comp.

Thanks for any suggestions whether this will work. If it will work, will the timing be critical enough to require the 4m resonator?

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-16 23:27
    I posted SX/B code to read the DS2760 awhile back.
    Here is the link: http://forums.parallax.com/showthread.php?p=601621

    As written it·is only for the K-Type thermocouple, and only for 0°C to 500°C.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin


    Post Edited (Bean (Hitt Consulting)) : 11/16/2006 11:33:36 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2006-11-17 00:23
    This is great! I was hoping it was out there somewhere. Thanks Bean
  • T ChapT Chap Posts: 4,223
    edited 2006-11-17 03:02
    Bean, it's working out like I needed. I am looking for a way to get the temperature out as a string. It looks like you assmebled the numbers on the LCD one at a time, I am curious why you didn't send it a value as integer(string)instead. Since I am not needing the LCD for the application, but rather sending a string to a PC, is the variable Temperature what I would use to send out serially?

    Thanks

    Post Edited (originator99) : 11/17/2006 4:56:47 AM GMT
  • PJMontyPJMonty Posts: 983
    edited 2006-11-17 06:27
    Originator99,

    Looking at the code, it's pretty obvious that "temperature" is the variable holding the temperature, and the one you want to send... but you know that already.

    Sometimes it's better to knock things around a bit, do some tests (boiling water), and verify what you believe to be true. It sounds like you read the code but didn't quite trust yourself. Give it a shot! It's the best way to learn.
      Thanks, PeterM
  • T ChapT Chap Posts: 4,223
    edited 2006-11-17 06:37
    You are correct, yet when I send that to the computer as a string( as shown in my code below), it shows up as all kinds of garbage, not something that looks like a usable number. I was hoping to get it out as an integer with no decimals.

    I merged the ReadString and Thermo codes and have everything working as needed except getting the Temp to look like it should.

    I have knocked it around, 4 hours non stop [noparse]:)[/noparse]

    Anything I send within quotes goes over no problem. But TX_Str temperature shows up as all kinds of symbols , no numbers

    Post Edited (originator99) : 11/17/2006 7:19:57 AM GMT
  • PJMontyPJMonty Posts: 983
    edited 2006-11-17 07:24
    Originator99,

    I'm don't use SX/B, but it looks to me like you're not sending a string, but rather sending an integer to the PC. You have this code:

    TX_STR temperature       ' send inline string  to PC  ???????????????????????
          TX_STR CrLf              ' send stored z-string
    
    



    The problem is that the definition of "temperature" is this:

    temperature  VAR Word                  ' Holds temperature in 0.1°C units (250 = 25.0°C)
    
    



    That is just an integer, and not a string. Furthermore, temperature is whittled away to create a string for the LCD, so when it's done, it has nothing or junk in it. It makes sense that you get junk on the PC side because I am assuming you're using a terminal program to read it. If so, then the terminal program takes whatever is receives and tries to interpret it as ASCII when it's not - it's a raw integer.

    You comment mentions "inline string" but there is no inline string that I see. Instead, the code creates an equivalent of the temperature and sends it a character at a time to the LCD as it creates it. I think that if you follow each call of:

    LCDSend temp
    
    



    with something like:

    temp = temp or $30 'Convert number to ASCII equivalent
         TX_STR temp, 1 'Send to PC
    



    You should get the results you're looking for.

    Bear in mind, I have no idea what hardware you're using. I'm not sure what LCD you have attached, and if it is working or not. I also don't know if you have verified that you are able to send any string data to the PC over a serial port. If not, then get that working first, and then figure out how to integrate that knowledge into this code you're working on.
      Thanks, PeterM
  • T ChapT Chap Posts: 4,223
    edited 2006-11-17 07:29
    Thanks Peter. I can send anything in "quotes" no problem. The LCD is working fine. What you are suggesting is exactly what I am looking for, only didn't say it correctly, I needed to convert the integer to a string, which is the obvious problem. I'll plug in the fixes and see what happens. Greatly appreciated! I don't use the SX, so it if foreign to me, the Propeller works easily for me doing this, but I have more experience with it.
  • T ChapT Chap Posts: 4,223
    edited 2006-11-17 08:23
    temp = temp or $30 'Convert number to ASCII equivalent
         TX_STR temp, 1 'Send to PC
    




    This works when TX_Str is replaced with TX_Byte

    Thanks for the schooling. I looked everywhere in the help and did not see a method to convert to string.
  • PJMontyPJMonty Posts: 983
    edited 2006-11-17 17:54
    Originator99,

    OR'ing the numbers 0 to 9 with $30 is a classic old school trick for converting to ASCII. It works because the ASCII value for the number "0" is $30, and ASCII for "9" is (you guessed it) $39. In this case simply adding them together would also work just as well.

    Glad to hear it helped.
      Thanks, PeterM
  • BeanBean Posts: 8,129
    edited 2006-11-18 01:06
    If you want trouble-free serial communication, I would recommend using an external resonator.
    If you were using a slower baud rate (say 1200 baud), you MIGHT get away with the internal 4MHz with IRC_CAL IRC4MHZ.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • DunnseptDunnsept Posts: 115
    edited 2006-11-21 16:35
    Just a quick side here. depending on the accuracy you need to have, we know that each bit of data coming from the TC is 15.625uv. Using K type TCs you can figure that 2.56 bits of TC data is 1 degree C. so, take your reading, adjust by the cold junction temp and multiply by 2.56 to get degrees C.
    I've been using it in my coffee roaster and it seems to be pretty accurate. I've not done a lot of testing to see exactly how accuracte, but someday I will... honest.
    Bean's method is likely more accurate tho.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
Sign In or Register to comment.