Shop OBEX P1 Docs P2 Docs Learn Events
LCD displaying results from DS1620 — Parallax Forums

LCD displaying results from DS1620

Basic JimBasic Jim Posts: 106
edited 2008-04-23 00:55 in General Discussion
Hello All,

Although I am sure this has been done before my forum search hasn't returned anything. What I am trying to do is to covert the SX/ Help file thermometer example·to displaying the tempurature on my Parallax 16X2 serial LCD. I have been able to make it work as shown in the help file using the 7 segment LEDs so I'm sure my hardware is OK. but when I modify the program to send it to the LCD the values are always 0. If anyone has already done this or similar and would like to share their code I would be greatfull. Can't see where I am going wrong with this program. Seems to me I should get something.

Thanks,
Jim W.

Comments

  • BeanBean Posts: 8,129
    edited 2007-11-21 19:37
    Jim,
    The internal 4MHz clock cannot be used with serial communication. It is not accurate enough.
    Change the OSC4MHZ parameter on the device line and use a resonator.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-11-21 19:46
    Jim-
    I have been trying to do this as well. I haven't finished (GEE...that doesn't sound like me? Move on to something else...? [noparse]:)[/noparse] ) but I can post what I have done if you think it will help.

    Shawn

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • Basic JimBasic Jim Posts: 106
    edited 2007-11-21 20:31
    Thanks Shawn,

    I'm sure it can't work anyworse than mine.

    Bean,

    I will try the resonator route tonight. But, If the reason you sugest it is about talking to the DS1620, the SX/B example doesn't require the resonator and it did work that way using the seven segment LEDs. As the program stands it talks to the LCD fine. I can display Variables and the little pong character chompers work. Anyway, I will be happy to give it a shot. I have yet to try the resonators. I just gotta find them.

    Best,
    Jim W.
  • stamptrolstamptrol Posts: 1,731
    edited 2007-11-22 01:16
    ·Jim,

    ··· I, too, am working my way up the SX/B learning curve.

    ··· I've modified one of the sample programs to use the Parallax LCD, a temperature probe, and a pot using RCTIME.

    ··· Some of it may be of value to you. It ain't pretty because I left in a lot stuff from the programs I borrowed from.

    · Cheers,



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
  • JDOhioJDOhio Posts: 72
    edited 2007-11-22 13:42
    Have you tried writing out hard coded numbers after you print " Indoor Temp "? After you print that, try printing "123" on the next line rather than the temperature. This might isolate where to focus your search for the issue.

    Joe
  • Basic JimBasic Jim Posts: 106
    edited 2007-11-22 16:25
    Thanks Tom,
    I will have a peek after the company leaves later today.

    Hi Joe,
    I tried instead of using the tempurature vaiable to make a simple counter and that displayed the counting fine. I also tried making the variable equal a certain number and that number is didplayed ok. I think the problem is in how the code is reading the chip or initializing the chip. I must be missing something sutle. I was hoping it might be obvious to someone with more experience. I will also try to locate my parallax o scope and see if the chip is getting input and outputing something. Even though I quadrupled checked the wiring, at this point there might still be a hardware issue.
    Thanks to all,
    Jim W.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-11-22 17:04
    Well, here is my input. It looks like I stopped after I tried to verify I was getting good data from the 1620. I finally hooked the darn thing to my BS2sx and verified it works. I have had BAD 1620's before so maybe you'll want to verify its good before you killl yourself over the code.

    Shawn

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
  • JDOhioJDOhio Posts: 72
    edited 2007-11-22 17:11
    Here is how I read/write data to the DS1620:

    Write
    SHIFTOUT DS1620DataIO,DS1620Clock,LSBFIRST,temp2

    Read
    SHIFTIN DS1620DataIO,DS1620Clock,MSBFIRST,temp1

    I have to call SHIFTIN twice like you are doing to get all the data. I remember a thread in this forum about the data conversion. I included some pseudo code to convey the concept. Basically, by using other information from the DS1620, it was possible to increase the resolution.


    CONVERT:
    theTemp = theTemp >> 1 = 29 (00111011) (00011101)
    theTemp = theTemp * 100 = 2900 29 * 100
    theTemp = theTemp – 25 = 2875 2900 - 25
    cRem = slope - cRem = 8 16 - 8
    cRem = cRem * 100 = 800 8 * 100
    cRem = cRem / slope = 50 800 / 16
    theTemp = theTemp + cRem = 2925 2875 + 50
    theTemp = theTemp */ $01CC = 5255 Explained below
    theTemp = theTemp + 3200 = 8455 5255 + 3200
    theTemp = theTemp / 100 = 84 8455 / 100 = 84.55 (drop decimal)
    cRem = __WREMAINDER = 55 Remainder from above
    RETURN


    Also, the DS1620 requires about 700 ms to make the conversion. I monitor the status byte to determine when the temperature is ready before reading it.

    Joe
  • jbrierleyjbrierley Posts: 9
    edited 2007-11-23 01:21
    Hi, Jim:· There's code for displaying on the serial LCD in the thread I just posted last week.· I've had trouble reading the accelerometer but the serial LCD output works slick and there's code for converting a byte variable (123, for example) to the numbers "123" for display on the LCD:

    http://forums.parallax.com/showthread.php?p=690243

    The code's a bit messy, but I'm sure you can figure it out.

    Regards,
    Jon
  • Basic JimBasic Jim Posts: 106
    edited 2007-11-23 02:41
    Thank you Jon,
    I have been working on the problem program that I posted at the begining of this thread. I found a couple problems with it and I finally got it working somewhat. One problem was that I was pulling up a pin that was actually being used. The second problem was that for some reason the rst line wasn't working when the exact same command worked fine in the helpfile example. The example has 'rst = 1' but what worked for me was saying 'high rst' or 'low rst'! I'm stumped why 'rst = x' wouldn't work but changing it worked! I'm not at the right temp yet but I can see a result when I warm up the chip. Attached is the code that is kinda working for anyone·that might want to check it out. I'll post a cleaner working one if I can get it totaly working.

    If anyone knows why 'High rst' works but 'rst = 1' doesn't please let me know.

    Thanks,
    Jim W.
  • JDOhioJDOhio Posts: 72
    edited 2007-11-23 13:34
    HIGH rst probably works because it tells RC.5 to be an output pin. If you added something like

    TRIS_C = %00000000 'all outputs

    near the beginning of your program (after the PLP commands, say), rst=1 might work again.

    The HIGH command produces seven lines of assembly because it assigns I/O direction (i.e., makes the pin an output). It could get expensive if you have a large program. By assigning your pins I/O direction at the start, you assign I/O direction once. From then on, you should be able to use rst=1 which produces a single line of assembly.

    Joe
  • Basic JimBasic Jim Posts: 106
    edited 2007-11-23 17:13
    Thank you Joe,
    You were right TRIS command did the trick. I changed the rst line back to the original setup and it works!

    Here is a working version of the program. It still needs cleaning up but it should be·a·decent starting point for anyone·wanting to show tempurature on a 16 X 2 LCD.

    Thanks everyone,
    Jim W.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2008-04-23 00:55
    Well, I just wanted to post my final code on this. Pretty sad it takes me this long, but for me, the learning curve+time to devote is high. But finally got it. Cool!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    Maybe I should have waited to do that......
Sign In or Register to comment.