There are literally sensors for measuring everything that a human can physically feel, hear or see. The sense of touch for example will reveal texture, temperature and sense vibration. A practical element of that is temperature.
Temperature is such a common attribute to measure that it verges on being boring. The principles however do help to illustrate how a PIC can be used to measure a physical quantity that we encounter every day.
The two types of sensors that I am going to discuss are an analogue sensor and a digital one. The analogue sensor is the LM35. It has a companion sensor the LM34 which measures temperature on the Fahrenheit scale. The digital sensor is the Microchip TC74, which has an I2C interface.
In principle, the LM35 can be very much like a variable resistor in application. The device has a +v, GND and then the voltage output. The temperature changes @ 10mV/’C. This gives you a resolution decent enough to measure more or less to 1/2 a degree which means that it’s better suited to domestic or non critical industrial applications.
Using this type of sensor is quite easy and only requires a single analogue input on your PIC and the right code to convert the analogue voltage reading to a usable temperature. Owing to the very low voltage output range, in on the order of 240 mV = 24 ‘C the device can be connected directly to the analogue input without the need for buffering or signal conditioning circuitry.
Thermocouple type temperature measurement is better suited to industrial applications.
The TC74 is a digital sensor accurate to 1 degree, and is also able to measure negative temperatures. Negative temperature measurement is useful especially if you have a system either monitoring or controlling a cold storage unit which looks after perishable foods.
The TC74 delivers it’s temperature reading via the I2C bus. This methods does have advantages, namely that there is no need at all for analogue to digital conversion since this is done by the sensor. The resulting temperature is delivered as 8 BIT, signed value.
When comparing performance the LM35 can very much be a victim of it’s own environment, voltage level degradation can take place if the sensor is too far from the PIC. As an advantage though, when the right buffering circuitry is in place, the LM35 could be positioned some distance from the PIC and still delivers reliable result.
This does not take place when using a TC74, although the I2C data can be affected by distance or ambient interference.
The I2C bus was developed for communication between devices on the same PCB and is not necessarily viable when the distances between devices are meters in length.
Using this device can be more tricky though since it requires the use of a communications bus, instead of the 1 to 1 connection that the LM35 uses. The I2C bus also allows for multiple TC74s to be connected and all to communicate with the same PIC. This would also be possible with the LM35, but you have a limited number of analogue inputs and each input is a used up pin.
Shown below is a brief non comprehensive summary of the two sensors. The choice would depend on the application, and if you are just self teaching then experimenting with both can also be useful.
|TC 74||LM 35|
|Temperature Range||-127 to 128||0 to 75′|
|Resolution||1 Degree / BIT||1 Degree /10 mV|
Having used both:
LM 35: This is a great sensor for simple measurement systems which are not to harsh as an environment. The device is reliable provided the correct conditioning / buffering circuitry is in place.
TC74: The ability to address multiple devices on the same bus and the intrinsic negative temperature measurement give this device the advantage. The digitised readout makes processing the measurement for easier and more flexible when either having to store the value or retransmit it using RS232.