Low Cost Smart Sensor Design

Problem statement: Sensor with local processing power that enables it to react to local conditions without having to refer back to the central controller. The size and the cost of smart sensor circuit have been reduced. Approach: The use of microcontroller, such as (PIC16C715), with an 8-bit ADC (Analogue to Digital Converter) in one chip. This reduction in the circuit size makes it possible sometimes to incorporate the primary sensor with the signal processing circuit in one unit, then the lookup table should be modified accordingly. The program mobility of smart sensor enables the system to perform self calibration routine by applying known input voltage signal, where its corresponding expected value is stored in the self calibration code. Results: The correction for the measurement signal is done by multiplying the measured signal by the gain correction value and then adding the result of the multiplication to the offset compensation value. The smart sensor performs the self calibration routine for every new measurement value, to adapt any changes in the system environment such as temperature drift. Conclusion: The system performance has been enhanced by implementing the PIC16C715 Circuit design complexity and cost has been reduced and also it’s easy to upgrade.


INTRODUCTION
The advent of integrated circuits, which became possible because of the tremendous progress in semiconductor technology, resulted in the low cost microprocessor. Thus if it is possible to design a low cost sensor which is silicon based then the overall cost of the control system can be reduced .We can have integrated sensors which has electronics and the transduction element together on one silicon chip. This complete system can be called as system-on-chip .The main aim of integrating the electronics and the sensor is to make an intelligent sensor the term smart sensor is used to describe a complete measurement system that can react to measurement environment disturbance without referring to other devices, which incorporates a digital processor. Processing the output measurement to correct for errors and improve the system accuracy. It's also known as intelligent sensor. The use of microcontroller in smart sensors has allowed it to apply pre-programmed signal processing (Mirbagheri et al., 2007). And data manipulation algorithms to measurements such as self calibration process. The programming capability of the smart sensor has also reduced the design time, circuit complexity and made it easy to upgrade

