Examples of temperature controls carried out with an USB data acquisition module from TECHNETEA
The same installation as before is used to illustrate some quick examples ot temperature controls with a setpoint of 40°C.
The temperature control is carried out in real time by a PC computer, to which is connected the USB data acquisition module. The temperature control function is written in JavaScript in an HTML page. This allows a very quick evaluation of various methods, without the need of a compiler.
In each of the 3 following examples, the temperature control function is called 4 times per second.
//********************************************************************************************************************** //**** Temperature control //********************************************************************************************************************** /* Temperature control on T1, with a rather too simple process but sometimes quite suffisant */ var _SETPOINT = 40; function TemperatureControl() { var module = document.getElementById("TPR1H3RE").m_oEquipment; // link to module Serial Number TPR1H3RE var T1 = module.Value[1]; // read temperature T1 on the channel 1 of the module if( T1 < _SETPOINT ) // if T1 is below the SetPoint ... module.SetDataChannel(4, 1); // heating ON else module.SetDataChannel(4, 0); // if not, stop heating }
//********************************************************************************************************************** //**** Temperature control //********************************************************************************************************************** /* Temperature control on T2, with the same process as before. */ var _SETPOINT = 40; function TemperatureControl() { var module = document.getElementById("TPR1H3RE").m_oEquipment; // link to module Serial Number TPR1H3RE var T2 = module.Value[2]; // read temperature T2 on the channel 2 of the module if( T2 < _SETPOINT ) // if T2 is below the SetPoint ... module.SetDataChannel(4, 1); // heating ON else module.SetDataChannel(4, 0); // if not, stop heating }
//********************************************************************************************************************** //**** Temperature control //********************************************************************************************************************** /* Temperature control on T2 with a little more efficient process. The function is called every 250 ms. */ var TimeCounter=0, DeltaTemp = 0, LastValue = 0; var _SETPOINT = 40; function TemperatureControl() { var module = document.getElementById("TPR1H3RE").m_oEquipment; // link to module Serial Number TPR1H3RE var T2 = module.Value[2]; // read temperature T2 on the channel 2 of the module if(++TimeCounter >= 12) // do the calculation every 3 seconds (12 x 250 ms) { DeltaTemp = T2 - LastValue; // DelTemp is the temperature change in 3 seconds LastValue = T2; // store temperature T2 for the next cakculation of DeltaTemp TimeCounter = 0; // reset the timer } if( (T2 + 1*DeltaTemp) < _SETPOINT ) // if T2 + ALPHA* DeltaT2 is below the SetPoint ... module.SetDataChannel(4, 1); // heating ON else module.SetDataChannel(4, 0); // if not, stop heating }