Author | Eur van Andel, eur@fiwihex.nl Copyright (c) 2010 |
Adapted-by | |
Compiler | =2.4h |
this library reads the TC77 temperature sensor from Microchip. The TC77 has a 12-bit plus sign temperature resolution of 0.0625°C per Least Significant Bit (LSb). It works via the SPI protocol Specs: 1C (max.) accuracy from +25°C to +65C, 2C (max.) accuracy from -40°C to +85C 3C (max.) accuracy from -55°C to +125C 2.7V to 5.5V Operating Range, Low Power: 250uA (typ.) Continuous Conversion Mode, 0.1uA (typ.) Shutdown Mode -------- I have several years of experience with hundreds of these sensors. They work very well: fast, good accuracy, good repeatability. If they have an offset, it can easily be calibrated in software. The hard part of using this sensor is gettting it watertigtht. It is SMD, so it needs a PCB, and a cable. Dipping in resin or shrinking in glue-covered shrinktube works. The SPI protocol is bit-banged here and can be used with any pins. Clock data in on rising edge of clock, program must pull CS low. This allows for multiple TC77s on the same 2-wire databus. Put a 100nF decoupling capacitor close the the TC77. If you don't, you WILL get weird data. Writing the status_word is not supported here.
This library expects two pins defined as SIO and SCK: var bit SCK is pin_xx = high -- TC77 common clock pin_xx_direction = output var bit SIO is pin_yy -- TC77 common data pin_yy_direction = input include temperature_tc77 -- this library A third pin is needed for /CS: var bit cs is pin_zz = high -- chipselect TC77 sensor pin_zz_direction = output Usage is: CS = low tc77_read_celsius_sword(T1) CS = high Multiple TC77s can share the same bus, but each needs its own /CS pin.
tc77_read_celsius_sdword(sdword out temperature)
tc77_read_raw(word out raw)
tc77_read_celsius_sword(sword out temperature)
tc77_read_celsius_sbyte(sbyte out temperature)
tc77_read_celsius_sdword(sdword out temperature)
read celsius temperature of TC77 output in one sdword with 4 digits, so T = xxx.xxxx C last bit is 0.0001C , range is -40C ... +125C
tc77_read_raw(word out raw)
get raw temperature of TC77 output in word, right justified
tc77_read_celsius_sword(sword out temperature)
read celsius temperature of TC77 output in one sword with 2 digits, so T = xxx.xx C last bit is 0.01C , range is -40C ... +125C best procedure if you want to display C in 0.1 accurate take care of rounding during printing
tc77_read_celsius_sbyte(sbyte out temperature)
read celsius temperature of TC77 output in one sbyte with zero digits, so T = +/- xxx C last bit is 1C, range is -40C ... +125C no rounding, celsius fraction is chopped
12hv615 | 12hv615_temperature_fan.jal |
16f876a | 16f876a_tc77.jal |