read temperature


Closed Thread
Results 1 to 17 of 17
  1. #1
    breeno's Avatar
    breeno Guest

    Unhappy read temperature

    I would read temperature from TC74 temperature sensor with PIC16F84 and LCD display.

    This is my code



    SCL var PORTA.3

    SDA var PORTA.4

    TEMP var BYTE



    MAIN:

    PAUSE 1000

    I2CWRITE SDA, SCL, $9A, $1, [$00]

    I2CREAD SDA, SCL, $9A, $0, [TEMP], NOREAD

    GOTO OK

    NOREAD:

    LCDOUT $FE, 1

    LCDOUT “NOREAD”

    GOTO MAIN

    OK:

    LCDOUT $FE, 1

    LCDOUT “TEMPERATURE= “, #TEMP

    GOTO MAIN

    END





    I don’t know why the display always screen “noread”….. i have verified the connections and it seems ok.... please HELP!!!!!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    could be some reasons.
    • 1. do you have 4.7k pullups on SDA & SCL pins ?
      2. Your device probably need a delay after I2Cwrite prior to read from.


    what about if you remove the NOREAD label?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    breeno's Avatar
    breeno Guest


    Did you find this post helpful? Yes | No

    Default

    I have 5k6 pullup resistor...
    i have tried to put a pause between write and read (500ms) but nothing!!!
    if i remove the noread label, the lcd always shows "TEMP=16"

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    breeno's Avatar
    breeno Guest


    Did you find this post helpful? Yes | No

    Default

    i have the same code but it doesn't work!!!!!
    maybe i have to put some config instruction?
    please help!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    can you do one test... change your SCL and SDA pins to PORTB and have 1.8k-2.2k resistor ??? after that i'll have an eye to the code.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    breeno's Avatar
    breeno Guest


    Did you find this post helpful? Yes | No

    Unhappy

    i'm desperate!!!
    i have changed scl and sda pins to portB..nothing
    i have changed resistor to 4k7....nothing

    this is my all code:


    @ DEVICE XT_OSC, WDT_OFF, PWRT_ON, PROTECT_OFF

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    ' DEFINE I2C_SCLOUT 1


    SCL var PORTA.2
    SDA var PORTA.3

    TEMP var BYTE
    TEMP=0


    MAIN:
    PAUSE 1000
    LCDOUT $FE, 1
    LCDOUT #TEMP
    ' i2cwrite sda,scl,$9A,$1,[$00],NOREAD
    i2cwrite sda,scl,$9A,$1,[$00]
    ' pause 1000
    i2cread sda,scl,$9A,$0,[temp] ' Read temperature
    goto prox
    noread: lcdout "noread"

    prox: GOTO MAIN
    END


    with the noread label the display always screens "0 noread"
    without noread label the display always screens "2"

    the same thing also with the pause between write and read and with or without the I2C_SLOUT option

    i attach an image with the hardware config...

    please save me!!!!!
    thanks!!!!
    Attached Images Attached Images  

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    can you try to place sensor in stand by before ?

    i2cwrite sda,scl,$9A,$1,[$80] ' Place sensor in stand-by mode
    pause 100
    i2cwrite sda,scl,$9A,$1,[$00] ' Place in normal operating mode
    i2cread sda,scl,$9A,$0,[temp] ' Read temperature

    maybe i'm wrong but worth a try.

    What about if you revert your SDA & SCL pins ???
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    breeno

    your code appears to be ok.
    (I don't have a TC74 handy to test it)

    Probably the Sensor is faulty, have you tried a different one ?
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  10. #10
    breeno's Avatar
    breeno Guest


    Did you find this post helpful? Yes | No

    Unhappy

    i have tried another sensor...nothing
    nothing also reverting sda and scl pins...

    maybe some option?

    regards
    breeno

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm, the only lasts things that sping to mind is ...

    1. is your supply line is neat and clean ?
    2. what about if you place 0.1 uF + 10 uF(close to PIC and close to sensor)
    3. are you sure of your Sensor pins... can it be reverted
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    breeno's Avatar
    breeno Guest


    Did you find this post helpful? Yes | No

    Unhappy

    after days of tests.... nothing...
    i don't know why with the noread label i have "no connection" while without noread label i have always "2" on LCD.
    i have reverted all pins, filtered supply line and sensor supply, i have tried every configuration option, i have inserted pauses betwen every instruction, i have changed resistor to 4k7..... always the same thing.....
    any idea?

  13. #13
    Join Date
    Apr 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Cool Device adress

    Hi!

    You're using device adress $9A thats mean label on your sensor is TC74A5 if not, you have found out your problem. Anyway you're using same adress-command for reading as for writing that's error too.

    For TC74A0 is adress 1001000* (thats mean $90 for writing $91 for read from device)

    For TC74A1 is adress 1001001*
    For TC74A2 is adress 1001010*
    For TC74A3 is adress 1001011*
    For TC74A4 is adress 1001100*
    For TC74A5 is adress 1001101*
    For TC74A6 is adress 1001110*
    For TC74A7 is adress 1001111*

    * is R/W, place 1 for reading from TC74, 0 for writing.

    Anyway i'am using 4,7k pullup on both of pins.

    This code is working for me (replace device adress if you've another):

    BStart ; initiate i2c start
    i2cwrite sda,scl,$90,$1,[$00] ' Place in normal operating mode
    BStop ; stop i2c
    Pause 10
    BStart ; initiate i2c start
    i2cread sda,scl,$91,$0,[temp] ' Read temperature
    BStop ; stop i2c


    Hope that will help you...
    (and sorry for my english)

    Milos

  14. #14
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Talking late is better than never ...

    Hi, Milos

    Many Thanks for that useful tip.

    BUT did you notice the last post was dated ... - 23rd February 2005, 12:51 ???

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  15. #15
    Join Date
    Apr 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Long long away ;)))

    Hi, yes i know, but i was searching by google for "TC74 picbasic" today and this topic is still one of firsts results.

    Problem has not been still solved (for 5 years). It's doesn't matter how old is it -it still can be googled, so it will be helpful for someone maybe (in next 5yr) No?

    Anyway i had to wrote answer -for peaceful sleeping ))

  16. #16
    Solomon's Avatar
    Solomon Guest


    Did you find this post helpful? Yes | No

    Lightbulb Thank you Segeer!

    Hi Segeer, I like your attitude. It is the right one, man. I am trying to implement the tc74 and because you posted the answer, helps me alot. Great stuff. One can just identify a true engineer in his attitude.

    I am using PICBasic Pro and will try your code today.

    Thank you again. I will post my PICBasic Pro Code for someone else in the future as well.

  17. #17
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    574


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Solomon View Post
    I will post my PICBasic Pro Code for someone else in the future as well.
    I like this attitude too; I wait for complete code, as good example for further projects !

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 08:14
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 12:20
  3. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 07:34
  4. Serout "onewire.bas"
    By puru in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th July 2005, 01:14
  5. read temperature sensor
    By breeno in forum General
    Replies: 5
    Last Post: - 10th January 2005, 07:04

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