12F675 and LM35 coding issue


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Charles Linquis View Post
    It loloks to me that you are taking the 10-bit A/D samples and putting them in BYTE variable called TEMP. Changing TEMP to a word should certainly get you one more step.
    Hi, Charles

    The point is interesting as the maximum ADC value WITH THIS SENSOR ... will be ~ 256, and always far from the actual use of the sensor.

    so, we could use ADRESH as an open line indicator ....

    Alain
    Last edited by Acetronics2; - 5th March 2010 at 15:10.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    LM35s don't have much output current, so you have to be careful with the load, but if you put a 100K ohm pull-up resistor to Vref, then you could detect an open sensor.

    Also look at the data sheet. They don't like capacitive loads, so if you have them located more than a few feet from the PIC, you should put a small resistor in series with the LM35 output pin.
    Charles Linquist

  3. #3
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hectic weekend and I was starting to have withdrawal symptoms for my PIC and breadboard, :-)

    I didn't get a chance on the weekend to try this code, however, I must say, I struggled for ages trying to work out how to use the CASE statement and your example above has shown me where I went wrong.

    I have run the example in the simulator (I really need to start bringing my board and programmer to the office, :-) ) however, even with the pause set to 1 it seems to take forever to get through it - thus taking 20 samples @ Pause 250 each time takes hours, :-( - I even tried to set the sim to run Ultra fast, however it still takes ages to run the 20 samples. Looks like im going to have to run it on the chip tonight.

    Something im trying to get right in my head: If the LM35 outputs 10mv per deg, on a 5v reference, would 0deg be 2.50V or would the 2.50V be at the mid point of the units full range (110 to -40) i.e. 34Deg C? The data sheet does not seem to be this specific.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    I have run the example in the simulator
    Vade retro, Satanas ... simulators are TOYS !!!

    Simulator ( which one ... might I understand ??? ) is a tool that doesn't "run" @ real speed ... so, pauses have to be divided per 50 or 100 not to become mad ... or even, have to be commented out !!!

    so, forget about this sim when some "pause" statements are there ...

    the program runs fine here ( I made a small demo where a counter increases temp from 0 to 100 instead of the 20 adc measures - was to verify the SELECT CASE structure, which is slightly different from "C" ... )

    for the LM35 ... take it simple !!! :

    0v for 0°C
    0.01v for 1°C
    0.10v for 10°C
    1.00v for 100 °C
    1.50 v for 150°C ... which is the maximum !!!

    so, 2.50 v is a fried chip !!!

    on a 5v00 ref ... 1.00v will show 1.00v / 5.00v x 1024 = 204 adc counts ... ( 1024 steps for full scale )



    just Work with REAL chips in a REAL World ... you'll get TRUE results ...

    Alain
    Last edited by Acetronics2; - 8th March 2010 at 12:36.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Right, sitting on the couch @ home and was about to post about a strange result I was getting (unexpected LED lighting up)...until I checked my wiring again and I found the breadboard was still swapped from when I was doing the PWM routines with the LEDs, :-).

    Just checked with my DMM and it's 100% spot on, will adjust the CASEes to accommodate the 3 ranges I need and move it to a PCB, :-)

    Just wanted to say a really BIG thank you to everyone who took the time to help a newbie like me see the light (hehe no pun intended).

    I've decided to waterproof the LM35 and place it in the bath to show my 3yr old daughter when the water is too hot to touch - although she knows not to touch unless me or my wife has checked it first.

    My next project will be to take an input from my RC transmitter and drive a servo to start with, think I'm going to have to do quite a bit of reading, :-)

    Once again, thank you Alain, Fratello, Charles and Hendrik, appreciate the assistance - a couple of light bulbs have gone on in my head, looking forward to the journey PICs might lead me on.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Be careful showing little ones you putting something in the bath with wires attached.

    Daddy did it with his gadget, I wonder what the radio sounds like under water....
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Dave, point taken , :-), will make sure its enclosed and placed well before she sees it. Although when she was 2 she dropped a doll in by accident and since then has learn't not to put anything in the water unless its classified as a bath toy.

Similar Threads

  1. 12F675 cant serout to PC
    By ruijc in forum General
    Replies: 9
    Last Post: - 3rd December 2007, 00:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts