PDA

View Full Version : read temperature



breeno
- 29th January 2005, 14:52
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!!!!!

mister_e
- 29th January 2005, 22:25
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?

breeno
- 31st January 2005, 19:10
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"

mister_e
- 31st January 2005, 19:28
perhaps, this could be usefull

http://list.picbasic.com/forum/messages/6851/7299.html?1087118475

breeno
- 31st January 2005, 20:34
i have the same code but it doesn't work!!!!!
maybe i have to put some config instruction?
please help!

mister_e
- 31st January 2005, 23:50
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.

breeno
- 3rd February 2005, 19:02
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!!!!

mister_e
- 3rd February 2005, 19:27
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 ???

NavMicroSystems
- 3rd February 2005, 20:07
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 ?

breeno
- 5th February 2005, 11:40
i have tried another sensor...nothing
nothing also reverting sda and scl pins...

maybe some option?

regards
breeno

mister_e
- 5th February 2005, 11:49
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

breeno
- 23rd February 2005, 12:51
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?

Segeer
- 8th April 2010, 20:06
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

Acetronics2
- 8th April 2010, 20:38
Hi, Milos

Many Thanks for that useful tip.

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

Alain

Segeer
- 9th April 2010, 01:36
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 ;)))

Solomon
- 6th October 2010, 11:51
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.

fratello
- 6th October 2010, 13:55
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 !