Tag Archives: scilab code

Last updated by at .

Measuring the response of the electric water heater using the Arduino

This post describes how to measure the response of the electric water heater using the Arduino. By using simple program on the Arduino is very simple to read the output of the temperature response. Arduino has a 10bit ADC accuracy is used to read the output of the LM35 temperature sensor.

The output voltage of the LM35 sensor is amplified using the LM358 with a voltage gain of 5.47. While the output voltage of the LM35 is 10mV per degree centigrade. So the total output voltage LM398 is 5.47x10mV = 54.7mV per degree centigrade.

Arduino simple program are as follows: 

To read the temperature using the Arduino ADC channel 0 (A0). Results of ADC convertion is sent in serial with baudrate of 115200baud. By using hyperterminal program, the conversion result is stored in a file in text format form. 

 Measurement steps

  1. Upload arduino program to arduino board
  2. Fill water with water and setup the water flow about 6ml/sec
  3. Connect output of temperature sensor to A0 of arduino
  4. Run hyperterminal and setup the filename to capture data
  5. Start no power on elektric heater for some seconds
  6. Start power of electric heater for some minutes
  7. Remove power of electric heater for some minutes
  8. Stop hyperterminal
  9. Graph the results using scilab

The result of temperature outputs can be downloaded here.

Graph the results using scilab 

 By using the Scilab command in the console such as the following, the response will be obtained graphically.

// read file

// convert to matrix

// check size of matrix
 ans  =

    2652.    1.  

// make matrix of time with sampling about 2ms

// check size t matrix must same with d matrix
 ans  =

    1.    2652.  

// convert to voltage, fullscale of adc = 5Volt

// convert to output voltage of LM35

// convert to exact temperature with 10mv per centigrade

// plot data

-->title("Step Responses of Water Heater")

-->xlabel("Number of Samplings")

-->xlabel("Time in second")

-->ylabel("Temperature of water heater fluid (centigrade)")


Posted in Electronics | Tagged , , , | Leave a comment

Scilab code: transfer function and performance of control systems using DC Motor Model

This post contains the simple code written for Scilab, associated with the modeling of permanent magnet dc motor. The code of this program are made by me and is for all who need it. So is open source, you can modify as appropriate. Do not forget you also include my name and my website link in your application or website, and do not forget me say thank you.

Source Code 1


 DC motor used is a permanent magnet, with the default parameters are:

  1. Moment of inertia of the rotor: 
  2. Electromotive force constant:  
  3. Damping ratio of the mechanical system:
  4. Electric resistance:
  5. Electric inductance: 

If you want another dc motor parameters, please edit that variable in the source program.  Enter the parameters of the control constants Kp, Ki, and Ki, then the dc motor transfer function and the total transfer function of each controller P,  PI, PD and PID will be displayed.

Also, the graphics performance of the control system for each controllers P, PI, PD and PID will be generated.



Posted in Program | Tagged , , | Leave a comment