Viscosity measurement using microcontrolle

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Abstract: A microcontroller based viscosity measurement setup has been developed to measure kinematic viscosity of liquids using redwood viscometer. This instrument system permits to keep the temperature of the sample at any desired value and recording of time for 50 cc of sample collection to compute viscosity of edible oil samples and to send data to personal computer to enable the computer processing of such data. A dedicated PIC16F877 based microcontroller board was employed for the hardware. A three layer neural network is used to train the viscosity at different temperature using back propagation algorithm and the trained neural network is used to compute the viscosity of edible oils. The details of its interface to measure kinematic viscosity and to measure, temperature and to control the temperature and evaluate results are explained in this paper.

Keywords: Microcontroller, kinematic viscosity, redwood viscometer, Back Propagation and Neural Network.


Viscosity measurement and control has great importance in food industry and accurate knowledge of viscosity is necessary for various industrial processes. Viscosity is a direct measurement of a fluid's quality. A change in viscosity can indicate a fundamental change in the material under test. Liquid viscosity, a basic physical property, directly influences unit operations such as pumping, filtration, filling, distillation, extraction, and evaporation, as well as heat and mass transfer. Viscosity is a very important property of lubricating oil. Kinematic viscosity is defined as the ratio of absolute viscosity to mass density and has the unit of m2/s. Properties, like temperature and pressure, influence the Kinematic viscosity. Frying is one of the most commonly used methods of food preparation in the home and in industry, and the prolonged use of oil for this purpose causes changes in its physical and/or chemical properties (Moretto and Fett, 1998). It is, therefore, essential to determine viscosities of the edible oils at various temperatures.

The application of artificial neural-networks in instrumentation particularly in measurement applications is the best increasing choice due to the efficiency in data acquisition and processing capability. Neural-networks will also find an additional usage in instrumentation and measurement applications due to the accomplished many tasks not feasible using conventional techniques such as the ability to learn and execute massive parallel processing structure. This paper explains the measurement of viscosity of edible oils using microcontroller-based instrument and the feasibility in computation of viscosity of edible oils at various temperatures using neural network.

Design scheme

