How to use LM34 to full range with PBP


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52

    Default How to use LM34 to full range with PBP

    How can I go about reading in an LM34 at full range with a 12F683 and PBP?
    It outputs -500mv at -50deg anf +3000mv at 300 deg.
    Can a pic read a negative voltage and how would PBP tell the the difference between -500 and +500?

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


    Did you find this post helpful? Yes | No

    Default

    You can do this several ways.

    But probably the best way is the method given in a National Semi application note: Put two diodes between the "-" terminal of the LM34 and GND. This offsets the voltage by about 1V. You will also note that - because the diodes have a temperature coefficient of their own, you should also measure the voltage at the junction of the diodes and the LM34 and take a differential reading. Of course, this will take two channels of A/D.

    Look for National Semi Application Note AN-460, and check out Figure 10.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    And yet another method that I have used:

    Your system probably has a precision reference voltage (for example: I use a 4.096V reference for the A/Ds). Use a resistive divider off that reference to give you about 1.0V, and then buffer that voltage with an op-amp. Use the output of the buffer for the negative supply of the LM34.
    Charles Linquist

  4. #4
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by polymer52 View Post
    Can a pic read a negative voltage and how would PBP tell the the difference between -500 and +500?
    No a pic can not read negative voltages. However the voltage may be shifted to a range the pic can read.

    One simple way I see of doing this to offset the voltage is by using a voltage divider to great a "fake" ground for the LM34. If you set this fake ground to +1VDC in refference to your pic's ground that will shift the output of the lm34 up 1000mv. The new range would be +500mv for -50*F and +4000mv for 300*F. Then in PBP remember to offset this value for the correct temp.
    Shawn

  5. #5
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by spcw1234 View Post
    No a pic can not read negative voltages. However the voltage may be shifted to a range the pic can read.

    One simple way I see of doing this to offset the voltage is by using a voltage divider to great a "fake" ground for the LM34. If you set this fake ground to +1VDC in refference to your pic's ground that will shift the output of the lm34 up 1000mv. The new range would be +500mv for -50*F and +4000mv for 300*F. Then in PBP remember to offset this value for the correct temp.
    How do I connect the floating ground to the pic? Does it need a separate isolated supply? I can't ground the floating ground correct?

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


    Did you find this post helpful? Yes | No

    Default

    The link I gave you from National Semi handles all the voltage offsets. It is all you need.
    Charles Linquist

  7. #7
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    The link I gave you from National Semi handles all the voltage offsets. It is all you need.
    I read that but that basically gives me 2 grounds. The supply ground and the new floating ground. Do I have to use 2 analog channels and read the difference or use a separate isolated supply? I was hoping to get away with just a single supply but that may not be possible.

  8. #8
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile Maybe this will help...

    Quote Originally Posted by polymer52 View Post
    I read that but that basically gives me 2 grounds. The supply ground and the new floating ground. Do I have to use 2 analog channels and read the difference or use a separate isolated supply? I was hoping to get away with just a single supply but that may not be possible.
    Hi polymer52,

    I was confused by the same thing. Think this is how it goes:
    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3869&stc=1&d=126298242 8">
    Attached Images Attached Images  
    Ohm it's not just a good idea... it's the LAW !

  9. #9
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Hi polymer52,

    I was confused by the same thing. Think this is how it goes:
    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3869&stc=1&d=126298242 8">
    Ohh. I get it.
    So it will take 2 A/D channels for each sensor. I'm using an 8 pin pic with 3 A/D channels in use and the 4th is used for the voltage ref. Looks like if I want full scale I'll have to go to an 18 pin pic or use the Dallas 1 wire devices which may be an option.
    Thanks guys.

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


    Did you find this post helpful? Yes | No

    Default

    Yes, the Nat Semi app note method requires two channels. If the temperature is above "0" then the output will be above the GND terminal of the LM34, if the temperature is below "0", then the the output will be below the GND terminal of the LM34, but both of them will be positive with respect to PIC GND.
    Read both channels. Subtract the smaller reading from the larger and compute the temp. If the channel 1 reading is larger than the channel 2 reading the temp is positive. Otherwise the temp is negative.

    Another way that takes only one channel: Replace the two diodes shown in the application note with a 1.25V precision reference. Since you now know that the GND terminal of the LM34 is at 1.25V, "0" degrees will give you 1.25V into the A/D. -20 degrees will give you 1.05V (1.25V - (10mv/degree * 20 degrees)).
    Charles Linquist

  11. #11
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Yes, the Nat Semi app note method requires two channels. If the temperature is above "0" then the output will be above the GND terminal of the LM34, if the temperature is below "0", then the the output will be below the GND terminal of the LM34, but both of them will be positive with respect to PIC GND.
    Read both channels. Subtract the smaller reading from the larger and compute the temp. If the channel 1 reading is larger than the channel 2 reading the temp is positive. Otherwise the temp is negative.

    Another way that takes only one channel: Replace the two diodes shown in the application note with a 1.25V precision reference. Since you now know that the GND terminal of the LM34 is at 1.25V, "0" degrees will give you 1.25V into the A/D. -20 degrees will give you 1.05V (1.25V - (10mv/degree * 20 degrees)).
    Yes! That sounds like what I need.
    I'm using all the analog inputs on my little 12F683 and I don't have any extra pins to use 2 per sensor.
    The 1.25v reference sounds perfect. I have some LM385's around here which are 1.235V if I can just find them.
    Thanks.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP Extensions, What are they?
    By PJALM in forum PBP Extensions
    Replies: 9
    Last Post: - 28th September 2021, 11:26
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30
  5. PBP / XP Crash
    By pondindustrial in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th November 2005, 03:16

Members who have read this thread : 1

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