Primary sensor:
The primary sensor required for this project should exhibit a nonlinear response, in order to illustrate how the smart sensor will adjust this nonlinearity.
The most common types of temperature sensors are: • Thermocouple • Resistance Temperature Dependent (RTD) • Thermistor The most suitable sensor type for the smart sensor project is the thermistor, due to its nonlinearity response, variety of sizes and shapes available and also it's reasonable cost.
The main procedures for selecting a thermistor for a particular application are: • Specify the system temperature scale: Smart sensor project is required to measure temperature in the scale of (-12 up-69°C) • Choose the value for R 25 that will be suitable for the system requirements • The value for R 25 should be high enough to minimise the power dissipation and improve the system stability (Siddiqui et al., 2009;AL-Khateeb et al., 2009;Sukontanakarn et al., 2009). It should not be too high that system will be affected by thermal noise • When a thermistor is selected for particular application, the minimum resistance at high temperature must be sufficient to avoid overloading of the readout device. Similarly, the maximum resistance at low temperature must not be so high that noise pickup becomes problem • Thermistor size: The size of the thermistor must be suitable to fit in the calibration unit • Reasonable cost Thermistor specifications: The selected primary sensor for the project is a Negative Temperature Coefficient (NTC) thermistor, diode package type, which has the following specifications in Table 1 So the thermistor has high sensitivity (-0.044/K), which gives a large output signal and good accuracy and resolution in temperature measurements Thermistor calibration: A heater and freezer unit is used in the calibration tests for the thermistor. "It contains plate made of bismuth telluride doped to obtain P and N type properties (Fernandes et al., 2009;Ramos and Tahan, 2009). P and N type pairs are thermally connected in parallel and electrically connected in series and sandwiched between ceramic plates. When (DC) power is applied, the passing current causes heat to be transferred from one side of the plate to the other. A Cold side and a hot side are now created. Reversing the power supply polarity will reverse the current flow. Thus, the cold and hot sides get reversed.
And as a result we got the following lookup Table 2: Software design: The program code is divided in two main sections:  • Declarations: these identify the RAM addresses for all file registers used in the program • Main program: the main program code for the smart sensor project is divided into many subroutines, to simplify the testing and the analysis of the system operation (Rocha et al., 2000) These subroutines are linked in the main program to achieve the system main functions.
The main program includes the following subroutines: • Initializing the PIC ports: configure the I/O pins for the PIC ports • Initializing the LCD: configure the LCD for 4-bit interface mode • Getting the actual temperature The PIC selects the primary sensor channel by sending its corresponding logic value to the analogue multiplexer (i.e., for CH-1 logic 001). Start the A/D conversion and when the conversion is finished, save the ADRES value into general purpose file register Self calibration algorithm: the self calibration algorithm needs some known values to be injected into The system during the calibration process and algorithm to correct the measured values to meet these known values. In the smart sensor project, two DC voltage levels at each extreme of the sensor range are used for the self calibration routine known as (X1 = 0.62V and X2 = 3.023V) provided from voltage divider circuit shown in Fig. 2.
Considering the gain to be the algebraic quantity slop and the offset to be intercepting the two test measurements will include both gain and offset error. So the transfer function of the measured values is in the form of: Y = m X+b Where: Y = is the corrected value for X M = is the correction for the gain error X = is the measured value B = is the correction for the offset error So the two test points will be in the form of these formulas: From the above two equations, (m) and (b) are unknown quantities and can be solved as: Thus, every time the system gets new temperature measurement from the ADC, correction on this measurement is given by this formula: In the smart sensor project, the self calibration routine runs whenever new measurement is required, to cope with any unexpected environment changes. This will increase the time take for the temperature measurement process, but as temperature changes very slowly and the PIC is running at fast speed. Thus, it will not be noticed.
The self calibration routine involves all four arithmetic operations (i.e., multiplication, division, addition and subtraction). The addition and subtraction operations are done by one single instruction (i.e., addwf or subwf), while the multiplication and division operations are performed by many different instructions (Rahmat et al., 2010;Elmetwaly, 2011;Rohini and Salivahanan, 2010).which takes time to be executed.
The multiplication program code is more accurate than the division, because the division program code does not solve the remainder, which requires complex program code with floating point operations. Thus for example if the dividend = 102 and the divisor = 100, the division result will be (1) instead of (1.02) and if the dividend = 100 and the divisor = 102, then the division result will be (0) instead of (0.98). That is why the value for (Y2) in the self calibration algorithm is made higher than what is expected, to avoid the zero division result, which will affect the output reading: • For example, the LCD executes the instructions or writes the data, wait for the ADC acquisition time and also wait for the ANA MUX and the instrumentation amplifier to settle down during the change over from one channel to another After the program has been written, it's ready to be assembled using MPLAB package. "This converts what has been written in words into a series of numbers is called hex code or hex file. If it fails to recognise one of the words, it will register an error, which means there things definitely wrong. It may register a warning, which means something is probably wrong. Also it may register a message, which means something is not wrong, but it has had to think about it when translating that particular line. Figure 4 shows the smart sensor program assembling result using MPASMWIN.
As the program hex code building has been completed successfully, it is ready to by simulated using MPLAB debugger and finally, blown or fused into the PIC using PIC START plus programmer. Once the programme is enabled, (Fig. 5 and 6) will be displayed that enables the user to adjust the configuration bits. The configuration bits are: • Oscillator: specifies the oscillator type, which has been set to (XT -for Crystal/Resonator) • Watchdog Timer: it automatically resets the PIC when it reaches its maximum time scale, which has been disabled to avoid resetting the PIC while it's performing delay subroutine or any other looping cases in the code  Brown out detect: It resets the PIC if the VDD falls below 4V for parameter greater than 35, which has been enabled.

Parity:
The PIC has on chip parity bits that can be used to check the contents of the program memory. When the parity bit is enabled and parity error has occurred it will reset the PIC. It has been enable in the smart sensor project code. After adjusting the configuration bits to the specified requirements, the program code is ready to be blown into the EPROM of the PIC. The computer will start loading the program code, once the program button in the PICSTART Plus window is activated, as shown in Fig. (6). Prototype assembling and testing: All the previously specified hardware and software components of the smart sensor are compiled in this process. The final circuit arrangement for the system, shown in Fig. 7, was built in the first place on the bread board and tested with variable resistor in place of the thermistor. The test results in Table 3 show that the system is working up to the specified requirements.
The expected LCD output is given by this formula: The project Printed Circuit Board (PCB) was built in the first place by using Edwin XP software package. Figure 8 shows the final project PCB. It has double layer, the blue lines are for the bottom layer while the red ones are for the top layer. Power supplies to all ICs are capacitive decoupled close to the device power pins using (0.1µF) ceramic capacitors to reduce the noise effect on the system. The thicker tracks are used for ground connections to minimise the impedance of ground return.

