PDA

View Full Version : TCN75 Temp Sensor



Frozen001
- 18th September 2008, 18:54
I want to use MicroChips TCN75 2-wire temperature sensor in a project, but still being a PIC Basic newbie, I am stumped on where to even start. I assume I have to use I2CREAD and I2CWRITE, but from there I do not know where to go.... I am using an 18F8722 Pic.

skimask
- 18th September 2008, 20:07
I want to sue MicroChips TCN75
That would be a good trick!


2-wire temperature sensor in a project, but still being a PIC Basic newbie, I am stumped on where to even start. I assume I have to use I2CREAD and I2CWRITE, but from there I do not know where to go.... I am using an 18F8722 Pic.

First off, you read the datasheet and learn a little bit about the part you want to play with.
The you take note of any and all addresses that the part might or might not use and/or any data that has to be transferred to and/or from the device depending on what you want to do.
If you have used any EEPROM devices at all, this device should act pretty much like those...write a location to do something, read another location to get some data back.
Write some code. Somebody might walk you thru it, somebody might help you figure out what is wrong. However, I'd doubt somebody wil write it for you...

Frozen001
- 18th September 2008, 20:27
That would be a good trick!



First off, you read the datasheet and learn a little bit about the part you want to play with.
The you take note of any and all addresses that the part might or might not use and/or any data that has to be transferred to and/or from the device depending on what you want to do.
If you have used any EEPROM devices at all, this device should act pretty much like those...write a location to do something, read another location to get some data back.
Write some code. Somebody might walk you thru it, somebody might help you figure out what is wrong. However, I'd doubt somebody wil write it for you...

Well I am not really a digital guy... more of an RF guy tring his hand at microcontrollers. I looked at the data sheet, and I thnk I see what I need to sent to the LM75, but I think I am more confued with the commands I2CREAD and I2CWRITE.

After Startup, I have to send 10010001 to go into read mode. The sensor will acknowledge receipt (SDA low). After ACK, the sensor will clock out the data which I have to read.

skimask
- 18th September 2008, 20:55
but I think I am more confued with the commands I2CREAD and I2CWRITE.

After Startup, I have to send 10010001 to go into read mode. The sensor will acknowledge receipt (SDA low). After ACK, the sensor will clock out the data which I have to read.

Ok, that sounds reasonable...
YOU don't have to worry about SCL, SDA, ACK, NACK, this, that, the other thing, whatever...
PBP and I2CREAD/I2CWRITE take care of that for you.
All you have to do is provide the right parameters for said commands (i.e. addresses, data, etc).

Frozen001
- 22nd September 2008, 12:44
OK SO I tried the following:

I2CWRITE PORTC.4, PORTC.3, $91, $00
I2CREAD PORTC.4, PORTC.3,$90, [STR Temperature\16]

And got nothing back...

Frozen001
- 22nd September 2008, 13:56
I connected the I2C port up to a scope, and I am getting pulses on the clock and SCL and the SDA pins, so I must be doing something correct... I think my problem is I am just not reading the data.

aratti
- 22nd September 2008, 14:36
Verify that you have 5k resistor as pullup on I2C line. Also verify the address you have set (did you connect a0;a1;a2 to ground). Use write only to configure the chip or to set the setpoints.
Use Read all the time you want to read out data from your chip. A 10- 15 millisecs delay between reading is recommended.

good luck

Frozen001
- 22nd September 2008, 15:28
OK I have it reading the data correctly, it think:

I2CREAD PORTC.4, PORTC.3,%10010001 ,$0, [temph,templ]

temph is the first 8 bits, and templ is the next 8 bits.

temph is difined earlier as the first byte in the word temp, while templ is defined at the second byte in the word temp.

Now that I have the temperature reading, is thre a way to convert it to ascii characters so I can send them to my display?

Archangel
- 22nd September 2008, 17:36
OK I have it reading the data correctly, it think:

I2CREAD PORTC.4, PORTC.3,%10010001 ,$0, [temph,templ]

temph is the first 8 bits, and templ is the next 8 bits.

temph is difined earlier as the first byte in the word temp, while templ is defined at the second byte in the word temp.

Now that I have the temperature reading, is thre a way to convert it to ascii characters so I can send them to my display?
Look at the modifiers listed in the Serial out routines, HEX, BIN, STR Etc. . . usually, if my poor memory serves me, data goes ascii without the modifiers, but go look at them anyway, also while you are checking those out look also at the DIG and DEC modifiers, they do good things too.
http://www.melabs.com/resources/pbpmanual/

Frozen001
- 22nd September 2008, 18:09
The modifier would be OK , but my display does not used a serial interface, rather I have to access address for each character to display (HDSP-2112).

skimask
- 22nd September 2008, 19:14
I2CREAD PORTC.4, PORTC.3,%10010001 ,$0, [temph,templ]
temph is the first 8 bits, and templ is the next 8 bits.
temph is difined earlier as the first byte in the word temp, while templ is defined at the second byte in the word temp.
Now that I have the temperature reading, is thre a way to convert it to ascii characters so I can send them to my display?

tempw var word
tempw.highbyte = temph
templw.lowbyte = templ
lcdout $fe,1,DEC5 tempw

Just like it shows in the LCDOUT section of the PBP manual.

Frozen001
- 22nd September 2008, 20:37
tempw var word
tempw.highbyte = temph
templw.lowbyte = templ
lcdout $fe,1,DEC5 tempw

Just like it shows in the LCDOUT section of the PBP manual.

Thanks for the information, but the display is not compatible with the LCDOUT routine. I got it working though, had to do some math. Working great so far.

Thanks again...