CY8CKIT-025 PSoC® Precision Analog Temperature Sensor Expansion Board Kit Guide, Doc. # 001-65791 Rev. *J
66
Example Projects
done after the ADC reconfiguration to ensure that reconfiguration completed before the next ADC
SOC is triggered.
5.3.3.3.2
Fixed Point Math
This project does not use floating point math when calculating the measurement results. This is done
to reduce processor overhead when converting ADC readings into measurement values. Therefore,
scaling is used to calculate the final measurement value. For ease of use, the values are converted
to float when displayed on the LCD. The following sections describe each measurement and how its
readings are converted into measurement values.
20 mV and 100 mV Input
For 20 mV and 100 mV reading, ADC_COUNTS_PER_VOLT is used to convert the ADC counts to
volts. Because integer math is used, dividing the ADC counts by this constant results in a precision
of only 1 V, which is not adequate to measure a 20 mV or 100 mV full scale input. To fix this, the
ADC counts for these readings are scaled up by 10000 and divided by ADC_COUNTS_PER_VOLT.
The result is in ten-thousandths of a volt.
3.3 V Rail and 5 V Rail
For the 3.3 V and 5 V reading, ADC_COUNTS_PER_VOLT is used to convert the ADC counts to
volts. Because integer math is used, dividing the ADC counts by this constant results in a precision
of only 1 V, which is not adequate to measure a 3.3 V or 5 V rail. To fix this, the ADC counts for these
readings are scaled up by 1000 and then divided by ADC_COUNTS_PER_VOLT. The result is in
thousandths of a volt.
RTD and DS600
To avoid floating point math, the conversion from ADC readings to temperature uses integer math.
To preserve precision, the readings are scaled up. Thus the final result of the temperature measure-
ments is in hundredths of a degree C. For more information on the conversion, see the inline code
comments in the associated project.
Diode
The diode temperature measurement uses floating point math. This is because the natural log of the
current ratio is taken. Not using floating point math with this measurement results in poor accuracy
and stability of the diode measurement.
5.3.3.3.3
Filter
A software IIR filter is applied on all ADC readings to eliminate noise. See application note
for details on the software IIR filter. The filter (attenuation factor) applied depends on the noise on
the voltage output of the sensor. Applying a filter increases the measurement settling time. A very
low cut-off filter requires a much larger time for the measurement to settle down. To avoid large set-
tling times when the input changes drastically, an algorithm is used where the filter is applied only
when required (when the measurement is closer to the final measurement).
The filter attenuation factor can be changed in the Init_Buffers routine in
Readings.c
. For example, to
change the filter attenuation factor of 3.3 V from 8 to 16, go to
Readings.c
and modify the following
line of code.
Filter_CoeffBuf[READ_RAIL3V3]=8;
to
Filter_CoeffBuf[READ_RAIL3V3]=16;
Note that a higher attenuation factor reduces LCD flicker, but increases temperature settling time.