MATERIALS AND METHODS
The primary sensor for the smart sensor Paper is thermostat. The thermistor is very definitely nonlinear sensor. However, the major advantages of thermostats are their relatively low cost and their small size. The nonlinearity of the thermistor is converted into a linear form by the use of lookup table method. The lookup table data is based on the average value of two or more calibration test results. This method is simple, but it requires a large space of memory and also if the thermistor has been replaced, then the lookup table should be modified accordingly. However, the analytic equation is another method for line arising the output of the thermistor, which is not convenient for the smart sensor project as thermistor curve equation is complex and given by: The very high sensitivity of the thermistor (i.e.-0.044/K) results a large output signal and good accuracy and resolution in temperature measurement, but it reduces the temperature scale, as a large voltage change will be represented by (1 deg. C) in the lookup table.
The Thermistor exhibits very large changes in resistance with temperature, which is converted in to changes in the form of a voltage level signal by using Wheatstone bridge. The values for the resistors used in the bridge arms are based on the system specifications (i.e. minimum temperature range (-12°C)) and thermistor maximum power dissipation (i.e., 3mW/°C) to minimise the self heating effect. The values for the resistors in the bridge also, has been selected to modify the large output voltage change into a reasonable change, which can be recognised by the ADC (i.e., Min = 0.015V/°C), in order to expand the temperature measurement scale. The Wheatstone bridge introduces an offset error into the system, due to the resistors tolerance. This error has been minimised by using exactly the same resistors used in the calibration tests. So the lookup table will include compensation for that error.
The system has also the advantages of performing self calibration, as electronic components are affected by aging, manufacturing tolerances and operating temperature, which introduces gain and offset error to the system. The self calibration process compensates for these errors without including the primary sensor. During the self calibration process, two known input voltages at each extreme of the sensor range are applied into the system and digitally processed by using a microcontroller. This embedded software system requires accuracy in performing the associated arithmetic operations to find out the offset and gain error compensation. The associated arithmetic operations are adding, subtracting, division and multiplication. While the adding, subtraction and multiplication are reasonably simple, the division code is more complex and doesn't solve the remainder, which needs floating point operations and fast speed processor.

RESULTS AND DISCUSSION
The system incorporates microcontroller that processes the signals digitally, by loading software codes to the PIC EPROM to perform different functions, instead of using electronic circuits for every individual function. Thus, the microcontroller has reduced the project circuit design complexity and cost and also its makes it easy to communicate other electronic components such as LCD and the analogue multiplexer.
The system also reduces the external noise effect that has been generated from the power supply (i.e., ac ripple) or other noise source surrounding the system PCB by using the instrumentation amplifier. However, the instrumentation amplifier limits the temperature measurement scale. As result of the two transistors at each input of the amplifier, which require biasing voltage of about (0.6V), the output voltage swing is limited to about (3.2V) in the smart sensor project.
The system requires single (+5V) supply and the output value on the LCD is independent of the supply voltage. In other words, if the supply voltage increases, the reference voltage will increase and also the input voltage will increase. Thus, the output value (i.e., ratio between the input and reference voltages) doesn't change only if the thermistor resistance changes

CONCLUSION
The smart sensor paper has the following characteristics: • Compensates for the primary sensor (thermostat) nonlinearity by using the lookup table method. The lookup table also includes compensation for the primary sensor and the Wheatstone bridge offset • The ability to perform self calibration for the electronic gain and offset errors without including the primary sensor, because of the difficulty in controlling the surrounding environments to the primary sensor • The system performance has been enhanced by implementing the PIC16C715 microcontroller with 8bit A/D converter, where signals are digitally processed that the circuit design complexity and cost has been reduced and also it's easy to upgrade • Provides temperature measurement within the range of (-12-69°C), with maximum error of ±0.5°C • The system is interfaced to LCD for displaying the temperature measurement values, using 4-bit data transfer to reduce the number of the PIC I/O pins required