The viscometer consists of a copper cup furnished with a pointer, which ensures a constant head and orifice at the center of the base of inner cylinder. The orifice is closed with a ball, which is lifted to allow the flow of oil during the experiment. The cylinder is surrounded by a water bath, which can maintain temperature of the sample to be tested at required temperature by the solid-state relay and microcontroller. The microcontroller (Block F) with 8 K words of flash programmable and erasable memory and 368 bytes of RAM. The PIC16F877 microcontroller is a low power, high performance RISC CPU 8-bit has two 8-bit and one 16-bit timer/counters, two capture, comparators and pulse width modulation (PWM) modules, a full duplex serial port, parallel ports, an on-chip oscillator, a programmable code protection, 14 interrupt sources and a 10- bit 8 channel A/D converter. It is designed for low power consumption to measure the temperature of the sample a chromel alumel thermocouple in block C is used. An instrumentation amplifier kept in block E is designed to amplify (gain 250) the emf generated by the thermocouple. The analog temperature in the form of voltage is given to Port A and it is digitized by the microcontroller. The solid-state power controller in block G is built with optocoupler (MOC3040), Triac (BT136) and other components are used to control the power of the electric heater in block H. The pulse width modulation (PWM) is used to control the temperature. The microcontroller will read the data for temperature of the sample and control the temperature of bath at the set temperature. The level detector in block B consists of IR emitter and detector, which are used to measure 50 cc of sample collection in the glass jar. The output from the IR detector is given to a signal conditioning circuit in block D that provides an input (Port C) to the micro controller. The micro controller to compute the viscosity of liquids uses the count value of the timer. Block L consists of keyboard and LCD display, which are interfaced with Port B and Port D of microcontroller. The keyboard is used to enter experimental parameters and measurement in sequences into the system. The LCD display will display the measured data and the results

  • The orifice is opened and the timer in the microcontroller is started and the timer is stopped when the IR detector senses the level of sample.
  • Measurement

    Edible oils like sunflower oil are purchased in local commerce. The principle of operation of redwood viscometer is based on measurement of time required to drain constant quantity of liquid through the narrow capillary tube. The cylinder of Redwood viscometer is filled up to a fixed height with sample of sunflower oil. The set temperature of the sample is given through the keyboard to keep the temperature of water bath at the set temperature. When lifting the ball valve, the timer in the micro controller is started and when the level in the jar reaches 50 ml mark the IR detector senses the level and the timer in the microcontroller is stopped. From the count value in the timer time taken for the collection of 50cc is measured and the Kinematic viscosity is computed by the microcontroller using the expression

    ?=A*t- (B/t) in centistokes


    Where A=0.26 and B=172 (when t > 34) are constants of the viscometer which depends upon the diameter and height of cylinder, diameter of orifice and the length of orifice. ? =Kinematic viscosity of liquid and the t=time required to pass 50cc of liquid. The Experiment is repeated to measure Kinematic viscosity of sunflower oil for different temperature ranging from 30°c to 90°c.

    Neural Network in Measurement Applications Learning and Testing

    Neural Network is used to determine the kinematic viscosity of edible oils at various temperatures using back propagation learning. A three-layered neural network (ANN) having seven neurons in hidden layer and one neuron in the input layer and one neuron in the output layer is used. The number of hidden neurons is determined empirically. The neurons in the hidden and output layer have sigmoid functions [3]. The weights between output and the hidden layers are updated using the pseudo impedance control algorithm [4]. It was found that for using this rule, convergence is relatively faster than the original generalized delta rule. A large ? would speed up the convergence initially but oscillation tends to alter as the error progressively becomes small and thus it has to be reduced. However alpha and beta are at 0.8 and -0.15 respectively [5]. A Neural Network is trained to temperature as input vector and Kinematic viscosity as output vector by using the back propagation algorithm method. The input and output vectors which are obtained from the experiments is used for learning. The objective of training is to adjust the weights so that application of a set of inputs produces the desired set of outputs. Before the training process, the weights are initialized to small random numbers. Under Supervised learning, both inputs and output data are given as data for the training. In this process, the weights are modified and the system is trained so as to get the desired output for a given input The training pattern for the input vectors is temperature of the sample and the output vector is kinematic viscosity. The sigmoid function is implemented for both input and output to train the neural network. Having trained, the neural network is used to process the kinematics viscosity densities of sunflower oil at various temperatures.

    Software is developed in 'C' language to initialize LCD display, to start ADC, to read data from ADC, to measure temperature of the sample, to control the temperature of bath by giving commands to solid state controller, to read data from level sensor, to measure the time of the collections of 50cc of liquid with the help of the level detector, to give data for constants A and B and to compute the viscosity and to display the results in the LCD.

    Results and Discussion

    The developed system has been used for measuring kinematic viscosity of unused (without heating) sunflower oil and another sample, which is used in frying condition (190oc). The viscosity is measured at different temperature for both unused and used samples. Comparing its responses to results obtained by rotational type viscometer checks the accuracy and reproducibility of the developed instrument. Table 1 shows the kinematic viscosity values of sunflower oil for temperatures ranging from 30 °C to 90 ° C. From the Table it is observed that measured kinematic viscosity of samples decrease with increase in temperature. This is due to a higher thermal movement among the molecules, reducing intermolecular forces, making flow among them easier and reducing viscosity

    In the present study ANN system is used to estimate the kinematic viscosity of unused and used sunflower oil at various temperatures. The data in the Table 1 is used as the training pattern for used and used sunflower oil. After training of the neural network the weight of the neural network are saved. They can be reloaded at any time to test experiment data to determine the viscosity at unknown temperatures. The Table 2 gives the kinematic viscosity of sunflower oil by the Measurement set up as well as computed by the designed neural network. From the table 2 it is observed that the designed neural network can compute kinematic viscosity of sunflower oil at known temperature. The Table 3 gives the kinematic viscosity of unused and used sunflower oil at various unknown temperature computed using neural network, which are not used for training. The error in the computation of kinematics viscosity of sunflower oil using neural network is found to be less than 1%. The error can be minimized by increasing the number of training cycles and by changing the number of neurons in the hidden layer. It is observed that even in the absence of measured kinematic viscosity of oil it is possible to obtain reliable corresponding estimates by trained ANN.

    Statistical analysis:

    Statistical analysis was made using software SPSS version 12. Table3.shows the data analysis studied for the calculated viscosity (dependent) with rise in temperature (independent). It was found that the power function to be the best curve fit with minimum error if the r sq value approaches 1.It was noted that r sq value ranges from 0.976 to 0.998. Therefore one can conclude that our regression model result is significantly better prediction of accuracy.


    The PIC16F877 micro controller based instrument system is developed to measure kinematic viscosity edible oils at different temperatures ranging from 30°c to 90°c.. The variation of viscosity at different temperatures will indicate the non - degradation of the oils samples. The temperature measurement and control system is tested and the error in measurement of temperature is found to be within 1%. The error occurred in kinematic viscosity determination by the neural network concept as well as our new hardware system was found less than 1 %. The error in the kinematic viscosity determination in the neural network with reference to the experimental density measurement is found to be less than 2%. The measurement system was configured to operate over the temperature range of 25°C to 100 °C. The system is highly reliable, ease of handling, less expensive and portable.


    1. J.C.O.Santos, A.G. de Souza, M.M.Silva Conceriao, M.C.D., prasad. A thermoalalytic and Kinematic study of sunflower oil. Brazilian Journal of chemical engineering No.3, 2004, pp. 265-273.
    2. M.A Rao, Rheology of liquid foods, Journal Tenure studies, 1997, pp. 135 - 168.
    3. M.A.Eiteman, and J.W Goodrum, Rheology of the triglycerides tricaprion, tricaprylin and tricaprin and of diesel fuel. Transactions ASAE 1993, pp. 503 - 507.
    4. C.Klotutar, D. Rudan - Tasic and K. Romih, Densities and thermal expansion coefficients of some vegetable oils. Acta chim. Slov 1997, pp. 45 - 55.
    5. M. Bernard Oliver, M. John, Electronic Measurement and Instrumentation -Cage (Mc graw hill), 1992.
    6. J.C.O Santos, I.M.G. dos Santos, A.G. Desow, S. Prasad, and A.V dos Santos, Thermal stability and Kinematic study on thermal decomposition of commercial edible oils by thermo gravity. Journal of Food Science,2002, pp. 1393 - 1398.
    7. PIC 16F877 Microcontroller datasheet, Microchip technology. pp
    8. M, S. Khalid Omatu, The Neural Network Controller for a Temperature Control System, IEEE control systems, vol. 12, 1992, pp.58-64.
    9. C.A.O. Nascimento, R. Giudici, and R. Guardani, Neural Network Based Approach for optimization of Industrial Chemical Processes, Comp. Chem. Eng., 24, 2000, pp. 2303
    10. Kamarthi, S.V. and Pittner, S, Accelerating neural network training using weight extrapolation, Neural Network, 12, 1999, 1285 - 1299,