Category

PARTS: I2C digital THERMOMETER (TC74)

Microchip’s TC74 is an affordable digital temperature sensor with a basic I2C interface. It has a resolution of 1 degree Celsius, and a variety of -40 to +125 degrees. This is an easy method to add temperature measurement to a job without an analog to digital converter. We’ll show you how to utilize the TC74 below.

Microchip TC74 digital temperature sensor (Octopart search, starting at $0.88)

The TC74 is available in five pin through-hole and surface mount packages, see the TC74 datasheet (PDF). We couldn’t find a Cadsoft Eagle footprint for any version of this part, if you know of one please link to it in the comments.

Different versions of the TC74 are calibrated for certain voltages, but all work from 2.7-5volts. The TC74A5 we utilized is a lot of accurate when operating at 5volts, but we powered it from a 3.3volt supply. The I2C connection needs 2 pull-up resistors to hold the bus high (R1, R2), 2K-10K must work. C1 is a 0.1uF decoupling capacitor.

We utilized the Bus Pirate universal serial interface in I2C mode to test drive the TC74, but the exact same principals apply to any microcontroller. We powered the TC74 from the Bus Pirate’s 3.3volt supply, and utilized the on-board pull-up resistors to hold the I2C bus high.

أمر
قيمة

Select temperature register
0x00

Select configuration register
0x01

The TC74’s compose address is 0x9a, and the checked out address 0x9b. It has two, one-byte registers. Register address 0 holds the temperature reading, register 1 holds the configuration settings.

Configuration register

Bit 6 of the configuration register is 0 at power-on, and modifications to 1 when the first valid temperature reading is available. bit 7 is writable, and puts the TC74 in a power saving standby mode. reading the register includes two steps: utilize a partial compose command to choose the register, then utilize the checked out command to retrieve the value.

I2C>{0x9a 1}
210 I2C begin CONDITION
220 I2C WRITE: 0x9A got ACK: indeed <–write address 220 I2C WRITE: 0x01 got ACK: indeed <–select config register 240 I2C وقف الشرط First, we choose the configuration register with a partial compose command. This doesn’t actually compose a value, it selects the register to checked out and write. { produces the I2C begin condition, complied with by the TC74 compose address (0x9a) and the choose configuration register command (0x01). } problems the I2C stop condition and ends the transaction. Now we can checked out the contents of the register. I2C>{0x9b r}
210 I2C begin CONDITION
220 I2C WRITE: 0x9B got ACK: indeed <–read address 230 I2C READ: 0x40 <– register value (01000000) 240 I2C وقف الشرط I2C>

The checked out address (0x9b) returns the one byte register value (r). The configuration register value, 0x40 or 01000000, shows that the device is out of standby (bit 7=0), and a valid temperature reading is available (bit 6=1).

The TC74 has a low-power standby mode. enable it by composing 1 to bit 7 of the configuration register.

I2C>{0x9a 1 0b10000000}
210 I2C begin CONDITION
220 I2C WRITE: 0x9A got ACK: indeed <–write address 220 I2C WRITE: 0x01 got ACK: indeed <–select config register 220 I2C WRITE: 0x80 got ACK: indeed <–value to compose (01000000) 240 I2C وقف الشرط I2C>

The register is written with single three-byte command. first we send the compose address (0x9a), complied with by the register to choose (0x01), and finally the value to compose (0x80). only bit 7 of the configuration register is writable, the values of bits 6-0 are ignored.

Read the register again to confirm that the command worked.

I2C>{0x9a 1}{0x9b r}
210 I2C begin condition <–first command sets register 220 I2C WRITE: 0x9A got ACK: indeed <–write address 220 I2C WRITE: 0x01 got ACK: indeed <–config register (1) 240 I2C stop condition <–end first command 210 I2C begin condition <–begin second command 220 I2C WRITE: 0x9B got ACK: indeed <–read address 230 I2C READ: 0x80 <– register value (10000000) 240 I2C stop condition <–end second command I2C>

The register value, 10000000, now shows that the device is in standby (bit 7=1). notice that bit 6 is now 0, no temperature data is available.

Clear bit 7 to exit standby, then wait on bit 6 to return to 1 before reading the temperature register.

I2C>{0x9a 1 0b00000000}
210 I2C begin CONDITION
220 I2C WRITE: 0x9A got ACK: indeed <–write address 220 I2C WRITE: 0x01 got ACK: YES<–select config register 220 I2C WRITE: 0x00 got ACK: YES<–value to compose (00000000) 240 I2C وقف الشرط I2C>

Temperature data is prepared when the configuration register value returns to 0x40 (01000000).

درجة حرارة

The temperature register is checked out in two steps. First, a partial compose command selects the temperature register (0), then a checked out sequence returns the contents.

I2C>{0x9a 0}{0x9b r}
210 I2C begin CONDITION
220 I2C WRITE: 0x9A got ACK: indeed <–write address 220 I2C WRITE: 0x00 got ACK: indeed <–selectتسجيل درجة الحرارة 240 I2C وقف الشرط 210 I2C تبدأ الحالة 220 I2C اكتب: 0x9b حصلت على ACK: في الواقع <-Read العنوان 230 I2C قراءة: 0x18 <- غراب بايت واحد 240 I2C وقف الشرط I2C>

درجة الحرارة هي قيمة عدد صحيح للدرجات مئوية، يتم تمثيل الأرقام السالبة كتكملة TWOS. يتم تمثيل القيم الإيجابية من 0 إلى 127 درجة مئوية فقط بهذه القيمة. درجات الحرارة السلبية تحتوي على مجموعة BIT 7، وتنوع من -1 إلى -65 (255-128)، انظر الجدول 4.4 في الصفحة 8 من ورقة البيانات. القيمة السداسية عشرية 0x18 تساوي 24 في عشري، وبالتالي فإن قراءة درجة الحرارة 24C (75F).

هل أعجبتك هذه التدوينة؟ فحص مقالات الأجزاء التي قد تفوتها.